/// <summary>
        /// Will have two behaviors, either "uses" the used entity at range on the target entity if it is capable of accepting that action
        /// Or it will use the used entity itself on the position clicked, regardless of what was there
        /// </summary>
        public override async Task <bool> InteractUsingRanged(EntityUid user, EntityUid used, EntityUid?target, EntityCoordinates clickLocation, bool inRangeUnobstructed)
        {
            // TODO PREDICTION move server-side interaction logic into the shared system for interaction prediction.
            if (InteractDoBefore(user, used, inRangeUnobstructed ? target : null, clickLocation, false))
            {
                return(true);
            }

            if (target != null)
            {
                var rangedMsg = new RangedInteractEvent(user, used, target.Value, clickLocation);
                RaiseLocalEvent(target.Value, rangedMsg);
                if (rangedMsg.Handled)
                {
                    return(true);
                }

                var rangedInteractions         = AllComps <IRangedInteract>(target.Value).ToList();
                var rangedInteractionEventArgs = new RangedInteractEventArgs(user, used, clickLocation);

                // See if we have a ranged interaction
                foreach (var t in rangedInteractions)
                {
                    // If an InteractUsingRanged returns a status completion we finish our interaction
#pragma warning disable 618
                    if (t.RangedInteract(rangedInteractionEventArgs))
#pragma warning restore 618
                    {
                        return(true);
                    }
                }
            }

            return(await InteractDoAfter(user, used, inRangeUnobstructed?target : null, clickLocation, false));
        }
예제 #2
0
        /// <summary>
        /// Will have two behaviors, either "uses" the used entity at range on the target entity if it is capable of accepting that action
        /// Or it will use the used entity itself on the position clicked, regardless of what was there
        /// </summary>
        public async Task <bool> InteractUsingRanged(EntityUid user, EntityUid used, EntityUid target, EntityCoordinates clickLocation, bool inRangeUnobstructed)
        {
            if (InteractDoBefore(user, used, inRangeUnobstructed ? target : null, clickLocation, false))
            {
                return(true);
            }

            if (target != default)
            {
                var rangedMsg = new RangedInteractEvent(user, used, target, clickLocation);
                RaiseLocalEvent(target, rangedMsg);
                if (rangedMsg.Handled)
                {
                    return(true);
                }

                var rangedInteractions         = EntityManager.GetComponents <IRangedInteract>(target).ToList();
                var rangedInteractionEventArgs = new RangedInteractEventArgs(user, used, clickLocation);

                // See if we have a ranged interaction
                foreach (var t in rangedInteractions)
                {
                    // If an InteractUsingRanged returns a status completion we finish our interaction
#pragma warning disable 618
                    if (t.RangedInteract(rangedInteractionEventArgs))
#pragma warning restore 618
                    {
                        return(true);
                    }
                }
            }

            return(await InteractDoAfter(user, used, inRangeUnobstructed?target : null, clickLocation, false));
        }
        /// <summary>
        /// Will have two behaviors, either "uses" the used entity at range on the target entity if it is capable of accepting that action
        /// Or it will use the used entity itself on the position clicked, regardless of what was there
        /// </summary>
        public async Task <bool> InteractUsingRanged(IEntity user, IEntity used, IEntity?target, EntityCoordinates clickLocation, bool inRangeUnobstructed)
        {
            if (target != null)
            {
                var rangedMsg = new RangedInteractEvent(user, used, target, clickLocation);
                RaiseLocalEvent(target.Uid, rangedMsg);
                if (rangedMsg.Handled)
                {
                    return(true);
                }

                var rangedInteractions         = target.GetAllComponents <IRangedInteract>().ToList();
                var rangedInteractionEventArgs = new RangedInteractEventArgs(user, used, clickLocation);

                // See if we have a ranged interaction
                foreach (var t in rangedInteractions)
                {
                    // If an InteractUsingRanged returns a status completion we finish our interaction
                    if (t.RangedInteract(rangedInteractionEventArgs))
                    {
                        return(true);
                    }
                }
            }

            if (inRangeUnobstructed)
            {
                return(await InteractDoAfter(user, used, target, clickLocation, false));
            }
            else
            {
                return(await InteractDoAfter(user, used, null, clickLocation, false));
            }
        }