Merge pull request #802 from FL-OZ/round_end_screen

This commit is contained in:
Pieter-Jan Briers
2020-04-16 22:33:38 +02:00
committed by GitHub
7 changed files with 232 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
namespace Content.Server.GameTicking
namespace Content.Server.GameTicking
{
/// <summary>
/// A round-start setup preset, such as which antagonists to spawn.
@@ -6,6 +6,7 @@ namespace Content.Server.GameTicking
public abstract class GamePreset
{
public abstract void Start();
public virtual string ModeTitle => "Sandbox";
public virtual string Description => "Secret!";
}
}

View File

@@ -1,4 +1,4 @@
using Content.Server.GameTicking.GameRules;
using Content.Server.GameTicking.GameRules;
using Content.Server.Interfaces.GameTicking;
using Robust.Shared.IoC;
@@ -15,6 +15,7 @@ namespace Content.Server.GameTicking.GamePresets
_gameTicker.AddGameRule<RuleDeathMatch>();
}
public override string Description => "Deathmatch, go and kill everybody else to win!";
public override string ModeTitle => "Deathmatch";
public override string Description => "Kill anything that moves!";
}
}

View File

@@ -1,4 +1,4 @@
using Content.Server.Sandbox;
using Content.Server.Sandbox;
using Robust.Shared.IoC;
namespace Content.Server.GameTicking.GamePresets
@@ -14,6 +14,7 @@ namespace Content.Server.GameTicking.GamePresets
_sandboxManager.IsSandboxEnabled = true;
}
public override string Description => "Sandbox, go and build something!";
public override string ModeTitle => "Sandbox";
public override string Description => "No stress, build something!";
}
}

View File

@@ -53,6 +53,7 @@ namespace Content.Server.GameTicking
private const string PlayerPrototypeName = "HumanMob_Content";
private const string ObserverPrototypeName = "MobObserver";
private const string MapFile = "Maps/stationstation.yml";
private static TimeSpan _roundStartTimeSpan;
[ViewVariables] private readonly List<GameRule> _gameRules = new List<GameRule>();
[ViewVariables] private readonly List<ManifestEntry> _manifest = new List<ManifestEntry>();
@@ -110,6 +111,7 @@ namespace Content.Server.GameTicking
_netManager.RegisterNetMessage<MsgTickerJoinGame>(nameof(MsgTickerJoinGame));
_netManager.RegisterNetMessage<MsgTickerLobbyStatus>(nameof(MsgTickerLobbyStatus));
_netManager.RegisterNetMessage<MsgTickerLobbyInfo>(nameof(MsgTickerLobbyInfo));
_netManager.RegisterNetMessage<MsgRoundEndMessage>(nameof(MsgRoundEndMessage));
SetStartPreset(_configurationManager.GetCVar<string>("game.defaultpreset"));
@@ -219,6 +221,7 @@ namespace Content.Server.GameTicking
SpawnPlayer(player, job, false);
}
_roundStartTimeSpan = IoCManager.Resolve<IGameTiming>().RealTime;
_sendStatusToAll();
}
@@ -240,7 +243,33 @@ namespace Content.Server.GameTicking
RunLevel = GameRunLevel.PostRound;
SendServerMessage("The round has ended!");
//Tell every client the round has ended.
var roundEndMessage = _netManager.CreateNetMessage<MsgRoundEndMessage>();
roundEndMessage.GamemodeTitle = MakeGamePreset().ModeTitle;
//Get the timespan of the round.
roundEndMessage.RoundDuration = IoCManager.Resolve<IGameTiming>().RealTime.Subtract(_roundStartTimeSpan);
//Generate a list of basic player info to display in the end round summary.
var listOfPlayerInfo = new List<RoundEndPlayerInfo>();
foreach(var ply in _playerManager.GetAllPlayers().OrderBy(p => p.Name))
{
if(ply.AttachedEntity.TryGetComponent<MindComponent>(out var mindComponent)
&& mindComponent.HasMind)
{
var playerEndRoundInfo = new RoundEndPlayerInfo()
{
PlayerOOCName = ply.Name,
PlayerICName = mindComponent.Mind.CurrentEntity.Name,
Role = mindComponent.Mind.AllRoles.FirstOrDefault()?.Name ?? Loc.GetString("Unkown"),
Antag = false
};
listOfPlayerInfo.Add(playerEndRoundInfo);
}
}
roundEndMessage.AllPlayersEndInfo = listOfPlayerInfo;
_netManager.ServerSendToAll(roundEndMessage);
}
public void Respawn(IPlayerSession targetPlayer)
@@ -654,10 +683,12 @@ namespace Content.Server.GameTicking
private string GetInfoText()
{
var gameMode = MakeGamePreset().Description;
var gmTitle = MakeGamePreset().ModeTitle;
var desc = MakeGamePreset().Description;
return _localization.GetString(@"Hi and welcome to [color=white]Space Station 14![/color]
The current game mode is [color=white]{0}[/color]", gameMode);
The current game mode is: [color=white]{0}[/color].
[color=yellow]{1}[/color]", gmTitle, desc );
}
private void UpdateInfoText()