Add a "give full access" button to the sandbox menu for convienence. (#1387)
Co-authored-by: scuffedjays <yetanotherscuffed@gmail.com>
This commit is contained in:
@@ -44,6 +44,8 @@ namespace Content.Client.Sandbox
|
|||||||
_netManager.RegisterNetMessage<MsgSandboxStatus>(nameof(MsgSandboxStatus),
|
_netManager.RegisterNetMessage<MsgSandboxStatus>(nameof(MsgSandboxStatus),
|
||||||
message => SetAllowed(message.SandboxAllowed));
|
message => SetAllowed(message.SandboxAllowed));
|
||||||
|
|
||||||
|
_netManager.RegisterNetMessage<MsgSandboxGiveAccess>(nameof(MsgSandboxGiveAccess));
|
||||||
|
|
||||||
_netManager.RegisterNetMessage<MsgSandboxRespawn>(nameof(MsgSandboxRespawn));
|
_netManager.RegisterNetMessage<MsgSandboxRespawn>(nameof(MsgSandboxRespawn));
|
||||||
|
|
||||||
_gameHud.SandboxButtonToggled = SandboxButtonPressed;
|
_gameHud.SandboxButtonToggled = SandboxButtonPressed;
|
||||||
@@ -109,10 +111,13 @@ namespace Content.Client.Sandbox
|
|||||||
_window.RespawnButton.OnPressed += OnRespawnButtonOnOnPressed;
|
_window.RespawnButton.OnPressed += OnRespawnButtonOnOnPressed;
|
||||||
_window.SpawnTilesButton.OnPressed += OnSpawnTilesButtonClicked;
|
_window.SpawnTilesButton.OnPressed += OnSpawnTilesButtonClicked;
|
||||||
_window.SpawnEntitiesButton.OnPressed += OnSpawnEntitiesButtonClicked;
|
_window.SpawnEntitiesButton.OnPressed += OnSpawnEntitiesButtonClicked;
|
||||||
|
_window.GiveFullAccessButton.OnPressed += OnGiveAdminAccessButtonClicked;
|
||||||
|
|
||||||
_window.OpenCentered();
|
_window.OpenCentered();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void WindowOnOnClose()
|
private void WindowOnOnClose()
|
||||||
{
|
{
|
||||||
_window = null;
|
_window = null;
|
||||||
@@ -135,6 +140,10 @@ namespace Content.Client.Sandbox
|
|||||||
ToggleTilesWindow();
|
ToggleTilesWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnGiveAdminAccessButtonClicked(BaseButton.ButtonEventArgs args)
|
||||||
|
{
|
||||||
|
_netManager.ClientSendMessage(_netManager.CreateNetMessage<MsgSandboxGiveAccess>());
|
||||||
|
}
|
||||||
private void ToggleEntitySpawnWindow()
|
private void ToggleEntitySpawnWindow()
|
||||||
{
|
{
|
||||||
if(_spawnWindow == null)
|
if(_spawnWindow == null)
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ namespace Content.Client.Sandbox
|
|||||||
public Button SpawnEntitiesButton { get; }
|
public Button SpawnEntitiesButton { get; }
|
||||||
public Button SpawnTilesButton { get; }
|
public Button SpawnTilesButton { get; }
|
||||||
|
|
||||||
|
public Button GiveFullAccessButton { get; } //A button that just puts a captain's ID in your hands.
|
||||||
|
|
||||||
public SandboxWindow(ILocalizationManager loc)
|
public SandboxWindow(ILocalizationManager loc)
|
||||||
{
|
{
|
||||||
Title = loc.GetString("Sandbox Panel");
|
Title = loc.GetString("Sandbox Panel");
|
||||||
@@ -29,13 +31,19 @@ namespace Content.Client.Sandbox
|
|||||||
Text = loc.GetString("Spawn Tiles")
|
Text = loc.GetString("Spawn Tiles")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GiveFullAccessButton = new Button
|
||||||
|
{
|
||||||
|
Text = loc.GetString("Give Full Access ID")
|
||||||
|
};
|
||||||
|
|
||||||
Contents.AddChild(new VBoxContainer
|
Contents.AddChild(new VBoxContainer
|
||||||
{
|
{
|
||||||
Children =
|
Children =
|
||||||
{
|
{
|
||||||
RespawnButton,
|
RespawnButton,
|
||||||
SpawnEntitiesButton,
|
SpawnEntitiesButton,
|
||||||
SpawnTilesButton
|
SpawnTilesButton,
|
||||||
|
GiveFullAccessButton
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using Content.Server.GameObjects;
|
||||||
|
using Content.Server.GameObjects.Components;
|
||||||
using Content.Server.GameTicking;
|
using Content.Server.GameTicking;
|
||||||
using Content.Server.Interfaces.GameTicking;
|
using Content.Server.Interfaces.GameTicking;
|
||||||
using Content.Shared.Sandbox;
|
using Content.Shared.Sandbox;
|
||||||
@@ -6,6 +8,7 @@ using Robust.Server.Interfaces.Placement;
|
|||||||
using Robust.Server.Interfaces.Player;
|
using Robust.Server.Interfaces.Player;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Interfaces.Network;
|
using Robust.Shared.Interfaces.Network;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
@@ -20,6 +23,7 @@ namespace Content.Server.Sandbox
|
|||||||
[Dependency] private readonly IGameTicker _gameTicker;
|
[Dependency] private readonly IGameTicker _gameTicker;
|
||||||
[Dependency] private readonly IPlacementManager _placementManager;
|
[Dependency] private readonly IPlacementManager _placementManager;
|
||||||
[Dependency] private readonly IConGroupController _conGroupController;
|
[Dependency] private readonly IConGroupController _conGroupController;
|
||||||
|
[Dependency] private readonly IEntityManager _entityManager;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
private bool _isSandboxEnabled;
|
private bool _isSandboxEnabled;
|
||||||
@@ -39,6 +43,7 @@ namespace Content.Server.Sandbox
|
|||||||
{
|
{
|
||||||
_netManager.RegisterNetMessage<MsgSandboxStatus>(nameof(MsgSandboxStatus));
|
_netManager.RegisterNetMessage<MsgSandboxStatus>(nameof(MsgSandboxStatus));
|
||||||
_netManager.RegisterNetMessage<MsgSandboxRespawn>(nameof(MsgSandboxRespawn), SandboxRespawnReceived);
|
_netManager.RegisterNetMessage<MsgSandboxRespawn>(nameof(MsgSandboxRespawn), SandboxRespawnReceived);
|
||||||
|
_netManager.RegisterNetMessage<MsgSandboxGiveAccess>(nameof(MsgSandboxGiveAccess), SandboxGiveAccessReceived);
|
||||||
|
|
||||||
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
|
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
|
||||||
_gameTicker.OnRunLevelChanged += GameTickerOnOnRunLevelChanged;
|
_gameTicker.OnRunLevelChanged += GameTickerOnOnRunLevelChanged;
|
||||||
@@ -94,6 +99,23 @@ namespace Content.Server.Sandbox
|
|||||||
_gameTicker.Respawn(player);
|
_gameTicker.Respawn(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SandboxGiveAccessReceived(MsgSandboxGiveAccess message)
|
||||||
|
{
|
||||||
|
if(!IsSandboxEnabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var player = _playerManager.GetSessionByChannel(message.MsgChannel);
|
||||||
|
if(player.AttachedEntity.TryGetComponent<HandsComponent>(out var hands))
|
||||||
|
{
|
||||||
|
;
|
||||||
|
hands.PutInHandOrDrop(
|
||||||
|
_entityManager.SpawnEntity("CaptainIDCard",
|
||||||
|
player.AttachedEntity.Transform.GridPosition).GetComponent<ItemComponent>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateSandboxStatusForAll()
|
private void UpdateSandboxStatusForAll()
|
||||||
{
|
{
|
||||||
var msg = _netManager.CreateNetMessage<MsgSandboxStatus>();
|
var msg = _netManager.CreateNetMessage<MsgSandboxStatus>();
|
||||||
|
|||||||
@@ -47,5 +47,24 @@ namespace Content.Shared.Sandbox
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected sealed class MsgSandboxGiveAccess : NetMessage
|
||||||
|
{
|
||||||
|
#region REQUIRED
|
||||||
|
|
||||||
|
public const MsgGroups GROUP = MsgGroups.Command;
|
||||||
|
public const string NAME = nameof(MsgSandboxGiveAccess);
|
||||||
|
public MsgSandboxGiveAccess(INetChannel channel) : base(NAME, GROUP) { }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user