mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
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:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user