Refactor mind and ghost deletion code (#3680)
* Refactor mind and ghost deletion code * Refactor to use EventBus and clean up deletes * Fix mind eject when being deleted * Refactor entity manager calls to use IEntity.EntityManager
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
using Content.Server.GameObjects.Components.Observer;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Interfaces.GameTicking;
|
||||
@@ -22,9 +22,6 @@ namespace Content.Server.GameObjects.Components.Mobs
|
||||
[RegisterComponent]
|
||||
public class MindComponent : Component, IExamine
|
||||
{
|
||||
[DataField("show_examine_info")]
|
||||
private bool _showExamineInfo;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => "Mind";
|
||||
|
||||
@@ -61,6 +58,8 @@ namespace Content.Server.GameObjects.Components.Mobs
|
||||
/// </summary>
|
||||
public void InternalEjectMind()
|
||||
{
|
||||
if (!Deleted)
|
||||
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new MindRemovedMessage());
|
||||
Mind = null;
|
||||
}
|
||||
|
||||
@@ -94,7 +93,7 @@ namespace Content.Server.GameObjects.Components.Mobs
|
||||
|
||||
Mind!.TransferTo(visiting);
|
||||
}
|
||||
else if(GhostOnShutdown)
|
||||
else if (GhostOnShutdown)
|
||||
{
|
||||
var spawnPosition = Owner.Transform.Coordinates;
|
||||
// Use a regular timer here because the entity has probably been deleted.
|
||||
@@ -153,4 +152,8 @@ namespace Content.Server.GameObjects.Components.Mobs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MindRemovedMessage : EntityEventArgs
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Mobs;
|
||||
#nullable enable
|
||||
using Content.Server.Mobs;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -18,4 +19,8 @@ namespace Content.Server.GameObjects.Components.Mobs
|
||||
Mind?.UnVisit();
|
||||
}
|
||||
}
|
||||
|
||||
public class MindUnvisitedMessage : EntityEventArgs
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user