Add IEntity.IsWeightless extension method (#2255)

Checking manually every time wasn't that cool
This commit is contained in:
DrSmugleaf
2020-10-14 22:37:25 +02:00
committed by GitHub
parent 17ee9814b0
commit 5fcd13d0e3
4 changed files with 18 additions and 10 deletions

View File

@@ -1,4 +1,8 @@
#nullable enable
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Physics;
using Robust.Shared.IoC;
namespace Content.Shared.GameObjects.Components.Movement
{
@@ -7,4 +11,15 @@ namespace Content.Shared.GameObjects.Components.Movement
{
public override string Name => "MovementIgnoreGravity";
}
public static class GravityExtensions
{
public static bool IsWeightless(this IEntity entity, IPhysicsManager? physicsManager = null)
{
physicsManager ??= IoCManager.Resolve<IPhysicsManager>();
return !entity.HasComponent<MovementIgnoreGravityComponent>() &&
physicsManager.IsWeightless(entity.Transform.Coordinates);
}
}
}