Antag preferences and antag prototype (#1264)

Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
ike709
2020-07-06 16:24:29 -05:00
committed by GitHub
parent cee8aaa84c
commit c019d428a7
42 changed files with 833 additions and 50 deletions

View File

@@ -267,12 +267,12 @@ namespace Content.Server.GameTicking
}
// Time to start the preset.
var preset = MakeGamePreset();
var preset = MakeGamePreset(profiles);
if (!preset.Start(assignedJobs.Keys.ToList(), force))
{
SetStartPreset(_configurationManager.GetCVar<string>("game.fallbackpreset"));
var newPreset = MakeGamePreset();
var newPreset = MakeGamePreset(profiles);
_chatManager.DispatchServerAnnouncement(
$"Failed to start {preset.ModeTitle} mode! Defaulting to {newPreset.ModeTitle}...");
if (!newPreset.Start(readyPlayers, force))
@@ -306,7 +306,7 @@ namespace Content.Server.GameTicking
//Tell every client the round has ended.
var roundEndMessage = _netManager.CreateNetMessage<MsgRoundEndMessage>();
roundEndMessage.GamemodeTitle = MakeGamePreset().ModeTitle;
roundEndMessage.GamemodeTitle = MakeGamePreset(null).ModeTitle;
//Get the timespan of the round.
roundEndMessage.RoundDuration = IoCManager.Resolve<IGameTiming>().RealTime.Subtract(_roundStartTimeSpan);
@@ -318,13 +318,13 @@ namespace Content.Server.GameTicking
var mind = ply.ContentData().Mind;
if (mind != null)
{
var antag = mind.AllRoles.Any(role => role.Antag);
var antag = mind.AllRoles.Any(role => role.Antagonist);
var playerEndRoundInfo = new RoundEndPlayerInfo()
{
PlayerOOCName = ply.Name,
PlayerICName = mind.CurrentEntity.Name,
Role = antag
? mind.AllRoles.First(role => role.Antag).Name
? mind.AllRoles.First(role => role.Antagonist).Name
: mind.AllRoles.FirstOrDefault()?.Name ?? Loc.GetString("Unknown"),
Antag = antag
};
@@ -805,7 +805,7 @@ namespace Content.Server.GameTicking
var mindComponent = mob.GetComponent<MindComponent>();
if (mindComponent.HasMind) //Redundancy checks.
{
if (mindComponent.Mind.AllRoles.Any(role => role.Antag)) //Give antags a new uplinkaccount.
if (mindComponent.Mind.AllRoles.Any(role => role.Antagonist)) //Give antags a new uplinkaccount.
{
var uplinkAccount =
new UplinkAccount(mob.Uid,
@@ -883,8 +883,8 @@ namespace Content.Server.GameTicking
private string GetInfoText()
{
var gmTitle = MakeGamePreset().ModeTitle;
var desc = MakeGamePreset().Description;
var gmTitle = MakeGamePreset(null).ModeTitle;
var desc = MakeGamePreset(null).Description;
return _localization.GetString(@"Hi and welcome to [color=white]Space Station 14![/color]
The current game mode is: [color=white]{0}[/color].
@@ -898,9 +898,11 @@ The current game mode is: [color=white]{0}[/color].
_netManager.ServerSendToMany(infoMsg, _playersInLobby.Keys.Select(p => p.ConnectedClient).ToList());
}
private GamePreset MakeGamePreset()
private GamePreset MakeGamePreset(Dictionary<string, HumanoidCharacterProfile> readyProfiles)
{
return _dynamicTypeFactory.CreateInstance<GamePreset>(_presetType ?? typeof(PresetSandbox));
var preset = _dynamicTypeFactory.CreateInstance<GamePreset>(_presetType ?? typeof(PresetSandbox));
preset.readyProfiles = readyProfiles;
return preset;
}
#pragma warning disable 649