Skip to content

Game.Input.ProxyActionMap

Assembly: Assembly-CSharp
Namespace: Game.Input

Type: class

Base: System.Object

Summary:
ProxyActionMap is a wrapper around UnityEngine.InputSystem.InputActionMap used by the game's input system to provide a modifiable, game-aware layer over raw input action maps. It tracks ProxyAction instances for each InputAction in the source map, maintains input barriers that can enable/disable the whole map, exposes bindings and actions for inspection, and propagates device masks to the underlying InputActionMap. This class is intended to allow dynamic action addition, masking by device type, and coordinated enable/disable driven by InputBarrier state.


Fields

  • private readonly UnityEngine.InputSystem.InputActionMap m_SourceMap
    This is the underlying InputActionMap that this proxy wraps. It is the authoritative source map used to add new actions and to apply the bindingMask when the ProxyActionMap.mask changes.

  • private readonly System.Collections.Generic.Dictionary<string, ProxyAction> m_Actions = new Dictionary<string, ProxyAction>()
    Holds ProxyAction instances keyed by action name. Each ProxyAction wraps a corresponding InputAction from m_SourceMap. This dictionary is the primary store for looking up and iterating actions exposed by the proxy.

  • internal System.Collections.Generic.HashSet<InputBarrier> m_Barriers = new HashSet<InputBarrier>()
    Set of InputBarrier objects that influence whether this ProxyActionMap is considered enabled. If any barrier in this set is blocking, the map is disabled. This collection is internal because barriers are managed by the game's input system.

  • private bool m_Enabled
    Cached enabled state of the ProxyActionMap computed from the barriers. When true the proxy allows its actions to be enabled; when false actions are updated to reflect being blocked.

  • private InputManager.DeviceType m_Mask = InputManager.DeviceType.All
    Device-type mask applied to the underlying InputActionMap (via bindingMask). Changing this mask updates the source map's bindingMask and triggers state updates for all ProxyAction instances.

Properties

  • internal UnityEngine.InputSystem.InputActionMap sourceMap => m_SourceMap
    Provides direct read-only access to the wrapped InputActionMap. Internal: intended for use by the input system and ProxyAction/ProxyBinding helpers.

  • public string name => m_SourceMap.name
    Name of the wrapped InputActionMap, forwarded from sourceMap.name.

  • public System.Collections.Generic.IReadOnlyDictionary<string, ProxyAction> actions => m_Actions
    Read-only view of the proxy's action dictionary. Use this to enumerate or look up ProxyAction objects without modifying the internal dictionary.

  • internal System.Collections.Generic.IReadOnlyCollection<InputBarrier> barriers => m_Barriers
    Read-only view of the barriers affecting this map. Internal visibility reflects that barrier management is handled by the input system.

  • public System.Collections.Generic.IEnumerable<ProxyBinding> bindings
    Enumerates all ProxyBinding instances across every ProxyAction and their composites. The iterator walks m_Actions -> proxyAction.composites -> composite.bindings and yields each ProxyBinding. Useful for inspecting or processing every binding exposed by this map.

  • public bool enabled => m_Enabled
    Indicates whether this ProxyActionMap is currently enabled (no blocking barriers). Changing internal barrier state may update this.

  • public InputManager.DeviceType mask { get; internal set }
    Gets or sets the device-type mask for this map. Setting the mask:

  • Applies the mask to the underlying InputActionMap via m_SourceMap.bindingMask = value.ToInputBinding();
  • If the mask changes, calls UpdateState() on every ProxyAction to refresh enabled/disabled states and any binding-related state. Setter is internal: external code should use InputManager helpers to change masks.

Constructors

  • internal ProxyActionMap(UnityEngine.InputSystem.InputActionMap sourceMap)
    Constructs a ProxyActionMap wrapping the provided InputActionMap. The constructor stores the source map reference; call InitActions() to create ProxyAction wrappers for existing actions in the map. Internal visibility: instances are created by the game's input manager.

Methods

  • internal void InitActions()
    Create ProxyAction instances for every InputAction currently present in sourceMap.actions and add them to m_Actions. After creating the ProxyAction objects the method calls UpdateState() to synchronize enabled/disabled states. Use this after constructing the proxy or after the source map has been populated.

  • public ProxyAction FindAction(string name)
    Return the ProxyAction with the given name if present; otherwise returns null. Simple dictionary lookup wrapper.

  • internal ProxyAction FindAction(UnityEngine.InputSystem.InputAction action)
    Convenience overload that finds a ProxyAction by an InputAction instance by using action.name to look up the proxy.

  • public bool TryFindAction(string name, out ProxyAction action)
    Attempt to get the ProxyAction by name and return true/false depending on existence. Standard Try pattern.

  • public ProxyAction AddAction(ProxyAction.Info actionInfo, bool bulk = false)
    Add a new action to the underlying InputActionMap and create a ProxyAction wrapper for it. Behavior:

  • Logs timing information via Colossal.PerformanceCounter and InputManager.log.InfoFormat when the action is added.
  • Uses InputManager.DeferUpdating() to batch updates while the action and its composites are created.
  • If an action with the same name already exists in m_Actions, returns that existing ProxyAction.
  • Adds an InputAction to m_SourceMap with the provided name, type and expected control layout (via actionInfo).
  • For each ProxyComposite.Info in actionInfo.m_Composites, delegates to InputManager.instance.CreateCompositeBinding to create composite bindings on the InputAction.
  • Creates and stores a new ProxyAction and calls InputManager.instance.InitializeMasks(action) to apply masks to the new action.
  • Returns the newly created (or existing) ProxyAction. Note: actionInfo contains proto metadata describing the action and its composites; this method is how the game dynamically injects built actions into the map.

  • internal void UpdateState()
    Compute whether the map should be enabled by checking that all barriers in m_Barriers are not blocking (m_Barriers.All(b => !b.blocked)). If the computed enabled flag differs from the cached m_Enabled, update m_Enabled and call UpdateState() on every ProxyAction to propagate the change. This is used whenever barriers change or when mask changes force a refresh.

Usage Example

// Typical usage from the input manager or mod code that has access
// to a Unity InputActionMap created/loaded elsewhere.

var sourceMap = /* obtain UnityEngine.InputSystem.InputActionMap from asset or runtime */;
var proxyMap = new ProxyActionMap(sourceMap);

// Initialize proxy actions for existing actions in the source map
proxyMap.InitActions();

// Lookup an action
var moveAction = proxyMap.FindAction("Move");
if (moveAction != null)
{
    // Inspect bindings
    foreach (var binding in proxyMap.bindings)
    {
        // process binding
    }
}

// Add a new action dynamically (requires constructing ProxyAction.Info)
var actionInfo = new ProxyAction.Info
{
    m_Name = "MyCustomAction",
    m_Type = ProxyAction.Type.Button, // example
    m_Composites = new List<ProxyComposite.Info>() // composites/bindings if any
};
var added = proxyMap.AddAction(actionInfo);

// Change device mask (internal setter - normally done via InputManager)
proxyMap.mask = InputManager.DeviceType.Keyboard;

// Manually force state update (normally done by input manager when barriers change)
proxyMap.UpdateState();

Notes: - ProxyActionMap is primarily managed by the game's InputManager; most consumer code interacts via InputManager high-level APIs. - Many members are internal — the class is designed for use inside the game's input subsystem rather than general public moddable API surface.