Exemple #1
0
 public int AmountOfMultiviewWithoutProperties(int itemId, ItemProperties properties)
 {
     if (this._allowMultiView && this._multiViews != null)
     {
         int num = 0;
         for (int i = this._multiViews.Count - 1; i >= 0; i--)
         {
             if (this._multiViews[i]._itemId == itemId && !this._multiViews[i].Properties.Match(properties))
             {
                 num++;
             }
         }
         return(num);
     }
     return(0);
 }
Exemple #2
0
 public override void Copy(ItemProperties other)
 {
     if (other != ItemProperties.Any)
     {
         base.ActiveBonus      = other.ActiveBonus;
         this.ActiveBonusValue = other.ActiveBonusValue;
         DecayingInventoryItemView.DecayingItemProperties decayingItemProperties = other as DecayingInventoryItemView.DecayingItemProperties;
         if (decayingItemProperties != null)
         {
             this._state         = decayingItemProperties._state;
             this._decayDoneTime = decayingItemProperties._decayDoneTime;
             this.StateChanged(this._state);
         }
     }
     else
     {
         base.ActiveBonus      = (WeaponStatUpgrade.Types)(-1);
         this.ActiveBonusValue = 0f;
     }
 }
Exemple #3
0
 public void SetMultiViewAmount(int amount, ItemProperties properties)
 {
     if (this._allowMultiView)
     {
         int i = Mathf.Clamp(amount, 0, this._maxMultiViews);
         if (this._multiViews == null)
         {
             this._multiViews = new List <InventoryItemView>();
         }
         base.gameObject.SetActive(true);
         int num = (properties != ItemProperties.Any) ? this.AmountOfMultiviewWithProperties(this._itemId, properties) : this._multiViews.Count;
         while (i > num)
         {
             num++;
             this.SpawnAnyMultiview(this, base.transform.parent, true, properties);
         }
         if (i < num)
         {
             this.RemovedMultiViews(this._itemId, num - i, properties, false);
         }
         base.gameObject.SetActive(false);
     }
 }
Exemple #4
0
        public void RemovedMultiViews(int itemId, int amount, ItemProperties properties, bool returnToInventory = false)
        {
            if (this._multiViews == null)
            {
                this._multiViews = new List <InventoryItemView>();
            }
            int num = this._multiViews.FindIndex((InventoryItemView mv) => mv._itemId == itemId && mv.Properties.Match(properties));

            while (num >= 0 && amount > 0)
            {
                amount--;
                if (this._multiViews[num])
                {
                    if (returnToInventory)
                    {
                        LocalPlayer.Inventory.AddItem(this._multiViews[num]._itemId, 1, true, true, this._multiViews[num].Properties);
                    }
                    this._multiViews[num].OnMultiviewDespawning();
                    UnityEngine.Object.Destroy(this._multiViews[num].gameObject);
                }
                this._multiViews.RemoveAt(num);
                num = this._multiViews.FindIndex((InventoryItemView mv) => mv._itemId == itemId && mv.Properties.Match(properties));
            }
        }
Exemple #5
0
 public override bool Match(ItemProperties other)
 {
     return(other == ItemProperties.Any || !(other is DecayingInventoryItemView.DecayingItemProperties) || other.ActiveBonus == (WeaponStatUpgrade.Types)(-2) || (base.ActiveBonus == other.ActiveBonus && this._state == ((DecayingInventoryItemView.DecayingItemProperties)other)._state));
 }
Exemple #6
0
 public virtual bool Match(ItemProperties other)
 {
     return(other == ItemProperties.Any || other.ActiveBonus == (WeaponStatUpgrade.Types)(-2) || (this.ActiveBonus == other.ActiveBonus && Mathf.Approximately(this.ActiveBonusValue, other.ActiveBonusValue)));
 }
Exemple #7
0
        public void SpawnAnyMultiview(InventoryItemView source, Transform parent, bool randomRotation, ItemProperties properties)
        {
            Vector3  euler     = new Vector3(0f, (float)UnityEngine.Random.Range(-50, 50), 0f);
            bool     flag      = source.Equals(this);
            Collider component = source.GetComponent <Collider>();
            Vector3  size;

            if (component is BoxCollider)
            {
                size = ((BoxCollider)component).size;
            }
            else if (component is CapsuleCollider)
            {
                CapsuleCollider capsuleCollider = (CapsuleCollider)component;
                int             direction       = capsuleCollider.direction;
                if (direction != 0)
                {
                    if (direction != 1)
                    {
                        size = new Vector3(capsuleCollider.radius * 2f, capsuleCollider.radius * 2f, capsuleCollider.height);
                    }
                    else
                    {
                        size = new Vector3(capsuleCollider.radius * 2f, capsuleCollider.height, capsuleCollider.radius * 2f);
                    }
                }
                else
                {
                    size = new Vector3(capsuleCollider.height, capsuleCollider.radius * 2f, capsuleCollider.radius * 2f);
                }
            }
            else
            {
                size = component.bounds.size;
            }
            Vector3 vector = UnityEngine.Random.insideUnitSphere;

            if (!flag)
            {
                vector *= 3f;
            }
            if (size.x * 2f < size.z)
            {
                vector   /= 15f;
                vector   *= size.x * 0.75f;
                vector.x /= 2f;
            }
            else if (size.z * 2f < size.x)
            {
                vector   /= 15f;
                vector   *= size.z * 0.75f;
                vector.z /= 2f;
            }
            else
            {
                vector /= 8f;
                bool flag2 = size.z * 2f > size.y;
                bool flag3 = size.x * 2f > size.y;
                if (flag2 && !flag3)
                {
                    euler.z = (float)UnityEngine.Random.Range(-45, 45);
                }
                if (flag3 && !flag2)
                {
                    euler.x = (float)UnityEngine.Random.Range(-45, 45);
                }
            }
            vector.y = 0f;
            InventoryItemView inventoryItemView = UnityEngine.Object.Instantiate <InventoryItemView>(source, base.transform.position + vector, (!randomRotation) ? source.transform.rotation : (source.transform.rotation * Quaternion.Euler(euler)));

            inventoryItemView.transform.parent     = parent;
            inventoryItemView.transform.localScale = source.transform.localScale;
            inventoryItemView._isCraft             = true;
            inventoryItemView.MultiViewOwner       = this;
            inventoryItemView.enabled = true;
            inventoryItemView.gameObject.SetActive(true);
            inventoryItemView.Init();
            inventoryItemView.Highlight(false);
            inventoryItemView.OnMultiviewSpawned();
            if (properties != ItemProperties.Any)
            {
                inventoryItemView.Properties.Copy(properties);
            }
            if (this._bonusListener)
            {
                this._bonusListener.ToggleItemViewMat(inventoryItemView);
            }
            this._multiViews.Add(inventoryItemView);
        }
Exemple #8
0
 public void SetAnyMultiViewAmount(InventoryItemView source, Transform parent, int amount, ItemProperties properties, bool returnExtrasToInventory)
 {
     if (this._allowMultiView)
     {
         int i = Mathf.Clamp(amount, 0, this._maxMultiViews);
         if (this._multiViews == null)
         {
             this._multiViews = new List <InventoryItemView>();
         }
         base.gameObject.SetActive(true);
         int num = (properties != ItemProperties.Any) ? this.AmountOfMultiviewWithProperties(source._itemId, properties) : this._multiViews.Count;
         i -= this.AmountOfMultiviewWithProperties(source._itemId, ItemProperties.Any) - num;
         while (i > num)
         {
             num++;
             this.SpawnAnyMultiview(source, parent, false, properties);
         }
         if (i < num)
         {
             this.RemovedMultiViews(source._itemId, num - i, properties, returnExtrasToInventory);
         }
     }
 }
 public bool AddItem(int itemId, int amount, bool preventAutoEquip, bool fromCraftingCog, ItemProperties properties)
 {
     return(LocalPlayer.Inventory.AddItemNF(itemId, amount, preventAutoEquip, fromCraftingCog, properties));
 }