internal static void Postfix(Panel_FireStart __instance)
 {
     Implementation.SelectFireStarter(__instance);
     Implementation.SelectTinder(__instance);
     Implementation.SelectFuel(__instance);
     Implementation.SelectAccelerant(__instance);
 }
Beispiel #2
0
        static bool Prefix(Panel_FireStart __instance, Campfire ___m_CampFireInstance, FireStarterItem ___m_KeroseneAccelerant, FireManager ___m_FireManager, bool skipResearchItemCheck = false)
        {
            var traverseInstance = Traverse.Create(__instance);

            traverseInstance.Field("m_FireManager").SetValue(GameManager.GetFireManagerComponent());

            var selectedFireStarter = traverseInstance.Method("GetSelectedFireStarter").GetValue <FireStarterItem>();
            var selectedTinder      = traverseInstance.Method("GetSelectedTinder").GetValue <FuelSourceItem>();
            var selectedFuelSource  = traverseInstance.Method("GetSelectedFuelSource").GetValue <FuelSourceItem>();
            var selectedAccelerant  = traverseInstance.Method("GetSelectedAccelerant").GetValue <FireStarterItem>();

            if (___m_CampFireInstance && ___m_CampFireInstance.TooWindyToStart())
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Itstoowindytostartafirethere"), false);
                return(false);
            }
            if (selectedFireStarter == null || (GameManager.GetSkillFireStarting().TinderRequired() && selectedTinder == null) || selectedFuelSource == null)
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Insufficientmaterialstocreatefire"), false);
                return(false);
            }

            if (selectedFireStarter.m_RequiresSunLight && !traverseInstance.Method("HasDirectSunlight").GetValue <bool>())
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Magnifyinglensrequiresdirectsunlight"), false);
                return(false);
            }
            if (!skipResearchItemCheck)
            {
                ResearchItem component = selectedFuelSource.GetComponent <ResearchItem>();
                if (component != null && !component.IsResearchComplete())
                {
                    Panel_Confirmation.CallbackDelegate forceBurnResearchItem = () => traverseInstance.Method("ForceBurnResearchItem").GetValue();
                    InterfaceManager.m_Panel_Confirmation.ShowBurnResearchNotification(forceBurnResearchItem);
                    return(false);
                }
            }
            if (selectedAccelerant != null && selectedAccelerant == ___m_KeroseneAccelerant)
            {
                GameManager.GetPlayerManagerComponent().DeductLiquidFromInventory(GameManager.GetFireManagerComponent().m_KeroseneLitersAccelerant, GearLiquidTypeEnum.Kerosene);
            }
            float percentChanceSuccess = TinderHelper.CalculateFireStartSuccess(selectedFireStarter, selectedTinder, selectedFuelSource, selectedAccelerant);

            ___m_FireManager.PlayerStartFire(___m_CampFireInstance, selectedFireStarter, selectedTinder, selectedFuelSource, selectedAccelerant, percentChanceSuccess);
            __instance.Enable(false);
            GameAudioManager.PlayGuiConfirm();
            return(false);
        }
Beispiel #3
0
        internal static void SelectTinder(Panel_FireStart instance)
        {
            int index = -1;

            if (Settings.Get().remember_tinder)
            {
                index = instance.m_TinderList.FindIndex(TinderPredicate);
            }
            if (index == -1)
            {
                index = 0;
            }
            instance.m_SelectedTinderIndex = index;
        }
Beispiel #4
0
        internal static void SelectAccelerant(Panel_FireStart instance)
        {
            int index = -1;

            if (Settings.Get().remember_accelerant)
            {
                index = instance.m_AccelerantList.FindIndex(AccelerantPredicate);
            }
            if (index == -1)
            {
                index = 0;
            }
            instance.m_SelectedAccelerantIndex = index;
        }
Beispiel #5
0
        internal static void SelectFuel(Panel_FireStart instance)
        {
            int index = -1;

            if (Settings.Get().remember_fuel)
            {
                index = instance.m_FuelList.FindIndex(FuelPredicate);
            }
            if (index == -1)
            {
                index = 0;
            }
            instance.m_SelectedFuelIndex = index;
        }
Beispiel #6
0
 private static void Postfix(Panel_FireStart __instance)
 {
     if (Settings.options.tinderMatters)
     {
         __instance.m_FireManager = GameManager.GetFireManagerComponent();
         FuelSourceItem tinder = __instance.GetSelectedTinder();
         if (tinder)
         {
             float num = float.Parse(__instance.m_Label_ChanceSuccess.text.Replace("%", ""));
             num += FireAddons.GetModifiedFireStartSkillModifier(tinder);
             num  = Mathf.Clamp(num, 0f, 100f);
             __instance.m_Label_ChanceSuccess.text = num.ToString("F0") + "%";
         }
     }
 }
Beispiel #7
0
        internal static void SaveLastUsedFireRessources(Panel_FireStart instance)

        {
            FireStarterItem fireStarter = instance.GetSelectedFireStarter();
            FuelSourceItem  tinder      = instance.GetSelectedTinder();
            FuelSourceItem  fuel        = instance.GetSelectedFuelSource();
            FireStarterItem accelerant  = instance.GetSelectedAccelerant();

            if (fireStarter)
            {
                var fireStarterGi = fireStarter.GetComponent <GearItem>();
                if (!fireStarterGi.m_TorchItem && !fireStarterGi.m_FlareItem)
                {
                    LastFireStarterID   = fireStarterGi.m_InstanceID;
                    LastFireStarterName = fireStarterGi.m_GearName;
                }
            }
            else
            {
                LastFireStarterID   = -1;
                LastFireStarterName = "";
            }
            if (tinder)
            {
                LastTinderName = tinder.GetComponent <GearItem>().m_GearName;
            }
            else
            {
                LastTinderName = "";
            }
            if (fuel)
            {
                LastFuelName = fuel.GetComponent <GearItem>().m_GearName;
            }
            else
            {
                LastFuelName = "";
            }
            if (accelerant)
            {
                LastAccelerantName = accelerant.GetComponent <GearItem>().m_GearName;
            }
            else
            {
                LastAccelerantName = "";
            }
        }
        internal static void Postfix(Panel_FireStart __instance, ref List <GearItem> gearList, FireStartMaterialType type)
        {
            switch (type)
            {
            case FireStartMaterialType.FireStarter:
                Implementation.SortFireStarter(ref gearList);
                break;

            case FireStartMaterialType.Tinder:
                Implementation.SortTinder(ref gearList);
                break;

            case FireStartMaterialType.FuelSource:
                Implementation.SortFuel(ref gearList);
                break;
            }
        }
Beispiel #9
0
        private static void Postfix(Panel_FireStart __instance)
        {
            Campfire m_CampFireInstance = AccessTools.Field(typeof(Panel_FireStart), "m_CampFireInstance").GetValue(__instance) as Campfire;

            if (m_CampFireInstance == null)
            {
                return;
            }

            Fire fire = m_CampFireInstance.GetComponent <Fire>();

            if (fire == null)
            {
                return;
            }

            FireManager.DestroyFireObject(fire);
        }
Beispiel #10
0
        static bool Prefix(Panel_FireStart __instance)
        {
            var traverseInstance = Traverse.Create(__instance);

            traverseInstance.Field("m_FireManager").SetValue(GameManager.GetFireManagerComponent());

            var selectedFireStarter = traverseInstance.Method("GetSelectedFireStarter").GetValue <FireStarterItem>();
            var selectedTinder      = traverseInstance.Method("GetSelectedTinder").GetValue <FuelSourceItem>();
            var selectedFuelSource  = traverseInstance.Method("GetSelectedFuelSource").GetValue <FuelSourceItem>();
            var selectedAccelerant  = traverseInstance.Method("GetSelectedAccelerant").GetValue <FireStarterItem>();

            float num = TinderHelper.CalculateFireStartSuccess(selectedFireStarter, selectedTinder, selectedFuelSource, selectedAccelerant);

            if (selectedFireStarter.m_RequiresSunLight && !traverseInstance.Method("HasDirectSunlight").GetValue <bool>())
            {
                num = 0f;
            }

            __instance.m_Label_ChanceSuccess.text = num.ToString("F0") + "%";
            return(false);
        }
Beispiel #11
0
        internal static void SelectFireStarter(Panel_FireStart instance)
        {
            int index = -1;

            if (Settings.Get().select_torches_flares_first)
            {
                index = instance.m_StarterList.FindIndex(TorchesOrFlaresPredicate);
            }
            if (Settings.Get().remember_fire_starter&& index == -1)
            {
                index = instance.m_StarterList.FindIndex(FireStarterPredicate); // Find the last fire starter.
                if (index == -1)
                {
                    index = instance.m_StarterList.FindIndex(EqualFireStarterPredicate);
                }                                                                                         // If not, find equal.
            }
            if (index == -1)
            {
                index = 0;
            }
            instance.m_SelectedStarterIndex = index;
        }
Beispiel #12
0
 internal static void Prefix(Panel_FireStart __instance)
 {
     Implementation.SaveLastUsedFireRessources(__instance);
 }