Replace usages of ISharedNotifyManager and IServerNotifyManager with extension methods (#1965)

* Replace usages of ISharedNotifyManager and IServerNotifyManager with extension methods

* Remove redundant code
This commit is contained in:
DrSmugleaf
2020-09-01 12:34:53 +02:00
committed by GitHub
parent 14259ed920
commit 8f9ed2f562
53 changed files with 247 additions and 375 deletions

View File

@@ -5,7 +5,6 @@ using Content.Server.GameObjects.Components.NodeContainer;
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using Content.Server.GameObjects.Components.Power.PowerNetComponents;
using Content.Server.Interfaces;
using Content.Server.Interfaces.GameObjects.Components.Items;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Power.AME;
@@ -20,11 +19,11 @@ using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.ViewVariables;
using System.Linq;
using System.Threading.Tasks;
using Content.Shared.Interfaces;
namespace Content.Server.GameObjects.Components.Power.AME
{
@@ -33,8 +32,6 @@ namespace Content.Server.GameObjects.Components.Power.AME
[ComponentReference(typeof(IInteractUsing))]
public class AMEControllerComponent : SharedAMEControllerComponent, IActivate, IInteractUsing
{
[Dependency] private readonly IServerNotifyManager _notifyManager = default!;
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(AMEControllerUiKey.Key);
[ViewVariables] private bool _injecting;
[ViewVariables] public int InjectionAmount;
@@ -117,8 +114,7 @@ namespace Content.Server.GameObjects.Components.Power.AME
if (!args.User.TryGetComponent(out IHandsComponent? hands))
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
Loc.GetString("You have no hands."));
Owner.PopupMessage(args.User, Loc.GetString("You have no hands."));
return;
}
@@ -328,15 +324,13 @@ namespace Content.Server.GameObjects.Components.Power.AME
{
if (!args.User.TryGetComponent(out IHandsComponent? hands))
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
Loc.GetString("You have no hands."));
Owner.PopupMessage(args.User, Loc.GetString("You have no hands."));
return true;
}
if (hands.GetActiveHand == null)
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
Loc.GetString("You have nothing on your hand."));
Owner.PopupMessage(args.User, Loc.GetString("You have nothing on your hand."));
return false;
}
@@ -345,22 +339,19 @@ namespace Content.Server.GameObjects.Components.Power.AME
{
if (HasJar)
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
Loc.GetString("The controller already has a jar loaded."));
Owner.PopupMessage(args.User, Loc.GetString("The controller already has a jar loaded."));
}
else
{
_jarSlot.Insert(activeHandEntity);
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
Loc.GetString("You insert the jar into the fuel slot."));
Owner.PopupMessage(args.User, Loc.GetString("You insert the jar into the fuel slot."));
UpdateUserInterface();
}
}
else
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
Loc.GetString("You can't put that in the controller..."));
Owner.PopupMessage(args.User, Loc.GetString("You can't put that in the controller..."));
}
return true;

View File

@@ -1,5 +1,4 @@
using Content.Server.GameObjects.Components.Interactable;
using Content.Server.Interfaces;
using Content.Server.Interfaces.GameObjects.Components.Items;
using Content.Shared.GameObjects.Components.Interactable;
using Content.Shared.Interfaces.GameObjects.Components;
@@ -10,6 +9,7 @@ using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using System.Threading.Tasks;
using Content.Shared.Interfaces;
namespace Content.Server.GameObjects.Components.Power.AME
{
@@ -19,15 +19,14 @@ namespace Content.Server.GameObjects.Components.Power.AME
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IServerEntityManager _serverEntityManager = default!;
[Dependency] private readonly IServerNotifyManager _notifyManager = default!;
public override string Name => "AMEPart";
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args)
{
if (!args.User.TryGetComponent(out IHandsComponent hands))
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
Loc.GetString("You have no hands."));
Owner.PopupMessage(args.User, Loc.GetString("You have no hands."));
return true;
}

View File

@@ -4,7 +4,6 @@ using Content.Server.GameObjects.Components.GUI;
using Content.Server.GameObjects.Components.Items.Storage;
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces;
using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.Damage;
using Content.Shared.Interfaces.GameObjects.Components;
@@ -63,8 +62,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
case BeginDeconstructCompMsg msg:
if (!msg.BlockDeconstruct && !(_lightBulbContainer.ContainedEntity is null))
{
var notifyManager = IoCManager.Resolve<IServerNotifyManager>();
notifyManager.PopupMessage(Owner, msg.User, "Remove the bulb.");
Owner.PopupMessage(msg.User, Loc.GetString("Remove the bulb."));
msg.BlockDeconstruct = true;
}
break;