DamageOnTouch
namespace Griff.Scenes;
public sealed class DamageOnTouch : ComponentHurts whatever with Health it touches, with no code: spikes, lava, enemies, bullets. Works on solid collisions and triggers, and keeps hurting while they stay touching (each hit still waits out the target’s InvincibleTime). Needs a collider on the same entity.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”Amount
Section titled “Amount”public float Amount { get; set; }How much health each hit takes.
AmountRoll
Section titled “AmountRoll”public string? AmountRoll { get; set; }Dice rolled for each hit in place of Amount, e.g. “1d8+2”; empty hits for Amount every time. Table Values sets it from a dice column given for Amount.
DestroyOnHit
Section titled “DestroyOnHit”public bool DestroyOnHit { get; set; }Destroy this entity when it touches something it can hurt, like a bullet or a one-hit kamikaze enemy.
DestroyOnWall
Section titled “DestroyOnWall”public bool DestroyOnWall { get; set; }Destroy this entity when it runs into a wall or anything else solid it can’t hurt: bullets, fireballs, arrows.
public bool Kill { get; set; }Kill outright, invincible or not, whatever the Amount: bottomless pits, lava, crushers.
Knockback
Section titled “Knockback”public float Knockback { get; set; }How hard a hit pushes the target’s body away, in units per second. 0 doesn’t push.
Layers
Section titled “Layers”public string? Layers { get; set; }The collision layers it hurts, e.g. “Player” on spikes and enemies, “Enemy” on the player’s bullets. Empty hurts anything with health.
Methods
Section titled “Methods”public bool Hurts(string? layer)True if it hurts things on collision layer layer.
RollAmount
Section titled “RollAmount”public float RollAmount()The damage of one hit: AmountRoll rolled, or Amount.