mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-02 18:17:09 +02:00
44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Robust.Client.GameObjects
|
|
{
|
|
/// <summary>
|
|
/// Contains physical properties of the entity. This component registers the entity
|
|
/// in the physics system as a dynamic ridged body object that has physics. This behavior overrides
|
|
/// the BoundingBoxComponent behavior of making the entity static.
|
|
/// </summary>
|
|
internal class PhysicsComponent : Component
|
|
{
|
|
/// <inheritdoc />
|
|
public override string Name => "Physics";
|
|
|
|
/// <inheritdoc />
|
|
public override uint? NetID => NetIDs.PHYSICS;
|
|
|
|
/// <summary>
|
|
/// Current mass of the entity in kg.
|
|
/// </summary>
|
|
[ViewVariables]
|
|
public float Mass { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Current velocity of the entity.
|
|
/// </summary>
|
|
[ViewVariables]
|
|
public Vector2 Velocity { get; private set; }
|
|
|
|
/// <inheritdoc />
|
|
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
|
{
|
|
if (curState == null)
|
|
return;
|
|
|
|
var newState = (PhysicsComponentState)curState;
|
|
Mass = newState.Mass / 1000f; // gram to kilogram
|
|
Velocity = newState.Velocity;
|
|
}
|
|
}
|
|
}
|