public void ToggleItemViewMat(InventoryItemView iiv)
 {
     if (iiv.NormalMaterial)
     {
         Material material = this._defaultMaterial;
         for (int i = 0; i < this._bonuses.Length; i++)
         {
             if (iiv.ActiveBonus == this._bonuses[i]._bonusToActivate)
             {
                 material = this._bonuses[i]._material;
                 break;
             }
         }
         if (!iiv.NormalMaterial.Equals(material))
         {
             iiv.NormalMaterial = material;
             Renderer component = iiv.GetComponent <Renderer>();
             if (component && !component.sharedMaterial.Equals(material))
             {
                 component.sharedMaterial = material;
             }
         }
         return;
     }
 }
Exemple #2
0
 private void RemovedMultiView(InventoryItemView view)
 {
     if (this._multiViews.Contains(view))
     {
         this._multiViews.Remove(view);
         UnityEngine.Object.Destroy(view.gameObject);
     }
 }
Exemple #3
0
 private void BubbleDownMultiview(InventoryItemView iiv)
 {
     if (this._multiViews.Contains(iiv))
     {
         this._multiViews.Remove(iiv);
         this._multiViews.Insert(0, iiv);
     }
 }
Exemple #4
0
        private void SpawnView(ItemStorage.InventoryItemX iix)
        {
            InventoryItemView inventoryItemView = LocalPlayer.Inventory.InventoryItemViewsCache[iix._itemId][0];
            Renderer          component         = inventoryItemView.GetComponent <Renderer>();
            Vector3           vector;
            Quaternion        localRotation;

            if (component)
            {
                if (inventoryItemView._modelOffsetTr)
                {
                    vector        = inventoryItemView._modelOffsetTr.localPosition;
                    localRotation = inventoryItemView._modelOffsetTr.localRotation;
                }
                else
                {
                    vector        = component.bounds.center;
                    vector.y      = component.bounds.min.y;
                    vector        = inventoryItemView.transform.position - vector;
                    localRotation = inventoryItemView.transform.localRotation;
                }
            }
            else
            {
                vector        = Vector3.zero;
                vector.y      = 0.02f;
                localRotation = inventoryItemView.transform.localRotation;
            }
            Vector3 vector2 = Vector3.zero;

            vector2 += vector;
            InventoryItemView inventoryItemView2 = UnityEngine.Object.Instantiate <InventoryItemView>(inventoryItemView);
            GameObject        gameObject         = inventoryItemView2.gameObject;

            gameObject.SetActive(true);
            gameObject.transform.localScale    = inventoryItemView.transform.lossyScale;
            gameObject.transform.parent        = this._contentRoot.transform;
            gameObject.transform.localRotation = localRotation;
            gameObject.transform.localPosition = vector2;
            gameObject.layer = this.GetLayerNum();
            Debug.DrawLine(gameObject.transform.position, gameObject.transform.position - gameObject.transform.TransformDirection(vector), Color.red, 20f);
            if (this._interactiveViews)
            {
                inventoryItemView2.Init();
                inventoryItemView2._isCraft           = true;
                inventoryItemView2._canEquipFromCraft = false;
                inventoryItemView2.Properties.Copy(iix._properties);
            }
            else
            {
                UnityEngine.Object.Destroy(inventoryItemView2);
                UnityEngine.Object.Destroy(gameObject.GetComponent <Collider>());
            }
        }
        private void SpawnView(int itemId)
        {
            InventoryItemView inventoryItemView = LocalPlayer.Inventory.InventoryItemViewsCache[itemId][0];
            Renderer          component         = inventoryItemView.GetComponent <Renderer>();
            Vector3           vector;

            if (component)
            {
                vector   = component.bounds.center;
                vector.y = component.bounds.min.y;
                vector   = inventoryItemView.transform.position - vector;
            }
            else
            {
                vector   = Vector3.zero;
                vector.y = 0.02f;
            }
            Vector3 vector2 = new Vector3(UnityEngine.Random.Range(this._xRange.x, this._xRange.y), UnityEngine.Random.Range(this._yRange.x, this._yRange.y), UnityEngine.Random.Range(this._zRange.x, this._zRange.y));

            vector2  = Vector3.zero;
            vector2 += vector;
            InventoryItemView inventoryItemView2 = UnityEngine.Object.Instantiate <InventoryItemView>(inventoryItemView);
            GameObject        gameObject         = inventoryItemView2.gameObject;

            gameObject.SetActive(true);
            gameObject.transform.localScale    = inventoryItemView.transform.lossyScale;
            gameObject.transform.parent        = this._contentRoot.transform;
            gameObject.transform.localRotation = inventoryItemView.transform.localRotation;
            gameObject.transform.localPosition = vector2;
            gameObject.layer = this.GetLayerNum();
            gameObject.AddComponent <AmplifyMotionObject>();
            Debug.DrawLine(gameObject.transform.position, gameObject.transform.position - gameObject.transform.TransformDirection(vector), Color.red, 20f);
            if (this._interactiveViews)
            {
                inventoryItemView2._isCraft = true;
                inventoryItemView2.Init();
            }
            else
            {
                UnityEngine.Object.Destroy(inventoryItemView2);
                UnityEngine.Object.Destroy(gameObject.GetComponent <Collider>());
            }
        }
Exemple #6
0
 public void ToggleItemViewMat(InventoryItemView iiv)
 {
     if (iiv.ItemCache != null)
     {
         Material material = this._defaultMaterial;
         for (int i = 0; i < this._bonuses.Length; i++)
         {
             if (iiv.ActiveBonus == this._bonuses[i]._bonusToActivate)
             {
                 material = this._bonuses[i]._material;
                 break;
             }
         }
         if (iiv._renderers[0]._defaultMaterial != material)
         {
             iiv._renderers[0]._defaultMaterial = material;
             iiv.Highlight(false);
         }
         return;
     }
 }
 public void SetAnyMultiViewAmount(InventoryItemView source, Transform parent, int amount, WeaponStatUpgrade.Types activeBonus)
 {
     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 = (activeBonus != (WeaponStatUpgrade.Types)(-2)) ? this.AmountOfMultiviewWithBonus(source._itemId, activeBonus) : this._multiViews.Count;
         while (i > num)
         {
             num++;
             this.SpawnAnyMultiview(source, parent, false, activeBonus);
         }
         if (i < num)
         {
             this.RemovedMultiViews(source._itemId, num - i, activeBonus);
         }
     }
 }
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);
         }
     }
 }
Exemple #9
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 #10
0
        public bool BelongWith(IVirtualCursorSnapNodeGroupTester group)
        {
            InventoryItemView inventoryItemView = group as InventoryItemView;

            return(inventoryItemView && inventoryItemView._itemId == this._itemId && this.Properties.Match(inventoryItemView.Properties) && this._isCraft == inventoryItemView._isCraft);
        }
Exemple #11
0
 public void ApplyUpgradeRecipe(InventoryItemView craftView, Receipe receipe, int amount)
 {
     this._currentIngredientIndex = 0;
     this._recipe = receipe;
     this._craftView = craftView;
     this._currentReceiver = null;
     this._upPositionV = craftView.transform.position + this._upPosition.parent.TransformDirection(new Vector3(0.5f, -1.05f, 0f));
     this._upRotation = craftView.transform.rotation * Quaternion.Euler(30f, 0f, 0f);
     this._receivers = this._craftView.GetAllComponentsInChildren<UpgradeViewReceiver>();
     this._downPosition = this._craftView.transform.position;
     this._downRotation = this._craftView.transform.rotation;
     this._state = UpgradeCog.States.MoveUp;
     this._totalUpgrades = amount;
     this._implantsDone = 0;
     this._totalIngredientImplants = 0;
     this._craftingCog.enabled = false;
     base.enabled = true;
     Scene.HudGui.ShowValidCraftingRecipes(null);
     Scene.HudGui.ShowUpgradesDistribution(this._recipe._productItemID, this._recipe._ingredients[1]._itemID, 1);
 }
Exemple #12
0
 private void Update()
 {
     if (this._player.CurrentView == PlayerInventory.PlayerViews.World)
     {
         if (!LocalPlayer.Create.Grabber.Target && LocalPlayer.MainCamTr.forward.y < -0.85f)
         {
             WeaponStatUpgrade.Types types = this.NextAvailableArrowBonus(this.BowItemView.ActiveBonus);
             if (types != this.BowItemView.ActiveBonus)
             {
                 this._showRotateArrowType = true;
                 if (!Scene.HudGui.ToggleArrowBonusIcon.activeSelf)
                 {
                     Scene.HudGui.ToggleArrowBonusIcon.SetActive(true);
                 }
                 if (TheForest.Utils.Input.GetButtonDown("Rotate"))
                 {
                     LocalPlayer.Sfx.PlayWhoosh();
                     this.SetActiveBowBonus(types);
                     Scene.HudGui.ToggleArrowBonusIcon.SetActive(false);
                 }
             }
             else if (this._showRotateArrowType)
             {
                 this._showRotateArrowType = false;
                 Scene.HudGui.ToggleArrowBonusIcon.SetActive(false);
             }
         }
         else if (this._showRotateArrowType)
         {
             this._showRotateArrowType = false;
             Scene.HudGui.ToggleArrowBonusIcon.SetActive(false);
         }
         if (this.CurrentArrowItemView.ActiveBonus != this.BowItemView.ActiveBonus)
         {
             LocalPlayer.Inventory.SortInventoryViewsByBonus(this.CurrentArrowItemView, this.BowItemView.ActiveBonus, false);
             if (this.CurrentArrowItemView.ActiveBonus != this.BowItemView.ActiveBonus)
             {
                 this.SetActiveBowBonus(this.CurrentArrowItemView.ActiveBonus);
             }
             this.UpdateArrowRenderer();
         }
         WeaponStatUpgrade.Types activeBonus = this.CurrentArrowItemView.ActiveBonus;
         bool canSetArrowOnFire = this.CanSetArrowOnFire;
         if (canSetArrowOnFire && TheForest.Utils.Input.GetButton("Lighter"))
         {
             Scene.HudGui.SetDelayedIconController(this);
         }
         else
         {
             Scene.HudGui.UnsetDelayedIconController(this);
         }
         if (canSetArrowOnFire)
         {
             if (TheForest.Utils.Input.GetButtonAfterDelay("Lighter", 0.5f))
             {
                 this.SetArrowOnFire();
             }
         }
         else if (activeBonus != WeaponStatUpgrade.Types.BurningAmmo && this._activeAmmoBonus != activeBonus)
         {
             this.SetActiveArrowBonus(activeBonus);
         }
         if (!this._lightingArrow)
         {
             if (TheForest.Utils.Input.GetButtonDown("Fire1") && !LocalPlayer.Animator.GetBool("ballHeld"))
             {
                 LocalPlayer.Inventory.CancelNextChargedAttack = false;
                 if (this._aimingReticle)
                 {
                     this._aimingReticle.enabled = true;
                 }
                 this.ReArm();
                 this._animator.SetBoolReflected("drawBowBool", true);
                 this._bowAnimator.SetBoolReflected("drawBool", true);
                 this._bowAnimator.SetBoolReflected("bowFireBool", false);
                 this._animator.SetBoolReflected("bowFireBool", false);
                 this._player.StashLeftHand();
                 this._animator.SetBoolReflected("checkArms", false);
                 this._animator.SetBoolReflected("onHand", false);
             }
             else if (TheForest.Utils.Input.GetButtonDown("AltFire") || LocalPlayer.Animator.GetBool("ballHeld"))
             {
                 LocalPlayer.AnimControl.animEvents.enableSpine();
                 this._player.CancelNextChargedAttack = true;
                 this._animator.SetBool("drawBowBool", false);
                 this._bowAnimator.SetBool("drawBool", false);
                 this.ShutDown(false);
             }
             if (TheForest.Utils.Input.GetButtonUp("Fire1") || LocalPlayer.Animator.GetBool("ballHeld"))
             {
                 this._currentAmmo = this.CurrentArrowItemView;
                 if (this._aimingReticle)
                 {
                     this._aimingReticle.enabled = false;
                 }
                 base.CancelInvoke();
                 if (this._animator.GetCurrentAnimatorStateInfo(1).tagHash == this._attackHash && this._animator.GetBool("drawBowBool") && !LocalPlayer.Animator.GetBool("ballHeld"))
                 {
                     this._animator.SetBoolReflected("bowFireBool", true);
                     this._bowAnimator.SetBoolReflected("bowFireBool", true);
                     this._animator.SetBoolReflected("drawBowBool", false);
                     this._bowAnimator.SetBoolReflected("drawBool", false);
                     LocalPlayer.TargetFunctions.sendPlayerAttacking();
                     this.InitReArm();
                 }
                 else if (LocalPlayer.Animator.GetBool("ballHeld"))
                 {
                     LocalPlayer.AnimControl.animEvents.enableSpine();
                     this._player.CancelNextChargedAttack = true;
                     this._animator.SetBoolReflected("drawBowBool", false);
                     this._bowAnimator.SetBoolReflected("drawBool", false);
                     this.ShutDown(false);
                 }
                 else
                 {
                     this.ShutDown(true);
                 }
             }
             else if (this._nextReArm < Time.time)
             {
                 this.ReArm();
             }
         }
         else
         {
             LocalPlayer.Inventory.CancelNextChargedAttack = true;
         }
     }
 }
 private void RemovedMultiView(InventoryItemView view)
 {
     if (this._multiViews.Contains(view))
     {
         this._multiViews.Remove(view);
         UnityEngine.Object.Destroy(view.gameObject);
     }
 }
 private void BubbleDownMultiview(InventoryItemView iiv)
 {
     if (this._multiViews.Contains(iiv))
     {
         this._multiViews.Remove(iiv);
         this._multiViews.Insert(0, iiv);
     }
 }
 public void SpawnAnyMultiview(InventoryItemView source, Transform parent, bool randomRotation, WeaponStatUpgrade.Types activeBonus)
 {
     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 = (InventoryItemView)UnityEngine.Object.Instantiate(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();
     if (activeBonus != (WeaponStatUpgrade.Types)(-2))
     {
         inventoryItemView.ActiveBonus = activeBonus;
     }
     this._multiViews.Add(inventoryItemView);
 }
 public void SetAnyMultiViewAmount(InventoryItemView source, Transform parent, int amount, WeaponStatUpgrade.Types activeBonus)
 {
     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 = (activeBonus != (WeaponStatUpgrade.Types)(-2)) ? this.AmountOfMultiviewWithBonus(source._itemId, activeBonus) : this._multiViews.Count;
         while (i > num)
         {
             num++;
             this.SpawnAnyMultiview(source, parent, false, activeBonus);
         }
         if (i < num)
         {
             this.RemovedMultiViews(source._itemId, num - i, activeBonus);
         }
     }
 }