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()
|
||||
|
||||
Reference in New Issue
Block a user