This commit is contained in:
ShadowCommander
2023-06-18 11:33:19 -07:00
committed by GitHub
parent 8a943fb374
commit dd7032a860
85 changed files with 1432 additions and 711 deletions

View File

@@ -5,6 +5,8 @@ using Content.Server.GameTicking.Rules.Components;
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.Components;
using Content.Server.NPC.Systems;
@@ -54,6 +56,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
[Dependency] private readonly MapLoaderSystem _map = default!;
[Dependency] private readonly ShuttleSystem _shuttle = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
public override void Initialize()
{
@@ -81,7 +84,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
continue;
// If entity has a prior mind attached, add them to the players list.
if (!TryComp<MindComponent>(uid, out var mindComponent))
if (!TryComp<MindContainerComponent>(uid, out var mindComponent))
continue;
var session = mindComponent.Mind?.Session;
@@ -571,22 +574,21 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
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;
foreach (var nukeops in EntityQuery<NukeopsRuleComponent>())
{
if (nukeops.OperativeMindPendingData.TryGetValue(uid, out var role) || !nukeops.SpawnOutpost || !nukeops.EndsRound)
{
role ??= nukeops.OperativeRoleProto;
mind.AddRole(new NukeopsRole(mind, _prototypeManager.Index<AntagPrototype>(role)));
_mindSystem.AddRole(mind, new NukeopsRole(mind, _prototypeManager.Index<AntagPrototype>(role)));
nukeops.OperativeMindPendingData.Remove(uid);
}
if (!mind.TryGetSession(out var playerSession))
if (!_mindSystem.TryGetSession(mind, out var playerSession))
return;
if (nukeops.OperativePlayers.ContainsValue(playerSession))
return;
@@ -756,15 +758,11 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
var mob = EntityManager.SpawnEntity(species.Prototype, _random.Pick(spawns));
SetupOperativeEntity(mob, spawnDetails.Name, spawnDetails.Gear, profile, component);
var newMind = _mindSystem.CreateMind(session.UserId, spawnDetails.Name);
_mindSystem.ChangeOwningPlayer(newMind, session.UserId);
_mindSystem.AddRole(newMind, new NukeopsRole(newMind, nukeOpsAntag));
var newMind = new Mind.Mind(session.UserId)
{
CharacterName = spawnDetails.Name
};
newMind.ChangeOwningPlayer(session.UserId);
newMind.AddRole(new NukeopsRole(newMind, nukeOpsAntag));
newMind.TransferTo(mob);
_mindSystem.TransferTo(newMind, mob);
}
else if (addSpawnPoints)
{
@@ -810,7 +808,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
return;
//ok hardcoded value bad but so is everything else here
mind.AddRole(new NukeopsRole(mind, _prototypeManager.Index<AntagPrototype>("Nukeops")));
_mindSystem.AddRole(mind, new NukeopsRole(mind, _prototypeManager.Index<AntagPrototype>("Nukeops")));
SetOutfitCommand.SetOutfit(mind.OwnedEntity.Value, "SyndicateOperativeGearFull", EntityManager);
}
@@ -859,10 +857,10 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
}
// Add pre-existing nuke operatives to the credit list.
var query = EntityQuery<NukeOperativeComponent, MindComponent, MetaDataComponent>(true);
var query = EntityQuery<NukeOperativeComponent, MindContainerComponent, MetaDataComponent>(true);
foreach (var (_, mindComp, metaData) in query)
{
if (mindComp.Mind == null || !mindComp.Mind.TryGetSession(out var session))
if (!mindComp.HasMind || !_mindSystem.TryGetSession(mindComp.Mind, out var session))
continue;
component.OperativePlayers.Add(metaData.EntityName, session);
}

View File

@@ -3,6 +3,7 @@ using Content.Server.Administration.Commands;
using Content.Server.Cargo.Systems;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Mind;
using Content.Server.Preferences.Managers;
using Content.Server.Spawners.Components;
using Content.Server.Station.Components;
@@ -40,6 +41,7 @@ public sealed class PiratesRuleSystem : GameRuleSystem<PiratesRuleComponent>
[Dependency] private readonly PricingSystem _pricingSystem = default!;
[Dependency] private readonly MapLoaderSystem _map = default!;
[Dependency] private readonly NamingSystem _namingSystem = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
/// <inheritdoc/>
@@ -205,16 +207,13 @@ public sealed class PiratesRuleSystem : GameRuleSystem<PiratesRuleComponent>
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);

View File

@@ -2,6 +2,7 @@ using System.Linq;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.NPC.Systems;
using Content.Server.Mind;
using Content.Server.Objectives.Interfaces;
using Content.Server.PDA.Ringer;
using Content.Server.Players;
@@ -34,6 +35,7 @@ public sealed class TraitorRuleSystem : GameRuleSystem<TraitorRuleComponent>
[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!;
@@ -250,11 +252,11 @@ public sealed class TraitorRuleSystem : GameRuleSystem<TraitorRuleComponent>
Loc.GetString("traitor-role-uplink-code-short", ("code", string.Join("", code))));
// Assign traitor roles
mind.AddRole(traitorRole);
_mindSystem.AddRole(mind, traitorRole);
SendTraitorBriefing(mind, traitorRule.Codewords, code);
traitorRule.Traitors.Add(traitorRole);
if (mind.TryGetSession(out var session))
if (_mindSystem.TryGetSession(mind, out var session))
{
// Notificate player about new role assignment
_audioSystem.PlayGlobal(traitorRule.GreetSoundNotification, session);
@@ -271,9 +273,10 @@ public sealed class TraitorRuleSystem : GameRuleSystem<TraitorRuleComponent>
for (var pick = 0; pick < maxPicks && maxDifficulty > difficulty; pick++)
{
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;
}
@@ -288,7 +291,7 @@ public sealed class TraitorRuleSystem : GameRuleSystem<TraitorRuleComponent>
/// <param name="code">Uplink codes</param>
private void SendTraitorBriefing(Mind.Mind mind, string[] codewords, Note[] code)
{
if (mind.TryGetSession(out var session))
if (_mindSystem.TryGetSession(mind, out var session))
{
_chatManager.DispatchServerMessage(session, Loc.GetString("traitor-role-greeting"));
_chatManager.DispatchServerMessage(session, Loc.GetString("traitor-role-codewords", ("codewords", string.Join(", ", codewords))));
@@ -367,7 +370,7 @@ public sealed class TraitorRuleSystem : GameRuleSystem<TraitorRuleComponent>
foreach (var t in traitor.Traitors)
{
var name = t.Mind.CharacterName;
t.Mind.TryGetSession(out var session);
_mindSystem.TryGetSession(t.Mind, out var session);
var username = session?.Name;
var objectives = t.Mind.AllObjectives.ToArray();

View File

@@ -3,6 +3,7 @@ using System.Linq;
using Content.Server.Actions;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Mind;
using Content.Server.Mind.Components;
using Content.Server.Players;
using Content.Server.Popups;
@@ -41,6 +42,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem<ZombieRuleComponent>
[Dependency] private readonly ActionsSystem _action = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly ZombifyOnDeathSystem _zombify = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
public override void Initialize()
{
@@ -92,7 +94,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem<ZombieRuleComponent>
{
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;
@@ -286,8 +288,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem<ZombieRuleComponent>
}
DebugTools.AssertNotNull(mind.OwnedEntity);
mind.AddRole(new ZombieRole(mind, _prototypeManager.Index<AntagPrototype>(component.PatientZeroPrototypeID)));
_mindSystem.AddRole(mind, new ZombieRole(mind, _prototypeManager.Index<AntagPrototype>(component.PatientZeroPrototypeID)));
var inCharacterName = string.Empty;
// Create some variation between the times of each zombie, relative to the time of the group as a whole.