Skip to main content

BasicChiselable

A class in Root.Township, Features.Gameplay.Activities.Carpentry.

Simple chisel target with a health value. The server takes off chisel damage and, when health runs out, fires its broken events on the server and on clients in the chunk.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private AltaEvent brokenClientEvent fired on clients when the object breaks.
private AltaEvent brokenServerEvent fired on the server when the object breaks.
private float healthDamage left before the object breaks. Default 1. Not synced or saved.
private MethodSync syncMethod sync used to send the break to clients.
private FloatEvent tookDamageEvent fired with the damage amount on each hit.

Properties​

MemberWhat it is
bool IsEnabled { get; set; }IChiselable flag, default true. ReceiveDamage checks the component's enabled instead, not this.

Methods​

MemberWhat it is
virtual void GetDirectionLeniency(ref float directionMultiplier)Virtual hook to change the chisel direction multiplier. Does nothing here.
virtual float GetHitMultiplier(Vector3 hitDirection)Virtual hook for a per-direction damage multiplier. Returns 1 here.
override void Initialize()Creates the break method sync on SyncB.
virtual void ReceiveDamage(float damage, Vector3 position, Vector3 direction, ChiselingTool tool, Collider hitCollider)Fires tookDamage on both sides; on the server, takes damage off health and breaks the object at zero.
protected virtual void OnBrokenServer(float damage, Vector3 position, Vector3 direction, ChiselingTool tool, Collider hitCollider)Server: tells clients in the chunk the object broke and fires brokenServer. Override to add behaviour.
protected virtual bool OnDamageTakenServer(float damage, Vector3 position, Vector3 direction, ChiselingTool tool, Collider hitCollider)Server: virtual check run before damage is applied; return false to ignore the hit. Returns true here.
1 private and internal method
MemberWhat it is
private void SyncBreak(IPlayer player, Stream stream)Client: fires brokenClient when the break message arrives, if there is a local player.