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

Draw()client
Positions the gear on its owner's bone, applies the model scale and draws it.
GetBone()shared
Returns the name of the bone the gear is attached to.
Returns whether the gear should be visible on the player.
Returns the item instance shown as this gear.
Returns the gear's angle offset from its bone.
Returns the gear's position offset from its bone.
Returns the player who owns the gear.
Returns where the gear should be drawn: the owner's attachment bone plus the item's offsets.
Returns whether the gear should still exist on the player.
Sets up the gear as a non-solid, shadowless physics entity.
Sets the gear slot and item the entity represents and networks the item's index.
Sets whether the gear is removed when the player no longer has the item in their inventory.
Sets up the networked Index integer holding the item's instance index.
Think()shared
Removes or hides the gear as ENT:GetShouldExist and ENT:GetIsVisible decide, and copies the owner's material.
Always transmits the gear to every client.

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

Returns 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 nil when 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 nil if it is not known

Returns the gear's angle offset from its bone.

Returns

  • Angle The item's attachmentOffsetAngles, or a zero angle

Returns 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 nil when the owner is not a valid player

Returns 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 nil when the owner or bone is missing
  • Angle The world angles

Returns 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 nil when 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:80

Sets 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

Sets 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

Sets 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

Always transmits the gear to every client.

Defined in