Revert "Mind ecs" (#14881)

This commit is contained in:
Leon Friedrich
2023-03-27 10:24:00 +13:00
committed by GitHub
parent c6c8fa2075
commit 4d71b1b81e
85 changed files with 684 additions and 1150 deletions

View File

@@ -6,8 +6,6 @@ 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;
@@ -55,8 +53,7 @@ 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
{
@@ -171,10 +168,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<MindContainerComponent>(uid, out var mindContainerComponent) || !RuleAdded)
if (!TryComp<MindComponent>(uid, out var mindComponent) || !RuleAdded)
return;
var session = mindContainerComponent.Mind?.Session;
var session = mindComponent.Mind?.Session;
var name = MetaData(uid).EntityName;
if (session != null)
_operativePlayers.Add(name, session);
@@ -576,18 +573,18 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
private void OnMindAdded(EntityUid uid, NukeOperativeComponent component, MindAddedMessage args)
{
if (!TryComp<MindContainerComponent>(uid, out var mindContainerComponent) || mindContainerComponent.Mind == null)
if (!TryComp<MindComponent>(uid, out var mindComponent) || mindComponent.Mind == null)
return;
var mind = mindContainerComponent.Mind;
var mind = mindComponent.Mind;
if (_operativeMindPendingData.TryGetValue(uid, out var role))
{
_mindSystem.AddRole(mind, new TraitorRole(mind, _prototypeManager.Index<AntagPrototype>(role)));
mind.AddRole(new TraitorRole(mind, _prototypeManager.Index<AntagPrototype>(role)));
_operativeMindPendingData.Remove(uid);
}
if (!_mindSystem.TryGetSession(mind, out var playerSession))
if (!mind.TryGetSession(out var playerSession))
return;
if (_operativePlayers.ContainsValue(playerSession))
return;
@@ -761,11 +758,14 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
var mob = EntityManager.SpawnEntity(species.Prototype, _random.Pick(spawns));
SetupOperativeEntity(mob, spawnDetails.Name, spawnDetails.Gear, profile);
var newMind = _mindSystem.CreateMind(session.UserId, spawnDetails.Name);
_mindSystem.ChangeOwningPlayer(newMind, session.UserId);
_mindSystem.AddRole(newMind, new TraitorRole(newMind, nukeOpsAntag));
var newMind = new Mind.Mind(session.UserId)
{
CharacterName = spawnDetails.Name
};
newMind.ChangeOwningPlayer(session.UserId);
newMind.AddRole(new TraitorRole(newMind, nukeOpsAntag));
_mindSystem.TransferTo(newMind, mob);
newMind.TransferTo(mob);
}
else if (addSpawnPoints)
{
@@ -801,7 +801,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
if (!mind.OwnedEntity.HasValue)
return;
_mindSystem.AddRole(mind, new TraitorRole(mind, _prototypeManager.Index<AntagPrototype>(_nukeopsRuleConfig.OperativeRoleProto)));
mind.AddRole(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, MindContainerComponent>(true);
var query = EntityQuery<NukeOperativeComponent, MindComponent>(true);
foreach (var (_, mindComp) in query)
{
if (!mindComp.HasMind || !_mindSystem.TryGetSession(mindComp.Mind, out var session))
if (mindComp.Mind == null || !mindComp.Mind.TryGetSession(out var session))
continue;
var name = MetaData(mindComp.Owner).EntityName;
_operativePlayers.Add(name, session);

View File

@@ -2,7 +2,6 @@ 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;
@@ -39,7 +38,6 @@ 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();
@@ -208,13 +206,16 @@ public sealed class PiratesRuleSystem : GameRuleSystem
var name = _namingSystem.GetName("Human", gender);
var session = ops[i];
var newMind = _mindSystem.CreateMind(session.UserId, name);
_mindSystem.ChangeOwningPlayer(newMind, session.UserId);
var newMind = new Mind.Mind(session.UserId)
{
CharacterName = name
};
newMind.ChangeOwningPlayer(session.UserId);
var mob = Spawn("MobHuman", _random.Pick(spawns));
MetaData(mob).EntityName = name;
_mindSystem.TransferTo(newMind, mob);
newMind.TransferTo(mob);
var profile = _prefs.GetPreferences(session.UserId).SelectedCharacter as HumanoidCharacterProfile;
_stationSpawningSystem.EquipStartingGear(mob, pirateGear, profile);

View File

@@ -2,7 +2,6 @@ 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;
@@ -51,7 +50,6 @@ 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";
@@ -173,11 +171,11 @@ public sealed class SuspicionRuleSystem : GameRuleSystem
DebugTools.AssertNotNull(mind?.OwnedEntity);
var traitorRole = new SuspicionTraitorRole(mind!, antagPrototype);
_mindSystem.AddRole(mind!, traitorRole);
mind!.AddRole(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)
@@ -187,7 +185,7 @@ public sealed class SuspicionRuleSystem : GameRuleSystem
DebugTools.AssertNotNull(mind);
_mindSystem.AddRole(mind!, new SuspicionInnocentRole(mind!, antagPrototype));
mind!.AddRole(new SuspicionInnocentRole(mind, antagPrototype));
}
foreach (var traitor in traitors)
@@ -206,11 +204,8 @@ public sealed class SuspicionRuleSystem : GameRuleSystem
_chatManager.DispatchServerAnnouncement(Loc.GetString("rule-suspicion-added-announcement"));
var filter = Filter.Empty().AddWhere(session =>
{
var mind = ((IPlayerSession) session).ContentData()?.Mind;
return mind != null && _mindSystem.HasRole<SuspicionTraitorRole>(mind);
});
var filter = Filter.Empty()
.AddWhere(session => ((IPlayerSession) session).ContentData()?.Mind?.HasRole<SuspicionTraitorRole>() ?? false);
SoundSystem.Play(_addedSound.GetSound(), filter, AudioParams.Default);
@@ -306,7 +301,7 @@ public sealed class SuspicionRuleSystem : GameRuleSystem
var mind = playerSession.ContentData()?.Mind;
if (mind != null && _mindSystem.HasRole<SuspicionTraitorRole>(mind))
if (mind != null && mind.HasRole<SuspicionTraitorRole>())
traitorsAlive++;
else
innocentsAlive++;

View File

@@ -3,7 +3,6 @@ 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;
@@ -42,7 +41,6 @@ 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";
@@ -83,7 +81,7 @@ public sealed class TraitorDeathMatchRuleSystem : GameRuleSystem
var antagPrototype = _prototypeManager.Index<AntagPrototype>(TraitorPrototypeID);
var traitorRole = new TraitorRole(mind, antagPrototype);
_mindSystem.AddRole(mind, traitorRole);
mind.AddRole(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.)

View File

@@ -1,6 +1,5 @@
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;
@@ -37,7 +36,6 @@ 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!;
@@ -256,7 +254,7 @@ public sealed class TraitorRuleSystem : GameRuleSystem
var antagPrototype = _prototypeManager.Index<AntagPrototype>(TraitorPrototypeID);
var traitorRole = new TraitorRole(mind, antagPrototype);
_mindSystem.AddRole(mind, traitorRole);
mind.AddRole(traitorRole);
Traitors.Add(traitorRole);
traitorRole.GreetTraitor(Codewords);
@@ -272,7 +270,7 @@ public sealed class TraitorRuleSystem : GameRuleSystem
{
var objective = _objectivesManager.GetRandomObjective(traitorRole.Mind, "TraitorObjectiveGroups");
if (objective == null) continue;
if (_mindSystem.TryAddObjective(traitorRole.Mind, objective))
if (traitorRole.Mind.TryAddObjective(objective))
difficulty += objective.Difficulty;
}
@@ -344,7 +342,7 @@ public sealed class TraitorRuleSystem : GameRuleSystem
foreach (var traitor in Traitors)
{
var name = traitor.Mind.CharacterName;
_mindSystem.TryGetSession(traitor.Mind, out var session);
traitor.Mind.TryGetSession(out var session);
var username = session?.Name;
var objectives = traitor.Mind.AllObjectives.ToArray();

View File

@@ -5,7 +5,6 @@ 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;
@@ -44,7 +43,6 @@ 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();
@@ -104,7 +102,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem
{
var meta = MetaData(survivor);
var username = string.Empty;
if (TryComp<MindContainerComponent>(survivor, out var mindcomp))
if (TryComp<MindComponent>(survivor, out var mindcomp))
if (mindcomp.Mind != null && mindcomp.Mind.Session != null)
username = mindcomp.Mind.Session.Name;
@@ -286,7 +284,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem
DebugTools.AssertNotNull(mind.OwnedEntity);
_mindSystem.AddRole(mind, new TraitorRole(mind, _prototypeManager.Index<AntagPrototype>(PatientZeroPrototypeID)));
mind.AddRole(new TraitorRole(mind, _prototypeManager.Index<AntagPrototype>(PatientZeroPrototypeID)));
var inCharacterName = string.Empty;
if (mind.OwnedEntity != null)