Effects/DelayedExplosion.cs
namespace PlanetMeat;
[Group( "Planet Meat - Effects" ), Title( "Delayed Explosion" ), Icon( "flare" )]
public sealed class DelayedExplosion : Component
{
[RequireComponent] public DelayedStages Stages { get; set; }
[Property] public GameObject Attacker { get; set; }
[Property] public int Damage { get; set; }
[Property] public float Radius { get; set; }
protected override void OnStart()
{
base.OnStart();
Stages?.StageStarted += OnStageStarted;
}
public void ApplyConfig( float delay, int damage, float radius )
{
Stages.Delay = delay;
Damage = damage;
Radius = radius;
}
public void OnStageStarted( int stage ) => Explode();
public void Explode()
{
var r = Radius;
foreach ( var effects in Components.GetAll<PreparedEffects>( FindMode.EnabledInSelf ) )
effects.PerformEffects( r );
new DamageInfo( Damage, Attacker ?? GameObject, GameObject ).Explode( this, r );
}
public void Blame( GameObject attacker )
{
Attacker = attacker;
}
}