More borg tweaks (#19143)

* borg tweaks but i'm gonna go code fun stuff first

* werkin' on it

* a ton of tweaks

* fuck everyone and then myself
This commit is contained in:
Nemanja
2023-08-14 19:34:23 -04:00
committed by GitHub
parent 8b0eb7e4de
commit 7ddee71379
40 changed files with 299 additions and 175 deletions

View File

@@ -30,6 +30,7 @@ public sealed class MindSystem : EntitySystem
[Dependency] private readonly ActorSystem _actor = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly GhostSystem _ghostSystem = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
@@ -125,11 +126,12 @@ public sealed class MindSystem : EntitySystem
/// </summary>
private void InternalEjectMind(EntityUid uid, MindContainerComponent? mind = null)
{
if (!Resolve(uid, ref mind, false))
if (!Resolve(uid, ref mind, false) || mind.Mind == null)
return;
var oldMind = mind.Mind;
mind.Mind = null;
RaiseLocalEvent(uid, new MindRemovedMessage(), true);
RaiseLocalEvent(uid, new MindRemovedMessage(oldMind), true);
}
private void OnVisitingTerminating(EntityUid uid, VisitingMindComponent component, ref EntityTerminatingEvent args)
@@ -159,7 +161,7 @@ public sealed class MindSystem : EntitySystem
return;
}
TransferTo(mind, null);
TransferTo(mind, null, createGhost: false);
if (component.GhostOnShutdown && mind.Session != null)
{
@@ -184,7 +186,7 @@ public sealed class MindSystem : EntitySystem
{
// This should be an error, if it didn't cause tests to start erroring when they delete a player.
Log.Warning($"Entity \"{ToPrettyString(uid)}\" for {mind.CharacterName} was deleted, and no applicable spawn location is available.");
TransferTo(mind, null);
TransferTo(mind, null, createGhost: false);
return;
}
@@ -381,7 +383,7 @@ public sealed class MindSystem : EntitySystem
/// <exception cref="ArgumentException">
/// Thrown if <paramref name="entity"/> is already owned by another mind.
/// </exception>
public void TransferTo(Mind mind, EntityUid? entity, bool ghostCheckOverride = false)
public void TransferTo(Mind mind, EntityUid? entity, bool ghostCheckOverride = false, bool createGhost = true)
{
if (entity == mind.OwnedEntity)
return;
@@ -407,6 +409,16 @@ public sealed class MindSystem : EntitySystem
alreadyAttached = true;
}
}
else if (createGhost)
{
var position = Deleted(mind.OwnedEntity)
? _gameTicker.GetObserverSpawnPoint().ToMap(EntityManager, _transform)
: Transform(mind.OwnedEntity.Value).MapPosition;
entity = Spawn("MobObserver", position);
var ghostComponent = Comp<GhostComponent>(entity.Value);
_ghostSystem.SetCanReturnToBody(ghostComponent, false);
}
var oldComp = mind.OwnedComponent;
var oldEntity = mind.OwnedEntity;