Class EquippableBuilder
Builder for creating equippable components that can be attached to items. Use this to create custom equippable behavior for items.
public sealed class EquippableBuilder
- Inheritance
-
EquippableBuilder
- Inherited Members
- Extension Methods
Constructors
EquippableBuilder()
public EquippableBuilder()
Methods
Build()
Builds and finalizes the equippable component. Configures the GameObject to be persistent and inactive (prefab-like state).
public Equippable Build()
Returns
- Equippable
A wrapper around the created equippable component.
CreateBasicEquippable(string)
Creates a basic equippable GameObject with the default Equippable component.
public EquippableBuilder CreateBasicEquippable(string name = null)
Parameters
namestringOptional name for the GameObject.
Returns
- EquippableBuilder
The builder instance for fluent chaining.
CreateEquippable<T>(string)
Creates an equippable GameObject with the specified equippable component type.
public EquippableBuilder CreateEquippable<T>(string name = null) where T : Equippable
Parameters
namestringOptional name for the GameObject. If not provided, uses the type name.
Returns
- EquippableBuilder
The builder instance for fluent chaining.
Type Parameters
TThe type of equippable component to create. Must inherit from the game's Equippable class.
CreateViewmodelEquippable(string)
Creates a viewmodel equippable GameObject with Equippable_Viewmodel component. This allows the item to be held in first-person with a 3D model.
public EquippableBuilder CreateViewmodelEquippable(string name = null)
Parameters
namestringOptional name for the GameObject.
Returns
- EquippableBuilder
The builder instance for fluent chaining.
WithAvatarEquippable(string, AvatarHand, string)
Configures the third-person avatar equippable animation. Only applies to viewmodel equippables created with CreateViewmodelEquippable(string).
public EquippableBuilder WithAvatarEquippable(string assetPath, AvatarHand hand = AvatarHand.Right, string animationTrigger = "RightArm_Hold_ClosedHand")
Parameters
assetPathstringResources path to the AvatarEquippable prefab (e.g., "Equippables/MyItem").
handAvatarHandWhich hand holds the item in third-person (Left or Right).
animationTriggerstringAnimation trigger/bool name for third-person animation.
Returns
- EquippableBuilder
The builder instance for fluent chaining.
WithInteraction(bool, bool)
Configures interaction and pickup capabilities when this item is equipped.
public EquippableBuilder WithInteraction(bool canInteract, bool canPickup)
Parameters
canInteractboolWhether the player can interact with objects when this is equipped.
canPickupboolWhether the player can pick up items when this is equipped.
Returns
- EquippableBuilder
The builder instance for fluent chaining.
WithUseCallback(Action<ItemInstance>)
Registers a callback to be invoked when the player uses this item (clicks while holding it). Only applies to viewmodel equippables created with CreateViewmodelEquippable(string). The callback receives the ItemInstance being used.
public EquippableBuilder WithUseCallback(Action<ItemInstance> callback)
Parameters
callbackAction<ItemInstance>Callback to invoke when the item is used.
Returns
- EquippableBuilder
The builder instance for fluent chaining.
WithViewmodelTransform(Vector3, Vector3, Vector3?)
Configures the first-person viewmodel transform settings. Only applies to viewmodel equippables created with CreateViewmodelEquippable(string).
public EquippableBuilder WithViewmodelTransform(Vector3 position, Vector3 rotation, Vector3? scale = null)
Parameters
positionVector3Local position offset for the viewmodel.
rotationVector3Local euler angles for the viewmodel.
scaleVector3?Local scale for the viewmodel (default: Vector3.one).
Returns
- EquippableBuilder
The builder instance for fluent chaining.