Add InRangeUnoccluded extension methods (#2224)
* Rename RangeExtensions to UnobstructedExtensions * Add InRangeUnoccluded extension methods
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Content.Shared.Utility;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Containers;
|
||||
@@ -92,6 +93,61 @@ namespace Content.Shared.GameObjects.EntitySystems
|
||||
return (rayResults[0].HitPos - other.Position).Length < 1f;
|
||||
}
|
||||
|
||||
public static bool InRangeUnOccluded(IEntity origin, IEntity other, float range, Ignored predicate, bool ignoreInsideBlocker = true)
|
||||
{
|
||||
var originPos = origin.Transform.MapPosition;
|
||||
var otherPos = other.Transform.MapPosition;
|
||||
|
||||
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
|
||||
}
|
||||
|
||||
public static bool InRangeUnOccluded(IEntity origin, IComponent other, float range, Ignored predicate, bool ignoreInsideBlocker = true)
|
||||
{
|
||||
var originPos = origin.Transform.MapPosition;
|
||||
var otherPos = other.Owner.Transform.MapPosition;
|
||||
|
||||
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
|
||||
}
|
||||
|
||||
public static bool InRangeUnOccluded(IEntity origin, EntityCoordinates other, float range, Ignored predicate, bool ignoreInsideBlocker = true)
|
||||
{
|
||||
var originPos = origin.Transform.MapPosition;
|
||||
var otherPos = other.ToMap(origin.EntityManager);
|
||||
|
||||
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
|
||||
}
|
||||
|
||||
public static bool InRangeUnOccluded(IEntity origin, MapCoordinates other, float range, Ignored predicate, bool ignoreInsideBlocker = true)
|
||||
{
|
||||
var originPos = origin.Transform.MapPosition;
|
||||
|
||||
return InRangeUnOccluded(originPos, other, range, predicate, ignoreInsideBlocker);
|
||||
}
|
||||
|
||||
public static bool InRangeUnOccluded(ITargetedInteractEventArgs args, float range, Ignored predicate, bool ignoreInsideBlocker = true)
|
||||
{
|
||||
var originPos = args.User.Transform.MapPosition;
|
||||
var otherPos = args.Target.Transform.MapPosition;
|
||||
|
||||
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
|
||||
}
|
||||
|
||||
public static bool InRangeUnOccluded(DragDropEventArgs args, float range, Ignored predicate, bool ignoreInsideBlocker = true)
|
||||
{
|
||||
var originPos = args.User.Transform.MapPosition;
|
||||
var otherPos = args.DropLocation.ToMap(args.User.EntityManager);
|
||||
|
||||
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
|
||||
}
|
||||
|
||||
public static bool InRangeUnOccluded(AfterInteractEventArgs args, float range, Ignored predicate, bool ignoreInsideBlocker = true)
|
||||
{
|
||||
var originPos = args.User.Transform.MapPosition;
|
||||
var otherPos = args.Target.Transform.MapPosition;
|
||||
|
||||
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
|
||||
}
|
||||
|
||||
public static FormattedMessage GetExamineText(IEntity entity, IEntity examiner)
|
||||
{
|
||||
var message = new FormattedMessage();
|
||||
|
||||
Reference in New Issue
Block a user