diff --git a/Content.Client/Doors/DoorSystem.cs b/Content.Client/Doors/DoorSystem.cs index 398d01e578..d14a973304 100644 --- a/Content.Client/Doors/DoorSystem.cs +++ b/Content.Client/Doors/DoorSystem.cs @@ -27,9 +27,9 @@ public sealed class DoorSystem : SharedDoorSystem } // TODO AUDIO PREDICT see comments in server-side PlaySound() - protected override void PlaySound(EntityUid uid, string sound, AudioParams audioParams, EntityUid? predictingPlayer, bool predicted) + protected override void PlaySound(EntityUid uid, SoundSpecifier soundSpecifier, AudioParams audioParams, EntityUid? predictingPlayer, bool predicted) { if (GameTiming.InPrediction && GameTiming.IsFirstTimePredicted) - SoundSystem.Play(sound, Filter.Local(), uid, audioParams); + Audio.Play(soundSpecifier, Filter.Local(), uid, audioParams); } } diff --git a/Content.Server/Doors/Systems/DoorSystem.cs b/Content.Server/Doors/Systems/DoorSystem.cs index e9640b5536..a690d7a3ba 100644 --- a/Content.Server/Doors/Systems/DoorSystem.cs +++ b/Content.Server/Doors/Systems/DoorSystem.cs @@ -30,6 +30,7 @@ public sealed class DoorSystem : SharedDoorSystem [Dependency] private readonly AirtightSystem _airtightSystem = default!; [Dependency] private readonly ConstructionSystem _constructionSystem = default!; [Dependency] private readonly ToolSystem _toolSystem = default!; + [Dependency] private readonly SharedContainerSystem _containerSystem = default!; public override void Initialize() { @@ -94,11 +95,12 @@ public sealed class DoorSystem : SharedDoorSystem /// Selectively send sound to clients, taking care to not send the double-audio. /// /// The audio source - /// The sound + /// The sound + /// The audio parameters. /// The user (if any) that instigated an interaction /// Whether this interaction would have been predicted. If the predicting player is null, /// this assumes it would have been predicted by all players in PVS range. - protected override void PlaySound(EntityUid uid, string sound, AudioParams audioParams, EntityUid? predictingPlayer, bool predicted) + protected override void PlaySound(EntityUid uid, SoundSpecifier soundSpecifier, AudioParams audioParams, EntityUid? predictingPlayer, bool predicted) { // If this sound would have been predicted by all clients, do not play any audio. if (predicted && predictingPlayer == null) @@ -113,7 +115,7 @@ public sealed class DoorSystem : SharedDoorSystem } // send the sound to players. - SoundSystem.Play(sound, filter, uid, audioParams); + Audio.Play(soundSpecifier, filter, uid, audioParams); } #region DoAfters @@ -158,7 +160,11 @@ public sealed class DoorSystem : SharedDoorSystem private void OnDoorAltVerb(EntityUid uid, DoorComponent component, GetVerbsEvent args) { - if (!args.CanInteract || !TryComp(args.User, out var tool) || !tool.Qualities.Contains(component.PryingQuality)) return; + if (!args.CanInteract || !args.CanAccess) + return; + + if (!TryComp(args.User, out var tool) || !tool.Qualities.Contains(component.PryingQuality)) + return; args.Verbs.Add(new AlternativeVerb() { @@ -173,7 +179,8 @@ public sealed class DoorSystem : SharedDoorSystem /// private bool TryPryDoor(EntityUid target, EntityUid tool, EntityUid user, DoorComponent door, bool force = false) { - if (door.BeingPried) return false; + if (door.BeingPried) + return false; if (door.State == DoorState.Welded) return false; @@ -274,9 +281,9 @@ public sealed class DoorSystem : SharedDoorSystem if (string.IsNullOrEmpty(door.BoardPrototype)) return; - var container = uid.EnsureContainer("board", out var existed); + var container = _containerSystem.EnsureContainer(uid, "board", out var existed); - if (existed & container.ContainedEntities.Count != 0) + if (existed && container.ContainedEntities.Count != 0) { // We already contain a board. Note: We don't check if it's the right one! return; @@ -298,7 +305,7 @@ public sealed class DoorSystem : SharedDoorSystem if (door.State == DoorState.Closed) { SetState(uid, DoorState.Emagging, door); - PlaySound(uid, door.SparkSound.GetSound(), AudioParams.Default.WithVolume(8), args.UserUid, false); + PlaySound(uid, door.SparkSound, AudioParams.Default.WithVolume(8), args.UserUid, false); args.Handled = true; } } @@ -309,12 +316,12 @@ public sealed class DoorSystem : SharedDoorSystem if (!Resolve(uid, ref door)) return; - DoorState lastState = door.State; + var lastState = door.State; SetState(uid, DoorState.Opening, door); if (door.OpenSound != null) - PlaySound(uid, door.OpenSound.GetSound(), AudioParams.Default.WithVolume(-5), user, predicted); + PlaySound(uid, door.OpenSound, AudioParams.Default.WithVolume(-5), user, predicted); if(lastState == DoorState.Emagging && TryComp(door.Owner, out var airlockComponent)) airlockComponent?.SetBoltsWithAudio(!airlockComponent.IsBolted()); diff --git a/Content.Shared/Doors/Systems/SharedDoorSystem.cs b/Content.Shared/Doors/Systems/SharedDoorSystem.cs index 3b2d3e99fa..dd25f74af7 100644 --- a/Content.Shared/Doors/Systems/SharedDoorSystem.cs +++ b/Content.Shared/Doors/Systems/SharedDoorSystem.cs @@ -23,6 +23,9 @@ public abstract class SharedDoorSystem : EntitySystem [Dependency] private readonly SharedStunSystem _stunSystem = default!; [Dependency] protected readonly TagSystem Tags = default!; [Dependency] protected readonly IGameTiming GameTiming = default!; + [Dependency] protected readonly SharedAudioSystem Audio = default!; + [Dependency] private readonly EntityLookupSystem _entityLookup = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; /// /// A body must have an intersection percentage larger than this in order to be considered as colliding with a @@ -167,7 +170,7 @@ public abstract class SharedDoorSystem : EntitySystem if (!TryComp(uid, out AppearanceComponent? appearance)) return; - appearance.SetData(DoorVisuals.State, door.State); + _appearance.SetData(uid, DoorVisuals.State, door.State); } #endregion @@ -199,7 +202,7 @@ public abstract class SharedDoorSystem : EntitySystem SetState(uid, DoorState.Denying, door); if (door.DenySound != null) - PlaySound(uid, door.DenySound.GetSound(), AudioParams.Default.WithVolume(-3), user, predicted); + PlaySound(uid, door.DenySound, AudioParams.Default.WithVolume(-3), user, predicted); } public bool TryToggleDoor(EntityUid uid, DoorComponent? door = null, EntityUid? user = null, bool predicted = false) @@ -265,14 +268,14 @@ public abstract class SharedDoorSystem : EntitySystem SetState(uid, DoorState.Opening, door); if (door.OpenSound != null) - PlaySound(uid, door.OpenSound.GetSound(), AudioParams.Default.WithVolume(-5), user, predicted); + PlaySound(uid, door.OpenSound, AudioParams.Default.WithVolume(-5), user, predicted); // I'm not sure what the intent here is/was? It plays a sound if the user is opening a door with a hands // component, but no actual hands!? What!? Is this the sound of them head-butting the door to get it to open?? // I'm 99% sure something is wrong here, but I kind of want to keep it this way. if (user != null && TryComp(user.Value, out SharedHandsComponent? hands) && hands.Hands.Count == 0) - PlaySound(uid, door.TryOpenDoorSound.GetSound(), AudioParams.Default.WithVolume(-2), user, predicted); + PlaySound(uid, door.TryOpenDoorSound, AudioParams.Default.WithVolume(-2), user, predicted); } /// @@ -329,7 +332,7 @@ public abstract class SharedDoorSystem : EntitySystem SetState(uid, DoorState.Closing, door); if (door.CloseSound != null) - PlaySound(uid, door.CloseSound.GetSound(), AudioParams.Default.WithVolume(-5), user, predicted); + PlaySound(uid, door.CloseSound, AudioParams.Default.WithVolume(-5), user, predicted); } /// @@ -422,7 +425,8 @@ public abstract class SharedDoorSystem : EntitySystem yield break; // TODO SLOTH fix electro's code. - var doorAABB = physics.GetWorldAABB(); + // ReSharper disable once InconsistentNaming + var doorAABB = _entityLookup.GetWorldAABB(uid); foreach (var otherPhysics in PhysicsSystem.GetCollidingEntities(Transform(uid).MapID, doorAABB)) { @@ -436,7 +440,7 @@ public abstract class SharedDoorSystem : EntitySystem && (otherPhysics.CollisionMask & physics.CollisionLayer) == 0) continue; - if (otherPhysics.GetWorldAABB().IntersectPercentage(doorAABB) < IntersectPercentage) + if (_entityLookup.GetWorldAABB(otherPhysics.Owner).IntersectPercentage(doorAABB) < IntersectPercentage) continue; yield return otherPhysics.Owner; @@ -614,5 +618,5 @@ public abstract class SharedDoorSystem : EntitySystem } #endregion - protected abstract void PlaySound(EntityUid uid, string sound, AudioParams audioParams, EntityUid? predictingPlayer, bool predicted); + protected abstract void PlaySound(EntityUid uid, SoundSpecifier soundSpecifier, AudioParams audioParams, EntityUid? predictingPlayer, bool predicted); }