Fix NPC awake assert (#15783)

This commit is contained in:
metalgearsloth
2023-04-25 22:33:13 +10:00
committed by GitHub
parent 4e87b59de8
commit fda607b2f6

View File

@@ -53,7 +53,7 @@ namespace Content.Server.NPC.Systems
private void OnPlayerNPCDetach(EntityUid uid, NPCComponent component, PlayerDetachedEvent args) private void OnPlayerNPCDetach(EntityUid uid, NPCComponent component, PlayerDetachedEvent args)
{ {
if (_mobState.IsIncapacitated(uid)) if (_mobState.IsIncapacitated(uid) || Deleted(uid))
return; return;
WakeNPC(uid, component); WakeNPC(uid, component);
@@ -83,9 +83,9 @@ namespace Content.Server.NPC.Systems
/// <summary> /// <summary>
/// Is the NPC awake and updating? /// Is the NPC awake and updating?
/// </summary> /// </summary>
public bool IsAwake(NPCComponent component, ActiveNPCComponent? active = null) public bool IsAwake(EntityUid uid, NPCComponent component, ActiveNPCComponent? active = null)
{ {
return Resolve(component.Owner, ref active, false); return Resolve(uid, ref active, false);
} }
/// <summary> /// <summary>
@@ -98,8 +98,8 @@ namespace Content.Server.NPC.Systems
return; return;
} }
_sawmill.Debug($"Waking {ToPrettyString(component.Owner)}"); _sawmill.Debug($"Waking {ToPrettyString(uid)}");
EnsureComp<ActiveNPCComponent>(component.Owner); EnsureComp<ActiveNPCComponent>(uid);
} }
public void SleepNPC(EntityUid uid, NPCComponent? component = null) public void SleepNPC(EntityUid uid, NPCComponent? component = null)
@@ -109,8 +109,8 @@ namespace Content.Server.NPC.Systems
return; return;
} }
_sawmill.Debug($"Sleeping {ToPrettyString(component.Owner)}"); _sawmill.Debug($"Sleeping {ToPrettyString(uid)}");
RemComp<ActiveNPCComponent>(component.Owner); RemComp<ActiveNPCComponent>(uid);
} }
/// <inheritdoc /> /// <inheritdoc />