Separate ghost warp message into two (#3310)

* Separate ghost warp message into two

* Remove redundant arguments

* Address reviews

* Move properties up
This commit is contained in:
DrSmugleaf
2021-02-19 19:29:34 +01:00
committed by GitHub
parent 6d666b92e9
commit 5667cffe95
6 changed files with 81 additions and 47 deletions

View File

@@ -20,6 +20,7 @@ namespace Content.Client.GameObjects.Components.Observer
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IComponentManager _componentManager = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
public List<string> WarpNames = new();
public Dictionary<EntityUid,string> PlayerNames = new();
@@ -42,7 +43,6 @@ namespace Content.Client.GameObjects.Components.Observer
}
}
private void SetGhostVisibility(bool visibility)
{
foreach (var ghost in _componentManager.GetAllComponents(typeof(GhostComponent), true))
@@ -99,7 +99,9 @@ namespace Content.Client.GameObjects.Components.Observer
public void SendReturnToBodyMessage() => SendNetworkMessage(new ReturnToBodyComponentMessage());
public void SendGhostWarpRequestMessage(EntityUid target = default, string warpName = default!) => SendNetworkMessage(new GhostWarpRequestMessage(target, warpName));
public void SendGhostWarpRequestMessage(string warpName) => SendNetworkMessage(new GhostWarpToLocationRequestMessage(warpName));
public void SendGhostWarpRequestMessage(EntityUid target) => SendNetworkMessage(new GhostWarpToTargetRequestMessage(target));
public void GhostRequestWarpPoint() => SendNetworkMessage(new GhostRequestWarpPointData());

View File

@@ -17,7 +17,7 @@ namespace Content.Client.UserInterface
private readonly Button _ghostRoles = new() {Text = Loc.GetString("Ghost Roles")};
private readonly GhostComponent _owner;
public GhostTargetWindow? TargetWindow { get; private set; }
public GhostTargetWindow? TargetWindow { get; }
public GhostGui(GhostComponent owner)
{
@@ -29,8 +29,8 @@ namespace Content.Client.UserInterface
MouseFilter = MouseFilterMode.Ignore;
_ghostWarp.OnPressed += args => TargetWindow.Populate();
_returnToBody.OnPressed += args => owner.SendReturnToBodyMessage();
_ghostWarp.OnPressed += _ => TargetWindow.Populate();
_returnToBody.OnPressed += _ => owner.SendReturnToBodyMessage();
_ghostRoles.OnPressed += _ => IoCManager.Resolve<IClientConsoleHost>().RemoteExecuteCommand(null, "ghostroles");
AddChild(new HBoxContainer
@@ -114,7 +114,7 @@ namespace Content.Client.UserInterface
ClipText = true,
};
currentButtonRef.OnPressed += (args) =>
currentButtonRef.OnPressed += (_) =>
{
_owner.SendGhostWarpRequestMessage(key);
};
@@ -138,9 +138,9 @@ namespace Content.Client.UserInterface
ClipText = true,
};
currentButtonRef.OnPressed += (args) =>
currentButtonRef.OnPressed += (_) =>
{
_owner.SendGhostWarpRequestMessage(default,name);
_owner.SendGhostWarpRequestMessage(name);
};
_buttonContainer.AddChild(currentButtonRef);