Esempio n. 1
0
    public void DetachHeavyObject(int index, bool destroy = false)
    {
        if (index < 0 || index >= this.m_Attached.Count)
        {
            return;
        }
        Transform transform = this.m_Attached.Keys.ElementAt(index);

        if (transform == null)
        {
            this.m_Attached.Remove(transform);
            return;
        }
        HeavyObject heavyObject = this.m_Attached[transform];

        Physics.IgnoreCollision(Player.Get().GetComponent <Collider>(), heavyObject.GetComponent <Collider>(), false);
        heavyObject.gameObject.transform.parent = null;
        heavyObject.OnItemDetachedFromHand();
        this.m_Attached.Remove(transform);
        if (destroy)
        {
            UnityEngine.Object.Destroy(heavyObject.gameObject);
        }
        else
        {
            heavyObject.transform.rotation = Player.Get().transform.rotation;
            Vector3 position = new Vector3(0.5f, 0.5f, 1.1f);
            position.x = System.Math.Max(0.5f, position.x);
            Vector3 a = Camera.main.ViewportToWorldPoint(position);
            heavyObject.transform.position = a + Vector3.up * (float)(index + 1) * 0.2f;
        }
    }
Esempio n. 2
0
    public bool AttachHeavyObject(HeavyObject ho)
    {
        if (!ho)
        {
            return(false);
        }
        Transform transform = this.FindFreeSlot();

        if (transform)
        {
            HeavyObject x = null;
            if (!this.m_Attached.TryGetValue(transform, out x) || x == null)
            {
                Physics.IgnoreCollision(Player.Get().m_Collider, ho.m_Collider, true);
                ho.transform.position          = transform.position;
                ho.transform.rotation          = transform.rotation;
                ho.gameObject.transform.parent = transform;
                transform.gameObject.tag       = this.m_AttachTag;
                this.m_Attached[transform]     = ho;
                ho.OnItemAttachedToHand();
                PlayerConditionModule.Get().GetDirtinessAdd(GetDirtyReason.HeavyObject, (HeavyObjectInfo)ho.m_Info);
                this.UpdatePhx();
                return(true);
            }
        }
        return(false);
    }
Esempio n. 3
0
 public override void OnExecute(TriggerAction.TYPE action)
 {
     base.OnExecute(action);
     if (action == TriggerAction.TYPE.Insert)
     {
         Item currentItem = Player.Get().GetCurrentItem(Hand.Right);
         if (currentItem && this.m_ItemID == currentItem.GetInfoID() && currentItem.m_Info.IsHeavyObject())
         {
             HeavyObject heavyObject = (HeavyObject)currentItem;
             if (heavyObject.m_Attached.Count > 0)
             {
                 this.Fulfill(false);
                 heavyObject.DetachHeavyObject(0, true);
                 return;
             }
             HeavyObjectController.Get().InsertToGhostSlot(this);
             return;
         }
         else
         {
             this.Fulfill(false);
             InventoryBackpack.Get().RemoveItem(this.m_ItemID, 1);
         }
     }
 }
Esempio n. 4
0
    private void RemoveItemFromHand()
    {
        HeavyObject heavyObject = (HeavyObject)Player.Get().GetCurrentItem(Hand.Right);

        if (heavyObject.m_Attached.Count > 0)
        {
            heavyObject.DetachHeavyObject(heavyObject.m_Attached.Count - 1, true);
            return;
        }
        Player.Get().DropItem(heavyObject);
        UnityEngine.Object.Destroy(heavyObject.gameObject);
    }
Esempio n. 5
0
    private bool AddItemToHand()
    {
        HeavyObject heavyObject = (HeavyObject)ItemsManager.Get().CreateItem(this.m_StoredItemId, false, Vector3.zero, Quaternion.identity);
        bool        flag        = heavyObject.PickUp(true);

        if (!flag)
        {
            UnityEngine.Object.Destroy(heavyObject.gameObject);
            this.m_NumItems++;
            this.UpdateVis();
            return(flag);
        }
        this.PlayInsertSound();
        return(flag);
    }
Esempio n. 6
0
    public override bool CanExecuteActions()
    {
        if (!base.CanExecuteActions())
        {
            return(false);
        }
        Item currentItem = Player.Get().GetCurrentItem(Hand.Right);

        if (!currentItem)
        {
            return(true);
        }
        HeavyObject heavyObject = null;

        if (currentItem.m_Info.IsHeavyObject())
        {
            heavyObject = (HeavyObject)currentItem;
        }
        return((!heavyObject || currentItem.m_Info.m_ID == this.m_Info.m_ID) && (!heavyObject || heavyObject.FindFreeSlot()));
    }
Esempio n. 7
0
    public void AttachHeavyObject(HeavyObject ho)
    {
        if (!ho)
        {
            return;
        }
        Transform transform = this.FindFreeSlot();

        if (transform)
        {
            HeavyObject x = null;
            if (!this.m_Attached.TryGetValue(transform, out x) || x == null)
            {
                Physics.IgnoreCollision(Player.Get().GetComponent <Collider>(), ho.GetComponent <Collider>(), true);
                ho.transform.position          = transform.position;
                ho.transform.rotation          = transform.rotation;
                ho.gameObject.transform.parent = transform;
                this.m_Attached[transform]     = ho;
                ho.OnItemAttachedToHand();
            }
        }
    }
Esempio n. 8
0
 protected override void Update()
 {
     base.Update();
     if (this.m_Item != this.GetCurrentItem())
     {
         this.Setup();
     }
     if (!this.m_Item)
     {
         return;
     }
     if (this.m_Item.m_Info.IsHeavyObject())
     {
         HeavyObject heavyObject = (HeavyObject)this.m_Item;
         this.m_HPBar.fillAmount = (float)(heavyObject.m_Attached.Count + 1) / (float)(heavyObject.m_NumObjectsToAttach + 1);
     }
     else
     {
         this.m_HPBar.fillAmount = this.m_Item.m_Info.m_Health / this.m_Item.m_Info.m_MaxHealth;
     }
     this.UpdateActions();
 }
Esempio n. 9
0
 private HeavyObject GetOrCreateHeavyObject()
 {
     return(_heavyObject ?? (_heavyObject = new HeavyObject()));
 }
Esempio n. 10
0
 public void Add(HeavyObject item)
 {
     container.Add(item);
 }