Remove IRadiationAct (#7757)

* Move radiation collector to ECS

* Damagable system

* Remove IRadiationAct

* Add small helper field

* Update Content.Server/Radiation/Systems/RadiationSystem.cs

Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>

* Delete comment

* Fixed total rads

Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
This commit is contained in:
Alex Evgrashin
2022-04-28 15:36:25 +03:00
committed by GitHub
parent 8be90ea53b
commit 4aa45dc695
9 changed files with 145 additions and 98 deletions

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Content.Server.Radiation.Systems;
using Content.Shared.Radiation;
using Content.Shared.Sound;
using JetBrains.Annotations;
@@ -12,8 +13,7 @@ namespace Content.Server.Radiation
[UsedImplicitly]
public sealed class RadiationPulseSystem : EntitySystem
{
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly RadiationSystem _radiation = default!;
private const float RadiationCooldown = 1.0f;
private float _accumulator;
@@ -36,18 +36,8 @@ namespace Content.Server.Radiation
if (Deleted(ent)) continue;
foreach (var entity in _lookup.GetEntitiesInRange(_entMan.GetComponent<TransformComponent>(ent).Coordinates, comp.Range))
{
// For now at least still need this because it uses a list internally then returns and this may be deleted before we get to it.
if ((!_entMan.EntityExists(entity) ? EntityLifeStage.Deleted : _entMan.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted) continue;
// Note: Radiation is liable for a refactor (stinky Sloth coding a basic version when he did StationEvents)
// so this ToArray doesn't really matter.
foreach (var radiation in _entMan.GetComponents<IRadiationAct>(entity).ToArray())
{
radiation.RadiationAct(RadiationCooldown, comp);
}
}
var cords = Transform(ent).MapPosition;
_radiation.IrradiateRange(cords, comp.Range, comp.RadsPerSecond, RadiationCooldown);
}
}
}