Skip to content

Commit

Permalink
Add emag functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
SlamBamActionman authored and SaphireLattice committed Nov 20, 2024
1 parent 68eaf6f commit 6e53cd9
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,27 +117,31 @@ private void HandleParticleCollide(EntityUid uid, ParticleProjectileComponent co
if (!EntityManager.TryGetComponent<SingularityGeneratorComponent>(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<Direction>().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<SingularityGeneratorComponent>(args.OtherEntity, generatorComp), transform))
contained = false;
var transform = Transform(args.OtherEntity);
var directions = Enum.GetValues<Direction>().Length;
for (var i = 0; i < directions - 1; i += 2) // Skip every other direction, checking only cardinals
{
if (!CheckContainmentField((Direction)i, new Entity<SingularityGeneratorComponent>(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
Expand All @@ -151,6 +155,8 @@ private void HandleParticleCollide(EntityUid uid, ParticleProjectileComponent co
},
generatorComp
);
}

EntityManager.QueueDeleteEntity(uid);
}

Expand Down

0 comments on commit 6e53cd9

Please sign in to comment.