Re-organize all projects (#4166)

This commit is contained in:
DrSmugleaf
2021-06-09 22:19:39 +02:00
committed by GitHub
parent 9f50e4061b
commit ff1a2d97ea
1773 changed files with 5258 additions and 5508 deletions

View File

@@ -0,0 +1,51 @@
using System;
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.GameTicking.Commands
{
[AdminCommand(AdminFlags.Server)]
class DelayStartCommand : IConsoleCommand
{
public string Command => "delaystart";
public string Description => "Delays the round start.";
public string Help => $"Usage: {Command} <seconds>\nPauses/Resumes the countdown if no argument is provided.";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
{
shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
return;
}
if (args.Length == 0)
{
var paused = ticker.TogglePause();
shell.WriteLine(paused ? "Paused the countdown." : "Resumed the countdown.");
return;
}
if (args.Length != 1)
{
shell.WriteLine("Need zero or one arguments.");
return;
}
if (!uint.TryParse(args[0], out var seconds) || seconds == 0)
{
shell.WriteLine($"{args[0]} isn't a valid amount of seconds.");
return;
}
var time = TimeSpan.FromSeconds(seconds);
if (!ticker.DelayStart(time))
{
shell.WriteLine("An unknown error has occurred.");
}
}
}
}

View File

@@ -0,0 +1,29 @@
using System;
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.GameTicking.Commands
{
[AdminCommand(AdminFlags.Server)]
class EndRoundCommand : IConsoleCommand
{
public string Command => "endround";
public string Description => "Ends the round and moves the server to PostRound.";
public string Help => String.Empty;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel != GameRunLevel.InRound)
{
shell.WriteLine("This can only be executed while the game is in a round.");
return;
}
ticker.EndRound();
}
}
}

View File

@@ -0,0 +1,41 @@
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.GameTicking.Commands
{
[AdminCommand(AdminFlags.Server)]
class ForcePresetCommand : IConsoleCommand
{
public string Command => "forcepreset";
public string Description => "Forces a specific game preset to start for the current lobby.";
public string Help => $"Usage: {Command} <preset>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
{
shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
return;
}
if (args.Length != 1)
{
shell.WriteLine("Need exactly one argument.");
return;
}
var name = args[0];
if (!ticker.TryGetPreset(name, out var type))
{
shell.WriteLine($"No preset exists with name {name}.");
return;
}
ticker.SetStartPreset(type, true);
shell.WriteLine($"Forced the game to start with preset {name}.");
}
}
}

View File

@@ -0,0 +1,47 @@
#nullable enable
using System;
using Content.Server.Administration;
using Content.Shared;
using Content.Shared.Administration;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.GameTicking.Commands
{
[AdminCommand(AdminFlags.Server)]
public class GoLobbyCommand : IConsoleCommand
{
public string Command => "golobby";
public string Description => "Enables the lobby and restarts the round.";
public string Help => $"Usage: {Command} / {Command} <preset>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
Type? preset = null;
var presetName = string.Join(" ", args);
var ticker = IoCManager.Resolve<IGameTicker>();
if (args.Length > 0)
{
if (!ticker.TryGetPreset(presetName, out preset))
{
shell.WriteLine($"No preset found with name {presetName}");
return;
}
}
var config = IoCManager.Resolve<IConfigurationManager>();
config.SetCVar(CCVars.GameLobbyEnabled, true);
ticker.RestartRound();
if (preset != null)
{
ticker.SetStartPreset(preset);
}
shell.WriteLine($"Enabling the lobby and restarting the round.{(preset == null ? "" : $"\nPreset set to {presetName}")}");
}
}
}

View File

@@ -0,0 +1,57 @@
using System.Collections.Generic;
using Content.Server.Administration;
using Content.Shared.Roles;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Server.GameTicking.Commands
{
[AnyCommand]
class JoinGameCommand : IConsoleCommand
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public string Command => "joingame";
public string Description => "";
public string Help => "";
public JoinGameCommand()
{
IoCManager.InjectDependencies(this);
}
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
var output = string.Join(".", args);
if (player == null)
{
return;
}
var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel == GameRunLevel.PreRoundLobby)
{
shell.WriteLine("Round has not started.");
return;
}
else if(ticker.RunLevel == GameRunLevel.InRound)
{
string ID = args[0];
var positions = ticker.GetAvailablePositions();
if(positions.GetValueOrDefault(ID, 0) == 0) //n < 0 is treated as infinite
{
var jobPrototype = _prototypeManager.Index<JobPrototype>(ID);
shell.WriteLine($"{jobPrototype.Name} has no available slots.");
return;
}
ticker.MakeJoinGame(player, args[0]);
return;
}
ticker.MakeJoinGame(player);
}
}
}

View File

@@ -0,0 +1,80 @@
// ReSharper disable once RedundantUsingDirective
// Used to warn the player in big red letters in debug mode
using System.Linq;
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Server.GameTicking.Commands
{
[AdminCommand(AdminFlags.Server | AdminFlags.Mapping)]
class MappingCommand : IConsoleCommand
{
public string Command => "mapping";
public string Description => "Creates and teleports you to a new uninitialized map for mapping.";
public string Help => $"Usage: {Command} <mapname> / {Command} <id> <mapname>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
shell.WriteLine("Only players can use this command");
return;
}
#if DEBUG
shell.WriteError("WARNING: The server is using a debug build. You are risking losing your changes.");
#endif
var mapManager = IoCManager.Resolve<IMapManager>();
int mapId;
string mapName;
switch (args.Length)
{
case 1:
if (player.AttachedEntity == null)
{
shell.WriteLine("The map name argument cannot be omitted if you have no entity.");
return;
}
mapId = (int) mapManager.NextMapId();
mapName = args[0];
break;
case 2:
if (!int.TryParse(args[0], out var id))
{
shell.WriteLine($"{args[0]} is not a valid integer.");
return;
}
mapId = id;
mapName = args[1];
break;
default:
shell.WriteLine(Help);
return;
}
shell.ExecuteCommand($"addmap {mapId} false");
shell.ExecuteCommand($"loadbp {mapId} \"{CommandParsing.Escape(mapName)}\" true");
shell.ExecuteCommand("aghost");
shell.ExecuteCommand($"tp 0 0 {mapId}");
var newGrid = mapManager.GetAllGrids().OrderByDescending(g => (int) g.Index).First();
var pauseManager = IoCManager.Resolve<IPauseManager>();
pauseManager.SetMapPaused(newGrid.ParentMapId, true);
shell.WriteLine($"Created unloaded map from file {mapName} with id {mapId}. Use \"savebp {newGrid.Index} foo.yml\" to save the new grid as a map.");
}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.GameTicking.Commands
{
[AdminCommand(AdminFlags.Server)]
public class NewRoundCommand : IConsoleCommand
{
public string Command => "restartround";
public string Description => "Moves the server from PostRound to a new PreRoundLobby.";
public string Help => String.Empty;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var ticker = IoCManager.Resolve<IGameTicker>();
ticker.RestartRound();
}
}
}

View File

@@ -0,0 +1,27 @@
using Content.Server.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.GameTicking.Commands
{
[AnyCommand]
class ObserveCommand : IConsoleCommand
{
public string Command => "observe";
public string Description => "";
public string Help => "";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
return;
}
var ticker = IoCManager.Resolve<IGameTicker>();
ticker.MakeObserve(player);
}
}
}

View File

@@ -0,0 +1,60 @@
using Content.Server.Players;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Network;
namespace Content.Server.GameTicking.Commands
{
class RespawnCommand : IConsoleCommand
{
public string Command => "respawn";
public string Description => "Respawns a player, kicking them back to the lobby.";
public string Help => "respawn [player]";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (args.Length > 1)
{
shell.WriteLine("Must provide <= 1 argument.");
return;
}
var playerMgr = IoCManager.Resolve<IPlayerManager>();
var ticker = IoCManager.Resolve<IGameTicker>();
NetUserId userId;
if (args.Length == 0)
{
if (player == null)
{
shell.WriteLine("If not a player, an argument must be given.");
return;
}
userId = player.UserId;
}
else if (!playerMgr.TryGetUserId(args[0], out userId))
{
shell.WriteLine("Unknown player");
return;
}
if (!playerMgr.TryGetSessionById(userId, out var targetPlayer))
{
if (!playerMgr.TryGetPlayerData(userId, out var data))
{
shell.WriteLine("Unknown player");
return;
}
data.ContentData()?.WipeMind();
shell.WriteLine("Player is not currently online, but they will respawn if they come back online");
return;
}
ticker.Respawn(targetPlayer);
}
}
}

View File

@@ -0,0 +1,28 @@
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.GameTicking.Commands
{
[AdminCommand(AdminFlags.Server)]
class SetGamePresetCommand : IConsoleCommand
{
public string Command => "setgamepreset";
public string Description => "";
public string Help => "";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteLine("Need exactly one argument.");
return;
}
var ticker = IoCManager.Resolve<IGameTicker>();
ticker.SetStartPreset(args[0]);
}
}
}

View File

@@ -0,0 +1,29 @@
using System;
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.GameTicking.Commands
{
[AdminCommand(AdminFlags.Server)]
class StartRoundCommand : IConsoleCommand
{
public string Command => "startround";
public string Description => "Ends PreRoundLobby state and starts the round.";
public string Help => String.Empty;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
{
shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
return;
}
ticker.StartRound();
}
}
}

View File

@@ -0,0 +1,36 @@
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.GameTicking.Commands
{
[AdminCommand(AdminFlags.Server)]
class ToggleDisallowLateJoinCommand : IConsoleCommand
{
public string Command => "toggledisallowlatejoin";
public string Description => "Allows or disallows latejoining during mid-game.";
public string Help => $"Usage: {Command} <disallow>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteLine("Need exactly one argument.");
return;
}
var ticker = IoCManager.Resolve<IGameTicker>();
if (bool.TryParse(args[0], out var result))
{
ticker.ToggleDisallowLateJoin(bool.Parse(args[0]));
shell.WriteLine(result ? "Late joining has been disabled." : "Late joining has been enabled.");
}
else
{
shell.WriteLine("Invalid argument.");
}
}
}
}

View File

@@ -0,0 +1,27 @@
using Content.Server.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.GameTicking.Commands
{
[AnyCommand]
class ToggleReadyCommand : IConsoleCommand
{
public string Command => "toggleready";
public string Description => "";
public string Help => "";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
return;
}
var ticker = IoCManager.Resolve<IGameTicker>();
ticker.ToggleReady(player, bool.Parse(args[0]));
}
}
}