From 6e53cd98a400466640586bf19b41ec281944795e Mon Sep 17 00:00:00 2001 From: SlamBamActionman Date: Tue, 19 Nov 2024 16:28:58 +0100 Subject: [PATCH] Add emag functionality --- .../SingularityGeneratorSystem.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Content.Server/Singularity/EntitySystems/SingularityGeneratorSystem.cs b/Content.Server/Singularity/EntitySystems/SingularityGeneratorSystem.cs index be0c5e49b5f612..cfca86bf4af7d4 100644 --- a/Content.Server/Singularity/EntitySystems/SingularityGeneratorSystem.cs +++ b/Content.Server/Singularity/EntitySystems/SingularityGeneratorSystem.cs @@ -117,27 +117,31 @@ private void HandleParticleCollide(EntityUid uid, ParticleProjectileComponent co if (!EntityManager.TryGetComponent(args.OtherEntity, out var generatorComp)) return; - if (_timing.CurTime < _metadata.GetPauseTime(uid) + generatorComp.NextFailsafe) + if (_timing.CurTime < _metadata.GetPauseTime(uid) + generatorComp.NextFailsafe && !generatorComp.FailsafeDisabled) { EntityManager.QueueDeleteEntity(uid); return; } var contained = true; - var transform = Transform(args.OtherEntity); - var directions = Enum.GetValues().Length; - for (var i = 0; i < directions - 1; i += 2) // Skip every other direction, checking only cardinals + if (!generatorComp.FailsafeDisabled) { - if (!CheckContainmentField((Direction)i, new Entity(args.OtherEntity, generatorComp), transform)) - contained = false; + var transform = Transform(args.OtherEntity); + var directions = Enum.GetValues().Length; + for (var i = 0; i < directions - 1; i += 2) // Skip every other direction, checking only cardinals + { + if (!CheckContainmentField((Direction)i, new Entity(args.OtherEntity, generatorComp), transform)) + contained = false; + } } - if (!contained) + if (!contained && !generatorComp.FailsafeDisabled) { generatorComp.NextFailsafe = _timing.CurTime + generatorComp.FailsafeCooldown; _popupSystem.PopupEntity(Loc.GetString("comp-generator-failsafe", ("target", args.OtherEntity)), args.OtherEntity, PopupType.LargeCaution); } else + { SetPower( args.OtherEntity, generatorComp.Power + component.State switch @@ -151,6 +155,8 @@ private void HandleParticleCollide(EntityUid uid, ParticleProjectileComponent co }, generatorComp ); + } + EntityManager.QueueDeleteEntity(uid); }