Explosive
A class in Root.Township, the global namespace.
Networked explosion: when triggered, the server damages health objects and impact detectors in range with linear falloff and can push rigidbodies; the effect plays on every client.
- Listed in Global namespace: E to H
- Inherits or implements
NetworkEntityBehaviour - Derived types
ColoredExplosive
Constructors
| Member | What it is |
|---|---|
Explosive() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
22 private and internal fields
| Member | What it is |
|---|---|
private Pickup basePickup | Pickup the explosive belongs to, used for the wielder. |
private float blastForce | Explosion force applied to rigidbodies in range. |
private bool btnTrigger | Inspector button that calls Trigger. |
private ImpactChannel[] channels | Impact channels a detector needs to be hit. |
private float crippleDamage | Cripple damage at full effectiveness. |
private float damageFallOff | Distance between maxDamageRange and range. |
private HashSet<ImpactDetector> detectors | Impact detectors without a health target hit by this blast. |
private PooledObjectDefinitionBase effectDefinition | Pooled effect played on explosion. |
private EvaluateWielder getWielder | Delegate that returns the entity and player credited with the damage. |
private int hardnessLevel | Highest detector hardness that can be hit; -1 skips the check. |
private float healthDamage | Health damage at full effectiveness. |
private HashSet<HealthObject> healths | Health objects hit by this blast. |
private ImpactType impactType | Impact type of the hit, explosive by default. |
private bool isTriggered | Set once Trigger has run. |
private LayerMask layerMask | Layers the overlap sphere checks. |
private float maxDamageRange | Distance within which targets take full damage. |
private float maxDamageRangeSquared | Square of maxDamageRange. |
private bool moveObjects | Inspector toggle that shows blastForce; the force is applied whenever it is above zero. |
private float playerDamageMultiplier | Multiplier on health damage dealt to players. |
private float range | Furthest distance anything is affected. |
private float rangeSquared | Square of range. |
private MethodSync syncEffect | Method sync that tells clients to play the effect. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Creates the effect sync. |
override void InitializeAsServer(SpawnData data) | Works out who gets credit for the damage: the parent pickup's last interactor, or the prefab root if there is no pickup. |
void OnDrawGizmosSelected() | Draws the full-damage and maximum ranges. |
void Trigger() | Server: overlap-spheres the range, damages matching detectors and health objects once each, applies blast force, plays the effect and syncs it. |
protected virtual PooledObject GetEffect(Vector3 position, Quaternion rotation) | Spawns the pooled explosion effect at a position; override to change the effect. |
3 private and internal methods
| Member | What it is |
|---|---|
private bool GetEffectiveness(Vector3 position, Vector3 origin, out float effectiveness) | Gives 1 inside maxDamageRange, falling linearly to 0 at range; false when out of range. |
private void RootChanged(CraftingPart newRoot) | When crafted into a new root, moves the last player interactor to the new root's pickup and tracks that. |
private void SyncEffect(IPlayer player, Stream stream) | On remote clients (not headless), plays the effect at the explosive's position. |