Fix Mind Transfer and Role Assignment Logic for Antagonists (#30711)

* AntagSelectionSystemFix

* readded the stuff that shouldn've been deleted in the first place

* re-arrange

* undo indentation

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
This commit is contained in:
NakataRin
2024-08-07 07:38:47 +04:00
committed by GitHub
parent 05630bd4ba
commit 5247878060

View File

@@ -18,6 +18,7 @@ using Content.Shared.GameTicking;
using Content.Shared.GameTicking.Components;
using Content.Shared.Ghost;
using Content.Shared.Humanoid;
using Content.Shared.Mind;
using Content.Shared.Players;
using Content.Shared.Preferences.Loadouts;
using Content.Shared.Roles;
@@ -231,7 +232,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
for (var i = 0; i < count; i++)
{
var session = (ICommonSession?) null;
var session = (ICommonSession?)null;
if (picking)
{
if (!playerPool.TryPickAndTake(RobustRandom, out session) && noSpawner)
@@ -341,13 +342,19 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
if (session != null)
{
var curMind = _mind.CreateMind(session.UserId, Name(antagEnt.Value));
_mind.SetUserId(curMind, session.UserId);
_mind.TransferTo(curMind, antagEnt, ghostCheckOverride: true);
_role.MindAddRoles(curMind, def.MindComponents, null, true);
ent.Comp.SelectedMinds.Add((curMind, Name(player)));
var curMind = session.GetMind();
if (curMind == null ||
!TryComp<MindComponent>(curMind.Value, out var mindComp) ||
mindComp.OwnedEntity != antagEnt)
{
curMind = _mind.CreateMind(session.UserId, Name(antagEnt.Value));
_mind.SetUserId(curMind.Value, session.UserId);
}
_mind.TransferTo(curMind.Value, antagEnt, ghostCheckOverride: true);
_role.MindAddRoles(curMind.Value, def.MindComponents, null, true);
ent.Comp.SelectedMinds.Add((curMind.Value, Name(player)));
SendBriefing(session, def.Briefing);
}
@@ -460,7 +467,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
private void OnObjectivesTextGetInfo(Entity<AntagSelectionComponent> ent, ref ObjectivesTextGetInfoEvent args)
{
if (ent.Comp.AgentName is not {} name)
if (ent.Comp.AgentName is not { } name)
return;
args.Minds = ent.Comp.SelectedMinds;