Playerinspectable
Overview
The PlayerInspectable component ensures that equipment and active skill selection state for a player entity are properly broadcast to clients via the network layer. It does not store persistent state but acts as a bridge between gameplay events (equipping items, activating skills) and network synchronization.
Dependencies & Tags
- Component Events Listened To:
equip,unequip,onactivateskill_server,ondeactivateskill_server,onsetskillselection_server - No components added or tags set by this component itself.
- Uses external modules:
equipslotutil(forEquipSlot.ToID)
Properties
No public properties are initialized in this component. It only holds a reference to the owner instance (self.inst) and registers event listeners in the constructor.
Main Functions
OnEquip(inst, data)
- Description: Handles the
equipevent by updating the network-equipped item for the corresponding equipment slot. UsesEquipSlot.ToIDto convert the slot enum to an ID and sends the item’s prefab name (or override/skin name if provided). - Parameters:
inst: The entity (player) that equipped an item.data: Table containing:data.eslot: Equipment slot (enum).data.item: The equipped item instance, expected to haveGetSkinName()and/orplayerinspectable_overrideorprefab.
OnUnequip(inst, data)
- Description: Handles the
unequipevent by clearing the network representation of the equipped item in the specified slot. - Parameters:
inst: The entity (player) that unequipped an item.data: Table containing:data.eslot: Equipment slot (enum).
OnSkillSelectionUpdated(inst, data)
- Description: Broadcasts the current player skill selection to clients via the network when skill activation/deactivation or explicit setting occurs. Returns early if
skilltreeupdatercomponent is absent. - Parameters:
inst: The player entity.data: Event data (unused in function body).
Events & Listeners
- Listens to
"equip"→ triggersOnEquip - Listens to
"unequip"→ triggersOnUnequip - Listens to
"onactivateskill_server"→ triggersOnSkillSelectionUpdated - Listens to
"ondeactivateskill_server"→ triggersOnSkillSelectionUpdated - Listens to
"onsetskillselection_server"→ triggersOnSkillSelectionUpdated