mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-02-14 19:29:57 +01:00
stable to master (#42038)
[HOTFIX] Fix MMI mind transfer (#41941) Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Silicons.Borgs.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This is used for an entity that is linked to an MMI, usually a brain.
|
||||
/// Mostly for receiving events.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(SharedBorgSystem))]
|
||||
[AutoGenerateComponentState]
|
||||
public sealed partial class MMILinkedComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The MMI this entity is linked to.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public EntityUid? LinkedMMI;
|
||||
}
|
||||
@@ -17,8 +17,7 @@ public abstract partial class SharedBorgSystem
|
||||
SubscribeLocalEvent<MMIComponent, MindAddedMessage>(OnMMIMindAdded);
|
||||
SubscribeLocalEvent<MMIComponent, MindRemovedMessage>(OnMMIMindRemoved);
|
||||
|
||||
SubscribeLocalEvent<MMILinkedComponent, MindAddedMessage>(OnMMILinkedMindAdded);
|
||||
SubscribeLocalEvent<MMILinkedComponent, EntGotRemovedFromContainerMessage>(OnMMILinkedRemoved);
|
||||
SubscribeLocalEvent<MMIComponent, EntRemovedFromContainerMessage>(OnMMILinkedRemoved);
|
||||
}
|
||||
|
||||
private void OnMMIInit(Entity<MMIComponent> ent, ref ComponentInit args)
|
||||
@@ -35,9 +34,6 @@ public abstract partial class SharedBorgSystem
|
||||
return;
|
||||
|
||||
var brain = args.Entity;
|
||||
var linked = EnsureComp<MMILinkedComponent>(brain);
|
||||
linked.LinkedMMI = ent.Owner;
|
||||
Dirty(brain, linked);
|
||||
|
||||
if (_mind.TryGetMind(brain, out var mindId, out var mindComp))
|
||||
{
|
||||
@@ -60,35 +56,22 @@ public abstract partial class SharedBorgSystem
|
||||
_appearance.SetData(ent.Owner, MMIVisuals.HasMind, false);
|
||||
}
|
||||
|
||||
private void OnMMILinkedMindAdded(Entity<MMILinkedComponent> ent, ref MindAddedMessage args)
|
||||
{
|
||||
if (ent.Comp.LinkedMMI == null || !_mind.TryGetMind(ent.Owner, out var mindId, out var mindComp))
|
||||
return;
|
||||
|
||||
_mind.TransferTo(mindId, ent.Comp.LinkedMMI, true, mind: mindComp);
|
||||
}
|
||||
|
||||
private void OnMMILinkedRemoved(Entity<MMILinkedComponent> ent, ref EntGotRemovedFromContainerMessage args)
|
||||
private void OnMMILinkedRemoved(Entity<MMIComponent> ent, ref EntRemovedFromContainerMessage args)
|
||||
{
|
||||
if (_timing.ApplyingState)
|
||||
return; // The changes are already networked with the same game state
|
||||
|
||||
if (Terminating(ent.Owner))
|
||||
if (args.Container.ID != ent.Comp.BrainSlotId)
|
||||
return;
|
||||
|
||||
if (ent.Comp.LinkedMMI is not { } linked)
|
||||
return;
|
||||
|
||||
RemCompDeferred<MMILinkedComponent>(ent.Owner);
|
||||
|
||||
if (_mind.TryGetMind(linked, out var mindId, out var mindComp))
|
||||
if (_mind.TryGetMind(ent, out var mindId, out var mindComp))
|
||||
{
|
||||
_mind.TransferTo(mindId, args.Entity, true, mind: mindComp);
|
||||
|
||||
if (_roles.MindHasRole<SiliconBrainRoleComponent>(mindId))
|
||||
_roles.MindRemoveRole<SiliconBrainRoleComponent>(mindId);
|
||||
|
||||
_mind.TransferTo(mindId, ent.Owner, true, mind: mindComp);
|
||||
}
|
||||
|
||||
_appearance.SetData(linked, MMIVisuals.BrainPresent, false);
|
||||
_appearance.SetData(ent, MMIVisuals.BrainPresent, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user