Mind ecs (#14412)
This commit is contained in:
@@ -6,6 +6,8 @@ using Content.Server.GameTicking.Rules.Configurations;
|
||||
using Content.Server.Ghost.Roles.Components;
|
||||
using Content.Server.Ghost.Roles.Events;
|
||||
using Content.Server.Humanoid;
|
||||
using Content.Server.Humanoid.Systems;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.NPC.Systems;
|
||||
using Content.Server.Nuke;
|
||||
@@ -53,7 +55,8 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
||||
[Dependency] private readonly GameTicker _ticker = default!;
|
||||
[Dependency] private readonly MapLoaderSystem _map = default!;
|
||||
[Dependency] private readonly ShuttleSystem _shuttle = default!;
|
||||
|
||||
[Dependency] private readonly RandomHumanoidSystem _randomHumanoid = default!;
|
||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
||||
|
||||
private enum WinType
|
||||
{
|
||||
@@ -168,10 +171,10 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
||||
private void OnComponentInit(EntityUid uid, NukeOperativeComponent component, ComponentInit args)
|
||||
{
|
||||
// If entity has a prior mind attached, add them to the players list.
|
||||
if (!TryComp<MindComponent>(uid, out var mindComponent) || !RuleAdded)
|
||||
if (!TryComp<MindContainerComponent>(uid, out var mindContainerComponent) || !RuleAdded)
|
||||
return;
|
||||
|
||||
var session = mindComponent.Mind?.Session;
|
||||
var session = mindContainerComponent.Mind?.Session;
|
||||
var name = MetaData(uid).EntityName;
|
||||
if (session != null)
|
||||
_operativePlayers.Add(name, session);
|
||||
@@ -573,18 +576,18 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
||||
|
||||
private void OnMindAdded(EntityUid uid, NukeOperativeComponent component, MindAddedMessage args)
|
||||
{
|
||||
if (!TryComp<MindComponent>(uid, out var mindComponent) || mindComponent.Mind == null)
|
||||
if (!TryComp<MindContainerComponent>(uid, out var mindContainerComponent) || mindContainerComponent.Mind == null)
|
||||
return;
|
||||
|
||||
var mind = mindComponent.Mind;
|
||||
var mind = mindContainerComponent.Mind;
|
||||
|
||||
if (_operativeMindPendingData.TryGetValue(uid, out var role))
|
||||
{
|
||||
mind.AddRole(new TraitorRole(mind, _prototypeManager.Index<AntagPrototype>(role)));
|
||||
_mindSystem.AddRole(mind, new TraitorRole(mind, _prototypeManager.Index<AntagPrototype>(role)));
|
||||
_operativeMindPendingData.Remove(uid);
|
||||
}
|
||||
|
||||
if (!mind.TryGetSession(out var playerSession))
|
||||
if (!_mindSystem.TryGetSession(mind, out var playerSession))
|
||||
return;
|
||||
if (_operativePlayers.ContainsValue(playerSession))
|
||||
return;
|
||||
@@ -758,14 +761,11 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
||||
var mob = EntityManager.SpawnEntity(species.Prototype, _random.Pick(spawns));
|
||||
SetupOperativeEntity(mob, spawnDetails.Name, spawnDetails.Gear, profile);
|
||||
|
||||
var newMind = new Mind.Mind(session.UserId)
|
||||
{
|
||||
CharacterName = spawnDetails.Name
|
||||
};
|
||||
newMind.ChangeOwningPlayer(session.UserId);
|
||||
newMind.AddRole(new TraitorRole(newMind, nukeOpsAntag));
|
||||
var newMind = _mindSystem.CreateMind(session.UserId, spawnDetails.Name);
|
||||
_mindSystem.ChangeOwningPlayer(newMind, session.UserId);
|
||||
_mindSystem.AddRole(newMind, new TraitorRole(newMind, nukeOpsAntag));
|
||||
|
||||
newMind.TransferTo(mob);
|
||||
_mindSystem.TransferTo(newMind, mob);
|
||||
}
|
||||
else if (addSpawnPoints)
|
||||
{
|
||||
@@ -801,7 +801,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
||||
if (!mind.OwnedEntity.HasValue)
|
||||
return;
|
||||
|
||||
mind.AddRole(new TraitorRole(mind, _prototypeManager.Index<AntagPrototype>(_nukeopsRuleConfig.OperativeRoleProto)));
|
||||
_mindSystem.AddRole(mind, new TraitorRole(mind, _prototypeManager.Index<AntagPrototype>(_nukeopsRuleConfig.OperativeRoleProto)));
|
||||
SetOutfitCommand.SetOutfit(mind.OwnedEntity.Value, "SyndicateOperativeGearFull", EntityManager);
|
||||
}
|
||||
|
||||
@@ -862,10 +862,10 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
||||
}
|
||||
|
||||
// Add pre-existing nuke operatives to the credit list.
|
||||
var query = EntityQuery<NukeOperativeComponent, MindComponent>(true);
|
||||
var query = EntityQuery<NukeOperativeComponent, MindContainerComponent>(true);
|
||||
foreach (var (_, mindComp) in query)
|
||||
{
|
||||
if (mindComp.Mind == null || !mindComp.Mind.TryGetSession(out var session))
|
||||
if (!mindComp.HasMind || !_mindSystem.TryGetSession(mindComp.Mind, out var session))
|
||||
continue;
|
||||
var name = MetaData(mindComp.Owner).EntityName;
|
||||
_operativePlayers.Add(name, session);
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
using Content.Server.Administration.Commands;
|
||||
using Content.Server.Cargo.Systems;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Preferences.Managers;
|
||||
using Content.Server.Spawners.Components;
|
||||
using Content.Server.Station.Components;
|
||||
@@ -38,6 +39,7 @@ public sealed class PiratesRuleSystem : GameRuleSystem
|
||||
[Dependency] private readonly PricingSystem _pricingSystem = default!;
|
||||
[Dependency] private readonly MapLoaderSystem _map = default!;
|
||||
[Dependency] private readonly NamingSystem _namingSystem = default!;
|
||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
||||
|
||||
[ViewVariables]
|
||||
private List<Mind.Mind> _pirates = new();
|
||||
@@ -206,16 +208,13 @@ public sealed class PiratesRuleSystem : GameRuleSystem
|
||||
var name = _namingSystem.GetName("Human", gender);
|
||||
|
||||
var session = ops[i];
|
||||
var newMind = new Mind.Mind(session.UserId)
|
||||
{
|
||||
CharacterName = name
|
||||
};
|
||||
newMind.ChangeOwningPlayer(session.UserId);
|
||||
var newMind = _mindSystem.CreateMind(session.UserId, name);
|
||||
_mindSystem.ChangeOwningPlayer(newMind, session.UserId);
|
||||
|
||||
var mob = Spawn("MobHuman", _random.Pick(spawns));
|
||||
MetaData(mob).EntityName = name;
|
||||
|
||||
newMind.TransferTo(mob);
|
||||
_mindSystem.TransferTo(newMind, mob);
|
||||
var profile = _prefs.GetPreferences(session.UserId).SelectedCharacter as HumanoidCharacterProfile;
|
||||
_stationSpawningSystem.EquipStartingGear(mob, pirateGear, profile);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.GameTicking.Rules.Configurations;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Roles;
|
||||
using Content.Server.Station.Components;
|
||||
@@ -50,6 +51,7 @@ public sealed class SuspicionRuleSystem : GameRuleSystem
|
||||
[Dependency] private readonly SharedDoorSystem _doorSystem = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookupSystem = default!;
|
||||
[Dependency] private readonly UplinkSystem _uplink = default!;
|
||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
||||
|
||||
public override string Prototype => "Suspicion";
|
||||
|
||||
@@ -171,11 +173,11 @@ public sealed class SuspicionRuleSystem : GameRuleSystem
|
||||
DebugTools.AssertNotNull(mind?.OwnedEntity);
|
||||
|
||||
var traitorRole = new SuspicionTraitorRole(mind!, antagPrototype);
|
||||
mind!.AddRole(traitorRole);
|
||||
_mindSystem.AddRole(mind!, traitorRole);
|
||||
traitors.Add(traitorRole);
|
||||
|
||||
// try to place uplink
|
||||
_uplink.AddUplink(mind.OwnedEntity!.Value, traitorStartingBalance);
|
||||
_uplink.AddUplink(mind!.OwnedEntity!.Value, traitorStartingBalance);
|
||||
}
|
||||
|
||||
foreach (var player in list)
|
||||
@@ -185,7 +187,7 @@ public sealed class SuspicionRuleSystem : GameRuleSystem
|
||||
|
||||
DebugTools.AssertNotNull(mind);
|
||||
|
||||
mind!.AddRole(new SuspicionInnocentRole(mind, antagPrototype));
|
||||
_mindSystem.AddRole(mind!, new SuspicionInnocentRole(mind!, antagPrototype));
|
||||
}
|
||||
|
||||
foreach (var traitor in traitors)
|
||||
@@ -204,8 +206,11 @@ public sealed class SuspicionRuleSystem : GameRuleSystem
|
||||
|
||||
_chatManager.DispatchServerAnnouncement(Loc.GetString("rule-suspicion-added-announcement"));
|
||||
|
||||
var filter = Filter.Empty()
|
||||
.AddWhere(session => ((IPlayerSession) session).ContentData()?.Mind?.HasRole<SuspicionTraitorRole>() ?? false);
|
||||
var filter = Filter.Empty().AddWhere(session =>
|
||||
{
|
||||
var mind = ((IPlayerSession) session).ContentData()?.Mind;
|
||||
return mind != null && _mindSystem.HasRole<SuspicionTraitorRole>(mind);
|
||||
});
|
||||
|
||||
SoundSystem.Play(_addedSound.GetSound(), filter, AudioParams.Default);
|
||||
|
||||
@@ -301,7 +306,7 @@ public sealed class SuspicionRuleSystem : GameRuleSystem
|
||||
|
||||
var mind = playerSession.ContentData()?.Mind;
|
||||
|
||||
if (mind != null && mind.HasRole<SuspicionTraitorRole>())
|
||||
if (mind != null && _mindSystem.HasRole<SuspicionTraitorRole>(mind))
|
||||
traitorsAlive++;
|
||||
else
|
||||
innocentsAlive++;
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.GameTicking.Rules.Configurations;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.PDA;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Spawners.Components;
|
||||
@@ -41,6 +42,7 @@ public sealed class TraitorDeathMatchRuleSystem : GameRuleSystem
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
||||
[Dependency] private readonly UplinkSystem _uplink = default!;
|
||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
||||
|
||||
public override string Prototype => "TraitorDeathMatch";
|
||||
|
||||
@@ -81,7 +83,7 @@ public sealed class TraitorDeathMatchRuleSystem : GameRuleSystem
|
||||
|
||||
var antagPrototype = _prototypeManager.Index<AntagPrototype>(TraitorPrototypeID);
|
||||
var traitorRole = new TraitorRole(mind, antagPrototype);
|
||||
mind.AddRole(traitorRole);
|
||||
_mindSystem.AddRole(mind, traitorRole);
|
||||
|
||||
// Delete anything that may contain "dangerous" role-specific items.
|
||||
// (This includes the PDA, as everybody gets the captain PDA in this mode for true-all-access reasons.)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Objectives.Interfaces;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Roles;
|
||||
@@ -36,6 +37,7 @@ public sealed class TraitorRuleSystem : GameRuleSystem
|
||||
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
|
||||
[Dependency] private readonly UplinkSystem _uplink = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
|
||||
@@ -254,7 +256,7 @@ public sealed class TraitorRuleSystem : GameRuleSystem
|
||||
|
||||
var antagPrototype = _prototypeManager.Index<AntagPrototype>(TraitorPrototypeID);
|
||||
var traitorRole = new TraitorRole(mind, antagPrototype);
|
||||
mind.AddRole(traitorRole);
|
||||
_mindSystem.AddRole(mind, traitorRole);
|
||||
Traitors.Add(traitorRole);
|
||||
traitorRole.GreetTraitor(Codewords);
|
||||
|
||||
@@ -270,7 +272,7 @@ public sealed class TraitorRuleSystem : GameRuleSystem
|
||||
{
|
||||
var objective = _objectivesManager.GetRandomObjective(traitorRole.Mind, "TraitorObjectiveGroups");
|
||||
if (objective == null) continue;
|
||||
if (traitorRole.Mind.TryAddObjective(objective))
|
||||
if (_mindSystem.TryAddObjective(traitorRole.Mind, objective))
|
||||
difficulty += objective.Difficulty;
|
||||
}
|
||||
|
||||
@@ -342,7 +344,7 @@ public sealed class TraitorRuleSystem : GameRuleSystem
|
||||
foreach (var traitor in Traitors)
|
||||
{
|
||||
var name = traitor.Mind.CharacterName;
|
||||
traitor.Mind.TryGetSession(out var session);
|
||||
_mindSystem.TryGetSession(traitor.Mind, out var session);
|
||||
var username = session?.Name;
|
||||
|
||||
var objectives = traitor.Mind.AllObjectives.ToArray();
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Server.Chat.Managers;
|
||||
using Content.Server.Disease;
|
||||
using Content.Server.Disease.Components;
|
||||
using Content.Server.Humanoid;
|
||||
using Content.Server.Mind;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Popups;
|
||||
@@ -43,6 +44,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem
|
||||
[Dependency] private readonly ActionsSystem _action = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
[Dependency] private readonly ZombifyOnDeathSystem _zombify = default!;
|
||||
[Dependency] private readonly MindSystem _mindSystem = default!;
|
||||
|
||||
private Dictionary<string, string> _initialInfectedNames = new();
|
||||
|
||||
@@ -102,7 +104,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem
|
||||
{
|
||||
var meta = MetaData(survivor);
|
||||
var username = string.Empty;
|
||||
if (TryComp<MindComponent>(survivor, out var mindcomp))
|
||||
if (TryComp<MindContainerComponent>(survivor, out var mindcomp))
|
||||
if (mindcomp.Mind != null && mindcomp.Mind.Session != null)
|
||||
username = mindcomp.Mind.Session.Name;
|
||||
|
||||
@@ -284,7 +286,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem
|
||||
|
||||
DebugTools.AssertNotNull(mind.OwnedEntity);
|
||||
|
||||
mind.AddRole(new TraitorRole(mind, _prototypeManager.Index<AntagPrototype>(PatientZeroPrototypeID)));
|
||||
_mindSystem.AddRole(mind, new TraitorRole(mind, _prototypeManager.Index<AntagPrototype>(PatientZeroPrototypeID)));
|
||||
|
||||
var inCharacterName = string.Empty;
|
||||
if (mind.OwnedEntity != null)
|
||||
|
||||
Reference in New Issue
Block a user