Skip to main content

ConsumableLock

A class in Root.Township, Alta.Inventory.

A lock that is used up: when unlocked it breaks the key and plays an unlock animation, and Break destroys the lock itself.

Constructors​

MemberWhat it is
ConsumableLock()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

3 private and internal fields
MemberWhat it is
private NetworkAnimator animatorNetwork animator that plays the Unlock trigger.
private LockEvent lockBreakEventBacking field for LockBreakEvent.
private MethodSync requestEffectNetwork message used to send the break to clients.

Properties​

MemberWhat it is
LockEvent LockBreakEvent { get; }Event fired when the lock breaks, on the server and (through a network message) on clients.

Methods​

MemberWhat it is
void Break()Server: fires the break event, tells the chunk's clients, and destroys the lock entity.
override void Initialize()Sets up the network message that plays the break effect on clients.
protected override void Unlocked()Removes the key joint, frees the rigidbody and, on the server, breaks the key and fires the Unlock trigger.
1 private and internal method
MemberWhat it is
private void NetworkBreak(IPlayer player, Stream stream)Client: fires the break event when the server reports the lock broke.