ItemNetwork
Network behaviour component for items. Initializes network interaction triggers on spawn by iterating all InteractionContext entries on the item's Interactable and attaching a NetworkTrigger keyed by interaction type name to each one.
Definition
Namespace: Paragon.Townskeep.ItemSystem
Assembly: Townskeep.dll
public class ItemNetwork : ParagonNetworkBehaviourInheritance: NetworkBehaviour → ParagonNetworkBehaviour → ItemNetwork
Remarks
ItemNetwork is a lightweight component whose sole responsibility is to bridge the gap between items and the multiplayer interaction system. When an item is spawned on the network, each of its interactions needs a NetworkTrigger so that remote clients can invoke those interactions.
The trigger type string is derived from the interaction's concrete class name (GetType().Name), which serves as a unique identifier for matching network trigger requests to the correct interaction context.
This component is expected to live on the same GameObject as Item and Interactable. It is initialized during Item.Awake() and its OnSpawn() is called from Item.OnSpawn().
Quick Lookup
Initialize with an item
itemNetwork.Initialize(item) — called by Item.Awake()
Register network triggers
itemNetwork.OnSpawn() — called by Item.OnSpawn()
Methods
Initialize
Stores references to the Item and its Interactable component for use during spawn.
item
Item
The owning item
OnSpawn
Iterates all InteractionContext entries in the item's InteractionTable and adds a NetworkTrigger to each one. The trigger type is the interaction's concrete class name.
Spawn pipeline:
Common Pitfalls
Initialize() must be called before OnSpawn()
OnSpawn() accesses interactable, which is set by Initialize(). Calling OnSpawn() before initialization causes a NullReferenceException.
Trigger type name is fragile
The trigger type string uses GetType().Name, which is the short class name without namespace. Renaming an interaction class breaks existing network trigger matching.
Triggers are added but never removed
OnSpawn() adds triggers to each context but does not track or remove them on despawn. If items are pooled and re-spawned, duplicate triggers may accumulate.
See Also
ItemSpawner — spawns items over the network
ParagonNetworkBehaviour — base class
Last updated