Class EquipmentController
Controls the character's equipment slots, handling equip/unequip logic and network synchronization. Manages client-server broadcasts for equipment changes and slot management.
Implements IPredictableController at Order 93 so equipment state participates
in the prediction pipeline. Equipment-driven attribute changes are reconciled alongside
other predicted state, eliminating the broadcast/reconcile race on ExternalModifier.
Three network paths feed this container and they must agree with one another:
- The spawn payload (WritePayload(NetworkConnection, Writer)/ReadPayload(NetworkConnection, Reader)) — owner shaped for the owner, template+seed only for everyone else.
- The owner's acknowledgement broadcasts and reconcile snapshot, which can arrive in either order and are reconciled against each other by instance id (see RestoreFromReconcile(EquipmentReconcileEntry[]) and the pending-request records).
- EquipmentObservedSlotBroadcast, sent by the server to the character's observers after every successful equip/unequip, applied by ApplyObservedSlot(int, int, int).
public class EquipmentController : ItemContainer, IEquipmentController, ICharacterBehaviour, IItemContainer, IPredictableController
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourNetworkBehaviourEquipmentController
- Implements
- Inherited Members
-
NetworkBehaviour.IsSpawnedNetworkBehaviour.ComponentIndexNetworkBehaviour.NetworkObjectNetworkBehaviour.MAXIMUM_NETWORKBEHAVIOURSNetworkBehaviour.UNSET_NETWORKBEHAVIOUR_IDNetworkBehaviour.ToString()NetworkBehaviour.Reset()NetworkBehaviour.OnValidate()NetworkBehaviour.IsBehaviourReconcilingNetworkBehaviour.ClearReplicateCache()NetworkBehaviour.CreateReconcile()NetworkBehaviour.Reconcile_Reader<T>(PooledReader, ref T)NetworkBehaviour.OnStartServerCalledNetworkBehaviour.OnStartClientCalledNetworkBehaviour.OnStopNetwork()NetworkBehaviour.OnStartServer()NetworkBehaviour.OnStopServer()NetworkBehaviour.OnOwnershipServer(NetworkConnection)NetworkBehaviour.OnSpawnServer(NetworkConnection)NetworkBehaviour.OnDespawnServer(NetworkConnection)NetworkBehaviour.OnStartClient()NetworkBehaviour.OnStopClient()NetworkBehaviour.OnOwnershipClient(NetworkConnection)NetworkBehaviour.ClearBuffedRpcs()NetworkBehaviour.ExcludeOwnerFromUnbufferedObserversRpcsNetworkBehaviour.IsClientOnlyNetworkBehaviour.IsServerOnlyNetworkBehaviour.IsHostNetworkBehaviour.IsClientNetworkBehaviour.IsServerNetworkBehaviour.IsDeinitializingNetworkBehaviour.NetworkManagerNetworkBehaviour.ServerManagerNetworkBehaviour.ClientManagerNetworkBehaviour.ObserverManagerNetworkBehaviour.TransportManagerNetworkBehaviour.TimeManagerNetworkBehaviour.SceneManagerNetworkBehaviour.PredictionManagerNetworkBehaviour.RollbackManagerNetworkBehaviour.NetworkObserverNetworkBehaviour.IsClientInitializedNetworkBehaviour.IsClientStartedNetworkBehaviour.IsClientOnlyInitializedNetworkBehaviour.IsClientOnlyStartedNetworkBehaviour.IsServerInitializedNetworkBehaviour.IsServerStartedNetworkBehaviour.IsServerOnlyInitializedNetworkBehaviour.IsServerOnlyStartedNetworkBehaviour.IsHostInitializedNetworkBehaviour.IsHostStartedNetworkBehaviour.IsOfflineNetworkBehaviour.IsNetworkedNetworkBehaviour.GetIsNetworked()NetworkBehaviour.IsManagerReconcilingNetworkBehaviour.ObserversNetworkBehaviour.IsOwnerNetworkBehaviour.IsControllerNetworkBehaviour.HasAuthorityNetworkBehaviour.OwnerNetworkBehaviour.OwnerIdNetworkBehaviour.ObjectIdNetworkBehaviour.LocalConnectionNetworkBehaviour.OwnerMatches(NetworkConnection)NetworkBehaviour.Despawn(GameObject, DespawnType?)NetworkBehaviour.Despawn(NetworkObject, DespawnType?)NetworkBehaviour.Despawn(DespawnType?)NetworkBehaviour.Spawn(GameObject, NetworkConnection, Scene)NetworkBehaviour.Spawn(NetworkObject, NetworkConnection, Scene)NetworkBehaviour.RemoveOwnership()NetworkBehaviour.GiveOwnership(NetworkConnection)NetworkBehaviour.GetInstance<T>()NetworkBehaviour.TryRegisterInstance<T>(T)NetworkBehaviour.UnregisterInstance<T>()NetworkBehaviour.CanLog(LoggingType)MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.didStartMonoBehaviour.didAwakeMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.GetComponent<T>()Component.TryGetComponent<T>(out T)Component.GetComponentInChildren<T>()Component.GetComponentsInChildren<T>()Component.GetComponentInParent<T>()Component.GetComponentsInParent<T>()Component.GetComponents<T>()Component.GetComponentIndex()Component.CompareTag(TagHandle)Component.transformComponent.transformHandleComponent.gameObjectComponent.tagObject.GetEntityId()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.nameObject.hideFlags
Properties
OnEquipTriggers
Triggers invoked when this character equips an item. EventData: EquipItemEventData.
public List<Trigger> OnEquipTriggers { get; }
Property Value
OnUnequipTriggers
Triggers invoked when this character unequips an item. EventData: EquipItemEventData.
public List<Trigger> OnUnequipTriggers { get; }
Property Value
Order
Execution order in the unified prediction pipeline. Runs after CooldownController (90) and before CharacterAttributeController (95) so equipment attribute modifiers are settled before the attribute reconcile snapshot.
public int Order { get; }
Property Value
Remarks
Must stay below Order (95). Restoring an
item restates its own ledger entry through
ItemGenerator.ApplyAttributes → CharacterAttribute.SetSource; the attribute
reconcile then installs the server's total as the residual over whatever those entries sum
to. Raising this above 95 would have that residual computed before this tick's equipment is
settled, so an item equipped on the reconciled tick counts twice. See the remarks on
Order.
Methods
Activate(int)
Activates the item in the specified equipment slot, typically triggering its use effect.
public void Activate(int index)
Parameters
indexintThe equipment slot index to activate.
ClearPendingRequest(ItemSlot)
public void ClearPendingRequest(ItemSlot slot)
Parameters
slotItemSlot
Equip(Item, int, IItemContainer, ItemSlot)
Equips the specified item into the given equipment slot, handling swaps and unequips as needed.
public bool Equip(Item item, int inventoryIndex, IItemContainer container, ItemSlot toSlot)
Parameters
itemItemThe item to equip.
inventoryIndexintThe index in the source inventory.
containerIItemContainerThe source item container (e.g., inventory or bank).
toSlotItemSlotThe equipment slot to equip the item into.
Returns
- bool
True if the item was successfully equipped, false otherwise.
NotifyEquipRequested(Item, int, InventoryType, ItemSlot)
public void NotifyEquipRequested(Item item, int inventoryIndex, InventoryType fromInventory, ItemSlot toSlot)
Parameters
itemIteminventoryIndexintfromInventoryInventoryTypetoSlotItemSlot
NotifyUnequipRequested(ItemSlot, InventoryType)
public void NotifyUnequipRequested(ItemSlot slot, InventoryType toInventory)
Parameters
slotItemSlottoInventoryInventoryType
OnAwake()
Called before InitializeOnce, character will not be set yet. Override for early setup.
public override void OnAwake()
OnCreateReconcile(ref CharacterReconcileData)
Writes this controller's authoritative state into the reconcile data (server only). Called once per tick after OnReplicate(ref CharacterReplicateData, ReplicateState, Channel).
public void OnCreateReconcile(ref CharacterReconcileData data)
Parameters
OnReconcile(CharacterReconcileData, Channel)
Restores this controller's state from the server's authoritative reconcile data.
public void OnReconcile(CharacterReconcileData data, Channel channel)
Parameters
dataCharacterReconcileDatachannelChannel
OnReplicate(ref CharacterReplicateData, ReplicateState, Channel)
Executes this controller's simulation for the current tick.
May modify input for observer prediction.
public void OnReplicate(ref CharacterReplicateData input, ReplicateState state, Channel channel)
Parameters
inputCharacterReplicateDatastateReplicateStatechannelChannel
OnStartCharacter()
Called after Character.OnStartClient. Use this for local client initialization.
public override void OnStartCharacter()
OnStartNetwork()
Called when the network has initialized this object. May be called for server or client but will only be called once. When as host or server this method will run before OnStartServer. When as client only the method will run before OnStartClient.
public override void OnStartNetwork()
OnStopCharacter()
Called right before Character.OnStopClient. Use this for local client cleanup.
public override void OnStopCharacter()
PopulateInput(ref CharacterReplicateData)
Populates this controller's portion of the unified input data (owner only). Called once per tick before OnReplicate(ref CharacterReplicateData, ReplicateState, Channel).
public void PopulateInput(ref CharacterReplicateData input)
Parameters
inputCharacterReplicateData
ReadPayload(NetworkConnection, Reader)
Called before network start callbacks, but after the object is initialized with network values. This may be used to read information from predicted spawning, or simply have values set before initialization without depending on SyncTypes.
public override void ReadPayload(NetworkConnection conn, Reader reader)
Parameters
connNetworkConnectionreaderReader
ResetState(bool)
Resets this NetworkBehaviour so that it may be added to an object pool.
public override void ResetState(bool asServer)
Parameters
asServerbool
Unequip(IItemContainer, byte, out List<Item>)
Unequips the item from the specified slot and adds it to the given container (e.g., inventory or bank).
public bool Unequip(IItemContainer container, byte slot, out List<Item> modifiedItems)
Parameters
containerIItemContainerThe destination item container.
slotbyteThe equipment slot to unequip from.
modifiedItemsList<Item>The list of items modified during the operation.
Returns
- bool
True if the item was successfully unequipped and added, false otherwise.
WritePayload(NetworkConnection, Writer)
Called when writing a spawn. This may be used to deliver information for predicted spawning, or simply have values set before initialization without depending on SyncTypes.
public override void WritePayload(NetworkConnection conn, Writer writer)
Parameters
connNetworkConnectionwriterWriter
Events
OnItemEquipped
Fired after an item is successfully equipped. Subscribers receive the item and the slot.
public event Action<Item, ItemSlot> OnItemEquipped
Event Type
OnItemUnequipped
Fired after an item is successfully unequipped. Subscribers receive the item and the slot.
public event Action<Item, ItemSlot> OnItemUnequipped