Пример #1
0
        private static void Prefix(Forge __instance)
        {
            var settings = Fire_RVSettings.Instance;

            __instance.m_MinTemperatureForCrafting = settings.MinTemperature;

            HeatReservoir myreservoir = Fire_RV.GetHeatReservoir(Utils.GetGuidFromGameObject(__instance.m_Fire.gameObject));

            if (myreservoir != null)
            {
                __instance.m_MinTemperatureForCrafting -= myreservoir.temp;
            }
        }
Пример #2
0
        private static void Postfix(ref string __result)
        {
            Vector3 pos = GameManager.GetPlayerTransform().position;


            Fire  result = null;
            float num    = float.PositiveInfinity;

            for (int i = 0; i < FireManager.m_Fires.Count; i++)
            {
                Fire  firem = FireManager.m_Fires[i];
                float num2  = Vector3.Distance(pos, firem.transform.position);
                if (num2 < num)
                {
                    num    = num2;
                    result = firem;
                }
            }
            Fire fire = result;

            if (fire == null)
            {
                return;
            }

            HeatSource myheat   = fire.m_HeatSource;
            float      maxTemp  = (float)AccessTools.Field(typeof(HeatSource), "m_MaxTempIncrease").GetValue(myheat);
            float      innerRad = (float)AccessTools.Field(typeof(HeatSource), "m_MaxTempIncreaseInnerRadius").GetValue(myheat);
            float      outerRad = (float)AccessTools.Field(typeof(HeatSource), "m_MaxTempIncreaseOuterRadius").GetValue(myheat);
            float      dist     = Vector3.Distance(pos, fire.transform.position);
            FireState  mystate  = (FireState)AccessTools.Field(typeof(Fire), "m_FireState").GetValue(fire);

            if (dist > 20)
            {
                return;
            }
            __result += "\n\nFire  state:" + Enum.GetName(typeof(FireState), mystate) + " dist:" + string.Format("{0:0.0}", dist) + " >>Heat  temp:" + string.Format("{0:0.00}", myheat.GetCurrentTempIncrease()) + " max:" + maxTemp + " isembers:" + fire.IsEmbers();
            __result += "\nRadius, Inner:" + innerRad + " Outer:" + outerRad;
            HeatReservoir myres = Fire_RV.GetHeatReservoir(Utils.GetGuidFromGameObject(fire.gameObject));

            if (myres == null)
            {
                // Debug.Log("no heat reservoir associated with fire");
                return;
            }
            __result += "\nRsvr temp:" + string.Format("{0:0.00}", myres.temp) + " size:" + myres.size_cmins + " ins:" + myres.insulation_factor + " LastFireTemp:" + string.Format("{0:0.00}", myres.lastFireTemp);
        }
Пример #3
0
        private static void Prefix(Fire __instance, GearItem fuel, ref List <string> ___m_TrackedBurntItems, ref float ___m_ElapsedOnTODSeconds, ref float ___m_FuelHeatIncrease)
        {
            HeatReservoir heatReservoir = Fire_RV.GetHeatReservoir(Utils.GetGuidFromGameObject(((Component)(object)__instance).gameObject));

            //Debug.Log(Fire_RV.getCentigradeMinutes(__instance).ToString());
            if (heatReservoir != null)
            {
                heatReservoir.TrackedBurntNames.Add(fuel.name);
                heatReservoir.TrackedBurntItemsCentigradminutesFire.Add(Fire_RV.getCentigradeMinutes(__instance) / Fire_RV.getStoveDurationModifier(((Component)(object)__instance).gameObject));
                heatReservoir.TrackedBurntGearItemHP.Add(fuel.GetNormalizedCondition());
            }
            else
            {
                Fire_RV.LastBurntItemsName = fuel.name;
                Fire_RV.LastBurntItemsCentigradminutesFire = Fire_RV.getCentigradeMinutes(__instance) / Fire_RV.getStoveDurationModifier(((Component)(object)__instance).gameObject);
                Fire_RV.LastBurntGearItemHP = fuel.GetNormalizedCondition();
            }
        }
Пример #4
0
        private static void Postfix(Fire __instance, string text, ref bool ___m_UseEmbers, EffectsControllerFire ___m_FX, ref FireState ___m_FireState)
        {
            HeatReservoir myreservoir = Fire_RV.GetHeatReservoir(Utils.GetGuidFromGameObject(__instance.gameObject));

            if (myreservoir == null)
            {
                return;
            }
            FireSaveDataProxy fireSaveDataProxy = Utils.DeserializeObject <FireSaveDataProxy>(text);

            float newelapsedtime = fireSaveDataProxy.m_ElapsedOnTODSecondsProxy + (GameManager.GetTimeOfDayComponent().GetHoursPlayedNotPaused() - fireSaveDataProxy.m_HoursPlayed) * 60 * 60;

            float maxburn = fireSaveDataProxy.m_MaxOnTODSecondsProxy;

            if (newelapsedtime > maxburn)
            {
                //fire went out inbetween. log minutes ago into reservoir.
                myreservoir.fireLastOnAt = Fire_RV.unitime() - (newelapsedtime - maxburn) / (60 * 60 * 24);
            }
        }
Пример #5
0
        private static bool Prefix(Fire __instance, FuelSourceItem fuel, bool maskTempIncrease, ref float ___m_FuelHeatIncrease, ref float ___m_ElapsedOnTODSeconds, ref float ___m_ElapsedOnTODSecondsUnmodified, ref float ___m_MaxOnTODSeconds, FireState ___m_FireState)
        {
            GearItem component = fuel.GetComponent <GearItem>();

            if (!component)
            {
                return(false);
            }
            //Fire_RV.PrintHierarchy(__instance.gameObject);



            __instance.m_HeatSource.TurnOn();
            __instance.m_HeatSource.m_MaskTempIncrease           = maskTempIncrease;
            __instance.m_HeatSource.m_MaxTempIncrease           += Fire_RV.getModifiedHeatIncrease(component);
            __instance.m_HeatSource.m_MaxTempIncreaseInnerRadius = fuel.m_HeatInnerRadius;

            float         outradscale = (float)AccessTools.Method(typeof(Fire), "GetFireOuterRadiusScale").Invoke(__instance, null);
            HeatReservoir reservoir   = Fire_RV.GetHeatReservoir(Utils.GetGuidFromGameObject(__instance.gameObject));

            if (reservoir == null)
            {
                __instance.m_HeatSource.m_MaxTempIncreaseOuterRadius = fuel.m_HeatOuterRadius * outradscale;
            }
            else
            {
                __instance.m_HeatSource.m_MaxTempIncreaseOuterRadius = fuel.m_HeatOuterRadius * outradscale + reservoir.heatingsize;
            }
            if (__instance.m_FX)
            {
                __instance.m_FX.TriggerStage(___m_FireState, true, true);
            }
            ___m_FuelHeatIncrease              = __instance.m_HeatSource.m_MaxTempIncrease;
            ___m_ElapsedOnTODSeconds           = 0f;
            ___m_ElapsedOnTODSecondsUnmodified = 0f;
            ___m_MaxOnTODSeconds = Fire_RV.getStoveDurationModifier(__instance.gameObject) * Fire_RV.getModifiedDuration(component) * 60f * 60f;
            return(false);
        }
Пример #6
0
        private static bool Prefix(Fire __instance, ref float ___m_BurningTimeTODHours, Campfire ___m_Campfire, bool ___m_IsPerpetual, float ___m_MaxOnTODSeconds, ref float ___m_ElapsedOnTODSeconds, ref float ___m_ElapsedOnTODSecondsUnmodified, FireState ___m_FireState, EffectsControllerFire ___m_FX, ref float ___m_FuelHeatIncrease, ref float ___m_EmberDurationSecondsTOD, ref bool ___m_UseEmbers)
        {
            var setting = Fire_RVSettings.Instance;

            if (Fire_RV.scene_loading || GameManager.m_IsPaused)
            {
                return(false);
            }

            if (___m_FireState == FireState.Off)
            {
                HeatReservoir reservoir = Fire_RV.GetHeatReservoir(Utils.GetGuidFromGameObject(__instance.gameObject));             //we have to update

                if (reservoir != null)
                {
                    if (__instance.m_HeatSource == null)
                    {
                        __instance.m_HeatSource = new HeatSource();
                        GameManager.GetHeatSourceManagerComponent().AddHeatSource(__instance.m_HeatSource);
                    }
                    if (!GameManager.GetHeatSourceManagerComponent().m_HeatSources.Contains(__instance.m_HeatSource))
                    {
                        GameManager.GetHeatSourceManagerComponent().AddHeatSource(__instance.m_HeatSource);
                    }
                    reservoir.Update(__instance);
                    AccessTools.Field(typeof(HeatSource), "m_MaxTempIncrease").SetValue(__instance.m_HeatSource, (object)(reservoir.temp));
                    AccessTools.Field(typeof(HeatSource), "m_TempIncrease").SetValue(__instance.m_HeatSource, (object)(reservoir.temp));
                    if (reservoir.temp < 0.05f)
                    {
                        Fire_RV.RemoveReservoir(reservoir.GUID);
                    }


                    __instance.m_HeatSource.m_MaskTempIncrease = false;
                }

                Utils.SetActive(___m_FX.lighting.gameObject, false);
                ___m_FX.DeactivateAllFX();
                // this.m_TimeOffSeconds = float.NegativeInfinity;
                //}
                return(false);
            }

            AccessTools.Method(typeof(Fire), "UpdateFireStage").Invoke(__instance, null);
            if (!___m_IsPerpetual)
            {
                AccessTools.Method(typeof(Fire), "MaybeBlowOutFromWind").Invoke(__instance, null);

                float deltaTime = GameManager.GetTimeOfDayComponent().GetTODSeconds(Time.deltaTime);
                float f         = 1;
                if ((bool)___m_Campfire)
                {
                    Vector3 position = __instance.transform.position;
                    position.y += 1f;
                    if (!GameManager.GetWindComponent().IsPositionOccludedFromWind(position) && setting.WindReworked)
                    {
                        float relativwind = GameManager.GetWindComponent().GetSpeedMPH() / GameManager.GetFireManagerComponent().m_WindSpeedThatBlowsOutFires;
                        float temp        = (float)AccessTools.Field(typeof(HeatSource), "m_TempIncrease").GetValue(__instance.m_HeatSource);

                        f *= (1 + relativwind);

                        temp /= (1 + relativwind * deltaTime / 60f);
                        AccessTools.Field(typeof(HeatSource), "m_TempIncrease").SetValue(__instance.m_HeatSource, temp);
                    }
                }
                ___m_ElapsedOnTODSecondsUnmodified += deltaTime;
                ___m_ElapsedOnTODSeconds           += deltaTime * f;
            }

            AccessTools.Method(typeof(Fire), "UpdateFireAudio").Invoke(__instance, null);

            bool fireOn = __instance.m_HeatSource.IsTurnedOn();

            //if (!fireOn || __instance.IsEmbers()) { ___m_FuelHeatIncrease = 0; }

            HeatReservoir myreservoir = Fire_RV.GetHeatReservoir(Utils.GetGuidFromGameObject(__instance.gameObject));

            if (myreservoir == null && fireOn)
            {
                //shucks create new one...
                Fire_RV.CreateHeatReservoir(Utils.GetGuidFromGameObject(__instance.gameObject));
                myreservoir = Fire_RV.GetHeatReservoir(Utils.GetGuidFromGameObject(__instance.gameObject));
            }


            float myreservoirtemp = 0;

            if (myreservoir != null)
            {
                myreservoirtemp = myreservoir.temp;
                //update the reservoir
                myreservoir.Update(__instance);

                if (!GameManager.GetWeatherComponent().IsIndoorEnvironment())
                {
                    myreservoir.heatingsize = Mathf.Clamp(myreservoir.heatingsize, 5f, 25f);
                }
                else
                {
                    myreservoir.heatingsize = Mathf.Clamp(myreservoir.heatingsize, 5f, 1000f);
                }

                //myreservoir.heatingsize = fuel.m_FuelSourceItem.m_HeatOuterRadius * fire_outer + reservoir.heatingsize;
                __instance.m_HeatSource.m_MaxTempIncreaseOuterRadius = myreservoir.heatingsize;

                if (!fireOn && Mathf.Abs(myreservoirtemp) < 0.05)
                {
                    Fire_RV.RemoveReservoir(myreservoir.GUID);
                }
            }



            if (___m_ElapsedOnTODSeconds <= ___m_MaxOnTODSeconds)
            {
                //fire is not in ember stage
                ___m_UseEmbers = false;
                AccessTools.Field(typeof(HeatSource), "m_MaxTempIncrease").SetValue(__instance.m_HeatSource, (object)(___m_FuelHeatIncrease + myreservoirtemp));

                // do some weird score keeping
                float           num  = ___m_ElapsedOnTODSecondsUnmodified / 60f / 60f;
                System.Object[] temp = { num };
                AccessTools.Method(typeof(Fire), "MaybeUpdateLongestBurningFireStat").Invoke(__instance, temp);
                ___m_BurningTimeTODHours = num;
            }
            else
            {
                //fire is past its natural lifetime, ember stage or out...


                //fire is past its natural lifetime, ember stage or out...



                // Debug.Log("HeatReservoir   " + myreservoir.embercmins.ToString());

                float fireRivieSkill = 1;
                switch (GameManager.GetSkillFireStarting().GetCurrentTierNumber())
                {
                case 0:
                    fireRivieSkill = 10f;
                    break;

                case 1:
                    fireRivieSkill = 1f;
                    break;

                case 2:
                    fireRivieSkill = 0.1f;
                    break;

                case 3:
                    fireRivieSkill = 0.01f;
                    break;

                case 4:
                    fireRivieSkill = 0.001f;
                    break;
                }
                if (myreservoir != null && (myreservoir.embercmins > fireRivieSkill || ___m_FuelHeatIncrease > 0.05) && (___m_FuelHeatIncrease + myreservoir.temp) > 1)
                {
                    ___m_UseEmbers = true;
                    ___m_FX.TriggerStage(FireState.Starting_TinderSmolder, ___m_UseEmbers, false);
                    AccessTools.Field(typeof(HeatSource), "m_MaxTempIncrease").SetValue(__instance.m_HeatSource, (object)(___m_FuelHeatIncrease + myreservoir.temp));
                }
                else
                {
                    //fire out
                    ___m_UseEmbers = false;
                    ___m_FX.TriggerStage(FireState.Starting_TinderSmolder, ___m_UseEmbers, false);


                    //if(myreservoir.temp<0.01) __instance.m_HeatSource.TurnOff();

                    __instance.TurnOff();


                    // AccessTools.Field(typeof(HeatSource), "m_TempIncrease").SetValue(__instance.m_HeatSource, (object)(myreservoir.temp));
                    if (___m_Campfire)
                    {
                        ___m_Campfire.SetState(CampfireState.BurntOut);
                    }
                }
            }

            return(false);
        }
Пример #7
0
        private static bool Prefix(Fire __instance, GearItem fuel, bool inForge, ref float ___m_MaxOnTODSeconds, ref float ___m_ElapsedOnTODSeconds, ref float ___m_FuelHeatIncrease)
        {
            //   Debug.Log("Fire:" + __instance.name);
            //Fire_RV.PrintHierarchy(__instance.gameObject);
            __instance.OnFuelBurnt(fuel);
            if (__instance.IsEmbers())
            {
                __instance.m_FX.TriggerStage(FireState.FullBurn, true, false);
                __instance.m_HeatSource.TurnOn();
            }
            if (___m_MaxOnTODSeconds < ___m_ElapsedOnTODSeconds)
            {
                ___m_MaxOnTODSeconds = ___m_ElapsedOnTODSeconds;
            }


            float old_time_remaining = __instance.GetRemainingLifeTimeSeconds();
            float old_max_tod        = ___m_MaxOnTODSeconds;
            float num = Fire_RV.getStoveDurationModifier(__instance.gameObject) * fuel.m_FuelSourceItem.GetModifiedBurnDurationHours(fuel.GetNormalizedCondition()) * 60f * 60f;

            if (!__instance.m_IsPerpetual)
            {
                ___m_MaxOnTODSeconds += num;
                float num2 = ___m_MaxOnTODSeconds - GameManager.GetFireManagerComponent().m_MaxDurationHoursOfFire * 60f * 60f;
                if (num2 > 0f)
                {
                    ___m_ElapsedOnTODSeconds -= num2;
                    ___m_ElapsedOnTODSeconds  = Mathf.Clamp(___m_ElapsedOnTODSeconds, 0f, float.PositiveInfinity);
                }
                ___m_MaxOnTODSeconds = Mathf.Clamp(___m_MaxOnTODSeconds, 0f, GameManager.GetFireManagerComponent().m_MaxDurationHoursOfFire * 60f * 60f);
            }
            float num3;

            if (inForge && fuel.m_FuelSourceItem.m_FireAgeMinutesBeforeAdding > 0f)
            {
                num3 = GameManager.GetFireManagerComponent().m_MaxHeatIncreaseOfFireInForge - ___m_FuelHeatIncrease;
            }
            else
            {
                num3 = GameManager.GetFireManagerComponent().m_MaxHeatIncreaseOfFire - ___m_FuelHeatIncrease;
            }
            num3 = Mathf.Clamp(num3, 0f, float.PositiveInfinity);

            float fuel_heat_increase     = Mathf.Min(num3, Fire_RV.getModifiedHeatIncrease(fuel));
            float fuel_duration_increase = __instance.GetRemainingLifeTimeSeconds() - old_time_remaining;

            ___m_MaxOnTODSeconds = old_max_tod;


            float degmins_old   = old_time_remaining * ___m_FuelHeatIncrease;
            float degmins_fuel  = fuel_duration_increase * fuel_heat_increase;
            float degmins_total = degmins_fuel + degmins_old;

            float shape_heat     = ___m_FuelHeatIncrease + fuel_heat_increase;
            float shape_duration = old_time_remaining + fuel_duration_increase;


            float correction = Mathf.Sqrt(degmins_total / (shape_heat * shape_duration));

            Debug.Log("Old Fire Duration:" + old_time_remaining / 60f + " Fire temp:" + ___m_FuelHeatIncrease);
            Debug.Log("Fuel Item:" + fuel.name + " Heat:" + fuel_heat_increase + " Duration:" + fuel_duration_increase / 60f);
            Debug.Log("degmins total:" + degmins_total + " reshaped degmins:" + (shape_heat * correction * shape_duration * correction));

            ___m_FuelHeatIncrease = shape_heat * correction;
            ___m_MaxOnTODSeconds  = ___m_ElapsedOnTODSeconds + shape_duration * correction;

            __instance.m_HeatSource.m_MaxTempIncrease            = ___m_FuelHeatIncrease;
            __instance.m_HeatSource.m_MaxTempIncreaseInnerRadius = Mathf.Max(fuel.m_FuelSourceItem.m_HeatInnerRadius, __instance.m_HeatSource.m_MaxTempIncreaseInnerRadius);

            float fire_outer = (float)AccessTools.Method(typeof(Fire), "GetFireOuterRadiusScale").Invoke(__instance, null);

            HeatReservoir reservoir = Fire_RV.GetHeatReservoir(Utils.GetGuidFromGameObject(__instance.gameObject));

            float extrasize = 0;

            if (reservoir != null)
            {
                reservoir.heatingsize += fuel.m_FuelSourceItem.m_HeatOuterRadius * fire_outer;
                extrasize              = reservoir.heatingsize;
            }
            //if (!GameManager.GetWeatherComponent().IsIndoorEnvironment()) __instance.m_HeatSource.m_MaxTempIncreaseOuterRadius = Mathf.Clamp(reservoir.heatingsize, 5f, 25f);

            __instance.m_HeatSource.m_MaxTempIncreaseOuterRadius = extrasize;  //Mathf.Max(fuel.m_FuelSourceItem.m_HeatOuterRadius * fire_outer, __instance.m_HeatSource.m_MaxTempIncreaseOuterRadius);



            __instance.m_FX.TriggerFlareupLarge();

            return(false);
        }