Exemple #1
0
 private void Update()
 {
     if (this.InFireTrigger)
     {
         if (Time.time > this.nextFireCheck && LocalPlayer.Inventory.RightHand._held != null && LocalPlayer.Inventory.RightHand._held.activeSelf)
         {
             if (this.burnableWeapon)
             {
                 BurnableCloth componentInChildren = LocalPlayer.Inventory.RightHand._held.GetComponentInChildren <BurnableCloth>();
                 if (componentInChildren && !componentInChildren._player.IsWeaponBurning)
                 {
                     componentInChildren.SendMessage("Light", SendMessageOptions.DontRequireReceiver);
                 }
             }
             else
             {
                 LocalPlayer.Inventory.RightHand._held.SendMessage("setIsLit", SendMessageOptions.DontRequireReceiver);
                 LocalPlayer.Inventory.RightHand._held.SendMessage("enableFire", SendMessageOptions.DontRequireReceiver);
                 LocalPlayer.Inventory.UseAltWorldPrefab = false;
             }
         }
     }
     else
     {
         this.nextFireCheck = Time.time + 1.3f;
     }
 }
Exemple #2
0
        public bool ApplyWeaponStatsUpgrades(int productItemId, int ingredientItemId, WeaponStatUpgrade[] bonuses, bool batched, int upgradeCount, WeaponStatUpgrade.Types lastIngredientActiveBonus = (WeaponStatUpgrade.Types)(-2))
        {
            bool       result         = false;
            Type       typeFromHandle = typeof(weaponInfo);
            weaponInfo heldWeaponInfo = this._itemViewsCache[productItemId]._heldWeaponInfo;
            int        i = 0;

            while (i < bonuses.Length)
            {
                switch (bonuses[i]._type)
                {
                case WeaponStatUpgrade.Types.BurningWeapon:
                {
                    BurnableCloth componentInChildren = this._itemViewsCache[productItemId]._held.GetComponentInChildren <BurnableCloth>();
                    if (componentInChildren)
                    {
                        this._itemViewsCache[productItemId].ActiveBonus = WeaponStatUpgrade.Types.BurningWeapon;
                        componentInChildren.EnableBurnableCloth();
                    }
                    result = true;
                    break;
                }

                case WeaponStatUpgrade.Types.StickyProjectile:
                    this._itemViewsCache[productItemId].ActiveBonus = WeaponStatUpgrade.Types.StickyProjectile;
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.WalkmanTrack:
                    WalkmanControler.LoadCassette(ingredientItemId);
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.BurningAmmo:
                    if (batched && this._itemViewsCache[productItemId]._allowMultiView)
                    {
                        this._itemViewsCache[productItemId].SetMultiviewsBonus(WeaponStatUpgrade.Types.BurningAmmo);
                    }
                    else
                    {
                        this._itemViewsCache[productItemId].ActiveBonus = WeaponStatUpgrade.Types.BurningAmmo;
                    }
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.Paint_Green:
                {
                    EquipmentPainting componentInChildren2 = this._itemViewsCache[productItemId]._held.GetComponentInChildren <EquipmentPainting>();
                    if (componentInChildren2)
                    {
                        componentInChildren2.PaintInGreen();
                    }
                    result = true;
                    break;
                }

                case WeaponStatUpgrade.Types.Paint_Orange:
                {
                    EquipmentPainting componentInChildren3 = this._itemViewsCache[productItemId]._held.GetComponentInChildren <EquipmentPainting>();
                    if (componentInChildren3)
                    {
                        componentInChildren3.PaintInOrange();
                    }
                    result = true;
                    break;
                }

                case WeaponStatUpgrade.Types.DirtyWater:
                case WeaponStatUpgrade.Types.CleanWater:
                case WeaponStatUpgrade.Types.Cooked:
                case WeaponStatUpgrade.Types.blockStaminaDrain:
                    goto IL_3DD;

                case WeaponStatUpgrade.Types.ItemPart:
                {
                    IItemPartInventoryView itemPartInventoryView = (IItemPartInventoryView)this._itemViewsCache[productItemId];
                    itemPartInventoryView.AddPiece(Mathf.RoundToInt(bonuses[i]._amount));
                    result = true;
                    break;
                }

                case WeaponStatUpgrade.Types.BatteryCharge:
                    LocalPlayer.Stats.BatteryCharge = Mathf.Clamp(LocalPlayer.Stats.BatteryCharge + bonuses[i]._amount, 0f, 100f);
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.FlareGunAmmo:
                    LocalPlayer.Inventory.AddItem(ItemDatabase.ItemByName("FlareGunAmmo")._id, Mathf.RoundToInt(bonuses[i]._amount * (float)upgradeCount), false, false, (WeaponStatUpgrade.Types)(-2));
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.SetWeaponAmmoBonus:
                    this._itemViewsCache[productItemId].ActiveBonus = ((lastIngredientActiveBonus != (WeaponStatUpgrade.Types)(-2)) ? lastIngredientActiveBonus : this._itemViewsCache[ingredientItemId].ActiveBonus);
                    LocalPlayer.Inventory.SortInventoryViewsByBonus(LocalPlayer.Inventory.InventoryItemViewsCache[ingredientItemId][0], this._itemViewsCache[productItemId].ActiveBonus, false);
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.AddMaxAmountBonus:
                    LocalPlayer.Inventory.AddMaxAmountBonus(ingredientItemId, Mathf.RoundToInt(bonuses[i]._amount));
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.SetMaxAmountBonus:
                    LocalPlayer.Inventory.AddMaxAmountBonus(ingredientItemId, Mathf.RoundToInt(bonuses[i]._amount));
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.PoisonnedAmmo:
                    if (batched && this._itemViewsCache[productItemId]._allowMultiView)
                    {
                        this._itemViewsCache[productItemId].SetMultiviewsBonus(WeaponStatUpgrade.Types.PoisonnedAmmo);
                    }
                    else
                    {
                        this._itemViewsCache[productItemId].ActiveBonus = WeaponStatUpgrade.Types.PoisonnedAmmo;
                    }
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.SetArrowMaxAmountBonus:
                    LocalPlayer.Inventory.AddMaxAmountBonus(ItemDatabase.ItemByName("Arrows")._id, Mathf.RoundToInt(bonuses[i]._amount));
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.BurningWeaponExtra:
                {
                    BurnableCloth componentInChildren4 = this._itemViewsCache[productItemId]._held.GetComponentInChildren <BurnableCloth>();
                    if (componentInChildren4 && this._itemViewsCache[productItemId].ActiveBonus == WeaponStatUpgrade.Types.BurningWeapon)
                    {
                        this._itemViewsCache[productItemId].ActiveBonus = WeaponStatUpgrade.Types.BurningWeaponExtra;
                        componentInChildren4.EnableBurnableClothExtra();
                    }
                    result = true;
                    break;
                }

                case WeaponStatUpgrade.Types.Incendiary:
                    this._itemViewsCache[productItemId].ActiveBonus = WeaponStatUpgrade.Types.Incendiary;
                    result = true;
                    break;

                default:
                    goto IL_3DD;
                }
IL_4C5:
                i++;
                continue;
IL_3DD:
                if (heldWeaponInfo)
                {
                    FieldInfo field = typeFromHandle.GetField(bonuses[i]._type.ToString(), BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                    float     upgradeBonusAmount = this.GetUpgradeBonusAmount(productItemId, ingredientItemId, bonuses[i], upgradeCount);
                    if (field.FieldType == typeof(float))
                    {
                        field.SetValue(heldWeaponInfo, (float)field.GetValue(heldWeaponInfo) + upgradeBonusAmount);
                    }
                    else if (field.FieldType == typeof(int))
                    {
                        field.SetValue(heldWeaponInfo, (int)field.GetValue(heldWeaponInfo) + Mathf.RoundToInt(upgradeBonusAmount));
                    }
                    result = true;
                    GameStats.UpgradesAdded.Invoke(upgradeCount);
                }
                else
                {
                    Debug.LogError("Attempting to upgrade " + this._itemViewsCache[productItemId].ItemCache._name + " which doesn't reference its weaponInfo component.");
                }
                goto IL_4C5;
            }
            return(result);
        }