Skip to content

Game.Input.CompositeInstance

Assembly:
This class is part of the game's input system assemblies used by Cities: Skylines 2 mods (references: InputManager, CompositeUtility, Usages types).

Namespace: Game.Input

Type: class

Base: ICustomComposite

Summary: Represents a concrete instance of an input composite (a custom composite binding) used by the input system. CompositeInstance stores configuration such as whether the composite is rebindable, modifier behaviour, platform restrictions, usages, linked GUIDs, processors and interactions, and converts itself to/from NameAndParameters for serialization. It is used by the game's InputManager and composite utilities to register and persist composite bindings for controls and rebindable actions.


Fields

  • private bool m_IsRebindable
    Controls whether the composite can be rebound. Default: true. The isRebindable property exposes this with special behavior for dummy instances.

  • private bool m_IsModifiersRebindable
    Controls whether modifiers for the composite are rebindable. Default: true. Exposed via isModifiersRebindable with additional checks against allowModifiers and isRebindable.

  • private bool m_AllowModifiers
    Whether modifiers are allowed for this composite. Default: true. Exposed via allowModifiers.

  • private bool m_CanBeEmpty
    Whether the composite can be left empty (no binding). Default: true. canBeEmpty returns true only when appropriate (e.g., for dummy instances or when isRebindable).

  • private bool m_DeveloperOnly
    Flag for developer-only composites. Default: false. Exposed via developerOnly.

  • private Platform m_Platform
    Platform filter for the composite. Default: Platform.All. Exposed via platform.

  • private bool m_BuiltIn
    Indicates if the composite is built-in. Default: true. Exposed via builtIn.

  • private bool m_IsDummy
    Flag that marks the instance as a dummy. When true, many checks return permissive values (e.g., rebindable/modifier allowances). Default: false. Exposed via isDummy.

  • private bool m_IsHidden
    Flag that hides the composite from certain UIs; if hidden, optionGroupOverride will return None. Default: false. Exposed via isHidden.

  • public OptionGroupOverride m_OptionGroupOverride
    Option group override value for grouping in options UI. Accessed through optionGroupOverride property which returns OptionGroupOverride.None when isHidden is true.

  • private Usages m_Usages
    Represents usage flags for the composite. Initialized to ICustomComposite.defaultUsages; usages property returns a copy and setter delegates to SetFrom. Internally set to read-only in some constructors.


Properties

  • public string typeName { get; internal set; }
    The name/type identifier of the composite. Used to look up composite metadata via InputManager.

  • public bool isRebindable { get; set; }
    Getter returns true for dummy instances; otherwise returns m_IsRebindable. Controls whether the composite can be rebound.

  • public bool isModifiersRebindable { get; set; }
    Getter returns true if dummy; otherwise returns true only when m_IsModifiersRebindable AND isRebindable AND allowModifiers are true. Controls whether the composite's modifier parts can be rebound.

  • public bool allowModifiers { get; set; }
    Getter returns true for dummy instances; otherwise returns m_AllowModifiers.

  • public bool canBeEmpty { get; set; }
    Getter returns true for dummy instances; otherwise returns true only when m_CanBeEmpty and isRebindable are true.

  • public bool developerOnly { get; set; }
    Plain getter/setter for m_DeveloperOnly.

  • public Platform platform { get; set; }
    Plain getter/setter for m_Platform. Determines platform filtering (e.g., PC, console).

  • public bool builtIn { get; set; }
    Plain getter/setter for m_BuiltIn.

  • public bool isDummy { get; set; }
    Plain getter/setter for m_IsDummy.

  • public bool isHidden { get; set; }
    Plain getter/setter for m_IsHidden.

  • public OptionGroupOverride optionGroupOverride { get; set; }
    Getter returns OptionGroupOverride.None when isHidden is true; otherwise returns m_OptionGroupOverride. Setter stores the value.

  • public Usages usages { get; set; }
    Getter returns a copy of m_Usages (to prevent external mutation). Setter applies incoming Usages via m_Usages.SetFrom(...).

  • public Guid linkedGuid { get; set; }
    A GUID linking this composite instance to something else (used by the composite linking utilities). Set/read via property; constructor and parameters setter create/get it via CompositeUtility.

  • public List<NameAndParameters> processors { get; }
    A list of processors to apply to the composite input. Initialized to an empty list.

  • public List<NameAndParameters> interactions { get; }
    A list of interactions attached to the composite. Initialized to an empty list.

  • public Mode mode { get; set; }
    Mode enum for composite behavior. Exposed directly.

  • public InputManager.CompositeData compositeData { get; }
    Lookup property that uses InputManager.TryGetCompositeData(typeName). Returns default(InputManager.CompositeData) if lookup fails. Useful to get metadata about the underlying composite type.

  • public NameAndParameters parameters { get; set; }
    Getter: Builds and returns a NameAndParameters that serializes this composite instance, including a parameter array with booleans, platform, mode, option override and linked GUID parts (m_LinkGuid1/m_LinkGuid2). The GUID parts are supplied by CompositeUtility.SetGuid.
    Setter: Parses a NameAndParameters.parameters array of NamedValue entries and assigns corresponding fields (booleans, platform, builtIn, mode, usages, dummy/hidden flags, option override, and link GUID parts). After reading link parts it recombines them via CompositeUtility.GetGuid and assigns linkedGuid.


Constructors

  • public CompositeInstance(string typeName)
    Creates a composite instance and sets typeName. m_Usages is initialized to default from ICustomComposite.

  • public CompositeInstance(NameAndParameters parameters)
    Creates a composite instance from serialized parameters. Uses parameters.name as typeName, resets m_Usages to ICustomComposite.defaultUsages, applies the parameters setter (parsing and applying fields) and then marks m_Usages read-only.

  • public CompositeInstance(NameAndParameters parameters, NameAndParameters usages)
    Creates a composite instance from serialized parameters and an explicit usages parameter. Initializes m_Usages as writable (new Usages(0, readOnly: false)), applies parameters, sets m_Usages.parameters = usages, then marks m_Usages read-only. Useful when serialized usages are provided separately.


Methods

This class does not declare additional public methods beyond property getters/setters and constructors. Most behavior is implemented in property accessors (especially parameters getter/setter). The class implements ICustomComposite, so it provides the required members (typeName, parameters, usages, etc.) used by the input system to register and serialize composites.


Usage Example

// Create a composite instance from a known composite type name
var composite = new Game.Input.CompositeInstance("MyCustomComposite");
composite.isRebindable = true;
composite.allowModifiers = true;
composite.platform = Platform.PC;
composite.mode = Mode.SomeMode; // replace with actual Mode enum member
composite.linkedGuid = Guid.NewGuid();

// Convert to NameAndParameters for serialization/storage
NameAndParameters serialized = composite.parameters;

// Recreate instance from serialized parameters (e.g., when loading)
var restored = new Game.Input.CompositeInstance(serialized);

// Retrieve composite metadata from InputManager (if available)
var data = restored.compositeData;
// data will be default if InputManager has no record for the typeName

Notes: - The parameters property is central for persisting and restoring CompositeInstance fields. It serializes many internal flags under names like "m_IsRebindable", "m_AllowModifiers", "m_LinkGuid1", etc., so custom code interacting with parameters should follow the same parameter names if interoperating with the game's serialization. - The class treats "dummy" instances specially: many checks (isRebindable, isModifiersRebindable, allowModifiers, canBeEmpty) return permissive true when isDummy is true. This is useful when creating placeholder or editor-only instances.