예제 #1
0
        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));
        }
예제 #2
0
        public static bool InRangeUnOccluded(ITargetedInteractEventArgs args, float range, Ignored?predicate, bool ignoreInsideBlocker = true)
        {
            var entMan    = IoCManager.Resolve <IEntityManager>();
            var originPos = entMan.GetComponent <TransformComponent>(args.User).MapPosition;
            var otherPos  = entMan.GetComponent <TransformComponent>(args.Target).MapPosition;

            return(InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker));
        }
 public static bool InRangeUnOccluded(
     this ITargetedInteractEventArgs args,
     float range              = InteractionRange,
     Ignored?predicate        = null,
     bool ignoreInsideBlocker = true)
 {
     return(ExamineSystemShared.InRangeUnOccluded(args, range, predicate,
                                                  ignoreInsideBlocker));
 }
예제 #4
0
 public static bool InRangeUnobstructed(
     this ITargetedInteractEventArgs args,
     float range = InteractionRange,
     CollisionGroup collisionMask = CollisionGroup.Impassable,
     Ignored?predicate            = null,
     bool ignoreInsideBlocker     = false,
     bool popup = false)
 {
     return(SharedInteractionSystem.InRangeUnobstructed(args.User, args.Target, range, collisionMask, predicate, ignoreInsideBlocker, popup));
 }
예제 #5
0
        /// <summary>
        /// Default interaction check for targeted attack interaction types.
        /// Same as <see cref="SharedInteractionSystem.InRangeUnobstructed"/>, but defaults to allow inside blockers.
        /// Validates that attacker is in range of the attacked entity. Additionally shows a popup if
        /// validation fails.
        /// </summary>
        public static bool InRangeUnobstructed(ITargetedInteractEventArgs eventArgs, bool insideBlockerValid = true)
        {
            if (!EntitySystem.Get <SharedInteractionSystem>().InRangeUnobstructed(eventArgs.User.Transform.MapPosition,
                                                                                  eventArgs.Target.Transform.WorldPosition, ignoredEnt: eventArgs.Target, insideBlockerValid: insideBlockerValid))
            {
                var localizationManager = IoCManager.Resolve <ILocalizationManager>();
                eventArgs.Target.PopupMessage(eventArgs.User, localizationManager.GetString("You can't reach there!"));
                return(false);
            }

            return(true);
        }
        /// <summary>
        ///     Checks that the user and target of a
        ///     <see cref="ITargetedInteractEventArgs"/> are within a certain
        ///     distance without any entity that matches the collision mask
        ///     obstructing them.
        ///     If the <paramref name="range"/> is zero or negative,
        ///     this method will only check if nothing obstructs the entity and component.
        /// </summary>
        /// <param name="args">The event args to use.</param>
        /// <param name="range">
        ///     Maximum distance between the two entity and set of map coordinates.
        /// </param>
        /// <param name="collisionMask">The mask to check for collisions.</param>
        /// <param name="predicate">
        ///     A predicate to check whether to ignore an entity or not.
        ///     If it returns true, it will be ignored.
        /// </param>
        /// <param name="ignoreInsideBlocker">
        ///     If true and both the user and target are inside
        ///     the obstruction, ignores the obstruction and considers the interaction
        ///     unobstructed.
        ///     Therefore, setting this to true makes this check more permissive,
        ///     such as allowing an interaction to occur inside something impassable
        ///     (like a wall). The default, false, makes the check more restrictive.
        /// </param>
        /// <param name="popup">
        ///     Whether or not to popup a feedback message on the user entity for
        ///     it to see.
        /// </param>
        /// <returns>
        ///     True if the two points are within a given range without being obstructed.
        /// </returns>
        public bool InRangeUnobstructed(
            ITargetedInteractEventArgs args,
            float range = InteractionRange,
            CollisionGroup collisionMask = CollisionGroup.Impassable,
            Ignored?predicate            = null,
            bool ignoreInsideBlocker     = false,
            bool popup = false)
        {
            var origin = args.User;
            var other  = args.Target;

            return(InRangeUnobstructed(origin, other, range, collisionMask, predicate, ignoreInsideBlocker, popup));
        }