Fuse
A class in Root.Township, the global namespace.
A burning fuse, as on dynamite. Once lit (a hit lights it) it burns down over FuseTime and the server raises Finished, probably what sets off the explosion.
- Listed in Global namespace: E to H
- Inherits or implements
NetworkEntityBehaviour,ISavable<FuseSaveData>,ISavableSave<FuseSaveData>,ISavableSaveBase,IFlammable,ICleanOnSerialize - Derived types
FuseSaveData - Nested types
DockSettings - Documented in Other systems
Constructors
| Member | What it is |
|---|---|
Fuse() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
19 private and internal fields
| Member | What it is |
|---|---|
private float currentFuseAmount | Fuse left, from 1 (full) to 0 (exploded). Backing field for CurrentFuseAmount. |
private float damageThreshold | Damage that should set it off, per the tooltip. Not used in this file. |
private Fuse.DockSettings dockSettings | How a lit fuse limits docking: Default, Single (only into an empty dock, then blocks it) or Blocked. |
private AltaEvent finishedOnServer | Event raised on the server when the fuse burns out. Exposed as Finished. |
private MethodSync finishSync | Method sync for the DynamiteExplosion message. |
private Transform fuse | Transform scaled along Y to show how much fuse is left. |
private AltaCoroutine fuseCoroutine | The running FuseTimer coroutine. |
private float fuseLength | Full length of the fuse visual. Backing field for FuseLength. |
private float fuseTime | Seconds from lighting to finishing. Backing field for FuseTime. |
private ImpactDetector impactDetector | Optional impact detector. Any hit lights the fuse. |
private bool isFinished | True once the fuse has burnt out. Backing field for IsFinished. |
private bool isLit | True while burning. Backing field for IsLit. |
private bool isPreventingDockingWhenLit | If set, a lit fuse can only dock into docks with one of whenLitAcceptOnlyTags. |
private GameObject litEffect | Object shown while lit, hidden when docked small. |
private Pickup pickup | The pickup holding the fuse. Made transient while lit. |
private AltaEvent started | Event raised when the fuse is lit. |
private AltaEvent stopped | Event raised when the fuse is put out. |
private MethodSync sync | Method sync for the DynamiteFuseProgress message. Sent to players as they connect. |
private PickupTag[] whenLitAcceptOnlyTags | Dock tags a lit fuse may still dock into when isPreventingDockingWhenLit is set. |
Properties
1 private and internal property
Events
| Member | What it is |
|---|---|
event Action Finished | Server: raised when the fuse burns out. Adds to the finishedOnServer event set in the prefab. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Sets up the fuse syncs and the dock rules (default, single, or blocked while lit). |
override void InitializeAsServer(SpawnData spawnData) | Server: restarts the burn timer if the fuse was saved while lit. |
override void OnConnected(Player player) | Server: sends the fuse state to the joining player. |
void ToggleLight(bool isLit) | Calls TryLight or Unlight. |
void TryLight() | Server: lights the fuse, makes the pickup transient, syncs and starts the burn timer. Ignored if already lit or finished. |
void Unlight() | Server: puts the fuse out and resets it to full length. |
void UpdateFuse() | Client: scales the fuse visual to the remaining amount and shows the lit effect while burning. |
15 private and internal methods
| Member | What it is |
|---|---|
private void Block(Interactor interactor, Pickup pickup, ref bool isBlocked) | Dock filter that blocks everything. Added to the dock a lit fuse sits in when dockSettings is Single. |
private void CancelFuse(NetworkEntity entity, bool isUnload) | Stops the fuse coroutine when the scene destroys the entity. |
private void CheckBlock(Interactor interactor, Pickup pickup, PickupDock dock) | On docking while lit, blocks that dock from taking anything else. |
private void DockFilter(Interactor interactor, PickupDock dock, ref bool result) | While lit, stops the pickup docking at all (Blocked) or into a dock that already holds something (Single). |
private void FilterAllDocking(Interactor interactor, PickupDock dock, ref bool result) | While lit with isPreventingDockingWhenLit, only allows docks whose tags include one of whenLitAcceptOnlyTags. |
private void FinishSync(IPlayer player, Stream stream) | Client: marks the fuse finished and undocks the pickup when the server says it exploded. |
private IEnumerator FuseTimer() (iterator) | Coroutine that burns the fuse down over fuseTime seconds. Server: at zero, syncs, undocks and drops the pickup, and raises Finished. |
private void OnDisable() | Unhooks the impact detector. |
private void OnEnable() | Hooks the impact detector so a hit lights the fuse. |
private void OnHit(ImpactHit impact) | Clears the impact detector's settings and tries to light the fuse. |
private void ICleanOnSerialize.OnSerialize() | Puts the fuse out before the entity is serialized, so copies aren't saved lit. |
private void Serialize(Stream stream) | Writes or reads the finished flag, and if not finished, the lit flag and fuse amount. Updates the visual on read. |
private void StartTimer() | Restarts the fuse coroutine and hooks cancelling it if the entity is destroyed. |
private void SyncFuse(IPlayer player, Stream stream) | Server to client sync of the fuse state. Client: starts or stops the burn, effects and dock rules to match. |
private void Unblock(Interactor interactor, Pickup pickup, PickupDock dock) | Removes the Block filter from the dock the pickup left. |