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:
FL-OZ
2020-05-31 12:40:36 -05:00
committed by GitHub
parent 8db5adb387
commit 53900b79e9
30 changed files with 137 additions and 97 deletions

View File

@@ -3,8 +3,11 @@ using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.Audio;
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.Random;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
@@ -22,6 +25,7 @@ namespace Content.Server.GameObjects.Components.Items
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly IRobustRandom _random;
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
#pragma warning restore 649
public override string Name => "Dice";
@@ -61,7 +65,7 @@ namespace Content.Server.GameObjects.Components.Items
{
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(_soundCollectionName);
var file = _random.Pick(soundCollection.PickFiles);
Owner.GetComponent<SoundComponent>().Play(file, AudioParams.Default);
EntitySystem.Get<AudioSystem>().Play(file, Owner, AudioParams.Default);
}
}

View File

@@ -5,6 +5,7 @@ using Content.Shared.Maps;
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.IoC;
@@ -53,8 +54,8 @@ namespace Content.Server.GameObjects.Components.Items
{
var desiredTile = _tileDefinitionManager[_outputTile];
mapGrid.SetTile(eventArgs.ClickLocation, new Tile(desiredTile.TileId));
_entitySystemManager.GetEntitySystem<AudioSystem>().Play("/Audio/items/genhit.ogg", eventArgs.ClickLocation, AudioParams.Default);
if(_stack.Count < 1){
EntitySystem.Get<AudioSystem>().Play("/Audio/items/genhit.ogg", eventArgs.ClickLocation);
if(Stack.Count < 1){
Owner.Delete();
}
}

View File

@@ -10,9 +10,11 @@ using Content.Shared.GameObjects.Components.Storage;
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.Components;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
@@ -28,6 +30,9 @@ namespace Content.Server.GameObjects.Components
[ComponentReference(typeof(IStorageComponent))]
public class EntityStorageComponent : Component, IActivate, IStorageComponent, IInteractUsing
{
#pragma warning disable 649
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
#pragma warning restore 649
public override string Name => "EntityStorage";
private const float MaxSize = 1.0f; // maximum width or height of an entity allowed inside the storage.
@@ -164,10 +169,7 @@ namespace Content.Server.GameObjects.Components
}
ModifyComponents();
if (Owner.TryGetComponent(out SoundComponent soundComponent))
{
soundComponent.Play("/Audio/machines/closetclose.ogg");
}
EntitySystem.Get<AudioSystem>().Play("/Audio/machines/closetclose.ogg", Owner);
_lastInternalOpenAttempt = default;
}
@@ -176,10 +178,8 @@ namespace Content.Server.GameObjects.Components
Open = true;
EmptyContents();
ModifyComponents();
if (Owner.TryGetComponent(out SoundComponent soundComponent))
{
soundComponent.Play("/Audio/machines/closetopen.ogg");
}
EntitySystem.Get<AudioSystem>().Play("/Audio/machines/closetopen.ogg", Owner);
}
private void ModifyComponents()