2019-11-13 17:37:46 -05:00
|
|
|
|
using Content.Server.Explosions;
|
2020-08-13 14:40:27 +02:00
|
|
|
|
using Content.Server.GameObjects.EntitySystems;
|
2019-06-07 16:15:20 +05:00
|
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
|
using Robust.Shared.Serialization;
|
|
|
|
|
|
|
2019-12-15 14:12:23 +01:00
|
|
|
|
namespace Content.Server.GameObjects.Components.Explosion
|
2019-06-07 16:15:20 +05:00
|
|
|
|
{
|
2019-07-31 15:02:36 +02:00
|
|
|
|
[RegisterComponent]
|
2019-06-07 16:15:20 +05:00
|
|
|
|
public class ExplosiveComponent : Component, ITimerTrigger, IDestroyAct
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string Name => "Explosive";
|
2019-12-15 14:12:23 +01:00
|
|
|
|
|
2019-06-07 16:15:20 +05:00
|
|
|
|
public int DevastationRange = 0;
|
|
|
|
|
|
public int HeavyImpactRange = 0;
|
|
|
|
|
|
public int LightImpactRange = 0;
|
|
|
|
|
|
public int FlashRange = 0;
|
|
|
|
|
|
|
2019-09-24 03:54:24 -04:00
|
|
|
|
private bool _beingExploded = false;
|
2019-06-07 16:15:20 +05:00
|
|
|
|
|
|
|
|
|
|
public override void ExposeData(ObjectSerializer serializer)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.ExposeData(serializer);
|
|
|
|
|
|
|
|
|
|
|
|
serializer.DataField(ref DevastationRange, "devastationRange", 0);
|
|
|
|
|
|
serializer.DataField(ref HeavyImpactRange, "heavyImpactRange", 0);
|
|
|
|
|
|
serializer.DataField(ref LightImpactRange, "lightImpactRange", 0);
|
|
|
|
|
|
serializer.DataField(ref FlashRange, "flashRange", 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-10-11 16:57:16 -04:00
|
|
|
|
public bool Explosion()
|
2019-06-07 16:15:20 +05:00
|
|
|
|
{
|
2019-09-24 03:54:24 -04:00
|
|
|
|
//Prevent adjacent explosives from infinitely blowing each other up.
|
|
|
|
|
|
if (_beingExploded) return true;
|
|
|
|
|
|
_beingExploded = true;
|
|
|
|
|
|
|
2019-10-11 16:57:16 -04:00
|
|
|
|
ExplosionHelper.SpawnExplosion(Owner.Transform.GridPosition, DevastationRange, HeavyImpactRange, LightImpactRange, FlashRange);
|
2019-07-07 00:39:00 +02:00
|
|
|
|
|
2019-09-24 03:54:24 -04:00
|
|
|
|
Owner.Delete();
|
2019-06-07 16:15:20 +05:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ITimerTrigger.Trigger(TimerTriggerEventArgs eventArgs)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Explosion();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void IDestroyAct.OnDestroy(DestructionEventArgs eventArgs)
|
|
|
|
|
|
{
|
|
|
|
|
|
Explosion();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|