- add: interaction part 2
This commit is contained in:
18
Content.Shared/_Amour/InteractionPanel/Checks/Distance.cs
Normal file
18
Content.Shared/_Amour/InteractionPanel/Checks/Distance.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Content.Shared.Interaction;
|
||||
|
||||
namespace Content.Shared._Amour.InteractionPanel.Checks;
|
||||
|
||||
public sealed class HasSmallDistance : IInteractionCheck
|
||||
{
|
||||
[DataField] private readonly float _range = SharedInteractionSystem.InteractionRange;
|
||||
public bool IsAvailable(Entity<InteractionPanelComponent> user, Entity<InteractionPanelComponent> target, IEntityManager entityManager)
|
||||
{
|
||||
var transformSystem = entityManager.System<SharedTransformSystem>();
|
||||
|
||||
if (_range <= 0)
|
||||
return true;
|
||||
|
||||
var distance = (transformSystem.GetWorldPosition(user) - transformSystem.GetWorldPosition(target)).Length();
|
||||
return distance <= _range;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user