ECS airlocks (#13500)

This commit is contained in:
metalgearsloth
2023-01-18 05:44:32 +11:00
committed by GitHub
parent 8550baa218
commit 2873a830bd
19 changed files with 270 additions and 291 deletions

View File

@@ -3,7 +3,7 @@ using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Coordinates.Helpers;
using Content.Server.DoAfter;
using Content.Server.Doors.Components;
using Content.Server.Doors.Systems;
using Content.Server.Magic.Events;
using Content.Server.Weapons.Ranged.Systems;
using Content.Shared.Actions;
@@ -18,9 +18,7 @@ using Content.Shared.Spawners.Components;
using Content.Shared.Storage;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
@@ -38,6 +36,7 @@ public sealed class MagicSystem : EntitySystem
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly AirlockSystem _airlock = default!;
[Dependency] private readonly BodySystem _bodySystem = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SharedDoorSystem _doorSystem = default!;
@@ -46,6 +45,7 @@ public sealed class MagicSystem : EntitySystem
[Dependency] private readonly GunSystem _gunSystem = default!;
[Dependency] private readonly PhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize()
{
@@ -272,7 +272,7 @@ public sealed class MagicSystem : EntitySystem
_transformSystem.SetCoordinates(args.Performer, args.Target);
transform.AttachToGridOrMap();
SoundSystem.Play(args.BlinkSound.GetSound(), Filter.Pvs(args.Target), args.Performer, AudioParams.Default.WithVolume(args.BlinkVolume));
_audio.PlayPvs(args.BlinkSound, args.Performer, AudioParams.Default.WithVolume(args.BlinkVolume));
args.Handled = true;
}
@@ -289,13 +289,13 @@ public sealed class MagicSystem : EntitySystem
var transform = Transform(args.Performer);
var coords = transform.Coordinates;
SoundSystem.Play(args.KnockSound.GetSound(), Filter.Pvs(coords), args.Performer, AudioParams.Default.WithVolume(args.KnockVolume));
_audio.PlayPvs(args.KnockSound, args.Performer, AudioParams.Default.WithVolume(args.KnockVolume));
//Look for doors and don't open them if they're already open.
foreach (var entity in _lookup.GetEntitiesInRange(coords, args.Range))
{
if (TryComp<AirlockComponent>(entity, out var airlock))
airlock.BoltsDown = false;
_airlock.SetBoltsDown(entity, airlock, false);
if (TryComp<DoorComponent>(entity, out var doorComp) && doorComp.State is not DoorState.Open)
_doorSystem.StartOpening(doorComp.Owner);