Generalized Store System (#10201)

This commit is contained in:
Nemanja
2022-08-17 00:34:25 -04:00
committed by GitHub
parent 1b50928d50
commit 2152914acc
68 changed files with 2493 additions and 1568 deletions

View File

@@ -20,6 +20,8 @@ using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Content.Server.Traitor;
using System.Data;
using Content.Server.Traitor.Uplink;
using Robust.Shared.Audio;
using Robust.Shared.Player;
@@ -35,6 +37,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly StationSpawningSystem _stationSpawningSystem = default!;
[Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
[Dependency] private readonly UplinkSystem _uplink = default!;
private Dictionary<Mind.Mind, bool> _aliveNukeops = new();
private bool _opsWon;

View File

@@ -8,7 +8,6 @@ using Content.Server.Station.Components;
using Content.Server.Suspicion;
using Content.Server.Suspicion.Roles;
using Content.Server.Traitor.Uplink;
using Content.Server.Traitor.Uplink.Account;
using Content.Shared.CCVar;
using Content.Shared.Doors.Systems;
using Content.Shared.EntityList;
@@ -17,7 +16,6 @@ using Content.Shared.Maps;
using Content.Shared.MobState.Components;
using Content.Shared.Roles;
using Content.Shared.Suspicion;
using Content.Shared.Traitor.Uplink;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Audio;
@@ -48,6 +46,7 @@ public sealed class SuspicionRuleSystem : GameRuleSystem
[Dependency] private readonly ITileDefinitionManager _tileDefMan = default!;
[Dependency] private readonly SharedDoorSystem _doorSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookupSystem = default!;
[Dependency] private readonly UplinkSystem _uplink = default!;
public override string Prototype => "Suspicion";
@@ -173,16 +172,8 @@ public sealed class SuspicionRuleSystem : GameRuleSystem
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(traitorStartingBalance, mind.OwnedEntity!);
var accounts = EntityManager.EntitySysManager.GetEntitySystem<UplinkAccountsSystem>();
accounts.AddNewAccount(uplinkAccount);
// try to place uplink
if (!EntityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
.AddUplink(mind.OwnedEntity!.Value, uplinkAccount))
if (!_uplink.AddUplink(mind.OwnedEntity!.Value, traitorStartingBalance))
continue;
}

View File

@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Rules.Configurations;
@@ -6,19 +6,18 @@ using Content.Server.Hands.Components;
using Content.Server.PDA;
using Content.Server.Players;
using Content.Server.Spawners.Components;
using Content.Server.Store.Components;
using Content.Server.Traitor;
using Content.Server.Traitor.Uplink;
using Content.Server.Traitor.Uplink.Account;
using Content.Server.Traitor.Uplink.Components;
using Content.Server.TraitorDeathMatch.Components;
using Content.Shared.CCVar;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Content.Shared.Inventory;
using Content.Shared.MobState.Components;
using Content.Shared.PDA;
using Content.Shared.Roles;
using Content.Shared.Traitor.Uplink;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Configuration;
@@ -39,6 +38,7 @@ public sealed class TraitorDeathMatchRuleSystem : GameRuleSystem
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
[Dependency] private readonly UplinkSystem _uplink = default!;
public override string Prototype => "TraitorDeathMatch";
@@ -48,7 +48,7 @@ public sealed class TraitorDeathMatchRuleSystem : GameRuleSystem
private bool _safeToEndRound = false;
private readonly Dictionary<UplinkAccount, string> _allOriginalNames = new();
private readonly Dictionary<EntityUid, string> _allOriginalNames = new();
private const string TraitorPrototypeID = "Traitor";
@@ -108,15 +108,10 @@ public sealed class TraitorDeathMatchRuleSystem : GameRuleSystem
newTmp = Spawn(BackpackPrototypeName, ownedCoords);
_inventory.TryEquip(owned, newTmp, "back", true);
// Like normal traitors, they need access to a traitor account.
var uplinkAccount = new UplinkAccount(startingBalance, owned);
var accounts = EntityManager.EntitySysManager.GetEntitySystem<UplinkAccountsSystem>();
accounts.AddNewAccount(uplinkAccount);
if (!_uplink.AddUplink(owned, startingBalance))
return;
EntityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
.AddUplink(owned, uplinkAccount, newPDA);
_allOriginalNames[uplinkAccount] = Name(owned);
_allOriginalNames[owned] = Name(owned);
// The PDA needs to be marked with the correct owner.
var pda = Comp<PDAComponent>(newPDA);
@@ -186,14 +181,17 @@ public sealed class TraitorDeathMatchRuleSystem : GameRuleSystem
var lines = new List<string>();
lines.Add(Loc.GetString("traitor-death-match-end-round-description-first-line"));
foreach (var uplink in EntityManager.EntityQuery<UplinkComponent>(true))
foreach (var uplink in EntityManager.EntityQuery<StoreComponent>(true))
{
var uplinkAcc = uplink.UplinkAccount;
if (uplinkAcc != null && _allOriginalNames.ContainsKey(uplinkAcc))
var owner = uplink.AccountOwner;
if (owner != null && _allOriginalNames.ContainsKey(owner.Value))
{
var tcbalance = _uplink.GetTCBalance(uplink);
lines.Add(Loc.GetString("traitor-death-match-end-round-description-entry",
("originalName", _allOriginalNames[uplinkAcc]),
("tcBalance", uplinkAcc.Balance)));
("originalName", _allOriginalNames[owner.Value]),
("tcBalance", tcbalance)));
}
}

View File

@@ -3,13 +3,14 @@ using Content.Server.Chat.Managers;
using Content.Server.Objectives.Interfaces;
using Content.Server.Players;
using Content.Server.Roles;
using Content.Server.Store.Systems;
using Content.Server.Traitor;
using Content.Server.Traitor.Uplink;
using Content.Server.Traitor.Uplink.Account;
using Content.Shared.CCVar;
using Content.Shared.Dataset;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Inventory;
using Content.Shared.Roles;
using Content.Shared.Traitor.Uplink;
using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.Configuration;
@@ -28,6 +29,10 @@ public sealed class TraitorRuleSystem : GameRuleSystem
[Dependency] private readonly IObjectivesManager _objectivesManager = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly StoreSystem _store = default!;
[Dependency] private readonly UplinkSystem _uplink = default!;
public override string Prototype => "Traitor";
@@ -35,6 +40,7 @@ public sealed class TraitorRuleSystem : GameRuleSystem
public List<TraitorRole> Traitors = new();
private const string TraitorPrototypeID = "Traitor";
private const string TraitorUplinkPresetId = "StorePresetUplink";
public int TotalTraitors => Traitors.Count;
public string[] Codewords = new string[3];
@@ -173,16 +179,12 @@ public sealed class TraitorRuleSystem : GameRuleSystem
}
// creadth: we need to create uplink for the antag.
// PDA should be in place already, so we just need to
// initiate uplink account.
// PDA should be in place already
DebugTools.AssertNotNull(mind.OwnedEntity);
var startingBalance = _cfg.GetCVar(CCVars.TraitorStartingBalance);
var uplinkAccount = new UplinkAccount(startingBalance, mind.OwnedEntity!);
var accounts = EntityManager.EntitySysManager.GetEntitySystem<UplinkAccountsSystem>();
accounts.AddNewAccount(uplinkAccount);
if (!EntityManager.EntitySysManager.GetEntitySystem<UplinkSystem>().AddUplink(mind.OwnedEntity!.Value, uplinkAccount))
if (!_uplink.AddUplink(mind.OwnedEntity!.Value, startingBalance))
return false;
var antagPrototype = _prototypeManager.Index<AntagPrototype>(TraitorPrototypeID);