Game.Prefabs.Modes.GameModeRule
Assembly: Assembly-CSharp
Namespace: Game.Prefabs.Modes
Type: class
Base: System.Object
Summary:
Represents a single rule/entry used by a game mode. This class is serializable and mainly stores the localization term id for the rule text together with an optional argument (name, numeric value and unit). It declares a nested enum ArgumentUnit to describe the unit type of the argument (integer, percentage, money, xp, custom). A private static dictionary maps ArgumentUnit values to their string representations and is used by GetUnit() to obtain the unit string used in UI/localization.
Fields
-
private static System.Collections.Generic.Dictionary<Game.Prefabs.Modes.GameModeRule.ArgumentUnit, string> kUnitDict
Static lookup mapping ArgumentUnit values to their string identifiers. Initialized with the pairs: integer -> "integer", percentage -> "percentage", money -> "money", xp -> "xp", custom -> "custom". Used internally by GetUnit(). -
public string m_Term
Localization term id. Tooltip in the editor advises to include the "Menu.GAME_MODE_RULES" prefix when specifying this term. This is the key used to look up the localized rule text. -
public string m_ArgName
Optional argument name used in the localized text. Tooltip indicates this should be used when the term contains an argument placeholder. -
public int m_ArgValue
Numeric value for the argument. Used when the localized term expects a numeric parameter. -
public Game.Prefabs.Modes.GameModeRule.ArgumentUnit m_ArgUnit
Unit type for m_ArgValue. Controls how the value is interpreted/presented (e.g., integer, percentage, money, xp, custom).
Properties
- None (this class exposes fields directly; no C# properties are defined).
Constructors
public GameModeRule()
Default parameterless constructor (implicit). The class is marked [Serializable] so instances are intended to be serialized by Unity (e.g., as part of prefab data).
Methods
public string GetUnit()
Returns the string representation of the currently selected m_ArgUnit by looking it up in the internal kUnitDict. Useful when preparing display text or passing a unit identifier to localization formatting.
Usage Example
// Create and populate a rule entry
var rule = new Game.Prefabs.Modes.GameModeRule();
rule.m_Term = "Menu.GAME_MODE_RULES.PopulationLimit";
rule.m_ArgName = "limit";
rule.m_ArgValue = 10000;
rule.m_ArgUnit = Game.Prefabs.Modes.GameModeRule.ArgumentUnit.integer;
// Use GetUnit to obtain the unit string to format/display the argument
string unit = rule.GetUnit(); // "integer"
// Example formatted display (pseudo-localization usage):
// Localize(rule.m_Term, rule.m_ArgName, rule.m_ArgValue, unit);