Skip to main content

GameRules

Provides access to CCitadelGameRules data. Automatically resolved when the citadel_gamerules proxy entity is created/destroyed.

public static class GameRules

Namespace: DeadworksManaged.Api
Source: GameRules.cs#L7

Properties​

GameRules.IsValid​

Whether the game rules entity is currently active and resolved.

Signature

public static bool IsValid { get; }

Source: GameRules.cs#L39

GameRules.Pointer​

Raw pointer to the CCitadelGameRules instance. Zero if not resolved.

Signature

public static nint Pointer { get; }

Source: GameRules.cs#L42

GameRules.LevelStartTime​

Signature

public static float LevelStartTime { get; }

Source: GameRules.cs#L46

GameRules.GameStartTime​

Signature

public static float GameStartTime { get; }

Source: GameRules.cs#L47

GameRules.GameStateStartTime​

Signature

public static float GameStateStartTime { get; }

Source: GameRules.cs#L48

GameRules.GameStateEndTime​

Signature

public static float GameStateEndTime { get; }

Source: GameRules.cs#L49

GameRules.RoundStartTime​

Signature

public static float RoundStartTime { get; }

Source: GameRules.cs#L50

GameRules.GameState​

Signature

public static EGameState GameState { get; }

Source: GameRules.cs#L51

GameRules.MatchMode​

Signature

public static ECitadelMatchMode MatchMode { get; }

Source: GameRules.cs#L52

GameRules.GameMode​

Signature

public static ECitadelGameMode GameMode { get; }

Source: GameRules.cs#L53

GameRules.MidbossKillCount​

Signature

public static int MidbossKillCount { get; }

Source: GameRules.cs#L54

GameRules.AmberRejuvCount​

Signature

public static int AmberRejuvCount { get; }

Source: GameRules.cs#L55

GameRules.SapphireRejuvCount​

Signature

public static int SapphireRejuvCount { get; }

Source: GameRules.cs#L56

GameRules.NextMidBossSpawnTime​

Signature

public static float NextMidBossSpawnTime { get; }

Source: GameRules.cs#L57

GameRules.MatchClockAtLastUpdate​

Signature

public static float MatchClockAtLastUpdate { get; }

Source: GameRules.cs#L58

GameRules.MatchID​

Signature

public static ulong MatchID { get; }

Source: GameRules.cs#L59

GameRules.ServerPaused​

Signature

public static bool ServerPaused { get; }

Source: GameRules.cs#L60

GameRules.WinningTeam​

The team that won the match, or -1 while it's still being played. Set it to end the match with that team as the winner; the enemy Patron is left standing.

Signature

public static int WinningTeam { get; set; }

Source: GameRules.cs#L66

GameRules.MatchStartOnAnyMap​

Gives every map the match start dl_midtown has: a countdown in base, then everyone launched down their lane's zipline (choose lanes with CCitadelPlayerController.AssignedLane). Off by default, when only dl_midtown starts that way and any other map goes straight into the match with everyone in base.

Signature

public static bool MatchStartOnAnyMap { get; set; }

Notes On a server without a matchmaking lobby the countdown also needs citadel_match_intro_force_enabled 1, the same as on dl_midtown. The setting lasts across map changes, so turn it off again when your plugin unloads.

Source: GameRules.cs#L80

GameRules.GamePaused​

Signature

public static bool GamePaused { get; }

Source: GameRules.cs#L130

GameRules.TotalPausedTicks​

Signature

public static int TotalPausedTicks { get; }

Source: GameRules.cs#L131

GameRules.PauseStartTick​

Signature

public static int PauseStartTick { get; }

Source: GameRules.cs#L132

GameRules.GameClock​

Returns the current game clock in seconds, accounting for pauses. Returns 0 if game rules or global vars are unavailable.

Signature

public static float GameClock { get; }

Source: GameRules.cs#L138

Methods​

GameRules.ChangeGameState()​

Calls the real CCitadelGameRules::ChangeGameState, running the engine's normal transition logic.

Signature

public static void ChangeGameState(EGameState state)

Source: GameRules.cs#L86

GameRules.SetWaitingForPlayersRoster()​

Overrides the roster used by the engine's internal WaitingForPlayersToJoin readiness check. The engine's own roster is populated by matchmaking/party data, which is always empty on a direct-connect dedicated server, so the check (and the counts it caches into the client-networked HUD fields) reflects a real target instead of always reading empty/zero. The state advances once readyCount >= totalCount. Pass a totalCount of 0 to disable the override and restore the engine's native behavior. This is native global state, not a field on the game rules entity; it is persists across map changes and is cleared on plugin unload.

Signature

public static void SetWaitingForPlayersRoster(uint readyCount, uint totalCount)

Source: GameRules.cs#L102

GameRules.SetGameStartTime()​

Sets m_flGameStartTime, which the match clock (GameClock and the client's HUD timer) is computed relative to. On a server without real matchmaking, this field is never reset once the pregame flow actually reaches GameInProgress, so the clock counts from map load instead of from when the match really starts.

Signature

public static void SetGameStartTime(float time)

Source: GameRules.cs#L110

GameRules.SetGameStateEndTime()​

Sets m_flGameStateEndTime, which drives the client's countdown display for states that show one (e.g. PreGameWait's "Game starting..."). The engine's own ChangeGameState only writes a real value here when an internal eligibility check passes; on servers where that check never passes, the field is left at a sentinel and the client shows no countdown number.

Signature

public static void SetGameStateEndTime(float time)

Source: GameRules.cs#L122