diff --git a/Content.Client/Atmos/UI/GasFilterBoundUserInterface.cs b/Content.Client/Atmos/UI/GasFilterBoundUserInterface.cs index 21600cc63b..3b16fc0609 100644 --- a/Content.Client/Atmos/UI/GasFilterBoundUserInterface.cs +++ b/Content.Client/Atmos/UI/GasFilterBoundUserInterface.cs @@ -26,7 +26,7 @@ namespace Content.Client.Atmos.UI { base.Open(); - var atmosSystem = EntitySystem.Get(); + var atmosSystem = IoCManager.Resolve().GetEntitySystem(); _window = new GasFilterWindow(atmosSystem.Gases); @@ -59,7 +59,7 @@ namespace Content.Client.Atmos.UI private void OnSelectGasPressed() { if (_window is null || _window.SelectedGas is null) return; - if (!Int32.TryParse(_window.SelectedGas, out var gas)) return; + if (!int.TryParse(_window.SelectedGas, out var gas)) return; SendMessage(new GasFilterSelectGasMessage(gas)); } @@ -78,7 +78,7 @@ namespace Content.Client.Atmos.UI _window.SetTransferRate(cast.TransferRate); if (cast.FilteredGas is not null) { - var atmos = EntitySystem.Get(); + var atmos = IoCManager.Resolve().GetEntitySystem(); var gas = atmos.GetGas((Gas) cast.FilteredGas); _window.SetGasFiltered(gas.ID, gas.Name); } diff --git a/Content.Client/Audio/AmbientSoundSystem.cs b/Content.Client/Audio/AmbientSoundSystem.cs index 2856fb8a30..3111e3177f 100644 --- a/Content.Client/Audio/AmbientSoundSystem.cs +++ b/Content.Client/Audio/AmbientSoundSystem.cs @@ -24,7 +24,8 @@ namespace Content.Client.Audio /// public sealed class AmbientSoundSystem : SharedAmbientSoundSystem { - [Dependency] private EntityLookupSystem _lookup = default!; + [Dependency] private readonly EntityLookupSystem _lookup = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; @@ -43,7 +44,7 @@ namespace Content.Client.Audio /// private int MaxSingleSound => (int) (_maxAmbientCount / (16.0f / 6.0f)); - private Dictionary _playingSounds = new(); + private readonly Dictionary _playingSounds = new(); private const float RangeBuffer = 3f; @@ -58,7 +59,7 @@ namespace Content.Client.Audio if (_overlayEnabled) { - _overlay = new AmbientSoundOverlay(EntityManager, this, Get()); + _overlay = new AmbientSoundOverlay(EntityManager, this, EntityManager.System()); overlayManager.AddOverlay(_overlay); } else @@ -119,7 +120,8 @@ namespace Content.Client.Audio foreach (var (_, (_, sound)) in _playingSounds) { - if (sound.Equals(countSound)) count++; + if (sound.Equals(countSound)) + count++; } return count; @@ -180,7 +182,7 @@ namespace Content.Client.Audio continue; } - var key = ambientComp.Sound.GetSound(); + var key = _audio.GetSound(ambientComp.Sound); if (!sourceDict.ContainsKey(key)) sourceDict[key] = new List(MaxSingleSound); @@ -188,6 +190,7 @@ namespace Content.Client.Audio sourceDict[key].Add(ambientComp); } + // TODO: Just store the distance from above... foreach (var (key, val) in sourceDict) { sourceDict[key] = val.OrderByDescending(x => @@ -236,7 +239,7 @@ namespace Content.Client.Audio if (_playingSounds.ContainsKey(comp)) continue; - var sound = comp.Sound.GetSound(); + var sound = _audio.GetSound(comp.Sound); if (PlayingCount(sound) >= MaxSingleSound) { @@ -250,7 +253,7 @@ namespace Content.Client.Audio continue; } - var audioParams = AudioHelpers + var audioParams = AudioParams.Default .WithVariation(0.01f) .WithVolume(comp.Volume + _ambienceVolume) .WithLoop(true) @@ -259,9 +262,7 @@ namespace Content.Client.Audio .WithPlayOffset(_random.NextFloat(0.0f, 100.0f)) .WithMaxDistance(comp.Range); - var stream = SoundSystem.Play(sound, - Filter.Local(), - comp.Owner, audioParams); + var stream = _audio.PlayPvs(comp.Sound, comp.Owner, audioParams); if (stream == null) continue; diff --git a/Content.Client/Audio/BackgroundAudioSystem.cs b/Content.Client/Audio/BackgroundAudioSystem.cs index b1c812f1d9..8e5d856b73 100644 --- a/Content.Client/Audio/BackgroundAudioSystem.cs +++ b/Content.Client/Audio/BackgroundAudioSystem.cs @@ -30,6 +30,7 @@ namespace Content.Client.Audio [Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IStateManager _stateManager = default!; [Dependency] private readonly ClientGameTicker _gameTicker = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; private readonly AudioParams _ambientParams = new(-10f, 1, "Master", 0, 0, 0, true, 0f); private readonly AudioParams _lobbyParams = new(-5f, 1, "Master", 0, 0, 0, true, 0f); @@ -211,7 +212,8 @@ namespace Content.Client.Audio return; _playingCollection = _currentCollection; var file = _robustRandom.Pick(_currentCollection.PickFiles).ToString(); - _ambientStream = SoundSystem.Play(file, Filter.Local(), _ambientParams.WithVolume(_ambientParams.Volume + _configManager.GetCVar(CCVars.AmbienceVolume))); + _ambientStream = _audio.PlayGlobal(file, Filter.Local(), + _ambientParams.WithVolume(_ambientParams.Volume + _configManager.GetCVar(CCVars.AmbienceVolume))); } private void EndAmbience() @@ -304,7 +306,8 @@ namespace Content.Client.Audio { return; } - _lobbyStream = SoundSystem.Play(file, Filter.Local(), _lobbyParams); + + _lobbyStream = _audio.PlayGlobal(file, Filter.Local(), _lobbyParams); } private void EndLobbyMusic() diff --git a/Content.Client/Audio/ClientGlobalSoundSystem.cs b/Content.Client/Audio/ClientGlobalSoundSystem.cs index c70513a5c9..6e744b093b 100644 --- a/Content.Client/Audio/ClientGlobalSoundSystem.cs +++ b/Content.Client/Audio/ClientGlobalSoundSystem.cs @@ -10,6 +10,7 @@ namespace Content.Client.Audio; public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem { [Dependency] private readonly IConfigurationManager _cfg = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; // Admin music private bool _adminAudioEnabled = true; @@ -64,7 +65,7 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem { if(!_adminAudioEnabled) return; - var stream = SoundSystem.Play(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams); + var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams); _adminAudio.Add(stream); } @@ -73,13 +74,13 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem // Either the cvar is disabled or it's already playing if(!_eventAudioEnabled || _eventAudio.ContainsKey(soundEvent.Type)) return; - var stream = SoundSystem.Play(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams); + var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams); _eventAudio.Add(soundEvent.Type, stream); } private void PlayGameSound(GameGlobalSoundEvent soundEvent) { - SoundSystem.Play(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams); + _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams); } private void StopStationEventMusic(StopStationEventMusic soundEvent) diff --git a/Content.Client/Cargo/BUI/CargoShuttleConsoleBoundUserInterface.cs b/Content.Client/Cargo/BUI/CargoShuttleConsoleBoundUserInterface.cs index f10ef90fbe..86b583206e 100644 --- a/Content.Client/Cargo/BUI/CargoShuttleConsoleBoundUserInterface.cs +++ b/Content.Client/Cargo/BUI/CargoShuttleConsoleBoundUserInterface.cs @@ -16,8 +16,12 @@ public sealed class CargoShuttleConsoleBoundUserInterface : BoundUserInterface protected override void Open() { base.Open(); - _menu = new CargoShuttleMenu(IoCManager.Resolve(), IoCManager.Resolve(), EntitySystem.Get()); + var collection = IoCManager.Instance; + if (collection == null) + return; + + _menu = new CargoShuttleMenu(collection.Resolve(), collection.Resolve(), collection.Resolve().GetEntitySystem()); _menu.ShuttleCallRequested += OnShuttleCall; _menu.ShuttleRecallRequested += OnShuttleRecall; _menu.OnClose += Close; diff --git a/Content.Client/CharacterInfo/Components/CharacterInfoComponent.cs b/Content.Client/CharacterInfo/Components/CharacterInfoComponent.cs index 01d3918438..a5b52b7c82 100644 --- a/Content.Client/CharacterInfo/Components/CharacterInfoComponent.cs +++ b/Content.Client/CharacterInfo/Components/CharacterInfoComponent.cs @@ -16,7 +16,7 @@ namespace Content.Client.CharacterInfo.Components public void Opened() { - EntitySystem.Get().RequestCharacterInfo(Owner); + IoCManager.Resolve().GetEntitySystem().RequestCharacterInfo(Owner); } public sealed class CharacterInfoControl : BoxContainer diff --git a/Content.Client/CharacterInfo/Components/CharacterInfoSystem.cs b/Content.Client/CharacterInfo/Components/CharacterInfoSystem.cs index 6589bf72f3..1423ef0cdb 100644 --- a/Content.Client/CharacterInfo/Components/CharacterInfoSystem.cs +++ b/Content.Client/CharacterInfo/Components/CharacterInfoSystem.cs @@ -10,6 +10,8 @@ namespace Content.Client.CharacterInfo.Components; public sealed class CharacterInfoSystem : EntitySystem { + [Dependency] private readonly SpriteSystem _sprite = default!; + public override void Initialize() { base.Initialize(); @@ -71,7 +73,7 @@ public sealed class CharacterInfoSystem : EntitySystem }; hbox.AddChild(new ProgressTextureRect { - Texture = objectiveCondition.SpriteSpecifier.Frame0(), + Texture = _sprite.Frame0(objectiveCondition.SpriteSpecifier), Progress = objectiveCondition.Progress, VerticalAlignment = Control.VAlignment.Center }); diff --git a/Content.Client/Chat/UI/ChatBox.xaml.cs b/Content.Client/Chat/UI/ChatBox.xaml.cs index d6ac16ee04..f84d3c9b0f 100644 --- a/Content.Client/Chat/UI/ChatBox.xaml.cs +++ b/Content.Client/Chat/UI/ChatBox.xaml.cs @@ -478,7 +478,7 @@ namespace Content.Client.Chat.UI UpdateChannelSelectButton(); // Warn typing indicator about change - EntitySystem.Get().ClientChangedChatText(); + IoCManager.Resolve().GetEntitySystem().ClientChangedChatText(); } private static ChatSelectChannel GetChannelFromPrefix(char prefix) @@ -523,7 +523,7 @@ namespace Content.Client.Chat.UI private void Input_OnTextEntered(LineEdit.LineEditEventArgs args) { // Warn typing indicator about entered text - EntitySystem.Get().ClientSubmittedChatText(); + IoCManager.Resolve().GetEntitySystem().ClientSubmittedChatText(); if (!string.IsNullOrWhiteSpace(args.Text)) { diff --git a/Content.Client/Stack/StackSystem.cs b/Content.Client/Stack/StackSystem.cs index ced790c2de..9025f74934 100644 --- a/Content.Client/Stack/StackSystem.cs +++ b/Content.Client/Stack/StackSystem.cs @@ -28,7 +28,7 @@ namespace Content.Client.Stack // TODO PREDICT ENTITY DELETION: This should really just be a normal entity deletion call. if (component.Count <= 0) { - Transform(uid).DetachParentToNull(); + Xform.DetachParentToNull(Transform(uid)); return; } diff --git a/Content.Client/Suspicion/SuspicionGui.xaml.cs b/Content.Client/Suspicion/SuspicionGui.xaml.cs index 47568a3316..13148754b3 100644 --- a/Content.Client/Suspicion/SuspicionGui.xaml.cs +++ b/Content.Client/Suspicion/SuspicionGui.xaml.cs @@ -20,6 +20,7 @@ namespace Content.Client.Suspicion [GenerateTypedNameReferences] public sealed partial class SuspicionGui : UIWidget { + [Dependency] private readonly IEntityManager _entManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IGameTiming _timing = default!; @@ -66,7 +67,7 @@ namespace Content.Client.Suspicion return false; } - return IoCManager.Resolve().TryGetComponent(_playerManager.LocalPlayer.ControlledEntity, out suspicion); + return _entManager.TryGetComponent(_playerManager.LocalPlayer.ControlledEntity, out suspicion); } public void UpdateLabel() @@ -83,7 +84,7 @@ namespace Content.Client.Suspicion return; } - var endTime = EntitySystem.Get().EndTime; + var endTime = _entManager.System().EndTime; if (endTime == null) { TimerLabel.Visible = false; diff --git a/Content.Client/Tabletop/TabletopSystem.cs b/Content.Client/Tabletop/TabletopSystem.cs index 931f2bf8a2..654d2b48ac 100644 --- a/Content.Client/Tabletop/TabletopSystem.cs +++ b/Content.Client/Tabletop/TabletopSystem.cs @@ -27,6 +27,7 @@ namespace Content.Client.Tabletop [Dependency] private readonly IUserInterfaceManager _uiManger = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; // Time in seconds to wait until sending the location of a dragged entity to the server again private const float Delay = 1f / 10; // 10 Hz @@ -219,8 +220,8 @@ namespace Content.Client.Tabletop if (EntityManager.TryGetComponent(draggedEntity, out var appearance)) { - appearance.SetData(TabletopItemVisuals.Scale, new Vector2(1.25f, 1.25f)); - appearance.SetData(TabletopItemVisuals.DrawDepth, (int) DrawDepth.Items + 1); + _appearance.SetData(draggedEntity, TabletopItemVisuals.Scale, new Vector2(1.25f, 1.25f), appearance); + _appearance.SetData(draggedEntity, TabletopItemVisuals.DrawDepth, (int) DrawDepth.Items + 1, appearance); } _draggedEntity = draggedEntity; diff --git a/Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs b/Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs index 61817f767b..1dead838ce 100644 --- a/Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs +++ b/Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs @@ -52,7 +52,8 @@ namespace Content.Client.VendingMachines.UI } var longestEntry = string.Empty; - var spriteSystem = EntitySystem.Get(); + var spriteSystem = IoCManager.Resolve().GetEntitySystem(); + for (var i = 0; i < inventory.Count; i++) { var entry = inventory[i]; diff --git a/Content.Client/VendingMachines/VendingMachineBoundUserInterface.cs b/Content.Client/VendingMachines/VendingMachineBoundUserInterface.cs index fe4aaa062d..516d5c6c81 100644 --- a/Content.Client/VendingMachines/VendingMachineBoundUserInterface.cs +++ b/Content.Client/VendingMachines/VendingMachineBoundUserInterface.cs @@ -22,7 +22,7 @@ namespace Content.Client.VendingMachines base.Open(); var entMan = IoCManager.Resolve(); - var vendingMachineSys = EntitySystem.Get(); + var vendingMachineSys = entMan.System(); _cachedInventory = vendingMachineSys.GetAllInventory(Owner.Owner); @@ -50,7 +50,7 @@ namespace Content.Client.VendingMachines private void OnItemSelected(ItemList.ItemListSelectedEventArgs args) { - if (_cachedInventory == null || _cachedInventory.Count == 0) + if (_cachedInventory.Count == 0) return; var selectedItem = _cachedInventory.ElementAtOrDefault(args.ItemIndex); diff --git a/Content.Client/Verbs/UI/VerbMenuElement.cs b/Content.Client/Verbs/UI/VerbMenuElement.cs index c1f4f5cd12..5fc6f81b05 100644 --- a/Content.Client/Verbs/UI/VerbMenuElement.cs +++ b/Content.Client/Verbs/UI/VerbMenuElement.cs @@ -24,7 +24,7 @@ namespace Content.Client.Verbs.UI public bool TextVisible { set => Label.Visible = value; } // Top quality variable naming - public Verb? Verb; + public readonly Verb? Verb; public VerbMenuElement(Verb verb) : base(verb.Text) { @@ -41,12 +41,14 @@ namespace Content.Client.Verbs.UI ExpansionIndicator.Visible = true; } + var entManager = IoCManager.Resolve(); + if (verb.Icon == null && verb.IconEntity != null) { var spriteView = new SpriteView() { OverrideDirection = Direction.South, - Sprite = IoCManager.Resolve().GetComponentOrNull(verb.IconEntity.Value) + Sprite = entManager.GetComponentOrNull(verb.IconEntity.Value) }; Icon.AddChild(spriteView); @@ -55,7 +57,7 @@ namespace Content.Client.Verbs.UI Icon.AddChild(new TextureRect() { - Texture = verb.Icon?.Frame0(), + Texture = verb.Icon != null ? entManager.System().Frame0(verb.Icon) : null, Stretch = TextureRect.StretchMode.KeepAspectCentered }); } @@ -66,7 +68,7 @@ namespace Content.Client.Verbs.UI Icon.AddChild(new TextureRect() { - Texture = category.Icon?.Frame0(), + Texture = category.Icon != null ? IoCManager.Resolve().GetEntitySystem().Frame0(category.Icon) : null, Stretch = TextureRect.StretchMode.KeepAspectCentered }); } diff --git a/Content.Client/Voting/VoteManager.cs b/Content.Client/Voting/VoteManager.cs index 12fbedab9f..9a95860cf8 100644 --- a/Content.Client/Voting/VoteManager.cs +++ b/Content.Client/Voting/VoteManager.cs @@ -4,6 +4,7 @@ using System.Linq; using Content.Shared.Voting; using Robust.Client; using Robust.Client.Console; +using Robust.Client.GameObjects; using Robust.Client.UserInterface; using Robust.Shared.IoC; using Robust.Shared.Network; @@ -117,7 +118,8 @@ namespace Content.Client.Voting } @new = true; - SoundSystem.Play("/Audio/Effects/voteding.ogg", Filter.Local()); + IoCManager.Resolve().GetEntitySystem() + .PlayGlobal("/Audio/Effects/voteding.ogg", Filter.Local()); // New vote from the server. var vote = new ActiveVote(voteId) diff --git a/Content.Shared/Actions/SharedActionsSystem.cs b/Content.Shared/Actions/SharedActionsSystem.cs index d8aec2ec4d..15ea245847 100644 --- a/Content.Shared/Actions/SharedActionsSystem.cs +++ b/Content.Shared/Actions/SharedActionsSystem.cs @@ -19,13 +19,14 @@ namespace Content.Shared.Actions; public abstract class SharedActionsSystem : EntitySystem { + [Dependency] protected readonly IGameTiming GameTiming = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!; [Dependency] private readonly RotateToFaceSystem _rotateToFaceSystem = default!; [Dependency] private readonly SharedPopupSystem _popupSystem = default!; - [Dependency] protected readonly IGameTiming GameTiming = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; public override void Initialize() { @@ -325,8 +326,7 @@ public abstract class SharedActionsSystem : EntitySystem var filter = Filter.Pvs(performer).RemoveWhereAttachedEntity(e => e == performer); - if (action.Sound != null) - SoundSystem.Play(action.Sound.GetSound(), filter, performer, action.AudioParams); + _audio.Play(action.Sound, filter, performer, action.AudioParams); if (string.IsNullOrWhiteSpace(action.Popup)) return true; diff --git a/Content.Shared/Blocking/BlockingSystem.cs b/Content.Shared/Blocking/BlockingSystem.cs index 274626c3cb..989756a421 100644 --- a/Content.Shared/Blocking/BlockingSystem.cs +++ b/Content.Shared/Blocking/BlockingSystem.cs @@ -23,15 +23,16 @@ namespace Content.Shared.Blocking; public sealed class BlockingSystem : EntitySystem { - [Dependency] private readonly SharedActionsSystem _actionsSystem = default!; + [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IPrototypeManager _proto = default!; + [Dependency] private readonly SharedActionsSystem _actionsSystem = default!; [Dependency] private readonly SharedTransformSystem _transformSystem = default!; [Dependency] private readonly FixtureSystem _fixtureSystem = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!; [Dependency] private readonly SharedPopupSystem _popupSystem = default!; - [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!; + [Dependency] private readonly SharedPhysicsSystem _physics = default!; public override void Initialize() { @@ -231,7 +232,7 @@ public sealed class BlockingSystem : EntitySystem _actionsSystem.SetToggled(component.BlockingToggleAction, false); _fixtureSystem.DestroyFixture(physicsComponent, BlockingComponent.BlockFixtureID); - physicsComponent.BodyType = blockingUserComponent.OriginalBodyType; + _physics.SetBodyType(physicsComponent, blockingUserComponent.OriginalBodyType); _popupSystem.PopupEntity(msgUser, user, Filter.Entities(user)); _popupSystem.PopupEntity(msgOther, user, Filter.Pvs(user).RemoveWhereAttachedEntity(e => e == user)); } diff --git a/Content.Shared/Blocking/BlockingUserSystem.cs b/Content.Shared/Blocking/BlockingUserSystem.cs index a815a5bea0..8b1d3ff598 100644 --- a/Content.Shared/Blocking/BlockingUserSystem.cs +++ b/Content.Shared/Blocking/BlockingUserSystem.cs @@ -13,6 +13,7 @@ public sealed class BlockingUserSystem : EntitySystem [Dependency] private readonly IPrototypeManager _proto = default!; [Dependency] private readonly BlockingSystem _blockingSystem = default!; [Dependency] private readonly DamageableSystem _damageable = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; public override void Initialize() { @@ -71,7 +72,7 @@ public sealed class BlockingUserSystem : EntitySystem if (_proto.TryIndex(blockingComponent.ActiveBlockDamageModifier, out DamageModifierSetPrototype? activeBlockModifier) && blockingComponent.IsBlocking) { args.Damage = DamageSpecifier.ApplyModifierSet(args.Damage, activeBlockModifier); - SoundSystem.Play(blockingComponent.BlockSound.GetSound(), Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner, AudioHelpers.WithVariation(0.2f)); + _audio.PlayPvs(blockingComponent.BlockSound, component.Owner, AudioParams.Default.WithVariation(0.2f)); } } } diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 561f309bcc..5a8b253dea 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -392,7 +392,7 @@ namespace Content.Shared.CCVar CVarDef.Create("database.pg_database", "ss14", CVar.SERVERONLY); public static readonly CVarDef DatabasePgUsername = - CVarDef.Create("database.pg_username", "", CVar.SERVERONLY); + CVarDef.Create("database.pg_username", "postgres", CVar.SERVERONLY); public static readonly CVarDef DatabasePgPassword = CVarDef.Create("database.pg_password", "", CVar.SERVERONLY | CVar.CONFIDENTIAL); diff --git a/Content.Shared/Chemistry/Components/Solution.cs b/Content.Shared/Chemistry/Components/Solution.cs index 4fb326dcd5..77722af789 100644 --- a/Content.Shared/Chemistry/Components/Solution.cs +++ b/Content.Shared/Chemistry/Components/Solution.cs @@ -90,7 +90,7 @@ namespace Content.Shared.Chemistry.Components return ""; } - var majorReagent = Contents.OrderByDescending(reagent => reagent.Quantity).First(); + var majorReagent = Contents.MaxBy(reagent => reagent.Quantity); return majorReagent.ReagentId; } @@ -134,9 +134,11 @@ namespace Content.Shared.Chemistry.Components /// The scalar to modify the solution by. public void ScaleSolution(float scale) { - if (scale == 1) return; + if (scale.Equals(1f)) + return; + var tempContents = new List(Contents); - foreach(ReagentQuantity current in tempContents) + foreach(var current in tempContents) { if(scale > 1) { @@ -231,7 +233,7 @@ namespace Content.Shared.Chemistry.Components Contents[i] = new ReagentQuantity(reagent.ReagentId, newQuantity); } - TotalVolume = TotalVolume * ratio; + TotalVolume *= ratio; } public void RemoveAllSolution() @@ -381,14 +383,10 @@ namespace Content.Shared.Chemistry.Components return newSolution; } + [Obsolete("Use ReactiveSystem.DoEntityReaction")] public void DoEntityReaction(EntityUid uid, ReactionMethod method) { - var chemistry = EntitySystem.Get(); - - foreach (var (reagentId, quantity) in Contents.ToArray()) - { - chemistry.ReactionEntity(uid, method, reagentId, quantity, this); - } + IoCManager.Resolve().GetEntitySystem().DoEntityReaction(uid, this, method); } [Serializable, NetSerializable] diff --git a/Content.Shared/Chemistry/ReactiveSystem.cs b/Content.Shared/Chemistry/ReactiveSystem.cs index 1a57d286e0..81c9078f3c 100644 --- a/Content.Shared/Chemistry/ReactiveSystem.cs +++ b/Content.Shared/Chemistry/ReactiveSystem.cs @@ -25,6 +25,14 @@ namespace Content.Shared.Chemistry } } + public void DoEntityReaction(EntityUid uid, Solution solution, ReactionMethod method) + { + foreach (var (reagentId, quantity) in solution.Contents.ToArray()) + { + ReactionEntity(uid, method, reagentId, quantity, solution); + } + } + public void ReactionEntity(EntityUid uid, ReactionMethod method, string reagentId, FixedPoint2 reactVolume, Solution? source) { // We throw if the reagent specified doesn't exist. diff --git a/Content.Shared/Clothing/SharedMagbootsSystem.cs b/Content.Shared/Clothing/SharedMagbootsSystem.cs index 194a29a895..f0304a7f9c 100644 --- a/Content.Shared/Clothing/SharedMagbootsSystem.cs +++ b/Content.Shared/Clothing/SharedMagbootsSystem.cs @@ -11,12 +11,13 @@ namespace Content.Shared.Clothing; public abstract class SharedMagbootsSystem : EntitySystem { - [Dependency] private readonly SharedActionsSystem _sharedActions = default!; [Dependency] private readonly ClothingSpeedModifierSystem _clothingSpeedModifier = default!; - [Dependency] private readonly InventorySystem _inventory = default!; - [Dependency] private readonly SharedItemSystem _item = default!; [Dependency] private readonly ClothingSystem _clothing = default!; + [Dependency] private readonly InventorySystem _inventory = default!; + [Dependency] private readonly SharedActionsSystem _sharedActions = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedContainerSystem _sharedContainer = default!; + [Dependency] private readonly SharedItemSystem _item = default!; public override void Initialize() { @@ -46,9 +47,7 @@ public abstract class SharedMagbootsSystem : EntitySystem _clothing.SetEquippedPrefix(uid, component.On ? "on" : null); } - if (TryComp(uid, out AppearanceComponent? appearance)) - appearance.SetData(ToggleVisuals.Toggled, component.On); - + _appearance.SetData(uid, ToggleVisuals.Toggled, component.Owner); OnChanged(component); Dirty(component); } diff --git a/Content.Shared/Construction/Conditions/NoWindowsInTile.cs b/Content.Shared/Construction/Conditions/NoWindowsInTile.cs index 448c84a881..4ceb3feed7 100644 --- a/Content.Shared/Construction/Conditions/NoWindowsInTile.cs +++ b/Content.Shared/Construction/Conditions/NoWindowsInTile.cs @@ -11,7 +11,8 @@ namespace Content.Shared.Construction.Conditions { public bool Condition(EntityUid user, EntityCoordinates location, Direction direction) { - var tagSystem = EntitySystem.Get(); + var tagSystem = IoCManager.Resolve().GetEntitySystem(); + foreach (var entity in location.GetEntitiesInTile(LookupFlags.Approximate | LookupFlags.Anchored)) { if (tagSystem.HasTag(entity, "Window")) diff --git a/Content.Shared/Construction/Conditions/WallmountCondition.cs b/Content.Shared/Construction/Conditions/WallmountCondition.cs index e44677e8ed..8639a52a35 100644 --- a/Content.Shared/Construction/Conditions/WallmountCondition.cs +++ b/Content.Shared/Construction/Conditions/WallmountCondition.cs @@ -33,11 +33,11 @@ namespace Content.Shared.Construction.Conditions return false; // now we need to check that user actually tries to build wallmount on a wall - var physics = EntitySystem.Get(); + var physics = entManager.System(); var rUserToObj = new CollisionRay(userWorldPosition, userToObject.Normalized, (int) CollisionGroup.Impassable); var length = userToObject.Length; - var tagSystem = EntitySystem.Get(); + var tagSystem = entManager.System(); var userToObjRaycastResults = physics.IntersectRayWithPredicate(entManager.GetComponent(user).MapID, rUserToObj, maxLength: length, predicate: (e) => !tagSystem.HasTag(e, "Wall")); diff --git a/Content.Shared/Damage/Systems/DamageableSystem.cs b/Content.Shared/Damage/Systems/DamageableSystem.cs index a9ed977927..4875ea9fa2 100644 --- a/Content.Shared/Damage/Systems/DamageableSystem.cs +++ b/Content.Shared/Damage/Systems/DamageableSystem.cs @@ -15,6 +15,7 @@ namespace Content.Shared.Damage public sealed class DamageableSystem : EntitySystem { [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; public override void Initialize() { @@ -121,9 +122,9 @@ namespace Content.Shared.Damage if (EntityManager.TryGetComponent(component.Owner, out var appearance) && damageDelta != null) { var data = new DamageVisualizerGroupData(damageDelta.GetDamagePerGroup(_prototypeManager).Keys.ToList()); - appearance.SetData(DamageVisualizerKeys.DamageUpdateGroups, data); + _appearance.SetData(component.Owner, DamageVisualizerKeys.DamageUpdateGroups, data, appearance); } - RaiseLocalEvent(component.Owner, new DamageChangedEvent(component, damageDelta, interruptsDoAfters), false); + RaiseLocalEvent(component.Owner, new DamageChangedEvent(component, damageDelta, interruptsDoAfters)); } /// diff --git a/Content.Shared/Disease/DiseasePrototype.cs b/Content.Shared/Disease/DiseasePrototype.cs index 67347a6fdf..2ec8c89808 100644 --- a/Content.Shared/Disease/DiseasePrototype.cs +++ b/Content.Shared/Disease/DiseasePrototype.cs @@ -1,6 +1,4 @@ using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array; namespace Content.Shared.Disease diff --git a/Content.Shared/Disposal/SharedDisposalUnitSystem.cs b/Content.Shared/Disposal/SharedDisposalUnitSystem.cs index a9eaab3168..0b06fdef09 100644 --- a/Content.Shared/Disposal/SharedDisposalUnitSystem.cs +++ b/Content.Shared/Disposal/SharedDisposalUnitSystem.cs @@ -3,9 +3,11 @@ using Content.Shared.Disposal.Components; using Content.Shared.DragDrop; using Content.Shared.Item; using Content.Shared.MobState.Components; +using Content.Shared.MobState.EntitySystems; using Content.Shared.Throwing; using JetBrains.Annotations; using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Dynamics; using Robust.Shared.Physics.Events; using Robust.Shared.Timing; @@ -16,6 +18,7 @@ namespace Content.Shared.Disposal public abstract class SharedDisposalUnitSystem : EntitySystem { [Dependency] protected readonly IGameTiming GameTiming = default!; + [Dependency] private readonly SharedMobStateSystem _mobState = default!; protected static TimeSpan ExitAttemptDelay = TimeSpan.FromSeconds(0.5); @@ -68,20 +71,16 @@ namespace Content.Shared.Disposal } //Check if the entity is a mob and if mobs can be inserted - if (EntityManager.HasComponent(entity) && !component.MobsCanEnter) + if (TryComp(entity, out var damageState) && !component.MobsCanEnter) return false; - if (!EntityManager.TryGetComponent(entity, out IPhysBody? physics) || - !physics.CanCollide && storable == null) + if (EntityManager.TryGetComponent(entity, out PhysicsComponent? physics) && + (physics.CanCollide || storable != null)) { - if (!(EntityManager.TryGetComponent(entity, out MobStateComponent? damageState) && - (!component.MobsCanEnter || damageState.IsDead()))) - { - return false; - } + return true; } - return true; + return damageState != null && (!component.MobsCanEnter || _mobState.IsDead(entity, damageState)); } } } diff --git a/Content.Shared/Doors/Systems/SharedAirlockSystem.cs b/Content.Shared/Doors/Systems/SharedAirlockSystem.cs index 5b289cad5e..3142c58fca 100644 --- a/Content.Shared/Doors/Systems/SharedAirlockSystem.cs +++ b/Content.Shared/Doors/Systems/SharedAirlockSystem.cs @@ -5,6 +5,7 @@ namespace Content.Shared.Doors.Systems; public abstract class SharedAirlockSystem : EntitySystem { + [Dependency] protected readonly SharedAppearanceSystem Appearance = default!; [Dependency] protected readonly SharedDoorSystem DoorSystem = default!; public override void Initialize() @@ -39,10 +40,7 @@ public abstract class SharedAirlockSystem : EntitySystem public void UpdateEmergencyLightStatus(SharedAirlockComponent component) { - if (TryComp(component.Owner, out var appearanceComponent)) - { - appearanceComponent.SetData(DoorVisuals.EmergencyLights, component.EmergencyAccess); - } + Appearance.SetData(component.Owner, DoorVisuals.EmergencyLights, component.EmergencyAccess); } public void ToggleEmergencyAccess(SharedAirlockComponent component) diff --git a/Content.Shared/Doors/Systems/SharedDoorSystem.cs b/Content.Shared/Doors/Systems/SharedDoorSystem.cs index b0a33c46ef..abb45c38f3 100644 --- a/Content.Shared/Doors/Systems/SharedDoorSystem.cs +++ b/Content.Shared/Doors/Systems/SharedDoorSystem.cs @@ -21,11 +21,11 @@ namespace Content.Shared.Doors.Systems; public abstract class SharedDoorSystem : EntitySystem { + [Dependency] protected readonly IGameTiming GameTiming = default!; [Dependency] protected readonly SharedPhysicsSystem PhysicsSystem = default!; [Dependency] private readonly DamageableSystem _damageableSystem = default!; [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!; @@ -380,7 +380,7 @@ public abstract class SharedDoorSystem : EntitySystem return; if (Resolve(uid, ref physics, false)) - physics.CanCollide = collidable; + PhysicsSystem.SetCanCollide(physics, collidable); if (!collidable) door.CurrentlyCrushing.Clear(); diff --git a/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.Crit.cs b/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.Crit.cs index 4fdda95ed6..36e9624233 100644 --- a/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.Crit.cs +++ b/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.Crit.cs @@ -8,18 +8,13 @@ public abstract partial class SharedMobStateSystem public virtual void EnterCritState(EntityUid uid) { Alerts.ShowAlert(uid, AlertType.HumanCrit); - - Standing.Down(uid); - - if (TryComp(uid, out var appearance)) - { - appearance.SetData(DamageStateVisuals.State, DamageState.Critical); - } + _standing.Down(uid); + _appearance.SetData(uid, DamageStateVisuals.State, DamageState.Critical); } public virtual void ExitCritState(EntityUid uid) { - Standing.Stand(uid); + _standing.Stand(uid); } public virtual void UpdateCritState(EntityUid entity, FixedPoint2 threshold) {} diff --git a/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.Dead.cs b/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.Dead.cs index d8af38d135..477c510514 100644 --- a/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.Dead.cs +++ b/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.Dead.cs @@ -8,28 +8,25 @@ public abstract partial class SharedMobStateSystem public virtual void EnterDeadState(EntityUid uid) { EnsureComp(uid); - Standing.Down(uid); + _standing.Down(uid); - if (Standing.IsDown(uid) && TryComp(uid, out var physics)) + if (_standing.IsDown(uid) && TryComp(uid, out var physics)) { - physics.CanCollide = false; + _physics.SetCanCollide(physics, false); } - if (TryComp(uid, out var appearance)) - { - appearance.SetData(DamageStateVisuals.State, DamageState.Dead); - } + _appearance.SetData(uid, DamageStateVisuals.State, DamageState.Dead); } public virtual void ExitDeadState(EntityUid uid) { RemComp(uid); - Standing.Stand(uid); + _standing.Stand(uid); - if (!Standing.IsDown(uid) && TryComp(uid, out var physics)) + if (!_standing.IsDown(uid) && TryComp(uid, out var physics)) { - physics.CanCollide = true; + _physics.SetCanCollide(physics, true); } } diff --git a/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.Norm.cs b/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.Norm.cs index 9c1d193a38..c24937db6f 100644 --- a/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.Norm.cs +++ b/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.Norm.cs @@ -6,12 +6,8 @@ public abstract partial class SharedMobStateSystem { public virtual void EnterNormState(EntityUid uid) { - Standing.Stand(uid); - - if (TryComp(uid, out var appearance)) - { - appearance.SetData(DamageStateVisuals.State, DamageState.Alive); - } + _standing.Stand(uid); + _appearance.SetData(uid, DamageStateVisuals.State, DamageState.Alive); } public virtual void UpdateNormState(EntityUid entity, FixedPoint2 threshold) {} diff --git a/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs b/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs index f0c66f6864..4b0ef72165 100644 --- a/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs +++ b/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs @@ -15,6 +15,7 @@ using Content.Shared.Speech; using Content.Shared.Standing; using Content.Shared.StatusEffect; using Content.Shared.Throwing; +using Robust.Shared.Physics.Systems; using Robust.Shared.Serialization; namespace Content.Shared.MobState.EntitySystems @@ -22,9 +23,11 @@ namespace Content.Shared.MobState.EntitySystems public abstract partial class SharedMobStateSystem : EntitySystem { [Dependency] protected readonly AlertsSystem Alerts = default!; - [Dependency] private readonly ActionBlockerSystem _blocker = default!; - [Dependency] protected readonly StandingStateSystem Standing = default!; + [Dependency] private readonly ActionBlockerSystem _blocker = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] protected readonly StatusEffectsSystem Status = default!; + [Dependency] private readonly StandingStateSystem _standing = default!; public override void Initialize() { diff --git a/Content.Shared/Stacks/SharedStackSystem.cs b/Content.Shared/Stacks/SharedStackSystem.cs index d35deb255e..b9a6ae80e7 100644 --- a/Content.Shared/Stacks/SharedStackSystem.cs +++ b/Content.Shared/Stacks/SharedStackSystem.cs @@ -13,8 +13,10 @@ namespace Content.Shared.Stacks [UsedImplicitly] public abstract class SharedStackSystem : EntitySystem { + [Dependency] protected readonly SharedAppearanceSystem Appearance = default!; [Dependency] protected readonly SharedPopupSystem PopupSystem = default!; [Dependency] protected readonly SharedHandsSystem HandsSystem = default!; + [Dependency] protected readonly SharedTransformSystem Xform = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; public override void Initialize() @@ -153,10 +155,7 @@ namespace Content.Shared.Stacks component.Count = amount; Dirty(component); - // Change appearance data. - if (TryComp(uid, out AppearanceComponent? appearance)) - appearance.SetData(StackVisuals.Actual, component.Count); - + Appearance.SetData(uid, StackVisuals.Actual, component.Count); RaiseLocalEvent(uid, new StackCountChangedEvent(old, component.Count), false); } @@ -189,9 +188,9 @@ namespace Content.Shared.Stacks if (!TryComp(uid, out AppearanceComponent? appearance)) return; - appearance.SetData(StackVisuals.Actual, component.Count); - appearance.SetData(StackVisuals.MaxCount, component.MaxCount); - appearance.SetData(StackVisuals.Hide, false); + Appearance.SetData(uid, StackVisuals.Actual, component.Count, appearance); + Appearance.SetData(uid, StackVisuals.MaxCount, component.MaxCount, appearance); + Appearance.SetData(uid, StackVisuals.Hide, false, appearance); } private void OnStackGetState(EntityUid uid, SharedStackComponent component, ref ComponentGetState args) diff --git a/Content.Shared/Standing/StandingStateSystem.cs b/Content.Shared/Standing/StandingStateSystem.cs index 84af6fb5d7..f7db16d91f 100644 --- a/Content.Shared/Standing/StandingStateSystem.cs +++ b/Content.Shared/Standing/StandingStateSystem.cs @@ -16,6 +16,8 @@ namespace Content.Shared.Standing { [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly INetManager _netMan = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; // If StandingCollisionLayer value is ever changed to more than one layer, the logic needs to be edited. private const int StandingCollisionLayer = (int) CollisionGroup.MidImpassable; @@ -28,10 +30,11 @@ namespace Content.Shared.Standing private void OnHandleState(EntityUid uid, StandingStateComponent component, ref ComponentHandleState args) { - if (args.Current is not StandingComponentState state) return; + if (args.Current is not StandingComponentState state) + return; component.Standing = state.Standing; - component.ChangedFixtures = new(state.ChangedFixtures); + component.ChangedFixtures = new List(state.ChangedFixtures); } private void OnGetState(EntityUid uid, StandingStateComponent component, ref ComponentGetState args) @@ -82,7 +85,7 @@ namespace Content.Shared.Standing RaiseLocalEvent(uid, new DownedEvent(), false); // Seemed like the best place to put it - appearance?.SetData(RotationVisuals.RotationState, RotationState.Horizontal); + _appearance.SetData(uid, RotationVisuals.RotationState, RotationState.Horizontal, appearance); // Change collision masks to allow going under certain entities like flaps and tables if (TryComp(uid, out FixturesComponent? fixtureComponent)) @@ -100,10 +103,9 @@ namespace Content.Shared.Standing if (!_gameTiming.IsFirstTimePredicted) return true; - // TODO audio prediction - if (playSound && _netMan.IsServer) + if (playSound) { - SoundSystem.Play(standingState.DownSound.GetSound(), Filter.Pvs(uid), uid, AudioHelpers.WithVariation(0.25f)); + _audio.PlayPredicted(standingState.DownSound, uid, uid, AudioParams.Default.WithVariation(0.25f)); } return true; @@ -133,7 +135,7 @@ namespace Content.Shared.Standing Dirty(standingState); RaiseLocalEvent(uid, new StoodEvent(), false); - appearance?.SetData(RotationVisuals.RotationState, RotationState.Vertical); + _appearance.SetData(uid, RotationVisuals.RotationState, RotationState.Vertical, appearance); if (TryComp(uid, out FixturesComponent? fixtureComponent)) { diff --git a/Content.Shared/Storage/EntitySystems/SharedItemMapperSystem.cs b/Content.Shared/Storage/EntitySystems/SharedItemMapperSystem.cs index c653039254..808e1e0b42 100644 --- a/Content.Shared/Storage/EntitySystems/SharedItemMapperSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedItemMapperSystem.cs @@ -13,6 +13,7 @@ namespace Content.Shared.Storage.EntitySystems [UsedImplicitly] public abstract class SharedItemMapperSystem : EntitySystem { + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedContainerSystem _container = default!; /// @@ -34,27 +35,28 @@ namespace Content.Shared.Storage.EntitySystems if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearanceComponent)) { var list = new List(component.MapLayers.Keys); - appearanceComponent.SetData(StorageMapVisuals.InitLayers, new ShowLayerData(list)); + _appearance.SetData(component.Owner, StorageMapVisuals.InitLayers, new ShowLayerData(list), appearanceComponent); } } private void MapperEntityRemoved(EntityUid uid, ItemMapperComponent itemMapper, EntRemovedFromContainerMessage args) { - if (EntityManager.TryGetComponent(itemMapper.Owner, out AppearanceComponent? appearanceComponent) - && TryGetLayers(args, itemMapper, out var containedLayers)) - { - appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers)); - } + UpdateAppearance(uid, itemMapper, args); } private void MapperEntityInserted(EntityUid uid, ItemMapperComponent itemMapper, EntInsertedIntoContainerMessage args) + { + UpdateAppearance(uid, itemMapper, args); + } + + private void UpdateAppearance(EntityUid uid, ItemMapperComponent itemMapper, ContainerModifiedMessage message) { if (EntityManager.TryGetComponent(itemMapper.Owner, out AppearanceComponent? appearanceComponent) - && TryGetLayers(args, itemMapper, out var containedLayers)) + && TryGetLayers(message, itemMapper, out var containedLayers)) { - appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers)); + _appearance.SetData(itemMapper.Owner, StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers), appearanceComponent); } } diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs index 34f2710044..b6493f42d2 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs @@ -44,7 +44,7 @@ public abstract partial class SharedGunSystem component.Entities.Add(args.Used); component.Container.Insert(args.Used); // Not predicted so - PlaySound(uid, component.SoundInsert?.GetSound(Random, ProtoManager), args.User); + Audio.PlayPredicted(component.SoundInsert, uid, args.User); args.Handled = true; UpdateBallisticAppearance(component); Dirty(component); @@ -80,10 +80,7 @@ public abstract partial class SharedGunSystem } Dirty(component); - var sound = component.SoundRack?.GetSound(Random, ProtoManager); - - if (sound != null) - PlaySound(component.Owner, sound, user); + Audio.PlayPredicted(component.SoundRack, component.Owner, user); var shots = GetBallisticShots(component); component.Cycled = true; @@ -208,9 +205,11 @@ public abstract partial class SharedGunSystem private void UpdateBallisticAppearance(BallisticAmmoProviderComponent component) { - if (!Timing.IsFirstTimePredicted || !TryComp(component.Owner, out var appearance)) return; - appearance.SetData(AmmoVisuals.AmmoCount, GetBallisticShots(component)); - appearance.SetData(AmmoVisuals.AmmoMax, component.Capacity); + if (!Timing.IsFirstTimePredicted || !TryComp(component.Owner, out var appearance)) + return; + + Appearance.SetData(appearance.Owner, AmmoVisuals.AmmoCount, GetBallisticShots(component), appearance); + Appearance.SetData(appearance.Owner, AmmoVisuals.AmmoMax, component.Capacity, appearance); } [Serializable, NetSerializable] diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.BasicEntity.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.BasicEntity.cs index ff2acfd225..73d8effe73 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.BasicEntity.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.BasicEntity.cs @@ -70,9 +70,10 @@ public abstract partial class SharedGunSystem private void UpdateBasicEntityAppearance(BasicEntityAmmoProviderComponent component) { if (!Timing.IsFirstTimePredicted || !TryComp(component.Owner, out var appearance)) return; - appearance.SetData(AmmoVisuals.HasAmmo, component.Count != 0); - appearance.SetData(AmmoVisuals.AmmoCount, component.Count ?? int.MaxValue); - appearance.SetData(AmmoVisuals.AmmoMax, component.Capacity ?? int.MaxValue); + + Appearance.SetData(appearance.Owner, AmmoVisuals.HasAmmo, component.Count != 0, appearance); + Appearance.SetData(appearance.Owner, AmmoVisuals.AmmoCount, component.Count ?? int.MaxValue, appearance); + Appearance.SetData(appearance.Owner, AmmoVisuals.AmmoMax, component.Capacity ?? int.MaxValue, appearance); } #region Public API diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Interactions.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Interactions.cs index e91f6fc1d6..b2afc368ab 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Interactions.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Interactions.cs @@ -69,7 +69,7 @@ public abstract partial class SharedGunSystem else component.NextFire += cooldown; - PlaySound(component.Owner, component.SoundModeToggle?.GetSound(Random, ProtoManager), user); + Audio.PlayPredicted(component.SoundModeToggle, component.Owner, user); Popup(Loc.GetString("gun-selected-mode", ("mode", GetLocSelector(fire))), component.Owner, user); Dirty(component); } diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Magazine.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Magazine.cs index ab961c5fda..aa742cd024 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Magazine.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Magazine.cs @@ -58,8 +58,10 @@ public abstract partial class SharedGunSystem private void OnMagazineSlotChange(EntityUid uid, MagazineAmmoProviderComponent component, ref ItemSlotChangedEvent args) { UpdateAmmoCount(uid); - if (!TryComp(uid, out var appearance)) return; - appearance.SetData(AmmoVisuals.MagLoaded, GetMagazineEntity(uid) != null); + if (!TryComp(uid, out var appearance)) + return; + + Appearance.SetData(uid, AmmoVisuals.MagLoaded, GetMagazineEntity(uid) != null, appearance); } protected (int, int) GetMagazineCountCapacity(MagazineAmmoProviderComponent component) @@ -93,7 +95,7 @@ public abstract partial class SharedGunSystem if (magEntity == null) { - appearance?.SetData(AmmoVisuals.MagLoaded, false); + Appearance.SetData(uid, AmmoVisuals.MagLoaded, false, appearance); return; } @@ -112,7 +114,7 @@ public abstract partial class SharedGunSystem if (component.AutoEject && args.Ammo.Count == 0) { EjectMagazine(component); - PlaySound(uid, component.SoundAutoEject?.GetSound(Random, ProtoManager), args.User); + Audio.PlayPredicted(component.SoundAutoEject, uid, args.User); } UpdateMagazineAppearance(appearance, true, count, capacity); @@ -144,11 +146,14 @@ public abstract partial class SharedGunSystem private void UpdateMagazineAppearance(AppearanceComponent? appearance, bool magLoaded, int count, int capacity) { + if (appearance == null) + return; + // Copy the magazine's appearance data - appearance?.SetData(AmmoVisuals.MagLoaded, magLoaded); - appearance?.SetData(AmmoVisuals.HasAmmo, count != 0); - appearance?.SetData(AmmoVisuals.AmmoCount, count); - appearance?.SetData(AmmoVisuals.AmmoMax, capacity); + Appearance.SetData(appearance.Owner, AmmoVisuals.MagLoaded, magLoaded, appearance); + Appearance.SetData(appearance.Owner, AmmoVisuals.HasAmmo, count != 0, appearance); + Appearance.SetData(appearance.Owner, AmmoVisuals.AmmoCount, count, appearance); + Appearance.SetData(appearance.Owner, AmmoVisuals.AmmoMax, capacity, appearance); } private void EjectMagazine(MagazineAmmoProviderComponent component) diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs index 7b3b4aceea..0a8d973e9a 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs @@ -84,7 +84,7 @@ public partial class SharedGunSystem component.AmmoSlots[index] = uid; component.AmmoContainer.Insert(uid); - PlaySound(component.Owner, component.SoundInsert?.GetSound(Random, ProtoManager), user); + Audio.PlayPredicted(component.SoundInsert, component.Owner, user); Popup(Loc.GetString("gun-revolver-insert"), component.Owner, user); UpdateRevolverAppearance(component); UpdateAmmoCount(uid); @@ -210,7 +210,7 @@ public partial class SharedGunSystem if (anyEmpty) { - PlaySound(component.Owner, component.SoundEject?.GetSound(Random, ProtoManager), user); + Audio.PlayPredicted(component.SoundEject, component.Owner, user); UpdateAmmoCount(component.Owner); UpdateRevolverAppearance(component); Dirty(component); @@ -219,16 +219,18 @@ public partial class SharedGunSystem private void UpdateRevolverAppearance(RevolverAmmoProviderComponent component) { - if (!TryComp(component.Owner, out var appearance)) return; + if (!TryComp(component.Owner, out var appearance)) + return; + var count = GetRevolverCount(component); - appearance.SetData(AmmoVisuals.HasAmmo, count != 0); - appearance.SetData(AmmoVisuals.AmmoCount, count); - appearance.SetData(AmmoVisuals.AmmoMax, component.Capacity); + Appearance.SetData(component.Owner, AmmoVisuals.HasAmmo, count != 0, appearance); + Appearance.SetData(component.Owner, AmmoVisuals.AmmoCount, count, appearance); + Appearance.SetData(component.Owner, AmmoVisuals.AmmoMax, component.Capacity, appearance); } protected virtual void SpinRevolver(RevolverAmmoProviderComponent component, EntityUid? user = null) { - PlaySound(component.Owner, component.SoundSpin?.GetSound(Random, ProtoManager), user); + Audio.PlayPredicted(component.SoundSpin, component.Owner, user); Popup(Loc.GetString("gun-revolver-spun"), component.Owner, user); } diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index fa22781e14..e6e3a0cecb 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -275,7 +275,7 @@ public abstract partial class SharedGunSystem : EntitySystem // Don't spam safety sounds at gun fire rate, play it at a reduced rate. // May cause prediction issues? Needs more tweaking gun.NextFire = TimeSpan.FromSeconds(Math.Max(lastFire.TotalSeconds + SafetyNextFire, gun.NextFire.TotalSeconds)); - PlaySound(gun.Owner, gun.SoundEmpty?.GetSound(Random, ProtoManager), user); + Audio.PlayPredicted(gun.SoundEmpty, gun.Owner, user); Dirty(gun); return; } @@ -351,15 +351,10 @@ public abstract partial class SharedGunSystem : EntitySystem xform.LocalRotation = Random.NextAngle(); xform.Coordinates = coordinates; - string? sound = null; - - if (TryComp(entity, out var cartridge)) + if (playSound && TryComp(entity, out var cartridge)) { - sound = cartridge.EjectSound?.GetSound(Random, ProtoManager); + Audio.PlayPvs(cartridge.EjectSound, entity, AudioParams.Default.WithVariation(0.05f).WithVolume(-1f)); } - - if (sound != null && playSound) - SoundSystem.Play(sound, Filter.Pvs(entity, entityManager: EntityManager), coordinates, AudioHelpers.WithVariation(0.05f).WithVolume(-1f)); } protected void MuzzleFlash(EntityUid gun, AmmoComponent component, EntityUid? user = null) diff --git a/Content.Shared/Whitelist/EntityWhitelist.cs b/Content.Shared/Whitelist/EntityWhitelist.cs index c32694b115..891c7626eb 100644 --- a/Content.Shared/Whitelist/EntityWhitelist.cs +++ b/Content.Shared/Whitelist/EntityWhitelist.cs @@ -72,7 +72,7 @@ namespace Content.Shared.Whitelist if (Components != null && _registrations == null) UpdateRegistrations(); - entityManager ??= IoCManager.Resolve(); + IoCManager.Resolve(ref entityManager); if (_registrations != null) { foreach (var reg in _registrations) @@ -89,7 +89,7 @@ namespace Content.Shared.Whitelist if (Tags != null && entityManager.TryGetComponent(uid, out TagComponent? tags)) { - var tagSystem = EntitySystem.Get(); + var tagSystem = entityManager.System(); return RequireAll ? tagSystem.HasAllTags(tags, Tags) : tagSystem.HasAnyTag(tags, Tags); }