Refactor Game Modes (#5857)

This commit is contained in:
Vera Aguilera Puerto
2021-12-21 21:23:29 +01:00
committed by GitHub
parent d1a1ee3cbe
commit f4d8ec1b35
62 changed files with 2087 additions and 1804 deletions

View File

@@ -1,4 +1,5 @@
using Content.Server.Administration;
using Content.Server.GameTicking.Presets;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
@@ -29,13 +30,13 @@ namespace Content.Server.GameTicking.Commands
}
var name = args[0];
if (!ticker.TryGetPreset(name, out var type))
if (!ticker.TryFindGamePreset(name, out var type))
{
shell.WriteLine($"No preset exists with name {name}.");
return;
}
ticker.SetStartPreset(type, true);
ticker.SetGamePreset(type, true);
shell.WriteLine($"Forced the game to start with preset {name}.");
}
}

View File

@@ -1,5 +1,6 @@
using System;
using Content.Server.Administration;
using Content.Server.GameTicking.Presets;
using Content.Shared;
using Content.Shared.Administration;
using Content.Shared.CCVar;
@@ -18,14 +19,14 @@ namespace Content.Server.GameTicking.Commands
public string Help => $"Usage: {Command} / {Command} <preset>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
Type? preset = null;
GamePresetPrototype? preset = null;
var presetName = string.Join(" ", args);
var ticker = EntitySystem.Get<GameTicker>();
if (args.Length > 0)
{
if (!ticker.TryGetPreset(presetName, out preset))
if (!ticker.TryFindGamePreset(presetName, out preset))
{
shell.WriteLine($"No preset found with name {presetName}");
return;
@@ -39,7 +40,7 @@ namespace Content.Server.GameTicking.Commands
if (preset != null)
{
ticker.SetStartPreset(preset);
ticker.SetGamePreset(preset);
}
shell.WriteLine($"Enabling the lobby and restarting the round.{(preset == null ? "" : $"\nPreset set to {presetName}")}");

View File

@@ -16,13 +16,19 @@ namespace Content.Server.GameTicking.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
if (shell.Player is not IPlayerSession player)
{
return;
}
var ticker = EntitySystem.Get<GameTicker>();
if (ticker.RunLevel == GameRunLevel.PreRoundLobby)
{
shell.WriteError("Wait until the round starts.");
return;
}
if (ticker.PlayersInLobby.ContainsKey(player))
ticker.MakeObserve(player);
else

View File

@@ -23,7 +23,7 @@ namespace Content.Server.GameTicking.Commands
var ticker = EntitySystem.Get<GameTicker>();
ticker.SetStartPreset(args[0]);
ticker.SetGamePreset(args[0]);
}
}
}