Gear entity
Entity defined in core/entities/entities/cw_gear
Shared definition of the cw_gear entity: its networked item Index and the accessors for its item, owner,
attachment bone and offsets.
ENT:GetRealPosition works out where the gear is drawn from the owner's bone (or their ragdoll's) and the item's
attachmentOffsetVector and attachmentOffsetAngles, which the item's AdjustAttachmentOffsetInfo can change.
Summary
Methods
Index integer holding the item's instance index.ENT:GetShouldExist and ENT:GetIsVisible decide, and copies the owner's material.Methods
Positions the gear on its owner's bone, applies the model scale and draws it.
Does nothing when PreGearEntityDraw returns true. The item's GetAttachmentModelScale can change the
scale, and GearEntityDraw can return false to skip drawing.
Returns the name of the bone the gear is attached to.
Returns
- String The item's
attachmentBone, or an empty string
ENT:GetIsVisible(player)
server gamemodes/catwork/gamemode/core/entities/entities/cw_gear/init.lua:57Returns whether the gear should be visible on the player.
Uses the item's GetAttachmentVisible(player, entity) when defined. Weapon gear is hidden while that
weapon is the active one; other gear is always visible.
Parameters
- player Player The player wearing the gear
Returns
- Boolean Whether the gear is visible, or
nilwhen the entity has no item
Returns the item instance shown as this gear.
On the client it uses the fetched item data, falling back to item.FindByID with the networked index.
Returns
- Item The item instance, or
nilif it is not known
ENT:GetOffsetAngle()
shared gamemodes/catwork/gamemode/core/entities/entities/cw_gear/shared.lua:110Returns the gear's angle offset from its bone.
Returns
- Angle The item's
attachmentOffsetAngles, or a zero angle
ENT:GetOffsetVector()
shared gamemodes/catwork/gamemode/core/entities/entities/cw_gear/shared.lua:103Returns the gear's position offset from its bone.
Returns
- Vector The item's
attachmentOffsetVector, or a zero vector
Returns the player who owns the gear.
Returns
- Player The owner, or
nilwhen the owner is not a valid player
ENT:GetRealPosition()
shared gamemodes/catwork/gamemode/core/entities/entities/cw_gear/shared.lua:26Returns where the gear should be drawn: the owner's attachment bone plus the item's offsets.
Uses the ragdoll's bone when the owner is ragdolled. The item's AdjustAttachmentOffsetInfo(player, entity, info) can change info.offsetVector and info.offsetAngle before they are applied.
Returns
- Vector The world position, or
nilwhen the owner or bone is missing - Angle The world angles
ENT:GetShouldExist(player)
server gamemodes/catwork/gamemode/core/entities/entities/cw_gear/init.lua:31Returns whether the gear should still exist on the player.
Uses the item's GetAttachmentExists(player, entity) when defined. Weapon items exist while the player (or
their ragdoll) has the weapon; other items always exist.
Parameters
- player Player The player wearing the gear
Returns
- Boolean Whether the gear should exist, or
nilwhen the entity has no item
Sets up the gear as a non-solid, shadowless physics entity.
ENT:SetItemTable(gearClass, itemTable)
server gamemodes/catwork/gamemode/core/entities/entities/cw_gear/init.lua:80Sets the gear slot and item the entity represents and networks the item's index.
Parameters
- gearClass String The gear slot name, used as the key in the player's gear table
- itemTable Item The item instance shown as gear
ENT:SetMustHave(bMustHave)
server gamemodes/catwork/gamemode/core/entities/entities/cw_gear/init.lua:73Sets whether the gear is removed when the player no longer has the item in their inventory.
Parameters
- bMustHave Boolean Remove the gear once the player loses the item
ENT:SetupDataTables()
shared gamemodes/catwork/gamemode/core/entities/entities/cw_gear/shared.lua:17Sets up the networked Index integer holding the item's instance index.
On the server
Removes or hides the gear as ENT:GetShouldExist and ENT:GetIsVisible decide, and copies the owner's material.
Recreates the gear with cw.player:CreateGear when the item's model changed since the gear was made or the
item's ShouldGearRespawn says so, and removes it when it must be carried (ENT:SetMustHave) but the player
lost the item.
On the client
Fetches the item data, then hides the gear while the local player wears it in first person or is dead.
Defined in
ENT:UpdateTransmitState()
server gamemodes/catwork/gamemode/core/entities/entities/cw_gear/init.lua:21Always transmits the gear to every client.