Fix multi-ghosts (#22964)

* Fix multi-ghosts

* Fix mind visits
This commit is contained in:
metalgearsloth
2023-12-26 00:19:12 +11:00
committed by GitHub
parent 724cde264c
commit c326e5d087
3 changed files with 22 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ using Robust.Shared.Player;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using System.Numerics; using System.Numerics;
using Content.Shared.Movement.Systems;
using Robust.Shared.Audio.Systems; using Robust.Shared.Audio.Systems;
namespace Content.Server.Body.Systems; namespace Content.Server.Body.Systems;
@@ -41,6 +42,13 @@ public sealed class BodySystem : SharedBodySystem
private void OnRelayMoveInput(EntityUid uid, BodyComponent component, ref MoveInputEvent args) private void OnRelayMoveInput(EntityUid uid, BodyComponent component, ref MoveInputEvent args)
{ {
// If they haven't actually moved then ignore it.
if ((args.Component.HeldMoveButtons &
(MoveButtons.Down | MoveButtons.Left | MoveButtons.Up | MoveButtons.Right)) == 0x0)
{
return;
}
if (_mobState.IsDead(uid) && _mindSystem.TryGetMind(uid, out var mindId, out var mind)) if (_mobState.IsDead(uid) && _mindSystem.TryGetMind(uid, out var mindId, out var mind))
{ {
mind.TimeOfDeath ??= _gameTiming.RealTime; mind.TimeOfDeath ??= _gameTiming.RealTime;

View File

@@ -15,6 +15,7 @@ using Content.Shared.Mind.Components;
using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems; using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Events; using Content.Shared.Movement.Events;
using Content.Shared.Movement.Systems;
using Content.Shared.Storage.Components; using Content.Shared.Storage.Components;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;
@@ -116,6 +117,13 @@ namespace Content.Server.Ghost
private void OnRelayMoveInput(EntityUid uid, GhostOnMoveComponent component, ref MoveInputEvent args) private void OnRelayMoveInput(EntityUid uid, GhostOnMoveComponent component, ref MoveInputEvent args)
{ {
// If they haven't actually moved then ignore it.
if ((args.Component.HeldMoveButtons &
(MoveButtons.Down | MoveButtons.Left | MoveButtons.Up | MoveButtons.Right)) == 0x0)
{
return;
}
// Let's not ghost if our mind is visiting... // Let's not ghost if our mind is visiting...
if (HasComp<VisitingMindComponent>(uid)) if (HasComp<VisitingMindComponent>(uid))
return; return;

View File

@@ -171,14 +171,17 @@ public sealed class MindSystem : SharedMindSystem
return; return;
} }
if (GetSession(mind) is { } session)
_players.SetAttachedEntity(session, entity);
mind.VisitingEntity = entity; mind.VisitingEntity = entity;
// EnsureComp instead of AddComp to deal with deferred deletions. // EnsureComp instead of AddComp to deal with deferred deletions.
var comp = EnsureComp<VisitingMindComponent>(entity); var comp = EnsureComp<VisitingMindComponent>(entity);
comp.MindId = mindId; comp.MindId = mindId;
// Do this AFTER the entity changes above as this will fire off a player-detached event
// which will run ghosting twice.
if (GetSession(mind) is { } session)
_players.SetAttachedEntity(session, entity);
Log.Info($"Session {mind.Session?.Name} visiting entity {entity}."); Log.Info($"Session {mind.Session?.Name} visiting entity {entity}.");
} }