-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds event for mass and angular inertia changes. (#5286)
* Adds MassDataChangedEvent to physics This event is raised in response to changes to an entities innate mass/angular inertia/center of mass * Use properties to fetch data from component * Comp1 * Vector2 * I sure love an analyzer that doesn't work half the time
- Loading branch information
1 parent
ad329a6
commit b7cc0ec
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.Physics.Components; | ||
using System.Numerics; | ||
|
||
namespace Robust.Shared.Physics.Events; | ||
|
||
/// <summary> | ||
/// By-ref directed event raised when the mass or angular inertia or center of mass of a physics body changes. | ||
/// </summary> | ||
/// <param name="Entity">The physics body that changed.</param> | ||
/// <param name="OldMass">The old mass of the physics body.</param> | ||
/// <param name="OldInertia">The old angular inertia of the physics body.</param> | ||
/// <param name="OldCenter">The old (local) center of mass of the physics body.</param> | ||
[ByRefEvent] | ||
public readonly record struct MassDataChangedEvent( | ||
Entity<PhysicsComponent, FixturesComponent> Entity, | ||
float OldMass, | ||
float OldInertia, | ||
Vector2 OldCenter | ||
) | ||
{ | ||
public float NewMass => Entity.Comp1._mass; | ||
public float NewInertia => Entity.Comp1._inertia; | ||
public Vector2 NewCenter => Entity.Comp1._localCenter; | ||
public bool MassChanged => NewMass != OldMass; | ||
public bool InertiaChanged => NewInertia != OldInertia; | ||
public bool CenterChanged => NewCenter != OldCenter; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters