/// <summary>
        ///     Raises an event directed at both the user and the target entity to check whether a user is capable of
        ///     interacting with this entity.
        /// </summary>
        /// <remarks>
        ///     If this is a generic interaction without a target (e.g., stop-drop-and-roll when burning), the target
        ///     may be null. Note that this is checked by <see cref="SharedInteractionSystem"/>. In the majority of
        ///     cases, systems that provide interactions will not need to check this themselves, though they may need to
        ///     check other blockers like <see cref="CanPickup(EntityUid)"/>
        /// </remarks>
        /// <returns></returns>
        public bool CanInteract(EntityUid user, EntityUid?target)
        {
            var ev = new InteractionAttemptEvent(user, target);

            RaiseLocalEvent(user, ev, true);

            if (ev.Cancelled)
            {
                return(false);
            }

            if (target == null)
            {
                return(true);
            }

            var targetEv = new GettingInteractedWithAttemptEvent(user, target);

            RaiseLocalEvent(target.Value, targetEv, true);

            if (!targetEv.Cancelled)
            {
                InteractWithItem(user, target.Value);
            }

            return(!targetEv.Cancelled);
        }
Esempio n. 2
0
 private void OnInteractionAttempt(EntityUid uid, DroneComponent component, InteractionAttemptEvent args)
 {
     if (HasComp <MobStateComponent>(args.Target) && !HasComp <DroneComponent>(args.Target))
     {
         args.Cancel();
     }
 }
Esempio n. 3
0
        public bool CanInteract(EntityUid uid)
        {
            var ev = new InteractionAttemptEvent(uid);

            RaiseLocalEvent(uid, ev);

            return(!ev.Cancelled);
        }
        public bool CanInteract(IEntity entity)
        {
            var ev = new InteractionAttemptEvent(entity);

            RaiseLocalEvent(entity.Uid, ev);

            return(!ev.Cancelled);
        }
Esempio n. 5
0
        private void OnInteractionAttempt(EntityUid uid, DroneComponent component, InteractionAttemptEvent args)
        {
            if (NonDronesInRange(uid, component))
            {
                args.Cancel();
            }

            if (HasComp <SharedItemComponent>(args.Target) && !HasComp <UnremoveableComponent>(args.Target))
            {
                if (!_tagSystem.HasAnyTag(args.Target.Value, "DroneUsable", "Trash"))
                {
                    args.Cancel();
                }
            }
        }
        public bool CanInteract(IEntity entity)
        {
            var ev = new InteractionAttemptEvent(entity);

            RaiseLocalEvent(entity.Uid, ev);

            foreach (var blocker in ev.Entity.GetAllComponents <IActionBlocker>())
            {
                if (!blocker.CanInteract())
                {
                    ev.Cancel();
                    break;
                }
            }

            return(!ev.Cancelled);
        }
Esempio n. 7
0
 private void OnInteractAttempt(EntityUid uid, SharedCuffableComponent component, InteractionAttemptEvent args)
 {
     CheckAct(uid, component, args);
 }
 private void OnInteractAttempt(EntityUid uid, StunnedComponent stunned, InteractionAttemptEvent args)
 {
     args.Cancel();
 }
 private void OnInteractAttempt(EntityUid uid, MobStateComponent component, InteractionAttemptEvent args)
 {
     CheckAct(uid, component, args);
 }
Esempio n. 10
0
 private void OnInteractAttempt(EntityUid uid, PAIComponent component, InteractionAttemptEvent args)
 {
     args.Cancel();
 }
 private void OnInteractAttempt(EntityUid uid, SharedGhostComponent component, InteractionAttemptEvent args)
 {
     if (!component.CanGhostInteract)
     {
         args.Cancel();
     }
 }