Make latejoining not hardcoded to presets (#2028)

* Make latejoining not hardcoded to presets

* Applied feedback

* Build error fix

* Applied more feedback

Co-authored-by: David Tan <>
This commit is contained in:
DTanxxx
2020-09-07 22:33:18 +12:00
committed by GitHub
parent f96f286ca4
commit 47554f99f0
5 changed files with 31 additions and 1 deletions

View File

@@ -58,6 +58,10 @@ namespace Content.IntegrationTests
{
}
public void ToggleDisallowLateJoin(bool disallowLateJoin)
{
}
public EntityCoordinates GetLateJoinSpawnPoint() => EntityCoordinates.Invalid;
public EntityCoordinates GetJobSpawnPoint(string jobId) => EntityCoordinates.Invalid;
public EntityCoordinates GetObserverSpawnPoint() => EntityCoordinates.Invalid;

View File

@@ -159,7 +159,6 @@ namespace Content.Server.GameTicking.GamePresets
return true;
}
public override string ModeTitle => "Suspicion";
public override string Description => "Suspicion on the Space Station. There are traitors on board... Can you kill them before they kill you?";
}

View File

@@ -411,6 +411,12 @@ namespace Content.Server.GameTicking
_netManager.ServerSendToAll(GetStatusSingle(player, status));
}
public void ToggleDisallowLateJoin(bool disallowLateJoin)
{
DisallowLateJoin = disallowLateJoin;
UpdateLateJoinStatus();
}
public T AddGameRule<T>() where T : GameRule, new()
{
var instance = _dynamicTypeFactory.CreateInstance<T>();

View File

@@ -244,6 +244,26 @@ namespace Content.Server.GameTicking
}
}
class ToggleDisallowLateJoinCommand: IClientCommand
{
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, IPlayerSession player, string[] args)
{
if (args.Length != 1)
{
shell.SendText(player, "Need exactly one argument.");
return;
}
var ticker = IoCManager.Resolve<IGameTicker>();
ticker.ToggleDisallowLateJoin(bool.Parse(args[0]));
}
}
class SetGamePresetCommand : IClientCommand
{
public string Command => "setgamepreset";

View File

@@ -30,6 +30,7 @@ namespace Content.Server.Interfaces.GameTicking
void MakeObserve(IPlayerSession player);
void MakeJoinGame(IPlayerSession player, string jobId);
void ToggleReady(IPlayerSession player, bool ready);
void ToggleDisallowLateJoin(bool disallowLateJoin);
EntityCoordinates GetLateJoinSpawnPoint();
EntityCoordinates GetJobSpawnPoint(string jobId);