void Start() { player = target.GetComponent<FakeParent>().other.transform; playerMovement = player.gameObject.GetComponent<Movement>(); playerInfo = player.gameObject.GetComponent<PlayerInfo>(); thisCamera = GetComponent<Camera>(); targetParent = target.GetComponent<FakeParent>(); ops = player.gameObject.GetComponent<PlayerOptionsManager>(); UpdateVariables(); }
private void TransferItemView(Transform itemView, Transform parent, int itemId) { itemView.parent = parent; if (LocalPlayer.Inventory) { InventoryItemView inventoryItemView = LocalPlayer.Inventory.InventoryItemViewsCache[itemId][0]; FakeParent component = inventoryItemView._held.GetComponent <FakeParent>(); itemView.transform.localPosition = ((!component) ? inventoryItemView._held.transform.localPosition : component.RealLocalPosition); itemView.transform.localRotation = ((!component) ? inventoryItemView._held.transform.localRotation : component.RealLocalRotation); } else { itemView.localPosition = Vector3.zero; itemView.localRotation = Quaternion.identity; } }
private void SpawnEquipmentItemView(Transform parent, int itemId) { if (LocalPlayer.Inventory) { Reparent.Locked = true; InventoryItemView inventoryItemView = LocalPlayer.Inventory.InventoryItemViewsCache[itemId][0]; GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>((!inventoryItemView.ItemCache._throwerProjectilePrefab) ? inventoryItemView._held : inventoryItemView.ItemCache._throwerProjectilePrefab.gameObject); FakeParent component = inventoryItemView._held.GetComponent <FakeParent>(); parent.gameObject.SetActive(true); gameObject.transform.parent = parent; gameObject.transform.localPosition = ((!component) ? inventoryItemView._held.transform.localPosition : component.RealLocalPosition); gameObject.transform.localRotation = ((!component) ? inventoryItemView._held.transform.localRotation : component.RealLocalRotation); gameObject.layer = base.gameObject.layer; gameObject.SetActive(true); if (!inventoryItemView.ItemCache._throwerProjectilePrefab) { IEnumerator enumerator = gameObject.transform.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; Transform transform = (Transform)obj; if (transform.name.Contains("collide") || transform.GetComponent <weaponInfo>()) { UnityEngine.Object.Destroy(transform.gameObject); } } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } foreach (MonoBehaviour obj2 in gameObject.GetComponents <MonoBehaviour>()) { UnityEngine.Object.Destroy(obj2); } } Reparent.Locked = false; } }
private void SpawnEquipment(int itemId, int slotId) { Reparent.Locked = true; InventoryItemView inventoryItemView = LocalPlayer.Inventory.InventoryItemViewsCache[itemId][0]; GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(inventoryItemView._held); FakeParent component = inventoryItemView._held.GetComponent <FakeParent>(); gameObject.transform.parent = this._slots[slotId]; gameObject.transform.localPosition = ((!component) ? inventoryItemView._held.transform.localPosition : component.RealLocalPosition); gameObject.transform.localRotation = ((!component) ? inventoryItemView._held.transform.localRotation : component.RealLocalRotation); gameObject.layer = base.gameObject.layer; Animator componentInChildren = gameObject.GetComponentInChildren <Animator>(); if (componentInChildren) { UnityEngine.Object.Destroy(componentInChildren); } this.CleanUpComponents(gameObject.transform); gameObject.SetActive(true); foreach (MonoBehaviour obj in gameObject.GetComponentsInChildren <MonoBehaviour>()) { UnityEngine.Object.Destroy(obj); } Reparent.Locked = false; if (inventoryItemView._materialWhenAttachedToPack != null) { MeshRenderer meshRenderer = gameObject.GetComponentInChildren <MeshRenderer>(); if (!meshRenderer) { meshRenderer = gameObject.GetComponent <MeshRenderer>(); } if (meshRenderer) { Material[] sharedMaterials = meshRenderer.sharedMaterials; sharedMaterials[0] = inventoryItemView._materialWhenAttachedToPack; meshRenderer.sharedMaterials = sharedMaterials; } } }
//RANGED MOD CHANGES--------------------------------------------------- protected override void FireRangedWeapon() { InventoryItemView inventoryItemView = _equipmentSlots[0]; TheForest.Items.Item itemCache = inventoryItemView.ItemCache; bool flag = itemCache._maxAmount < 0; bool flag2 = false; if (flag || RemoveItem(itemCache._ammoItemId, 1, false, true)) { InventoryItemView inventoryItemView2 = _inventoryItemViewsCache[itemCache._ammoItemId][0]; TheForest.Items.Item itemCache2 = inventoryItemView2.ItemCache; FakeParent component = inventoryItemView2._held.GetComponent <FakeParent>(); if (UseAltWorldPrefab) { Debug.Log("Firing " + itemCache._name + " with '" + inventoryItemView.ActiveBonus + "' ammo (alt=" + UseAltWorldPrefab + ")"); } GameObject gameObject = (!(bool)component || component.gameObject.activeSelf) ? Object.Instantiate(itemCache2._ammoPrefabs.GetPrefabForBonus(inventoryItemView.ActiveBonus, true).gameObject, inventoryItemView2._held.transform.position, inventoryItemView2._held.transform.rotation) : Object.Instantiate(itemCache2._ammoPrefabs.GetPrefabForBonus(inventoryItemView.ActiveBonus, true).gameObject, component.RealPosition, component.RealRotation); gameObject.transform.localScale *= ModdedPlayer.instance.ProjectileSizeRatio; if ((bool)gameObject.GetComponent <Rigidbody>()) { if (itemCache.MatchRangedStyle(TheForest.Items.Item.RangedStyle.Shoot)) { gameObject.GetComponent <Rigidbody>().AddForce(gameObject.transform.TransformDirection(Vector3.forward * (0.016666f / Time.fixedDeltaTime) * ModdedPlayer.instance.ProjectileSpeedRatio * itemCache._projectileThrowForceRange), ForceMode.VelocityChange); } else { float num = Time.time - _weaponChargeStartTime; if (ForestVR.Enabled) { gameObject.GetComponent <Rigidbody>().AddForce(inventoryItemView2._held.transform.up * ModdedPlayer.instance.ProjectileSpeedRatio * itemCache._projectileThrowForceRange); } else { gameObject.GetComponent <Rigidbody>().AddForce(inventoryItemView2._held.transform.up * ModdedPlayer.instance.ProjectileSpeedRatio * Mathf.Clamp01(num / itemCache._projectileMaxChargeDuration) * (0.016666f / Time.fixedDeltaTime) * itemCache._projectileThrowForceRange); } if (LocalPlayer.Inventory.HasInSlot(TheForest.Items.Item.EquipmentSlot.RightHand, LocalPlayer.AnimControl._bowId)) { gameObject.SendMessage("setCraftedBowDamage", SendMessageOptions.DontRequireReceiver); } } inventoryItemView._held.SendMessage("OnAmmoFired", gameObject, SendMessageOptions.DontRequireReceiver); } if (itemCache._attackReleaseSFX != 0) { LocalPlayer.Sfx.SendMessage(itemCache._attackReleaseSFX.ToString(), SendMessageOptions.DontRequireReceiver); } Mood.HitRumble(); } else { flag2 = true; if (itemCache._dryFireSFX != 0) { LocalPlayer.Sfx.SendMessage(itemCache._dryFireSFX.ToString(), SendMessageOptions.DontRequireReceiver); } } if (flag) { UnequipItemAtSlot(itemCache._equipmentSlot, false, false, flag); } else { ToggleAmmo(inventoryItemView, true); } _weaponChargeStartTime = 0f; SetReloadDelay((!flag2) ? itemCache._reloadDuration : itemCache._dryFireReloadDuration); _isThrowing = false; }
//RANGED MOD CHANGES--------------------------------------------------- // public override void Start() // { // base.Start(); // string log = ""; // foreach (var list in _inventoryItemViewsCache) // { // foreach (var item in list.Value) // { // try // { //string s = "• _inventoryItemViewsCache[" + list.Key + "][" + list.Value + "]\n" + // "\tItem: " + item.ItemCache._name + " " + item.ItemCache._id; // s += "\n\tHeld Gameobject" + item._held.name + "\n\n"; // log += s; // } // catch (System.Exception) // { // } // } // } // ModAPI.Log.Write(log); // } protected override void FireRangedWeapon() { if (ModSettings.IsDedicated) { return; } InventoryItemView inventoryItemView = _equipmentSlots[0]; TheForest.Items.Item itemCache = inventoryItemView.ItemCache; bool flag = itemCache._maxAmount < 0; bool flag2 = false; int repeats = 1; if (Effects.Multishot.IsOn) { if (SpellCaster.RemoveStamina(5 * ModdedPlayer.instance.MultishotCount * ModdedPlayer.instance.MultishotCount)) { repeats += ModdedPlayer.instance.MultishotCount; } else { Effects.Multishot.IsOn = false; Effects.Multishot.localPlayerInstance.SetActive(false); } } for (int i = 0; i < repeats; i++) { if (flag || RemoveItem(itemCache._ammoItemId, 1, false, true)) { ModdedPlayer.instance.lastShotProjectile = itemCache; InventoryItemView inventoryItemView2 = _inventoryItemViewsCache[itemCache._ammoItemId][0]; TheForest.Items.Item itemCache2 = inventoryItemView2.ItemCache; FakeParent component = inventoryItemView2._held.GetComponent <FakeParent>(); Vector3 pos = inventoryItemView2._held.transform.position; if (i > 0 && i < 9) { pos += inventoryItemView2._held.transform.right * Mathf.Cos(45 * (i - 1)) * 0.5f + inventoryItemView2._held.transform.up * Mathf.Sin(45 * (i + 1)) * 5f; } else if (i >= 9 && i < 22) { pos += inventoryItemView2._held.transform.right * Mathf.Cos(30 * (i + 5)) * 1f + inventoryItemView2._held.transform.up * Mathf.Sin(30 * (i + 5)) * 1f; } else if (i > 21) { pos += inventoryItemView2._held.transform.right * Mathf.Cos(25 * (i)) * 1.5f + inventoryItemView2._held.transform.up * Mathf.Sin(25 * (i)) * 1.5f; } GameObject gameObject = (!(bool)component || component.gameObject.activeSelf) ? Object.Instantiate(itemCache2._ammoPrefabs.GetPrefabForBonus(inventoryItemView.ActiveBonus, true).gameObject, pos, inventoryItemView2._held.transform.rotation) : Object.Instantiate(itemCache2._ammoPrefabs.GetPrefabForBonus(inventoryItemView.ActiveBonus, true).gameObject, component.RealPosition, component.RealRotation); gameObject.transform.localScale *= ModdedPlayer.instance.ProjectileSizeRatio; gameObject.AddComponent <ProjectileIgnoreCollision>(); if ((bool)gameObject.GetComponent <Rigidbody>()) { if (itemCache.MatchRangedStyle(TheForest.Items.Item.RangedStyle.Shoot)) { gameObject.GetComponent <Rigidbody>().AddForce(gameObject.transform.TransformDirection(Vector3.forward * (0.016666f / Time.fixedDeltaTime) * ModdedPlayer.instance.ProjectileSpeedRatio * itemCache._projectileThrowForceRange), ForceMode.VelocityChange); } else { float num = Time.time - _weaponChargeStartTime; if (ForestVR.Enabled) { gameObject.GetComponent <Rigidbody>().AddForce(inventoryItemView2._held.transform.up * ModdedPlayer.instance.ProjectileSpeedRatio * itemCache._projectileThrowForceRange); } else { gameObject.GetComponent <Rigidbody>().AddForce(inventoryItemView2._held.transform.up * ModdedPlayer.instance.ProjectileSpeedRatio * Mathf.Clamp01(num / itemCache._projectileMaxChargeDuration) * (0.016666f / Time.fixedDeltaTime) * itemCache._projectileThrowForceRange); } if (LocalPlayer.Inventory.HasInSlot(TheForest.Items.Item.EquipmentSlot.RightHand, LocalPlayer.AnimControl._bowId)) { gameObject.SendMessage("setCraftedBowDamage", SendMessageOptions.DontRequireReceiver); } } inventoryItemView._held.SendMessage("OnAmmoFired", gameObject, SendMessageOptions.DontRequireReceiver); } if (itemCache._attackReleaseSFX != 0) { LocalPlayer.Sfx.SendMessage(itemCache._attackReleaseSFX.ToString(), SendMessageOptions.DontRequireReceiver); } Mood.HitRumble(); } else { flag2 = true; if (itemCache._dryFireSFX != 0) { LocalPlayer.Sfx.SendMessage(itemCache._dryFireSFX.ToString(), SendMessageOptions.DontRequireReceiver); } } } if (flag) { UnequipItemAtSlot(itemCache._equipmentSlot, false, false, flag); } else { ToggleAmmo(inventoryItemView, true); } _weaponChargeStartTime = 0f; SetReloadDelay((!flag2) ? itemCache._reloadDuration : itemCache._dryFireReloadDuration); _isThrowing = false; }
private void SpawnEquipmentItemView() { Reparent.Locked = true; InventoryItemView inventoryItemView = LocalPlayer.Inventory.InventoryItemViewsCache[this._storedItemId][0]; if (inventoryItemView._held == null) { Debug.LogError(string.Concat(new string[] { "Attempting to spawn invalid item! No 'held' version of \"", ItemDatabase.ItemById(this._storedItemId)._name, "\" \"", base.gameObject.GetFullName(), "\"" })); return; } GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(inventoryItemView._held); FakeParent component = inventoryItemView._held.GetComponent <FakeParent>(); if (this._applyUpsideDownOffset && inventoryItemView.ItemCache._allowUpsideDownPlacement) { gameObject.transform.parent = this._upsideDownBaseOffset; gameObject.transform.localPosition = ((!component) ? inventoryItemView._held.transform.localPosition : component.RealLocalPosition) + inventoryItemView.ItemCache._upsideDownOffset; } else { gameObject.transform.parent = base.transform; gameObject.transform.localPosition = ((!component) ? inventoryItemView._held.transform.localPosition : component.RealLocalPosition); } gameObject.transform.localRotation = ((!component) ? inventoryItemView._held.transform.localRotation : component.RealLocalRotation); gameObject.transform.parent = base.transform; ItemUtils.FixItemPosition(gameObject, this._storedItemId); Item item = ItemDatabase.ItemById(this._storedItemId); RackPlacement placementOverride = this.GetPlacementOverride(item); if (placementOverride != null) { Vector3 zero = Vector3.zero; Quaternion identity = Quaternion.identity; Vector3 one = Vector3.one; placementOverride.ApplyTo(ref zero, ref identity, ref one); gameObject.transform.localScale = one; gameObject.transform.parent = base.transform; gameObject.transform.localPosition = zero; gameObject.transform.localRotation = identity; gameObject.transform.localPosition += WeaponRackSlot.GetJitterVector3(this._jitterPosition); gameObject.transform.localRotation = Quaternion.Euler(WeaponRackSlot.GetJitterVector3(this._jitterRotation)) * gameObject.transform.localRotation; } gameObject.layer = base.gameObject.layer; Animator animator = gameObject.GetComponent <Animator>() ?? gameObject.transform.GetChild(0).GetComponent <Animator>(); if (animator) { UnityEngine.Object.Destroy(animator); } this.CleanUpComponents(gameObject.transform); gameObject.SetActive(true); foreach (MonoBehaviour obj in gameObject.GetComponentsInChildren <MonoBehaviour>()) { UnityEngine.Object.Destroy(obj); } this._storedItemGO = gameObject; Reparent.Locked = false; if (this.OnItemAdded != null) { this.OnItemAdded.Invoke(this._storedItemId); } }
public IEnumerator AsyncRangedFire(PlayerInventory inv, float _weaponChargeStartTime, InventoryItemView inventoryItemView, InventoryItemView inventoryItemView2, bool noconsume) { TheForest.Items.Item itemCache = inventoryItemView.ItemCache; bool flag = itemCache._maxAmount < 0; int repeats = ModdedPlayer.RangedRepetitions(); Vector3 forceUp = inventoryItemView2._held.transform.up; Vector3 right = inventoryItemView2._held.transform.right; Vector3 up = inventoryItemView2._held.transform.up; Vector3 originalPos = inventoryItemView2._held.transform.position; FakeParent component = inventoryItemView2._held.GetComponent <FakeParent>(); Quaternion rotation = inventoryItemView2._held.transform.rotation; TheForest.Items.Item itemCache2 = inventoryItemView2.ItemCache; for (int i = 0; i < repeats; i++) { if (noconsume) { Vector3 pos = originalPos; if (i > 0) { // pos += 0.5f * up * (i + 1) / 3; pos += 0.5f * right * (((i - 1) % 3) - 1); } GameObject projectileObject = (!(bool)component || component.gameObject.activeSelf) ? Object.Instantiate(itemCache2._ammoPrefabs.GetPrefabForBonus(inventoryItemView.ActiveBonus, true).gameObject, pos, rotation) : Object.Instantiate(itemCache2._ammoPrefabs.GetPrefabForBonus(inventoryItemView.ActiveBonus, true).gameObject, pos, rotation); projectileObject.transform.localScale *= ModdedPlayer.Stats.projectileSize; try { projectileObject.transform.GetChild(0).gameObject.layer = 19; } catch (System.Exception) { throw; } projectileObject.layer = 19; Physics.IgnoreLayerCollision(19, 19, true); if (noconsume) { GameObject.Destroy(projectileObject, 40f); } else { if (i >= 4) { GameObject.Destroy(projectileObject, 40); //if spamming arrows, delete 4th and further after really short time } } if ((bool)projectileObject.GetComponent <Rigidbody>()) { if (itemCache.MatchRangedStyle(TheForest.Items.Item.RangedStyle.Shoot)) { projectileObject.GetComponent <Rigidbody>().AddForce(projectileObject.transform.TransformDirection(Vector3.forward * (0.016666f / Time.fixedDeltaTime) * ModdedPlayer.Stats.projectileSpeed * itemCache._projectileThrowForceRange), ForceMode.VelocityChange); } else { float num = Time.time - _weaponChargeStartTime; if (ForestVR.Enabled) { projectileObject.GetComponent <Rigidbody>().AddForce(inventoryItemView2._held.transform.up * ModdedPlayer.Stats.projectileSpeed * itemCache._projectileThrowForceRange); } else { Vector3 proj_force = forceUp * ModdedPlayer.Stats.projectileSpeed * Mathf.Clamp01(num / itemCache._projectileMaxChargeDuration) * (0.016666f / Time.fixedDeltaTime) * itemCache._projectileThrowForceRange; var proj_rb = projectileObject.GetComponent <Rigidbody>(); proj_rb.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; var col = projectileObject.GetComponent <CapsuleCollider>(); if (col) { col.height *= ModdedPlayer.Stats.projectileSpeed; } else { Debug.LogError("No capsule collider on projectile"); } if (GreatBow.isEnabled) { proj_force *= 1.1f; proj_rb.useGravity = false; } if (ModdedPlayer.Stats.spell_bia_AccumulatedDamage > 0) { proj_force *= 1.1f; proj_rb.useGravity = false; if (ModReferences.bloodInfusedMaterial == null) { ModReferences.bloodInfusedMaterial = BuilderCore.Core.CreateMaterial(new BuilderCore.BuildingData() { EmissionColor = new Color(0.6f, 0.1f, 0), renderMode = BuilderCore.BuildingData.RenderMode.Opaque, MainColor = Color.red, Metalic = 1f, Smoothness = 0.9f, }); } var trail = projectileObject.AddComponent <TrailRenderer>(); trail.widthCurve = new AnimationCurve(new Keyframe[] { new Keyframe(0f, 1f, 0f, 0f), new Keyframe(0.5f, 1f, 0f, 0f), new Keyframe(1f, 0.006248474f, 0f, 0f), }); trail.material = ModReferences.bloodInfusedMaterial; trail.widthMultiplier = 0.45f; trail.time = 1.25f; trail.autodestruct = false; } if (i > 0) { float dmgPen = 1; for (int k = 0; k < i; k++) { dmgPen *= ModdedPlayer.Stats.perk_multishotDamagePennalty.Value; } //using XBArrowDamageMod as a typename here results in erros with modapi projectileObject.SendMessage("ModifyStartingDamage", dmgPen, SendMessageOptions.DontRequireReceiver); } proj_rb.AddForce(proj_force); } if (LocalPlayer.Inventory.HasInSlot(TheForest.Items.Item.EquipmentSlot.RightHand, LocalPlayer.AnimControl._bowId)) { projectileObject.SendMessage("setCraftedBowDamage", SendMessageOptions.DontRequireReceiver); } } inventoryItemView._held.SendMessage("OnAmmoFired", projectileObject, SendMessageOptions.DontRequireReceiver); } if (itemCache._attackReleaseSFX != 0) { LocalPlayer.Sfx.SendMessage(itemCache._attackReleaseSFX.ToString(), SendMessageOptions.DontRequireReceiver); } Mood.HitRumble(); } else { if (itemCache._dryFireSFX != 0) { LocalPlayer.Sfx.SendMessage(itemCache._dryFireSFX.ToString(), SendMessageOptions.DontRequireReceiver); } } if (i % 2 == 1) { yield return(null); } } if (flag) { inv.UnequipItemAtSlot(itemCache._equipmentSlot, false, false, flag); } else { inv.ToggleAmmo(inventoryItemView, true); } yield break; }
private void Update() { if (this._inventory._craftingCog._upgradeCog.enabled || (this._inventory._craftingCog.CraftOverride != null && this._inventory._craftingCog.CraftOverride.IsCombining)) { return; } bool buttonDown = TheForest.Utils.Input.GetButtonDown("Combine"); bool flag = (InventoryItemView.CombiningItemId != this._itemId || !this.Properties.Match(InventoryItemView.CombiningItemProperty)) ? buttonDown : TheForest.Utils.Input.GetButton("Combine"); if (flag) { InventoryItemView.CombiningItemId = this._itemId; InventoryItemView.CombiningItemProperty = this.Properties; } else { InventoryItemView.CombiningItemId = -1; InventoryItemView.CombiningItemProperty = ItemProperties.Any; } bool flag2 = this._item.MatchType(Item.Types.Special); SpecialItemControlerBase specialItemControlerBase = flag2 ? LocalPlayer.Inventory.SpecialItemsControlers[this._itemId] : null; if (this._isCraft) { if (flag) { if (flag2) { specialItemControlerBase.ToggleSpecialCraft(false); } if (this._allowMultiView && this.MultiViewOwner != null) { Scene.HudGui.HideItemInfoView(this, this._isCraft); this.MultiViewOwner.BubbleDownMultiview(this); } if (buttonDown) { LocalPlayer.Inventory.SkipNextAddItemWoosh = true; LocalPlayer.Sfx.PlayInventorySound(Item.SFXCommands.PlayWhoosh); } int num = (!TheForest.Utils.Input.GetButton("Batch")) ? this.GetCombineAmount() : 10; if (this._addMaxToCraft) { num = int.MaxValue; } if (num == 0) { return; } if (this._inventory._craftingCog.Storage && base.GetComponentInParent <ItemStorageProxy>()) { num -= this._inventory._craftingCog.Storage.Remove(this._itemId, num, this._properties); } else { num -= this._inventory.CurrentStorage.Remove(this._itemId, num, this._properties); } this._inventory.AddItem(this._itemId, num, true, true, this._properties); this.ActiveBonus = (WeaponStatUpgrade.Types)(-1); if (LocalPlayer.Inventory.CurrentStorage is CraftingCog) { ((CraftingCog)LocalPlayer.Inventory.CurrentStorage).CheckForValidRecipe(); } } if (this._canEquipFromCraft && TheForest.Utils.Input.GetButtonUp("Equip") && this._item.MatchType(Item.Types.Equipment)) { this._inventory.AddItem(this._itemId, 1, true, true, this._properties); this._inventory.Equip(this._itemId, false); this._inventory.CurrentStorage.Remove(this._itemId, 1, null); this.ActiveBonus = (WeaponStatUpgrade.Types)(-1); if (!this.ItemCache._preventClosingInventoryAfterEquip) { this._inventory.Close(); } } } else { if (flag) { if (!this.CanUseWithPrimary && this.CanUseWithSecondary && LocalPlayer.Inventory.CurrentStorage is CraftingCog) { if (buttonDown) { this.UseEdible(); } } else if (this.CanBeStored && this._item._equipmentSlot < Item.EquipmentSlot.Chest) { if (!flag2 || specialItemControlerBase.ToggleSpecialCraft(true)) { if (this._allowMultiView && this.MultiViewOwner != null) { Scene.HudGui.HideItemInfoView(this, this._isCraft); this.MultiViewOwner.RemovedMultiView(this); } if (buttonDown) { LocalPlayer.Inventory.SkipNextAddItemWoosh = true; LocalPlayer.Sfx.PlayInventorySound(Item.SFXCommands.PlayWhoosh); } if (this._inventory.HasInSlot(this._item._equipmentSlot, this._itemId) && this._inventory.AmountOf(this._itemId, false) == 1) { this._inventory.MemorizeItem(this._item._equipmentSlot); } int num2; if (this._addMaxToCraft) { num2 = this._inventory.AmountOfItemWithBonus(this._itemId, this.ActiveBonus); } else if (TheForest.Utils.Input.GetButton("Batch")) { num2 = Mathf.Min(this._inventory.AmountOfItemWithBonus(this._itemId, this.ActiveBonus), 10); } else { num2 = Mathf.Min(this._inventory.AmountOfItemWithBonus(this._itemId, this.ActiveBonus), this.GetCombineAmount()); } if (num2 == 0) { return; } if (num2 > 1) { LocalPlayer.Inventory.SortInventoryViewsByBonus(this, this.ActiveBonus, true); } else { this._inventory.BubbleUpInventoryView(this); } int num3 = this._inventory.CurrentStorage.Add(this._itemId, num2, this._properties); this._inventory.RemoveItem(this._itemId, num2 - num3, true, true); } } else if (buttonDown) { if (this._canDropFromInventory && this._item.MatchType(Item.Types.Droppable)) { FakeParent component = this._held.GetComponent <FakeParent>(); GameObject worldGo; if (!BoltNetwork.isRunning || !this.ItemCache._pickupPrefabMP) { worldGo = UnityEngine.Object.Instantiate <GameObject>((!this.ItemCache._pickupPrefab) ? this._worldPrefab : this.ItemCache._pickupPrefab.gameObject, (!component) ? this._held.transform.position : component.RealPosition, (!component) ? this._held.transform.rotation : component.RealRotation); } else { worldGo = BoltNetwork.Instantiate(this.ItemCache._pickupPrefabMP.gameObject, (!component) ? this._held.transform.position : component.RealPosition, (!component) ? this._held.transform.rotation : component.RealRotation).gameObject; } this.OnItemDropped(worldGo); this._inventory.BubbleUpInventoryView(this); this._inventory.RemoveItem(this._itemId, 1, false, true); } else if (this._item._equipmentSlot >= Item.EquipmentSlot.Chest && LocalPlayer.Inventory.EquipmentSlots[(int)this._item._equipmentSlot] == this) { LocalPlayer.Inventory.UnequipItemAtSlot(this._item._equipmentSlot, false, true, false); } } } if (TheForest.Utils.Input.GetButtonUp("Equip")) { if (this.CanUseWithPrimary) { this.UseEdible(); } else if (this._item.MatchType(Item.Types.Equipment)) { if (!this._item._inventoryTooltipOnly) { this._inventory.BubbleUpInventoryView(this); if (!this.ItemCache._preventClosingInventoryAfterEquip) { Time.timeScale = 1f; } this._inventory.Equip(this._itemId, false); if (!this.ItemCache._preventClosingInventoryAfterEquip) { this._inventory.Close(); } } } else if (flag2) { this._inventory.SpecialItemsControlers[this._itemId].ToggleSpecial(true); if (this._item._equipedSFX != Item.SFXCommands.None) { this._inventory.SendMessage(this._item._equipedSFX.ToString()); } if (!this.ItemCache._preventClosingInventoryAfterEquip) { this._inventory.Close(); } } } } }
private void Awake() { this.parentScript = base.transform.GetComponent <FakeParent>(); }