Moved the uplink creation code to the PresetSuspicion.Start method to ensure uplink created when we give the traitor role (#1974)
Moved the starting TC balance to cvars
This commit is contained in:
@@ -9,9 +9,14 @@ using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.GUI;
|
||||
using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.GameObjects.Components.PDA;
|
||||
using Content.Server.GameObjects.Components.Suspicion;
|
||||
using Content.Server.Mobs.Roles;
|
||||
using Content.Server.Mobs.Roles.Suspicion;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
using Content.Shared.GameObjects.Components.PDA;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.Configuration;
|
||||
@@ -32,6 +37,9 @@ namespace Content.Server.GameTicking.GamePresets
|
||||
public int MinTraitors { get; set; }
|
||||
public int PlayersPerTraitor { get; set; }
|
||||
|
||||
public int TraitorStartingBalance { get; set; }
|
||||
|
||||
|
||||
public override bool DisallowLateJoin => true;
|
||||
|
||||
private static string TraitorID = "SuspicionTraitor";
|
||||
@@ -42,6 +50,7 @@ namespace Content.Server.GameTicking.GamePresets
|
||||
cfg.RegisterCVar("game.suspicion_min_players", 5);
|
||||
cfg.RegisterCVar("game.suspicion_min_traitors", 2);
|
||||
cfg.RegisterCVar("game.suspicion_players_per_traitor", 5);
|
||||
cfg.RegisterCVar("game.suspicion_starting_balance", 20);
|
||||
}
|
||||
|
||||
public override bool Start(IReadOnlyList<IPlayerSession> readyPlayers, bool force = false)
|
||||
@@ -49,6 +58,7 @@ namespace Content.Server.GameTicking.GamePresets
|
||||
MinPlayers = _cfg.GetCVar<int>("game.suspicion_min_players");
|
||||
MinTraitors = _cfg.GetCVar<int>("game.suspicion_min_traitors");
|
||||
PlayersPerTraitor = _cfg.GetCVar<int>("game.suspicion_players_per_traitor");
|
||||
TraitorStartingBalance = _cfg.GetCVar<int>("game.suspicion_starting_balance");
|
||||
|
||||
if (!force && readyPlayers.Count < MinPlayers)
|
||||
{
|
||||
@@ -109,6 +119,28 @@ namespace Content.Server.GameTicking.GamePresets
|
||||
var traitorRole = new SuspicionTraitorRole(mind, antagPrototype);
|
||||
mind.AddRole(traitorRole);
|
||||
traitors.Add(traitorRole);
|
||||
// creadth: we need to create uplink for the antag.
|
||||
// PDA should be in place already, so we just need to
|
||||
// initiate uplink account.
|
||||
var uplinkAccount =
|
||||
new UplinkAccount(mind.OwnedEntity.Uid,
|
||||
TraitorStartingBalance);
|
||||
var inventory = mind.OwnedEntity.GetComponent<InventoryComponent>();
|
||||
if (!inventory.TryGetSlotItem(EquipmentSlotDefines.Slots.IDCARD, out ItemComponent pdaItem))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var pda = pdaItem.Owner;
|
||||
|
||||
var pdaComponent = pda.GetComponent<PDAComponent>();
|
||||
if (pdaComponent.IdSlotEmpty)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
pdaComponent.InitUplinkAccount(uplinkAccount);
|
||||
|
||||
}
|
||||
|
||||
foreach (var player in list)
|
||||
@@ -127,6 +159,7 @@ 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?";
|
||||
}
|
||||
|
||||
@@ -861,17 +861,6 @@ namespace Content.Server.GameTicking
|
||||
var accessTags = access.Tags;
|
||||
accessTags.UnionWith(jobPrototype.Access);
|
||||
pdaComponent.SetPDAOwner(characterName);
|
||||
var mindComponent = mob.GetComponent<MindComponent>();
|
||||
if (mindComponent.HasMind) //Redundancy checks.
|
||||
{
|
||||
if (mindComponent.Mind.AllRoles.Any(role => role.Antagonist)) //Give antags a new uplinkaccount.
|
||||
{
|
||||
var uplinkAccount =
|
||||
new UplinkAccount(mob.Uid,
|
||||
20); //TODO: make me into a variable based on server pop or something.
|
||||
pdaComponent.InitUplinkAccount(uplinkAccount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddManifestEntry(string characterName, string jobId)
|
||||
|
||||
Reference in New Issue
Block a user