public bool CanInteract(InteractionEvent interactionEvent)
        {
            if (!InteractionExtensions.RangeCheck(interactionEvent))
            {
                return(false);
            }

            var provider = interactionEvent.Source as IGameObjectProvider;

            if (provider == null)
            {
                return(false);
            }

            var container = provider.GameObject.GetComponent <SubstanceContainer>();

            if (container == null)
            {
                return(false);
            }

            if (container.Locked)
            {
                return(false);
            }

            if (container.IsEmpty())
            {
                return(false);
            }

            return(CanInteractCallback.Invoke(interactionEvent));
        }
Beispiel #2
0
        public bool CanInteract(InteractionEvent interactionEvent)
        {
            // if the target is whatever the hell Alain did
            // and the part that matters, if the interaction source is a hand
            if (interactionEvent.Target is IGameObjectProvider targetBehaviour && interactionEvent.Source is Hands hands)
            {
                // if the selected hand is not empty we return false
                if (!hands.SelectedHandEmpty)
                {
                    return(false);
                }

                // we try to get the Item component from the GameObject we just interacted with
                // you can only pickup items (for now, TODO: we have to consider people too), which makes sense
                Item item = targetBehaviour.GameObject.GetComponent <Item>();
                if (item == null)
                {
                    return(false);
                }
                // then we just do a range check, to make sure we can interact
                // and we check if the item is not in a container, you can only pick things that are not in a container
                return(InteractionExtensions.RangeCheck(interactionEvent) && !item.InContainer());
            }

            return(false);
        }
Beispiel #3
0
        public bool CanInteract(InteractionEvent interactionEvent)
        {
            if (!InteractionExtensions.RangeCheck(interactionEvent))
            {
                return(false);
            }

            var container = interactionEvent.Target.GetComponent <AttachedContainer>();

            if (container == null)
            {
                return(false);
            }
            var inventory = interactionEvent.Source.GetComponentInTree <Inventory>();

            if (inventory == null)
            {
                return(false);
            }

            Entity entity = interactionEvent.Source.GetEntity();

            if (entity == null)
            {
                return(false);
            }
            return(!inventory.HasContainer(container) && entity.CanInteract(container.gameObject));
        }
        public override bool CanInteract(InteractionEvent interactionEvent)
        {
            if (RangeCheck && !InteractionExtensions.RangeCheck(interactionEvent))
            {
                return(false);
            }

            if (interactionEvent.Target is IGameObjectProvider targetBehaviour)
            {
                // Get target tile
                // TargetTile = TileManager.Instance.CanBuild()
                TargetPlacedObject = targetBehaviour.GameObject.GetComponentInParent <PlacedTileObject>();
                if (TargetPlacedObject == null)
                {
                    return(false);
                }

                // Ready if no obstacles
                if (ObstacleMask == 0)
                {
                    return(true);
                }

                // Check for obstacle
                Vector3 center   = TargetPlacedObject.gameObject.transform.position;
                bool    obstacle = Physics.CheckBox(center, BuildDimensions / 2, Quaternion.identity, ObstacleMask, QueryTriggerInteraction.Ignore);
                return(!obstacle);
            }

            return(false);
        }
        public override bool CanInteract(InteractionEvent interactionEvent)
        {
            if (!InteractionExtensions.RangeCheck(interactionEvent))
            {
                return(false);
            }

            if (interactionEvent.Target is IGameObjectProvider targetBehaviour)
            {
                TileObject targetTile = targetBehaviour.GameObject.GetComponentInParent <TileObject>();
                if (targetTile == null)
                {
                    return(false);
                }

                if (targetTile.Tile.GetFixtureAtLayer(FixtureLayers.Furniture) != null)
                {
                    return(false);
                }

                return(true);
            }

            return(false);
        }
Beispiel #6
0
        public bool CanInteract(InteractionEvent interactionEvent)
        {
            // Check whether the object is in range
            if (!InteractionExtensions.RangeCheck(interactionEvent))
            {
                return(false);
            }

            // Confirm that there is an entity doing this interaction
            Entity entity = interactionEvent.Source.GetEntity();

            if (entity == null)
            {
                return(false);
            }

            if (interactionEvent.Target is IGameObjectProvider target)
            {
                // Check that the entity is actually capable of interacting with the target
                if (entity.CanInteract(target.GameObject) && IsFirstContainerOpenable(target))
                {
                    return(target.GameObject.GetComponent <Animator>() != null);
                }
            }
            return(false);
        }
        public bool CanInteract(InteractionEvent interactionEvent)
        {
            if (RangeCheck && !InteractionExtensions.RangeCheck(interactionEvent))
            {
                return(false);
            }

            var provider = interactionEvent.Source as IGameObjectProvider;

            if (provider == null)
            {
                return(false);
            }

            SubstanceContainer container = provider.GameObject.GetComponent <SubstanceContainer>();

            if (container == null)
            {
                return(false);
            }

            // You cannot dispense to a container that is already full.
            if (container.RemainingVolume < 0.01f)
            {
                return(false);
            }

            return(CanInteractCallback.Invoke(interactionEvent));
        }
Beispiel #8
0
 public bool CanInteract(InteractionEvent interactionEvent)
 {
     if (!InteractionExtensions.RangeCheck(interactionEvent))
     {
         return(false);
     }
     return((interactionEvent.Target as IGameObjectProvider)?.GameObject?.GetComponent <Container>() != null);
 }
Beispiel #9
0
 public bool CanInteract(InteractionEvent interactionEvent)
 {
     if (interactionEvent.Target is PepperSpray spray)
     {
         return(InteractionExtensions.RangeCheck(interactionEvent) && spray.CanSpray());
     }
     return(false);
 }
Beispiel #10
0
 public bool CanInteract(InteractionEvent interactionEvent)
 {
     if (RangeCheck && !InteractionExtensions.RangeCheck(interactionEvent))
     {
         return(false);
     }
     return(CanInteractCallback.Invoke(interactionEvent));
 }
Beispiel #11
0
        public bool CanInteract(InteractionEvent interactionEvent)
        {
            if (!(interactionEvent.Source.Parent is Hands))
            {
                return(false);
            }

            return(InteractionExtensions.RangeCheck(interactionEvent));
        }
Beispiel #12
0
 public bool CanInteract(InteractionEvent interactionEvent)
 {
     // if the interaction source's parent is not a hand we return false
     if (!(interactionEvent.Source.Parent is Hands))
     {
         return(false);
     }
     // and we do a range check just in case
     return(InteractionExtensions.RangeCheck(interactionEvent));
 }
Beispiel #13
0
 public bool CanInteract(InteractionEvent interactionEvent)
 {
     if (interactionEvent.Target is DisposalBin disposal)
     {
         if (!InteractionExtensions.RangeCheck(interactionEvent))
         {
             return(false);
         }
         return(true);
     }
     return(false);
 }
Beispiel #14
0
            public bool CanInteract(InteractionEvent interactionEvent)
            {
                if (interactionEvent.Target is ServiceBell bell)
                {
                    if (!InteractionExtensions.RangeCheck(interactionEvent))
                    {
                        return(false);
                    }
                    return(true);
                }

                return(false);
            }
Beispiel #15
0
            public bool CanInteract(InteractionEvent interactionEvent)
            {
                if (interactionEvent.Target is Bikehorn horn)
                {
                    if (!InteractionExtensions.RangeCheck(interactionEvent))
                    {
                        return(false);
                    }
                    return(!horn.IsHonking());
                }

                return(false);
            }
Beispiel #16
0
            public bool CanInteract(InteractionEvent interactionEvent)
            {
                if (interactionEvent.Target is Boombox boom)
                {
                    if (!InteractionExtensions.RangeCheck(interactionEvent))
                    {
                        return(false);
                    }
                    return(boom.radioOn);
                }

                return(false);
            }
Beispiel #17
0
        public bool CanInteract(InteractionEvent interactionEvent)
        {
            if (!InteractionExtensions.RangeCheck(interactionEvent))
            {
                return(false);
            }

            if (interactionEvent.Target is IGameObjectProvider target)
            {
                return(target.GameObject.GetComponent <Animator>() != null);
            }
            return(false);
        }
Beispiel #18
0
    private bool CanTurnOn(InteractionEvent interactionEvent)
    {
        if (!InteractionExtensions.RangeCheck(interactionEvent))
        {
            return(false);
        }

        if (storageContainer != null && storageContainer.IsOpen())
        {
            return(false);
        }

        return(!isOn);
    }
Beispiel #19
0
        public virtual bool CanInteract(InteractionEvent interactionEvent)
        {
            if (!InteractionExtensions.RangeCheck(interactionEvent))
            {
                return(false);
            }

            if (interactionEvent.Source.Parent is Hands hands && interactionEvent.Target is IGameObjectProvider target)
            {
                return(hands.GetItemInHand() != null && CanStore(target.GameObject));
            }

            return(false);
        }
Beispiel #20
0
        public override bool CanInteract(InteractionEvent interactionEvent)
        {
            // Range check
            if (!InteractionExtensions.RangeCheck(interactionEvent))
            {
                return(false);
            }

            // easy access to shit
            GameObject source = interactionEvent.Source.GetComponentInTree <Entity>().gameObject;
            GameObject target = interactionEvent.Target?.GetComponent <Transform>().gameObject;

            // I absolutely despise how this is done, please if you have the knowledge to clean this mess do it
            Consumable itemInHand   = interactionEvent.Source.GetComponent <Consumable>();
            Entity     entity       = source.GetComponent <Entity>();
            Entity     targetEntity = target?.GetComponent <Entity>();

            // if there's no targeted entity and no item in hand
            if (targetEntity == null && itemInHand == null)
            {
                return(false);
            }
            // if there's no targeted entity and the item in hand is not the target (interactions with itself require this check)
            if (targetEntity == null && itemInHand.gameObject != target)
            {
                return(false);
            }

            // if the target is yourself
            if (target == itemInHand)
            {
                Delay = 0f;
            }

            // if there's another entity as target and it's not the player
            if (targetEntity && target != source)
            {
                Verb  = "Feed";
                Delay = itemInHand.feedTime;
            }

            // Consumable checks (is playing audio, is empty)
            if (itemInHand.audio.isPlaying || itemInHand.content.TotalMoles <= 0)
            {
                return(false);
            }


            return(true);
        }
Beispiel #21
0
        public override bool CanInteract(InteractionEvent interactionEvent)
        {
            // easy access to shit
            GameObject source = interactionEvent.Source.GetComponentInTree <Creature>().gameObject;
            GameObject target = interactionEvent.Target?.GetComponent <Transform>().gameObject;

            // I absolutely despise how this is done, please if you have the knowledge to clean this mess do it
            Consumable itemInHand     = source.GetComponentInChildren <Hands>().GetItemInHand()?.GetComponent <Consumable>();
            Creature   creature       = source.GetComponent <Creature>();
            Creature   targetCreature = target?.GetComponent <Creature>();

            Debug.Log("source:  " + source.name + " target: " + target?.name + " item: " + itemInHand?.gameObject.name);

            // if there's no targeted creature and no item in hand
            if (targetCreature == null && itemInHand == null)
            {
                return(false);
            }
            // if there's no targeted creature and the item in hand is not the target (interactions with itself require this check)
            if (targetCreature == null && itemInHand.gameObject != target)
            {
                return(false);
            }

            // if the target is yourself
            if (target == itemInHand)
            {
                Delay = 0f;
            }

            // if there's another creature as target and it's not the player
            if (targetCreature && target != source)
            {
                Verb  = "Feed";
                Delay = itemInHand.feedTime;
            }

            // Range check
            if (!InteractionExtensions.RangeCheck(interactionEvent))
            {
                // Consumable checks (is playing audio, is empty)
                if (!itemInHand.audio.isPlaying && itemInHand.content.CurrentVolume > 0)
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #22
0
    private bool CanTurnOn(InteractionEvent interactionEvent)
    {
        if (!InteractionExtensions.RangeCheck(interactionEvent))
        {
            return(false);
        }

        // Can't be turned on if the door is open, we might add a hacking thing to bypass this later
        if (storageContainer != null && storageContainer.IsOpen())
        {
            return(false);
        }

        return(!isOn);
    }
Beispiel #23
0
        public virtual bool CanInteract(InteractionEvent interactionEvent)
        {
            if (!InteractionExtensions.RangeCheck(interactionEvent))
            {
                return(false);
            }

            var target = interactionEvent.Target.GetComponent <AttachedContainer>();

            if (interactionEvent.Source.Parent is Hands hands && target != null)
            {
                return(!hands.SelectedHandEmpty && CanStore(interactionEvent.GetSourceItem(), target));
            }
            return(false);
        }
    public bool CanInteract(InteractionEvent interactionEvent)
    {
        Item item = interactionEvent.Source as Item;

        if (item == null || item.ItemId != ItemId)
        {
            return(false);
        }

        if (!InteractionExtensions.RangeCheck(interactionEvent))
        {
            return(false);
        }

        return(true);
    }
Beispiel #25
0
        public virtual bool CanInteract(InteractionEvent interactionEvent)
        {
            if (!InteractionExtensions.RangeCheck(interactionEvent))
            {
                return(false);
            }

            // Will only appear if the current hand is empty and the container isn't empty
            var target = containerDescriptor.attachedContainer;

            if (interactionEvent.Source is Hands hands && target != null)
            {
                return(hands.SelectedHandEmpty && !target.Container.Empty);
            }

            return(false);
        }
Beispiel #26
0
    private bool CanTurnOn(InteractionEvent interactionEvent)
    {
        if (!InteractionExtensions.RangeCheck(interactionEvent))
        {
            return(false);
        }

        var open = animator.GetBool((Animator.StringToHash("Open")));

        if (open)
        {
            return(false);
        }


        // Can't be turned on if the door is open, we might add a hacking thing to bypass this later
        return(!isOn);
    }
Beispiel #27
0
        public override bool CanInteract(InteractionEvent interactionEvent)
        {
            if (!InteractionExtensions.RangeCheck(interactionEvent))
            {
                return(false);
            }

            if (interactionEvent.Source.Parent is Hands hands && interactionEvent.Target is IGameObjectProvider target)
            {
                Item handItem = hands.GetItemInHand();
                if (handItem != null && CanStore(target.GameObject))
                {
                    return(handItem.GetComponent <IChargeable>() != null);
                }
            }

            return(false);
        }
Beispiel #28
0
        public bool CanInteract(InteractionEvent interactionEvent)
        {
            if (interactionEvent.Target is IGameObjectProvider targetBehaviour && interactionEvent.Source is Hands hands)
            {
                if (!hands.SelectedHandEmpty)
                {
                    return(false);
                }

                Item item = targetBehaviour.GameObject.GetComponent <Item>();
                if (item == null)
                {
                    return(false);
                }

                return(InteractionExtensions.RangeCheck(interactionEvent) && !item.InContainer());
            }

            return(false);
        }
Beispiel #29
0
        public bool Start(InteractionEvent interactionEvent, InteractionReference reference)
        {
            if (!InteractionExtensions.RangeCheck(interactionEvent))
            {
                return(false);
            }

            if (!(interactionEvent.Target is IIgnitable ignitable))
            {
                return(false);
            }

            if (ignitable.Lit)
            {
                ignitable.Extinguish();
            }
            else
            {
                ignitable.Ignite();
            }
            return(false);
        }
Beispiel #30
0
        public override bool CanInteract(InteractionEvent interactionEvent)
        {
            GameObject target = (interactionEvent.Target as IGameObjectProvider)?.GameObject;

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

            if (!InteractionExtensions.RangeCheck(interactionEvent))
            {
                return(false);
            }

            // Needs to be used on tile
            TileObject tileObject = target.GetComponentInParent <TileObject>();

            if (tileObject == null || tileObject.Tile.turf == null)
            {
                return(false);
            }

            Turf turf = tileObject.Tile.turf;

            // Check if welder is on
            if ((interactionEvent.Source as IToggleable)?.GetState() == false)
            {
                return(false);
            }

            // Check if turf is in dict
            if (!TurfReinforceList.ContainsKey(turf) && !TurfReinforceList.ContainsValue(turf))
            {
                return(false);
            }

            return(true);
        }