Allow more lobby parameters to be configured.
This commit is contained in:
@@ -68,5 +68,9 @@ namespace Content.IntegrationTests
|
||||
public void SetStartPreset(Type type)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetStartPreset(string type)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,9 +48,6 @@ namespace Content.Server.GameTicking
|
||||
private const string ObserverPrototypeName = "MobObserver";
|
||||
private const string MapFile = "Maps/stationstation.yml";
|
||||
|
||||
// Seconds.
|
||||
private const float LobbyDuration = 20;
|
||||
|
||||
[ViewVariables] private readonly List<GameRule> _gameRules = new List<GameRule>();
|
||||
[ViewVariables] private readonly List<ManifestEntry> _manifest = new List<ManifestEntry>();
|
||||
|
||||
@@ -86,11 +83,17 @@ namespace Content.Server.GameTicking
|
||||
|
||||
public event Action<GameRunLevelChangedEventArgs> OnRunLevelChanged;
|
||||
|
||||
private TimeSpan LobbyDuration =>
|
||||
TimeSpan.FromSeconds(_configurationManager.GetCVar<int>("game.lobbyduration"));
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
DebugTools.Assert(!_initialized);
|
||||
|
||||
_configurationManager.RegisterCVar("game.lobbyenabled", false, CVar.ARCHIVE);
|
||||
_configurationManager.RegisterCVar("game.lobbyduration", 20, CVar.ARCHIVE);
|
||||
_configurationManager.RegisterCVar("game.defaultpreset", "Sandbox", CVar.ARCHIVE);
|
||||
|
||||
_playerManager.PlayerStatusChanged += _handlePlayerStatusChanged;
|
||||
|
||||
_netManager.RegisterNetMessage<MsgTickerJoinLobby>(nameof(MsgTickerJoinLobby));
|
||||
@@ -98,6 +101,8 @@ namespace Content.Server.GameTicking
|
||||
_netManager.RegisterNetMessage<MsgTickerLobbyStatus>(nameof(MsgTickerLobbyStatus));
|
||||
_netManager.RegisterNetMessage<MsgTickerLobbyInfo>(nameof(MsgTickerLobbyInfo));
|
||||
|
||||
SetStartPreset(_configurationManager.GetCVar<string>("game.defaultpreset"));
|
||||
|
||||
RestartRound();
|
||||
|
||||
_initialized = true;
|
||||
@@ -131,7 +136,7 @@ namespace Content.Server.GameTicking
|
||||
if (_playerManager.PlayerCount == 0)
|
||||
_roundStartCountdownHasNotStartedYetDueToNoPlayers = true;
|
||||
else
|
||||
_roundStartTimeUtc = DateTime.UtcNow + TimeSpan.FromSeconds(LobbyDuration);
|
||||
_roundStartTimeUtc = DateTime.UtcNow + LobbyDuration;
|
||||
|
||||
_sendStatusToAll();
|
||||
}
|
||||
@@ -258,6 +263,14 @@ namespace Content.Server.GameTicking
|
||||
UpdateInfoText();
|
||||
}
|
||||
|
||||
public void SetStartPreset(string type) =>
|
||||
SetStartPreset(type switch
|
||||
{
|
||||
"Sandbox" => typeof(PresetSandbox),
|
||||
"DeathMatch" => typeof(PresetDeathMatch),
|
||||
_ => throw new NotSupportedException()
|
||||
});
|
||||
|
||||
private IEntity _spawnPlayerMob(Job job, bool lateJoin = true)
|
||||
{
|
||||
GridCoordinates coordinates = lateJoin ? _getLateJoinSpawnPoint() : _getJobSpawnPoint(job.Prototype.ID);
|
||||
@@ -272,6 +285,7 @@ namespace Content.Server.GameTicking
|
||||
inventory.Equip(slot, equipmentEntity.GetComponent<ItemComponent>());
|
||||
}
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -313,7 +327,8 @@ namespace Content.Server.GameTicking
|
||||
foreach (var entity in _entityManager.GetEntities(new TypeEntityQuery(typeof(SpawnPointComponent))))
|
||||
{
|
||||
var point = entity.GetComponent<SpawnPointComponent>();
|
||||
if (point.SpawnType == SpawnPointType.Job && point.Job.ID == jobId) possiblePoints.Add(entity.Transform.GridPosition);
|
||||
if (point.SpawnType == SpawnPointType.Job && point.Job.ID == jobId)
|
||||
possiblePoints.Add(entity.Transform.GridPosition);
|
||||
}
|
||||
|
||||
if (possiblePoints.Count != 0) location = _robustRandom.Pick(possiblePoints);
|
||||
@@ -388,7 +403,7 @@ namespace Content.Server.GameTicking
|
||||
if (LobbyEnabled && _roundStartCountdownHasNotStartedYetDueToNoPlayers)
|
||||
{
|
||||
_roundStartCountdownHasNotStartedYetDueToNoPlayers = false;
|
||||
_roundStartTimeUtc = DateTime.UtcNow + TimeSpan.FromSeconds(LobbyDuration);
|
||||
_roundStartTimeUtc = DateTime.UtcNow + LobbyDuration;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -190,21 +190,7 @@ namespace Content.Server.GameTicking
|
||||
|
||||
var ticker = IoCManager.Resolve<IGameTicker>();
|
||||
|
||||
Type presetType;
|
||||
switch (args[0])
|
||||
{
|
||||
case "DeathMatch":
|
||||
presetType = typeof(PresetDeathMatch);
|
||||
break;
|
||||
case "Sandbox":
|
||||
presetType = typeof(PresetSandbox);
|
||||
break;
|
||||
default:
|
||||
shell.SendText(player, "That is not a valid game preset!");
|
||||
return;
|
||||
}
|
||||
|
||||
ticker.SetStartPreset(presetType);
|
||||
ticker.SetStartPreset(args[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,5 +33,6 @@ namespace Content.Server.Interfaces.GameTicking
|
||||
IEnumerable<GameRule> ActiveGameRules { get; }
|
||||
|
||||
void SetStartPreset(Type type);
|
||||
void SetStartPreset(string type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using Robust.Server.Player;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Sandbox
|
||||
{
|
||||
@@ -23,6 +24,7 @@ namespace Content.Server.Sandbox
|
||||
|
||||
private bool _isSandboxEnabled;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool IsSandboxEnabled
|
||||
{
|
||||
get => _isSandboxEnabled;
|
||||
|
||||
Reference in New Issue
Block a user