Moving PDA to ECS (#4538)
* Moved pen slot to separate component * Moved it all to more generic item slot class * Add sounds * Item slots now supports many slots * Some clean-up * Refactored slots a bit * Moving ID card out * Moving pda to system * Moving PDA owner to ECS * Moved PDA flashlight to separate component * Toggle lights work through events * Fixing UI * Moving uplink to separate component * Continue moving uplink to separate component * More cleaning * Removing pda shared * Nuked shared pda component * Fixed flashlight * Pen slot now showed in UI * Light toggle now shows correctly in UI * Small refactoring of item slots * Added contained entity * Fixed tests * Finished with PDA * Moving PDA uplink to separate window * Adding-removing uplink should show new button * Working on a better debug * Debug command to add uplink * Uplink send state to UI * Almost working UI * Uplink correcty updates when you buy-sell items * Ups * Moved localization to separate file * Minor fixes * Removed item slots methods events * Removed PDA owner name * Removed one uplink event * Deleted all uplink events * Removed flashlight events * Update Content.Shared/Traitor/Uplink/UplinkVisuals.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/Containers/ItemSlot/ItemSlotsSystem.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/Containers/ItemSlot/ItemSlotsSystem.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/GameTicking/Presets/PresetTraitorDeathMatch.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Item slots system review * Flashlight review * PDA to XAML * Move UplinkMenu to seperate class, fix WeightedColors methods * Move UI to XAML * Moved events to entity id * Address review * Removed uplink extensions * Minor fix * Moved item slots to shared * My bad Robust... * Fixed pda sound * Fixed pda tests * Fixed pda test again Co-authored-by: Alexander Evgrashin <evgrashin.adl@gmail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Visne <vincefvanwijk@gmail.com>
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.GameTicking.Rules;
|
||||
using Content.Server.Inventory.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Server.PDA;
|
||||
using Content.Server.PDA.Managers;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Suspicion;
|
||||
using Content.Server.Suspicion.Roles;
|
||||
using Content.Shared;
|
||||
using Content.Server.Traitor.Uplink;
|
||||
using Content.Server.Traitor.Uplink.Components;
|
||||
using Content.Server.Traitor.Uplink.Systems;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.PDA;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Traitor.Uplink;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -31,6 +33,8 @@ namespace Content.Server.GameTicking.Presets
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] protected readonly IEntityManager EntityManager = default!;
|
||||
[Dependency] private readonly IUplinkManager _uplinkManager = default!;
|
||||
|
||||
public int MinPlayers { get; set; }
|
||||
public int MinTraitors { get; set; }
|
||||
@@ -109,28 +113,17 @@ namespace Content.Server.GameTicking.Presets
|
||||
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))
|
||||
{
|
||||
var uplinkAccount = new UplinkAccount(mind.OwnedEntity!.Uid, TraitorStartingBalance);
|
||||
_uplinkManager.AddNewAccount(uplinkAccount);
|
||||
|
||||
// try to place uplink
|
||||
if (!EntityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
|
||||
.AddUplink(mind.OwnedEntity, uplinkAccount))
|
||||
continue;
|
||||
}
|
||||
|
||||
var pda = pdaItem.Owner;
|
||||
|
||||
var pdaComponent = pda.GetComponent<PDAComponent>();
|
||||
if (pdaComponent.IdSlotEmpty)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
pdaComponent.InitUplinkAccount(uplinkAccount);
|
||||
|
||||
}
|
||||
|
||||
foreach (var player in list)
|
||||
|
||||
@@ -7,13 +7,16 @@ using Content.Server.Inventory.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Content.Server.PDA;
|
||||
using Content.Server.PDA.Managers;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Traitor;
|
||||
using Content.Shared;
|
||||
using Content.Server.Traitor.Uplink;
|
||||
using Content.Server.Traitor.Uplink.Components;
|
||||
using Content.Server.Traitor.Uplink.Systems;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Dataset;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.PDA;
|
||||
using Content.Shared.Traitor.Uplink;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -34,6 +37,8 @@ namespace Content.Server.GameTicking.Presets
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] protected readonly IEntityManager EntityManager = default!;
|
||||
[Dependency] private readonly IUplinkManager _uplinkManager = default!;
|
||||
|
||||
public override string ModeTitle => Loc.GetString("traitor-title");
|
||||
|
||||
@@ -120,27 +125,15 @@ namespace Content.Server.GameTicking.Presets
|
||||
DebugTools.AssertNotNull(mind.OwnedEntity);
|
||||
|
||||
var uplinkAccount = new UplinkAccount(mind.OwnedEntity!.Uid, StartingBalance);
|
||||
var inventory = mind.OwnedEntity.GetComponent<InventoryComponent>();
|
||||
if (!inventory.TryGetSlotItem(EquipmentSlotDefines.Slots.IDCARD, out ItemComponent? pdaItem))
|
||||
{
|
||||
Logger.ErrorS("preset", "Failed getting pda for picked traitor.");
|
||||
continue;
|
||||
}
|
||||
_uplinkManager.AddNewAccount(uplinkAccount);
|
||||
|
||||
var pda = pdaItem.Owner;
|
||||
|
||||
var pdaComponent = pda.GetComponent<PDAComponent>();
|
||||
if (pdaComponent.IdSlotEmpty)
|
||||
{
|
||||
Logger.ErrorS("preset","PDA had no id for picked traitor");
|
||||
if (!EntityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
|
||||
.AddUplink(mind.OwnedEntity, uplinkAccount))
|
||||
continue;
|
||||
}
|
||||
|
||||
var traitorRole = new TraitorRole(mind);
|
||||
|
||||
mind.AddRole(traitorRole);
|
||||
_traitors.Add(traitorRole);
|
||||
pdaComponent.InitUplinkAccount(uplinkAccount);
|
||||
}
|
||||
|
||||
var adjectives = _prototypeManager.Index<DatasetPrototype>("adjectives").Values;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.GameTicking.Rules;
|
||||
@@ -17,7 +16,6 @@ using Content.Shared.CCVar;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.MobState;
|
||||
using Content.Shared.PDA;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -27,6 +25,11 @@ using Robust.Shared.Localization;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Random;
|
||||
using Content.Server.Traitor.Uplink.Components;
|
||||
using Content.Shared.Traitor.Uplink;
|
||||
using Content.Server.PDA.Managers;
|
||||
using Content.Server.Traitor.Uplink;
|
||||
using Content.Server.Traitor.Uplink.Systems;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
|
||||
namespace Content.Server.GameTicking.Presets
|
||||
@@ -40,6 +43,7 @@ namespace Content.Server.GameTicking.Presets
|
||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IUplinkManager _uplinkManager = default!;
|
||||
|
||||
public string PDAPrototypeName => "CaptainPDA";
|
||||
public string BeltPrototypeName => "ClothingBeltJanitorFilled";
|
||||
@@ -103,12 +107,16 @@ namespace Content.Server.GameTicking.Presets
|
||||
|
||||
// Like normal traitors, they need access to a traitor account.
|
||||
var uplinkAccount = new UplinkAccount(mind.OwnedEntity.Uid, startingBalance);
|
||||
var pdaComponent = newPDA.GetComponent<PDAComponent>();
|
||||
pdaComponent.InitUplinkAccount(uplinkAccount);
|
||||
_uplinkManager.AddNewAccount(uplinkAccount);
|
||||
_entityManager.EntitySysManager.GetEntitySystem<UplinkSystem>()
|
||||
.AddUplink(mind.OwnedEntity, uplinkAccount, newPDA);
|
||||
|
||||
_allOriginalNames[uplinkAccount] = mind.OwnedEntity.Name;
|
||||
|
||||
// The PDA needs to be marked with the correct owner.
|
||||
pdaComponent.SetPDAOwner(mind.OwnedEntity.Name);
|
||||
var pda = newPDA.GetComponent<PDAComponent>();
|
||||
_entityManager.EntitySysManager.GetEntitySystem<PDASystem>()
|
||||
.SetOwner(pda, mind.OwnedEntity.Name);
|
||||
newPDA.AddComponent<TraitorDeathMatchReliableOwnerTagComponent>().UserId = mind.UserId;
|
||||
}
|
||||
|
||||
@@ -217,14 +225,14 @@ namespace Content.Server.GameTicking.Presets
|
||||
{
|
||||
var lines = new List<string>();
|
||||
lines.Add("traitor-death-match-end-round-description-first-line");
|
||||
foreach (var pda in _entityManager.EntityQuery<PDAComponent>())
|
||||
foreach (var uplink in _entityManager.EntityQuery<UplinkComponent>(true))
|
||||
{
|
||||
var uplink = pda.SyndicateUplinkAccount;
|
||||
if (uplink != null && _allOriginalNames.ContainsKey(uplink))
|
||||
var uplinkAcc = uplink.UplinkAccount;
|
||||
if (uplinkAcc != null && _allOriginalNames.ContainsKey(uplinkAcc))
|
||||
{
|
||||
lines.Add(Loc.GetString("traitor-death-match-end-round-description-entry",
|
||||
("originalName", _allOriginalNames[uplink]),
|
||||
("tcBalance", uplink.Balance)));
|
||||
("originalName", _allOriginalNames[uplinkAcc]),
|
||||
("tcBalance", uplinkAcc.Balance)));
|
||||
}
|
||||
}
|
||||
return string.Join('\n', lines);
|
||||
|
||||
Reference in New Issue
Block a user