Remove physics sleep cancelling (#4813)

* Remove physics sleep cancelling

Was a bad idea, in the future I'm going to add even more asserts around this but for now I can fix content.

* Fix this
This commit is contained in:
metalgearsloth
2024-01-06 13:38:41 +11:00
committed by GitHub
parent 16af5cff9c
commit ac147dc2a1
2 changed files with 4 additions and 26 deletions

View File

@@ -7,11 +7,4 @@ namespace Robust.Shared.Physics;
public readonly record struct PhysicsWakeEvent(EntityUid Entity, PhysicsComponent Body);
[ByRefEvent]
public record struct PhysicsSleepEvent(EntityUid Entity, PhysicsComponent Body)
{
/// <summary>
/// Marks the entity as still being awake and cancels sleeping.
/// This only works if <see cref="PhysicsComponent.CanCollide"/> is still enabled and the object is not a static object..
/// </summary>
public bool Cancelled;
};
public record struct PhysicsSleepEvent(EntityUid Entity, PhysicsComponent Body);

View File

@@ -401,29 +401,14 @@ public partial class SharedPhysicsSystem
}
else
{
// TODO C# event?
var ev = new PhysicsSleepEvent(uid, body);
RaiseLocalEvent(uid, ref ev, true);
// Reset the sleep timer.
if (ev.Cancelled && canWake)
{
body.Awake = true;
// TODO C# event?
var wakeEv = new PhysicsWakeEvent(uid, body);
RaiseLocalEvent(uid, ref wakeEv, true);
if (updateSleepTime)
SetSleepTime(body, 0);
return;
}
ResetDynamics(body, dirty: false);
}
// Update wake system after we are sure that the wake/sleep event wasn't cancelled.
_wakeSystem.UpdateCanCollide(ent, checkTerminating: false, dirty: false);
// Update wake system last, if sleeping but still colliding.
if (!value && body.CanCollide)
_wakeSystem.UpdateCanCollide(ent, checkTerminating: false, dirty: false);
if (updateSleepTime)
SetSleepTime(body, 0);