Esempio n. 1
0
        public static bool Prefix(ExosuitClawArm __instance)
        {
            Exosuit componentInParent = __instance.GetComponentInParent <Exosuit>();

            if (componentInParent.GetActiveTarget())
            {
                Pickupable pickupable = componentInParent.GetActiveTarget().GetComponent <Pickupable>();
                PickPrefab component  = componentInParent.GetActiveTarget().GetComponent <PickPrefab>();
                if (pickupable != null && pickupable.isPickupable && componentInParent.storageContainer.container.HasRoomFor(pickupable))
                {
                    NitroxServiceLocator.LocateService <Item>().PickedUp(pickupable.gameObject, pickupable.GetTechType());
                }
                else if (component != null)
                {
                    Log.Debug("Delete Pickprefab for exosuit claw arm");
                    NitroxServiceLocator.LocateService <Item>().PickedUp(component.gameObject, component.pickTech);
                }
            }
            return(true);
        }
Esempio n. 2
0
        private bool TryUse(out float cooldownDuration)
        {
            if (Time.time - timeUsed >= cooldownTime)
            {
                Pickupable pickupable = null;
                PickPrefab x          = null;

                GameObject activeTarget = Exosuit.GetActiveTarget();

                if (activeTarget)
                {
                    pickupable = activeTarget.GetComponent <Pickupable>();
                    x          = activeTarget.GetComponent <PickPrefab>();
                }
                if (pickupable != null && pickupable.isPickupable)
                {
                    if (Exosuit.storageContainer.container.HasRoomFor(pickupable))
                    {
                        animator.SetTrigger("use_tool");
                        cooldownTime            = (cooldownDuration = cooldownPickup);
                        shownNoRoomNotification = false;
                        return(true);
                    }
                    if (!shownNoRoomNotification)
                    {
                        ErrorMessage.AddMessage(Language.main.Get("ContainerCantFit"));
                        shownNoRoomNotification = true;
                    }
                }
                else
                {
                    if (x != null)
                    {
                        animator.SetTrigger("use_tool");
                        cooldownTime = (cooldownDuration = cooldownPickup);
                        return(true);
                    }
                    animator.SetTrigger("bash");
                    cooldownTime = (cooldownDuration = cooldownPunch);
                    fxControl.Play(0);
                    return(true);
                }
            }
            cooldownDuration = 0f;
            return(false);
        }
Esempio n. 3
0
        public void OnPickup()
        {
            GameObject activeTarget = Exosuit.GetActiveTarget();

            if (activeTarget)
            {
                Pickupable pickupable = activeTarget.GetComponent <Pickupable>();
                PickPrefab component  = activeTarget.GetComponent <PickPrefab>();

                bool hasRoomForItem = Exosuit.storageContainer.container.HasRoomFor(pickupable);

                if (pickupable != null && pickupable.isPickupable && hasRoomForItem)
                {
                    pickupable = pickupable.Initialize();
                    InventoryItem item = new InventoryItem(pickupable);
                    Exosuit.storageContainer.container.UnsafeAdd(item);
                    Utils.PlayFMODAsset(pickupSound, front, 5f);
                }
                else if (component != null && component.AddToContainer(Exosuit.storageContainer.container))
                {
                    component.SetPickedUp();
                }
            }
        }