Esempio n. 1
0
 public static void Postfix(Panel_FeedFire __instance)
 {
     if (__instance.m_TabWater.activeSelf)
     {
         Cooking.RefreshTabWater(__instance);
     }
 }
Esempio n. 2
0
        internal static void ExecuteTakeEmbers()
        {
            GearItem emberBox = GameManager.GetInventoryComponent().GetBestGearItemWithName("GEAR_EmberBox");

            if (emberBox == null)
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_ToolRequiredToForceOpen").Replace("{item-name}", Localization.Get("GAMEPLAY_EmberBox")), false);
                return;
            }

            Panel_FeedFire panel = InterfaceManager.m_Panel_FeedFire;
            Fire           fire  = Traverse.Create(panel).Field("m_Fire").GetValue <Fire>();

            if (fire && !fire.m_IsPerpetual)
            {
                fire.ReduceHeatByDegrees(1);
            }

            GameManager.GetInventoryComponent().DestroyGear(emberBox.gameObject);
            GearItem activeEmberBox = GameManager.GetPlayerManagerComponent().InstantiateItemInPlayerInventory("GEAR_ActiveEmberBox");

            GearMessage.AddMessage(activeEmberBox, Localization.Get("GAMEPLAY_Harvested"), activeEmberBox.m_DisplayName, false);

            InterfaceManager.m_Panel_FeedFire.ExitFeedFireInterface();
        }
Esempio n. 3
0
        internal static void FeedFire(Panel_FeedFire __instance)
        {
            Fire     _fire = __instance.m_Fire;
            string   guid  = Utils.GetGuidFromGameObject(_fire.gameObject);
            GearItem fuel  = __instance.GetSelectedFuelSource();

            // cool off fire with water
            if (fuel.name.ToLower().Contains("recycledcan") || fuel.name.ToLower().Contains("cookingpot"))
            {
                GearItem gi_wt = GameManager.GetInventoryComponent().GetPotableWaterSupply();
                if (gi_wt.m_WaterSupply.m_VolumeInLiters >= 0.25f && _fire.m_HeatSource.m_MaxTempIncrease > Settings.options.waterTempRemoveDeg)
                {
                    GameAudioManager.StopAllSoundsFromGameObject(InterfaceManager.GetSoundEmitter());
                    GameAudioManager.PlaySound(gi_wt.m_PickUpAudio, InterfaceManager.GetSoundEmitter());
                    gi_wt.m_WaterSupply.m_VolumeInLiters -= 0.25f;
                    _fire.ReduceHeatByDegrees(Settings.options.waterTempRemoveDeg);
                }
                else if (gi_wt.m_WaterSupply.m_VolumeInLiters < 0.25f)
                {
                    HUDMessage.AddMessage("Need water in inventory.", false);
                    GameAudioManager.StopAllSoundsFromGameObject(InterfaceManager.GetSoundEmitter());
                    GameAudioManager.PlayGUIError();
                }
                else
                {
                    HUDMessage.AddMessage("Temperature is too low.", false);
                    GameAudioManager.StopAllSoundsFromGameObject(InterfaceManager.GetSoundEmitter());
                    GameAudioManager.PlayGUIError();
                }

                /* we consume can/pot so recreate it
                 * we could hack it to not consume but after some time (minutes) of feed fire dialog, said object is getting corrupted in such way that it's lagging game
                 * on each interaction with said item
                 */
                GearItem clone = Utils.InstantiateGearFromPrefabName(fuel.name);
                clone.m_CurrentHP = fuel.m_CurrentHP;
                GameManager.GetInventoryComponent().AddGear(clone.gameObject);
                GameManager.GetInventoryComponent().DestroyGear(fuel.gameObject);
            }
            // added fuel while embers
            else if (_fire.m_EmberTimer > 0f)
            {
                ResetEmbersOnRestart(_fire);
            }
            // try add fuel to embers unless it wasn't comming out from ember state.
            else if (fuel.name.ToLower().Contains("wood") || fuel.name.ToLower().Contains("coal"))
            {
                if (_fire.GetRemainingLifeTimeSeconds() < 39600 && (_fire.m_EmberDurationSecondsTOD < (Settings.options.embersTime * 3600)))
                {
                    float fuelmove = fuel.m_FuelSourceItem.m_BurnDurationHours * Settings.options.embersFuelRatio;
                    _fire.m_MaxOnTODSeconds         -= fuelmove * 3600;
                    _fire.m_EmberDurationSecondsTOD += (fuelmove * 3600) * Settings.options.embersFuelEx;
                    _fire.m_BurningTimeTODHours     -= fuelmove;
                }
            }
        }
Esempio n. 4
0
        internal static void RefreshTabWater(Panel_FeedFire panel)
        {
            MeasurementUnits units = InterfaceManager.m_Panel_OptionsMenu.m_State.m_Units;

            panel.m_Label_PotableSupply.text    = Utils.GetLiquidQuantityStringNoOunces(units, WATER.ActualPotable) + "/" + Utils.GetLiquidQuantityStringWithUnitsNoOunces(units, WATER.CapacityPotable);
            panel.m_Label_NonpotableSupply.text = Utils.GetLiquidQuantityStringNoOunces(units, WATER.ActualNonPotable) + "/" + Utils.GetLiquidQuantityStringWithUnitsNoOunces(units, WATER.CapacityNonPotable);
            labelEmptyCapacity.text             = Utils.GetLiquidQuantityStringWithUnitsNoOunces(units, WATER.CapacityEmpty);

            panel.m_Texture_InspectItem.gameObject.SetActive(Cookware != null);
            panel.m_Texture_GearItem.alpha = 0.25f;
        }
Esempio n. 5
0
 public static void Postfix(Panel_FeedFire __instance)
 {
     if (__instance.m_TabWater.activeSelf)
     {
         Cooking.ShowCookingGearInInspect(__instance);
     }
     else
     {
         Cooking.HideCookingGearInInspect(__instance);
     }
 }
Esempio n. 6
0
        internal static void ShowCookingGearInInspect(Panel_FeedFire panel)
        {
            if (inInspect || Cookware == null)
            {
                return;
            }

            Utils.ShowInspectForGearItem(Cookware);
            panel.m_Texture_InspectItem.gameObject.SetActive(true);
            panel.m_Texture_GearItem.gameObject.SetActive(false);

            inInspect = true;
        }
Esempio n. 7
0
 public static void Postfix(Panel_FeedFire __instance, bool enable)
 {
     if (enable)
     {
         Cooking.SelectCookingGear();
         Cooking.Configure(__instance);
     }
     else
     {
         Cooking.Restore(__instance);
         Cooking.UnselectCookingGear();
     }
 }
Esempio n. 8
0
        internal static void ClampBoilWaterAmount(Panel_FeedFire panel)
        {
            float totalCapacity = Water.GetRemainingCapacity(LiquidQuality.Potable) + Water.GetRemainingCapacityEmpty();

            labelCookingWarning.gameObject.SetActive(Cookware == null);

            FieldInfo boilWaterLitersField = AccessTools.Field(panel.GetType(), "m_BoilWaterLiters");
            float     value = Mathf.Clamp((float)boilWaterLitersField.GetValue(panel), 0, MaxLiters);

            boilWaterLitersField.SetValue(panel, value);

            panel.m_ButtonIncreaseWater.SetActive(panel.m_ButtonIncreaseWater.activeSelf && value < MaxLiters);
            panel.m_WaterAmountLabel.text = Utils.GetLiquidQuantityStringWithUnitsNoOunces(InterfaceManager.m_Panel_OptionsMenu.m_State.m_Units, value);
        }
Esempio n. 9
0
        private static bool Prefix(Panel_FeedFire __instance, Fire ___m_Fire)

        {
            if ((bool)AccessTools.Method(typeof(Panel_FeedFire), "ProgressBarIsActive").Invoke(__instance, null) || !___m_Fire)
            {
                GameAudioManager.PlayGUIError();
                return(false);
            }
            if (!___m_Fire.CanTakeTorch())//then we can't take torch
            {
                GameAudioManager.PlayGUIError();
                return(false);
            }
            GearItem gearItem = GameManager.GetPlayerManagerComponent().InstantiateItemInPlayerInventory("GEAR_Torch");

            if (gearItem == null || gearItem.m_TorchItem == null)
            {
                return(false);
            }
            gearItem.OverrideGearCondition(GearStartCondition.Low);
            gearItem.m_TorchItem.m_ElapsedBurnMinutes = Mathf.Clamp01(1f - gearItem.m_CurrentHP / gearItem.m_MaxHP) * gearItem.m_TorchItem.GetModifiedBurnLifetimeMinutes();
            GameManager.GetPlayerAnimationComponent().MaybeDropAndResetCurrentWeapon();
            gearItem.m_TorchItem.Ignite();
            GameManager.GetPlayerManagerComponent().EquipItem(gearItem, false);
            GameManager.GetPlayerManagerComponent().ClearRestoreItemInHandsAfterInteraction();
            if (!___m_Fire.m_IsPerpetual)
            {
                float torchcost_cs      = Fire_RV.torch_cost(___m_Fire);
                float fire_temp         = (float)AccessTools.Field(typeof(Fire), "m_FuelHeatIncrease").GetValue(___m_Fire);
                float fire_time         = ___m_Fire.GetRemainingLifeTimeSeconds();
                float remaining_fire_cs = fire_time * fire_temp;
                float new_fire_cs       = (remaining_fire_cs - torchcost_cs);
                float myfactor          = Mathf.Pow(new_fire_cs / remaining_fire_cs, 0.5f);
                float time_reduction    = fire_time - (fire_time * myfactor);
                float heat_reduction    = fire_temp - (fire_temp * myfactor);
                Debug.Log("new_cs:" + new_fire_cs + " ratio::" + (new_fire_cs / remaining_fire_cs) + " myfactor::" + myfactor + " timered::" + time_reduction + " heat_red:" + heat_reduction);
                ___m_Fire.ReduceDurationByTODSeconds(time_reduction);
                ___m_Fire.ReduceHeatByDegrees(heat_reduction);

                fire_temp = (float)AccessTools.Field(typeof(Fire), "m_FuelHeatIncrease").GetValue(___m_Fire);
                fire_time = ___m_Fire.GetRemainingLifeTimeSeconds();
                Debug.Log("Reducing Fire: Old cs:" + remaining_fire_cs + " New cs:" + fire_temp * fire_time);
            }
            __instance.ExitFeedFireInterface();
            return(false);
        }
Esempio n. 10
0
        internal static void Prepare(Panel_FeedFire panel)
        {
            labelCookingWarning                    = NGUITools.AddChild <UILabel>(panel.m_TabWater);
            labelCookingWarning.depth              = 2000;
            labelCookingWarning.color              = new Color(0.640f, 0.202f, 0.231f);
            labelCookingWarning.bitmapFont         = panel.m_Label_Water.bitmapFont;
            labelCookingWarning.fontSize           = 14;
            labelCookingWarning.alignment          = NGUIText.Alignment.Center;
            labelCookingWarning.pivot              = UIWidget.Pivot.Center;
            labelCookingWarning.width              = 400;
            labelCookingWarning.height             = 20;
            labelCookingWarning.capsLock           = true;
            labelCookingWarning.transform.position = new Vector3(0, -0.858f, 0);

            UISprite[] sprites = Resources.FindObjectsOfTypeAll <UISprite>();
            foreach (UISprite eachSprite in sprites)
            {
                if (eachSprite.width == 320 && eachSprite.height == 60 && NGUITools.IsChild(panel.transform, eachSprite.transform) && eachSprite.transform.localPosition.x == -160 && eachSprite.transform.localPosition.y == -30)
                {
                    eachSprite.pivot  = UIWidget.Pivot.Top;
                    eachSprite.height = (int)(eachSprite.height + Mathf.Abs(offset.y));
                }
            }

            UITexture texturePotable = WaterUtils.GetUITexure("gearIcon_Potable");

            if (texturePotable != null)
            {
                UITexture textureEmpty = Object.Instantiate(texturePotable, texturePotable.transform.parent);
                textureEmpty.transform.localPosition = texturePotable.transform.localPosition + offset;
                textureEmpty.mainTexture             = (Texture)Resources.Load("InventoryGridIcons/ico_GearItem__WaterSupplyNone");
            }

            UILabel labelPotable = WaterUtils.GetUILabel("LabelPotable");

            if (labelPotable != null)
            {
                UILabel labelEmpty = Object.Instantiate(labelPotable, labelPotable.transform.parent);
                labelEmpty.transform.localPosition         = labelPotable.transform.localPosition + offset;
                labelEmpty.GetComponent <UILocalize>().key = "GAMEPLAY_Empty";
            }

            labelEmptyCapacity = Object.Instantiate(panel.m_Label_PotableSupply, panel.m_Label_PotableSupply.transform.parent);
            labelEmptyCapacity.transform.localPosition = panel.m_Label_PotableSupply.transform.localPosition + offset;
        }
Esempio n. 11
0
            private static void Prefix(Panel_FeedFire __instance)
            {
                Inventory inventoryComponent = GameManager.GetInventoryComponent();

                foreach (GearItemObject item in inventoryComponent.m_Items)
                {
                    GearItem gearItem = item;
                    if ((bool)gearItem)
                    {
                        FuelSourceItem fuelSourceItem = gearItem.m_FuelSourceItem;
                        if ((bool)fuelSourceItem)
                        {
                            if (Settings.options.embersSystem && (gearItem.name.ToLower().Contains("recycledcan") || gearItem.name.ToLower().Contains("cookingpot")))
                            {
                                FireAddons.ModifyWater(gearItem, false);
                            }
                        }
                    }
                }
            }
Esempio n. 12
0
            private static void Postfix(Panel_FeedFire __instance)
            {
                Inventory inventoryComponent = GameManager.GetInventoryComponent();

                foreach (GearItemObject item in inventoryComponent.m_Items)
                {
                    GearItem gearItem = item;
                    if ((bool)gearItem)
                    {
                        FuelSourceItem fuelSourceItem = gearItem.m_FuelSourceItem;
                        if ((bool)fuelSourceItem)
                        {
                            if (FireAddons.IsNamedTinder(gearItem))
                            {
                                gearItem.m_FuelSourceItem.m_IsTinder = true;
                            }
                        }
                    }
                }
            }
Esempio n. 13
0
        internal static void ClampMeltSnowAmount(Panel_FeedFire panel)
        {
            float totalCapacity = Water.GetRemainingCapacity(LiquidQuality.NonPotable) + Water.GetRemainingCapacityEmpty();

            float limit = MaxLiters;

            if (limit > 0 && totalCapacity == 0)
            {
                labelCookingWarning.text = Localization.Get("GAMEPLAY_NoCapacityAvailable");
                limit = 0;
            }
            labelCookingWarning.gameObject.SetActive(limit == 0);

            FieldInfo meltSnowLitersField = AccessTools.Field(panel.GetType(), "m_MeltSnowLiters");
            float     value = Mathf.Clamp((float)meltSnowLitersField.GetValue(panel), 0, limit);

            meltSnowLitersField.SetValue(panel, value);

            panel.m_ButtonIncreaseWater.SetActive(panel.m_ButtonIncreaseWater.activeSelf && value < limit);
            panel.m_WaterAmountLabel.text = Utils.GetLiquidQuantityStringWithUnitsNoOunces(InterfaceManager.m_Panel_OptionsMenu.m_State.m_Units, value);
        }
Esempio n. 14
0
        internal static void Configure(Panel_FeedFire panel)
        {
            panel.m_MaxMeltSnowLiters = MaxLiters;

            FieldInfo meltSnowLitersField = AccessTools.Field(panel.GetType(), "m_MeltSnowLiters");

            meltSnowLitersField.SetValue(panel, Mathf.Clamp((float)meltSnowLitersField.GetValue(panel), 0, MaxLiters));

            FieldInfo boilWaterLitersField = AccessTools.Field(panel.GetType(), "m_BoilWaterLiters");

            boilWaterLitersField.SetValue(panel, Mathf.Clamp((float)boilWaterLitersField.GetValue(panel), 0, MaxLiters));

            if (Cookware == null)
            {
                labelCookingWarning.text = Localization.Get("GAMEPLAY_RequiresCookware");
                labelCookingWarning.gameObject.SetActive(true);
            }
            else
            {
                labelCookingWarning.gameObject.SetActive(false);
            }
        }
Esempio n. 15
0
        private static void Postfix(Panel_FeedFire __instance, ref List <GearItem> ___m_FuelSourcesList)
        {
            Inventory inventoryComponent = GameManager.GetInventoryComponent();

            foreach (GearItemObject item in inventoryComponent.m_Items)
            {
                GearItem gearItem = item;
                if ((bool)gearItem)
                {
                    FuelSourceItem fuelSourceItem = gearItem.m_FuelSourceItem;
                    if ((bool)fuelSourceItem)
                    {
                        foreach (string tinder in Lists.tinderitems)
                        {
                            if (gearItem.name == tinder)
                            {
                                gearItem.m_FuelSourceItem.m_IsTinder = true;
                            }
                        }
                    }
                }
            }
        }
 public static void Prefix(Panel_FeedFire __instance)
 {
     Debug.LogFormat("Panel_FeedFire::StartBoil");
     __instance.m_BoilProgressBarSeconds = actionTime;
 }
Esempio n. 17
0
        private static bool Prefix(Panel_FeedFire __instance, Fire ___m_Fire, GameObject ___m_FireContainer, GearItem ___m_ResearchItemToBurn)
        {
            if ((bool)AccessTools.Method(typeof(Panel_FeedFire), "ProgressBarIsActive").Invoke(__instance, null))
            {
                GameAudioManager.PlayGUIError();
                return(false);
            }
            GearItem selectedFuelSource = (GearItem)AccessTools.Method(typeof(Panel_FeedFire), "GetSelectedFuelSource").Invoke(__instance, null);

            if (selectedFuelSource == null)
            {
                GameAudioManager.PlayGUIError();
                return(false);
            }
            FuelSourceItem fuelSourceItem = selectedFuelSource.m_FuelSourceItem;

            if (fuelSourceItem == null)
            {
                GameAudioManager.PlayGUIError();
                return(false);
            }
            if (!___m_FireContainer)
            {
                GameAudioManager.PlayGUIError();
                return(false);
            }
            if (!___m_Fire)
            {
                return(false);
            }
            if (___m_Fire.FireShouldBlowOutFromWind())
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_TooWindyToAddFuel"), false);
                GameAudioManager.PlayGUIError();
                return(false);
            }
            bool flag = true;

            if ((bool)AccessTools.Method(typeof(Panel_FeedFire), "FireInForge").Invoke(__instance, null) && fuelSourceItem.m_FireAgeMinutesBeforeAdding > 0f)
            {
                flag = false;
            }
            flag = false; //allow any duration of fire
            if (flag)
            {
                float num  = fuelSourceItem.GetModifiedBurnDurationHours(selectedFuelSource.GetNormalizedCondition()) * 60f;
                float num2 = ___m_Fire.GetRemainingLifeTimeSeconds() / 60f;
                float num3 = (num + num2) / 60f;
                if (num3 > GameManager.GetFireManagerComponent().m_MaxDurationHoursOfFire)
                {
                    GameAudioManager.PlayGUIError();
                    HUDMessage.AddMessage(Localization.Get("GAMEPLAY_CannotAddMoreFuel"), false);
                    return(false);
                }
            }
            int num4 = Mathf.RoundToInt(fuelSourceItem.m_FireAgeMinutesBeforeAdding - ___m_Fire.GetUnmodifiedMinutesBurning() - 10);

            if (num4 >= 1)
            {
                string text = Localization.Get("GAMEPLAY_BurnTimeNeededForCoal");
                text = text.Replace("{minutes}", num4.ToString());
                HUDMessage.AddMessage(text, false);
                GameAudioManager.PlayGUIError();
                return(false);
            }
            if (selectedFuelSource.m_ResearchItem && !selectedFuelSource.m_ResearchItem.IsResearchComplete())
            {
                ___m_ResearchItemToBurn = selectedFuelSource;
                InterfaceManager.m_Panel_Confirmation.ShowBurnResearchNotification(() => { AccessTools.Method(typeof(Panel_FeedFire), "ForceBurnResearchItem", null, null).Invoke(__instance, null); });
                return(false);
            }
            if (selectedFuelSource == GameManager.GetPlayerManagerComponent().m_ItemInHands)
            {
                GameManager.GetPlayerManagerComponent().UnequipItemInHandsSkipAnimation();
            }
            if (selectedFuelSource == GameManager.GetPlayerManagerComponent().m_PickupGearItem)
            {
                GameManager.GetPlayerManagerComponent().ResetPickup();
            }
            GameAudioManager.PlaySound(__instance.m_FeedFireAudio, InterfaceManager.GetSoundEmitter());
            ___m_Fire.AddFuel(selectedFuelSource, (bool)AccessTools.Method(typeof(Panel_FeedFire), "FireInForge").Invoke(__instance, null));
            GameManager.GetPlayerManagerComponent().ConsumeUnitFromInventory(fuelSourceItem.gameObject);
            return(false);
        }
Esempio n. 18
0
 public static void Postfix(Panel_FeedFire __instance)
 {
     Cooking.ClampMeltSnowAmount(__instance);
 }
Esempio n. 19
0
 public static void Postfix(Panel_FeedFire __instance)
 {
     Cooking.ClampBoilWaterAmount(__instance);
 }
Esempio n. 20
0
 public static void Postfix(Panel_FeedFire __instance)
 {
     Cooking.Prepare(__instance);
 }
Esempio n. 21
0
 internal static void Restore(Panel_FeedFire panel)
 {
     HideCookingGearInInspect(panel);
 }
Esempio n. 22
0
 private static void Postfix(Panel_FeedFire __instance)
 {
     FireAddons.FeedFire(__instance);
 }