Rename SoundComponent and refactor its wrong usages. (#1036)
* Rename `SoundComponent` and refactor its wrong usages. * Replace verbose IoC grabs with EntitySysetm.Get * unused depend Co-authored-by: FL-OZ <anotherscuffed@gmail.com> Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
@@ -8,8 +8,10 @@ using Content.Shared.GameObjects.Components;
|
||||
using Content.Shared.Interfaces;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.Components.Container;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
@@ -27,6 +29,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly ISharedNotifyManager _notifyManager;
|
||||
[Dependency] private readonly ILocalizationManager _localizationManager;
|
||||
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
|
||||
#pragma warning restore 649
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)] public float Wattage { get; set; } = 10;
|
||||
@@ -66,10 +69,8 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent(out SoundComponent soundComponent))
|
||||
{
|
||||
soundComponent.Play("/Audio/items/weapons/pistol_magin.ogg");
|
||||
}
|
||||
EntitySystem.Get<AudioSystem>().Play("/Audio/items/weapons/pistol_magin.ogg", Owner);
|
||||
|
||||
|
||||
Dirty();
|
||||
|
||||
@@ -132,10 +133,8 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
SetState(false);
|
||||
Activated = false;
|
||||
|
||||
if (Owner.TryGetComponent(out SoundComponent soundComponent))
|
||||
{
|
||||
soundComponent.Play("/Audio/items/flashlight_toggle.ogg");
|
||||
}
|
||||
EntitySystem.Get<AudioSystem>().Play("/Audio/items/flashlight_toggle.ogg", Owner);
|
||||
|
||||
}
|
||||
|
||||
private void TurnOn(IEntity user)
|
||||
@@ -146,13 +145,10 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
}
|
||||
|
||||
var cell = Cell;
|
||||
SoundComponent soundComponent;
|
||||
if (cell == null)
|
||||
{
|
||||
if (Owner.TryGetComponent(out soundComponent))
|
||||
{
|
||||
soundComponent.Play("/Audio/machines/button.ogg");
|
||||
}
|
||||
|
||||
EntitySystem.Get<AudioSystem>().Play("/Audio/machines/button.ogg", Owner);
|
||||
|
||||
_notifyManager.PopupMessage(Owner, user, _localizationManager.GetString("Cell missing..."));
|
||||
return;
|
||||
@@ -163,11 +159,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
// Simple enough.
|
||||
if (cell.AvailableCharge(1) < Wattage)
|
||||
{
|
||||
if (Owner.TryGetComponent(out soundComponent))
|
||||
{
|
||||
soundComponent.Play("/Audio/machines/button.ogg");
|
||||
}
|
||||
|
||||
EntitySystem.Get<AudioSystem>().Play("/Audio/machines/button.ogg", Owner);
|
||||
_notifyManager.PopupMessage(Owner, user, _localizationManager.GetString("Dead cell..."));
|
||||
return;
|
||||
}
|
||||
@@ -175,10 +167,8 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
Activated = true;
|
||||
SetState(true);
|
||||
|
||||
if (Owner.TryGetComponent(out soundComponent))
|
||||
{
|
||||
soundComponent.Play("/Audio/items/flashlight_toggle.ogg");
|
||||
}
|
||||
EntitySystem.Get<AudioSystem>().Play("/Audio/items/flashlight_toggle.ogg", Owner);
|
||||
|
||||
}
|
||||
|
||||
private void SetState(bool on)
|
||||
@@ -225,10 +215,8 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
cell.Owner.Transform.GridPosition = user.Transform.GridPosition;
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent(out SoundComponent soundComponent))
|
||||
{
|
||||
soundComponent.Play("/Audio/items/weapons/pistol_magout.ogg");
|
||||
}
|
||||
EntitySystem.Get<AudioSystem>().Play("/Audio/items/weapons/pistol_magout.ogg", Owner);
|
||||
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Shared.GameObjects.Components.Interactable;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Serialization;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -66,7 +67,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
Owner.TryGetComponent(out _tool);
|
||||
Owner.TryGetComponent(out _sprite);
|
||||
|
||||
_audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>();
|
||||
_audioSystem = EntitySystem.Get<AudioSystem>();
|
||||
|
||||
SetTool();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
@@ -89,7 +90,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>();
|
||||
_audioSystem = EntitySystem.Get<AudioSystem>();
|
||||
_interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
|
||||
Owner.TryGetComponent(out _spriteComponent);
|
||||
}
|
||||
@@ -125,7 +126,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
{
|
||||
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(name);
|
||||
var file = _robustRandom.Pick(soundCollection.PickFiles);
|
||||
_entitySystemManager.GetEntitySystem<AudioSystem>()
|
||||
EntitySystem.Get<AudioSystem>()
|
||||
.Play(file, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user