Example #1
0
        internal static void Refuel(GearItem gearItem)
        {
            Panel_Inventory_Examine panel = InterfaceManager.m_Panel_Inventory_Examine;

            float currentLiters  = GetCurrentLiters(panel.m_GearItem);
            float capacityLiters = GetCapacityLiters(panel.m_GearItem);

            if (Mathf.Approximately(currentLiters, capacityLiters))
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_AlreadyFilled"), false);
                return;
            }

            float totalCurrent = GetTotalCurrentLiters(panel.m_GearItem);

            if (totalCurrent < Implementation.MIN_LITERS)
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_NoKeroseneavailable"), false);
                return;
            }

            GameAudioManager.PlayGuiConfirm();
            InterfaceManager.m_Panel_GenericProgressBar.Launch(
                Localization.Get("GAMEPLAY_RefuelingProgress"),
                REFUEL_TIME,
                0,
                0,
                REFUEL_AUDIO,
                null,
                false,
                true,
                new OnExitDelegate(OnRefuelFinished));
        }
Example #2
0
        private static void OnTransfer()
        {
            //MelonLoader.MelonLogger.Log("Transfer");
            var liquidItem = WaterButtons.currentLiquidItemShowing;

            if (liquidItem == null)
            {
                return;
            }
            if (Water.IsEmpty(liquidItem))             // If the selected liquid container is empty.
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_BWM_Empty"));
                GameAudioManager.PlayGUIError();
                return;
            }
            float spaceAvailable = Water.GetRemainingCapacityEmpty() + Water.GetRemainingCapacity(liquidItem.m_LiquidQuality) - liquidItem.m_LiquidCapacityLiters + liquidItem.m_LiquidLiters;

            if (Water.IsNone(spaceAvailable))
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_BWM_NoCapacityAvailable"));
                GameAudioManager.PlayGUIError();
                return;
            }
            float maximumWaterTransfer = Mathf.Min(spaceAvailable, liquidItem.m_LiquidLiters);

            GameAudioManager.PlayGuiConfirm();
            float refillDuration = Mathf.Max(maximumWaterTransfer * 4, 1);

            InterfaceManager.m_Panel_GenericProgressBar.Launch(Localization.Get("GAMEPLAY_BWM_TransferingProgress"), refillDuration, 0f, 0f,
                                                               "Play_SndActionRefuelLantern", null, false, true, new System.Action <bool, bool, float>(OnTransferFinished));
        }
Example #3
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();
        }
Example #4
0
        private static void AppendToFile(string line, string informationType)
        {
            StreamWriter file = File.AppendText(Path.Combine(Implementation.GetModsFolderPath(), @"Coordinates-Grabber-Output.txt"));

            file.WriteLine(line);
            file.Close();
            HUDMessage.AddMessage(informationType + " appended to file");
        }
Example #5
0
        static bool ShouldPreventReading()
        {
            var settings = ReadWhenHungrySettings.Instance;

            if (GameManager.GetWeatherComponent().IsTooDarkForAction(ActionsToBlock.Reading))
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_TooDarkToRead"), false);
                return(true);
            }
            if (!settings.allowReadingWhenTired && GameManager.GetFatigueComponent().IsExhausted())
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_TooTiredToRead"), false);
                return(true);
            }
            if (!settings.allowReadingWhenFreezing && GameManager.GetFreezingComponent().IsFreezing())
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_TooColdToRead"), false);
                return(true);
            }
            if (!settings.allowReadingWhenHungry && GameManager.GetHungerComponent().IsStarving())
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_TooHungryToRead"), false);
                return(true);
            }
            if (!settings.allowReadingWhenThirsty && GameManager.GetThirstComponent().IsDehydrated())
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_TooThirstyToRead"), false);
                return(true);
            }
            if (!settings.allowReadingWhenWounded && GameManager.GetConditionComponent().GetNormalizedCondition() < 0.1f)
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_TooWoundedToRead"), false);
                return(true);
            }
            if (GameManager.GetConditionComponent().HasNonRiskAffliction())
            {
                if ((!settings.allowReadingWithCabinFever && HasAffliction(AfflictionType.CabinFever)) ||
                    (!settings.allowReadingWithFoodPoisoning && HasAffliction(AfflictionType.FoodPoisioning)) ||
                    (!settings.allowReadingWithDysentery && HasAffliction(AfflictionType.Dysentery)) ||
                    (!settings.allowReadingWithInfection && HasAffliction(AfflictionType.Infection)) ||
                    (!settings.allowReadingWithHypothermia && HasAffliction(AfflictionType.Hypothermia)) ||
                    (!settings.allowReadingWithIntestinalParasites && HasAffliction(AfflictionType.IntestinalParasites))

                    || (!settings.allowReadingWithBloodLoss && HasAffliction(AfflictionType.BloodLoss)) ||
                    (!settings.allowReadingWithBrokenRib && HasAffliction(AfflictionType.BrokenRib)) ||
                    (!settings.allowReadingWithBurns && HasAffliction(AfflictionType.Burns)) ||
                    (!settings.allowReadingWithSprainedAnkle && HasAffliction(AfflictionType.SprainedAnkle)) ||
                    (!settings.allowReadingWithSprainedWrist && HasAffliction(AfflictionType.SprainedWrist)))
                {
                    HUDMessage.AddMessage(Localization.Get("GAMEPLAY_CannotReadWithAfflictions"), false);
                    return(true);
                }
                return(false);
            }
            return(false);
        }
Example #6
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;
                }
            }
        }
Example #7
0
        private static void CopyToClipboard(string line, string informationType)
        {
            TextEditor editor = new TextEditor();

            editor.text = line;
            editor.SelectAll();
            editor.Copy();

            HUDMessage.AddMessage(informationType + " copied to clipboard");
        }
Example #8
0
        internal static void GetObjectNameUnderPoint()
        {
            vp_FPSCamera cam        = GameManager.GetVpFPSPlayer().FPSCamera;
            RaycastHit   raycastHit = DoRayCast(cam.transform.position, cam.transform.forward);

            GameObject go = raycastHit.collider.gameObject;

            HUDMessage.AddMessage(go.name);
            Debug.Log("[remove-clutter] Object under crosshair:>>>>> " + go.name);
        }
Example #9
0
 private static bool Prefix()
 {
     if (PlayerIsCarryingCarcass)
     {
         HUDMessage.AddMessage("CANNOT EQUIP ITEM WHILE CARRYING CARCASS", false);
         GameAudioManager.PlayGUIError();
         return(false);
     }
     return(true);
 }
Example #10
0
 public static void LogHUD(string text, bool isDebug = false)
 {
     if (isDebug && !AmbientLights.debugVer)
     {
         return;
     }
     else
     {
         HUDMessage.AddMessage(text, false, false);
     }
 }
Example #11
0
        private IEnumerator StartPlaying()
        {
            try
            {
                this.starting = true;
                LockControls();

                string         songsDirectory = this.GetSongsDirectory();
                PrepareSongJob prepareSongJob = new PrepareSongJob(songsDirectory);
                prepareSongJob.Start();
                yield return(this.EquippableModComponent.StartCoroutine(prepareSongJob.WaitFor()));

                if (prepareSongJob.SelectedSong == null)
                {
                    HUDMessage.AddMessage("[Instrument-Pack]: No songs in directory '" + songsDirectory + "'");
                    yield break;
                }

                Debug.Log("[Instrument-Pack]: Selected song " + prepareSongJob.SelectedSong);

                this.reader = prepareSongJob.Reader;
                if (this.reader == null)
                {
                    HUDMessage.AddMessage("[Instrument-Pack]: Cannot play song '" + prepareSongJob.SelectedSong + "'.", 10, true);
                    yield break;
                }

                this.reader.Volume = TARGET_VOLUME * InterfaceManager.m_Panel_OptionsMenu.m_State.m_MasterVolume / prepareSongJob.MaxSample;

                this.pitchShifter = new SmbPitchShiftingSampleProvider(reader);

                this.waveOutEvent = new WaveOutEvent();
                this.waveOutEvent.PlaybackStopped += this.OnPlaybackStopped;
                this.waveOutEvent.Init(pitchShifter);
                this.waveOutEvent.Play();

                if (this.EquippableModComponent.EquippedModel != null)
                {
                    Playing playing = ModUtils.GetOrCreateComponent <Playing>(this.EquippableModComponent.EquippedModel);
                    playing.Instrument   = this;
                    playing.MistakeAudio = this.MistakeAudio;
                    playing.RefreshSkillEffect();
                }
                else
                {
                    // the equipped model is gone -> stop playing
                    StopPlaying();
                }
            }
            finally
            {
                this.starting = false;
            }
        }
Example #12
0
 private static void Postfix()
 {
     try
     {
         Implementation.Initialize();
     }
     catch (System.Exception e)
     {
         HUDMessage.AddMessage("[" + Implementation.NAME + "] Could not initialize.");
         UnityEngine.Debug.LogException(e);
     }
 }
Example #13
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);
        }
Example #14
0
 private static void Postfix(GearItem gi)
 {
     if (gi.m_ClothingItem != null && gi.m_ClothingItem.m_Region == ClothingRegion.Feet)
     {
         try
         {
             Implementation.UpdateAnkleSupport();
         }
         catch (System.Exception e)
         {
             HUDMessage.AddMessage("[" + Implementation.NAME + "] Could not update ankle protection.");
             UnityEngine.Debug.LogException(e);
         }
     }
 }
Example #15
0
        public static void Log(string text, bool showHUD = true, bool forceLog = false, bool forceHUD = false)
        {
            if (AmbientLights.debugVer || forceLog)
            {
                Debug.Log("[Ambient Lights] " + text);
                MelonLoader.MelonLogger.Msg(text);

                if (showHUD)
                {
                    HUDMessage.AddMessage(text, false, false);
                }
            }
            else if (forceHUD)
            {
                HUDMessage.AddMessage(text, false, false);
            }
        }
Example #16
0
        private static void OnFill()
        {
            //MelonLoader.MelonLogger.Log("Fill");
            var liquidItem = WaterButtons.currentLiquidItemShowing;

            if (liquidItem == null)
            {
                return;
            }
            if (liquidItem.m_LiquidLiters >= liquidItem.m_LiquidCapacityLiters)            //if the container is already full
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_BWM_AlreadyFull"));
                GameAudioManager.PlayGUIError();
                return;
            }

            //If an empty container held nonpotable water before, we want to fill it with potable water.
            if (Water.IsEmpty(liquidItem) && liquidItem.m_LiquidQuality == LiquidQuality.NonPotable)
            {
                liquidItem.m_LiquidQuality = LiquidQuality.Potable;
            }

            //If the current water supply is empty.
            if (Water.IsNone(Water.GetActual(liquidItem.m_LiquidQuality)))
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_BWM_Empty"));
                GameAudioManager.PlayGUIError();
                return;
            }
            float maxWaterInBottle   = Mathf.Min(Water.GetActual(liquidItem.m_LiquidQuality), liquidItem.m_LiquidCapacityLiters);
            float maximumWaterRefill = Mathf.Max(maxWaterInBottle - liquidItem.m_LiquidLiters, 0);

            if (Water.IsNone(maximumWaterRefill))             // If nothing gets transferred.
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_None"));
                GameAudioManager.PlayGUIError();
                return;
            }
            GameAudioManager.PlayGuiConfirm();
            float refuelDuration = Mathf.Max(maximumWaterRefill * 4, 1);

            InterfaceManager.m_Panel_GenericProgressBar.Launch(Localization.Get("GAMEPLAY_BWM_FillingProgress"), refuelDuration, 0f, 0f,
                                                               "Play_SndActionRefuelLantern", null, false, true, new System.Action <bool, bool, float>(OnFillFinished));
        }
Example #17
0
        public override bool ProcessInteraction()
        {
            if (IsTooDarkToRepair())
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_RequiresLightToRepair"));
                GameAudioManager.PlayGUIError();
                return(true);
            }

            if (IsMissingRequiredTools())
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_ToolRequiredToForceOpen").Replace("{item-name}", Localization.Get("GAMEPLAY_RadialTools")));
                GameAudioManager.PlayGUIError();
                return(true);
            }

            this.StartProgressBar("GAMEPLAY_RepairingProgress", GetRepairAudio(), 5);

            return(true);
        }
Example #18
0
 internal static void Postfix(Panel_PickWater __instance)
 {
     if (InputManager.GetEquipPressed(__instance))
     {
         var waterSource = __instance.m_WaterSource;
         if (!waterSource)
         {
             Implementation.LogError("UpdateCapacityInfo: Could not find WaterSource");
             return;
         }
         if (Water.IsNone(waterSource.m_CurrentLiters))
         {
             HUDMessage.AddMessage(Localization.Get("GAMEPLAY_BWM_Empty"));
             GameAudioManager.PlayGUIError();
             return;
         }
         float waterVolumeToDrink = GameManager.GetPlayerManagerComponent().CalculateWaterVolumeToDrink(waterSource.m_CurrentLiters);
         if (Water.IsNone(waterVolumeToDrink))
         {
             GameAudioManager.PlayGUIError();
             HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Youarenotthirsty"));
             return;
         }
         GameAudioManager.PlayGuiConfirm();
         WaterSupply waterSupply;
         if (waterSource.GetQuality() == LiquidQuality.Potable)
         {
             waterSupply = __instance.InstantiateWaterSupply(__instance.m_WaterSupply_Potable).m_WaterSupply;
         }
         else
         {
             waterSupply = __instance.InstantiateWaterSupply(__instance.m_WaterSupply_NonPotable).m_WaterSupply;
         }
         waterSupply.m_VolumeInLiters = waterSource.m_CurrentLiters;
         waterSource.RemoveLiters(waterVolumeToDrink);
         GameManager.GetPlayerManagerComponent().DrinkFromWaterSupply(waterSupply, waterSupply.m_VolumeInLiters);
         UnityEngine.Object.Destroy(waterSupply.gameObject);
         __instance.ExitInterface();
     }
 }
Example #19
0
        private static bool Prefix(Panel_Inventory_Examine __instance)
        {
            if (GameManager.GetWeatherComponent().IsTooDarkForAction(ActionsToBlock.Harvest))
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_RequiresLightToHarvest"), false);
                GameAudioManager.PlayGUIError();
                return(false);
            }
            Harvest component = __instance.m_GearItem.GetComponent <Harvest>();

            Debug.Log("gear:" + component.m_YieldGear[0].name);
            if (component.m_YieldGear[0].name == "GEAR_Stick")
            {
                __instance.m_HarvestTimeSeconds /= 6.0f;
            }
            __instance.StartHarvest(component.m_DurationMinutes, component.m_Audio);
            if (component.m_YieldGear[0].name == "GEAR_Stick")
            {
                __instance.m_HarvestTimeSeconds *= 6.0f;
            }
            return(false);
        }
Example #20
0
        private static void OnDump()
        {
            //MelonLoader.MelonLogger.Log("Dump");
            LiquidItem liquidItem = WaterButtons.currentLiquidItemShowing;

            if (liquidItem == null)
            {
                return;
            }
            if (liquidItem.m_LiquidLiters <= 0.001f)
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_BWM_Empty"));
                GameAudioManager.PlayGUIError();
                return;
            }

            GameAudioManager.PlayGuiConfirm();
            float lostLitersDuration = Mathf.Max(liquidItem.m_LiquidLiters * 4, 1);

            InterfaceManager.m_Panel_GenericProgressBar.Launch(Localization.Get("GAMEPLAY_BWM_DumpingProgress"), lostLitersDuration, 0f, 0f,
                                                               "Play_SndActionRefuelLantern", null, false, true, new System.Action <bool, bool, float>(OnDumpFinished));
        }
Example #21
0
        internal static void Drain(GearItem gearItem)
        {
            Panel_Inventory_Examine panel = InterfaceManager.m_Panel_Inventory_Examine;

            float currentLiters = GetCurrentLiters(panel.m_GearItem);

            if (currentLiters < MIN_LITERS)
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_AlreadyEmpty"));
                GameAudioManager.PlayGUIError();
                return;
            }

            float totalCapacity = GetTotalCapacityLiters(panel.m_GearItem);
            float totalCurrent  = GetTotalCurrentLiters(panel.m_GearItem);

            if (Mathf.Approximately(totalCapacity, totalCurrent))
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_NoFuelCapacityAvailable"));
                GameAudioManager.PlayGUIError();
                return;
            }

            GameAudioManager.PlayGuiConfirm();
            InterfaceManager.m_Panel_GenericProgressBar.Launch(
                Localization.Get("GAMEPLAY_DrainingProgress"),
                REFUEL_TIME,
                0,
                0,
                REFUEL_AUDIO,
                null,
                false,
                true,
                new OnExitDelegate(OnDrainFinished));

            // HACK: somehow this is needed to revert the button text to "Refuel", which will be active when draining finishes
            BetterFuelManagementUtils.SetButtonLocalizationKey(panel.m_RefuelPanel.GetComponentInChildren <UIButton>(), "GAMEPLAY_Refuel");
        }
Example #22
0
        internal static bool Prefix(CookingPotItem __instance)
        {
            float waterAmount = __instance.m_LitersWaterBeingBoiled;

            if (Water.IsNone(waterAmount))             //only applies with water
            {
                return(true);
            }
            float waterVolumeToDrink = GameManager.GetPlayerManagerComponent().CalculateWaterVolumeToDrink(waterAmount);

            if (Water.IsNone(waterVolumeToDrink))             // Not thirsty.
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Youarenotthirsty"));
                GameAudioManager.PlayGUIError();
                return(false);
            }
            bool is_ready = __instance.GetCookingState() == CookingPotItem.CookingState.Ready;
            bool is_not_ready_and_no_fire = __instance.GetCookingState() == CookingPotItem.CookingState.Cooking && !__instance.AttachedFireIsBurning();

            if (is_ready || is_not_ready_and_no_fire)             //patch applies if ready or if still cooking but no fire.
            {
                DrinkFromPot.cookingPot = __instance;

                DrinkFromPot.OnDrink();

                if (Water.IsNone(__instance.m_LitersWaterBeingBoiled))
                {
                    return(true);
                }
                else
                {
                    GameManager.GetPlayerManagerComponent().ExitInspectGearMode(false);
                    return(false);
                }
            }
            return(true);
        }
Example #23
0
 public static string onScreen(this string str, bool highPriority = false)
 {
     HUDMessage.AddMessage(str, highPriority);
     return(str);
 }
Example #24
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);
        }
Example #25
0
 internal static void SignalItemBlocked()
 {
     GameAudioManager.PlayGUIError();
     HUDMessage.AddMessage(Localization.Get("GAMEPLAY_BlockedByItemAbove"), false);
 }
        public static void SnowFoxFetchItem()
        {
            if ((FoxVars.foundItem == true) && FoxVars.targetTransform != null && Settings.options.foxCalories >= 300)
            {
                FoxVars.rangeToTarget = Vector3.Distance(FoxVars.foxTransform.position, FoxVars.targetTransform.position);

                if (FoxVars.rangeToTarget >= 1.0f)
                {
                    FoxVars.foxState_Movement = "move";
                    FoxVars.foxanimator.SetBool("Stand", false);
                    FoxVars.idleStateChangeTimer = 0;
                    FoxVars.idleStateCounter     = 0;

                    //rotate to look at the target
                    FoxVars.targetPlayerDir = FoxVars.targetTransform.position - FoxVars.foxTransform.position;

                    FoxVars.angleToTarget     = Vector3.SignedAngle(FoxVars.targetPlayerDir, FoxVars.foxTransform.forward, Vector3.up);
                    FoxVars.angleToTargetTree = (FoxVars.angleToTarget / 100) * -1; // Range [-1.8] - [1.8]

                    // Smooth turn animation
                    FoxVars.angleToTargetTreeTemp = Mathf.SmoothDamp(FoxVars.angleToTargetTreeTemp, FoxVars.angleToTargetTree, ref FoxVars.angleVelocity, 0.2f);
                    FoxVars.foxanimator.SetFloat("Horizontal", FoxVars.angleToTargetTreeTemp);


                    // Set speed in relation to distance to target
                    if (FoxVars.rangeToTarget >= 16f)
                    {
                        if (FoxVars.foxanimator.speed != 1.8)
                        {
                            FoxVars.foxanimator.speed = 1.8f;
                        }
                        FoxVars.foxanimator.SetFloat("Vertical", FoxVars.rangeToTarget / 3);
                    }
                    else if (FoxVars.rangeToTarget < 16f && FoxVars.rangeToTarget >= 12f)
                    {
                        if (FoxVars.foxanimator.speed != 1.5)
                        {
                            FoxVars.foxanimator.speed = 1.5f;
                        }
                        FoxVars.foxanimator.SetFloat("Vertical", FoxVars.rangeToTarget / 3);
                    }
                    else if (FoxVars.rangeToTarget < 12f && FoxVars.rangeToTarget >= 5f)
                    {
                        if (FoxVars.foxanimator.speed != 1.3)
                        {
                            FoxVars.foxanimator.speed = 1.3f;
                        }
                        FoxVars.foxanimator.SetFloat("Vertical", FoxVars.rangeToTarget / 3);
                    }
                    else if (FoxVars.rangeToTarget < 5f && FoxVars.rangeToTarget >= 0f)
                    {
                        if (FoxVars.foxanimator.speed != 1.3)
                        {
                            FoxVars.foxanimator.speed = 1.3f;
                        }
                        FoxVars.foxanimator.SetFloat("Vertical", 1.2f);
                    }



                    FoxVars._velocity.y += FoxVars.Gravity * Time.deltaTime;
                    FoxVars.foxController.Move(FoxVars._velocity * Time.deltaTime);
                }
                else
                {
                    //MelonLogger.Log("Got the item! " + FoxVars.sphereLastHitObj.name);

                    GameObject foxJaw;
                    foxJaw = FoxVars.foxTransform.GetChild(0).GetChild(0).GetChild(0).GetChild(2).GetChild(0).GetChild(0).GetChild(0).GetChild(2).gameObject;
                    FoxVars.sphereLastHitObj.transform.SetParent(foxJaw.transform, true);
                    FoxVars.targetHitObject.GetComponent <GearItem>().m_NonInteractive = false;


                    FoxVars.sphereTargetObject = 0;

                    // Turn item if lantern
                    if (FoxVars.sphereLastHitObj.name.Contains("KeroseneLamp") == true)
                    {
                        //MelonLogger.Log("Got the lamp! " + FoxVars.sphereLastHitObj.name);
                        FoxVars.lanternRigid = FoxVars.sphereLastHitObj.GetComponent <Rigidbody>();
                        //FoxVars.lanternRigid.isKinematic = false;
                        //FoxVars.lanternRigid.useGravity = false;
                        //FoxVars.lanternRigid.detectCollisions = false;

                        FoxVars.sphereLastHitObj.transform.localPosition = new Vector3(-0.3f, 0.3f, 0);
                        //FoxVars.lanternRigid.MovePosition(new Vector3(-0.3f,0.3f,0f));

                        //FoxVars.lanternRigid.constraints = RigidbodyConstraints.FreezeAll;
                        //FoxVars.lanternRigid.centerOfMass = Vector3.zero;
                        //FoxVars.lanternRigid.inertiaTensorRotation = Quaternion.identity;

                        //FoxVars.lanternRigid.transform.localPosition = new Vector3(FoxVars.lanternX, FoxVars.lanternY, FoxVars.lanternZ);
                        //FoxVars.lanternRigid.transform.localRotation = Quaternion.Euler(0, 0, 0.0f);
                    }
                    else
                    {
                        FoxVars.sphereLastHitObj.transform.localPosition = new Vector3(-0.05f, 0.05f, 0);
                        //FoxVars.carryLantern.transform.localPosition = new Vector3(FoxVars.lanternX, FoxVars.lanternY, FoxVars.lanternZ); //new Vector3(0.01f, 0.05f, 0.523f);
                        //FoxVars.carryLantern.transform.localRotation = Quaternion.Euler(0, 0, 0.0f);
                    }

                    //child.transform.SetParent(null);
                    FoxVars.foxShouldFollowPlayer    = true;
                    FoxVars.foxShouldFollowSomething = false;
                }
            }
            else if (Settings.options.foxCalories < 300)
            {
                FoxVars.foundItem = false;
                FoxVars.foxShouldFollowSomething = false;

                if (Settings.options.settingDisplayMsg == true)
                {
                    HUDMessage.AddMessage("[The fox is too hungry to obey]", false);
                }
            }
        }
Example #27
0
        public static void SnowFoxFetchTarget()
        {
            if ((FoxVars.foundRabbit == true) && FoxVars.targetTransform != null && Settings.options.foxCalories >= 300)
            {
                FoxVars.rangeToTarget = Vector3.Distance(FoxVars.foxTransform.position, FoxVars.targetTransform.position);

                if (FoxVars.rangeToTarget >= 0.3f)
                {
                    FoxVars.foxState_Movement = "move";
                    FoxVars.foxanimator.SetBool("Stand", false);
                    FoxVars.idleStateChangeTimer = 0;
                    FoxVars.idleStateCounter     = 0;

                    //rotate to look at the target
                    FoxVars.targetPlayerDir = FoxVars.targetTransform.position - FoxVars.foxTransform.position;

                    FoxVars.angleToTarget     = Vector3.SignedAngle(FoxVars.targetPlayerDir, FoxVars.foxTransform.forward, Vector3.up);
                    FoxVars.angleToTargetTree = (FoxVars.angleToTarget / 100) * -1; // Range [-1.8] - [1.8]

                    // Smooth turn animation
                    FoxVars.angleToTargetTreeTemp = Mathf.SmoothDamp(FoxVars.angleToTargetTreeTemp, FoxVars.angleToTargetTree, ref FoxVars.angleVelocity, 0.2f);
                    FoxVars.foxanimator.SetFloat("Horizontal", FoxVars.angleToTargetTreeTemp);



                    // Set speed in relation to distance to target
                    if (FoxVars.rangeToTarget >= 16f)
                    {
                        FoxVars.foxanimator.speed = 1.8f;
                    }
                    else if (FoxVars.rangeToTarget < 16f && FoxVars.rangeToTarget >= 12f)
                    {
                        FoxVars.foxanimator.speed = 1.5f;
                    }
                    else if (FoxVars.rangeToTarget < 12f && FoxVars.rangeToTarget >= 7f)
                    {
                        FoxVars.foxanimator.speed = 1.3f;
                    }
                    else if (FoxVars.rangeToTarget < 7f && FoxVars.rangeToTarget >= 0.5f)
                    {
                        if (FoxVars.rabbidEvaded == false)
                        {
                            FoxVars.targetHitObject.GetComponentInChildren <BaseAi>().ForceWanderPause(-1);
                        }

                        if (FoxVars.foxJumping == false)
                        {
                            FoxVars.foxanimator.speed = 1.3f;
                        }
                        else
                        {
                            FoxVars.foxanimator.speed = 2.2f;
                            //FoxVars.foxanimator.SetFloat("Vertical", 3f);
                        }


                        if (Mathf.Abs(FoxVars.rangeToTarget - 3.3f) < 0.15f && !FoxVars.foxanimator.GetCurrentAnimatorStateInfo(FoxVars.foxanimator.GetLayerIndex("Fox")).IsName("Jump Forward (Single)"))
                        {
                            FoxVars.foxJumping = true;
                            FoxVars.foxanimator.Play("Jump Forward (Single)", FoxVars.foxanimator.GetLayerIndex("Fox"), 0f);
                            MelonLogger.Log("Jump!");
                            FoxVars.rabbidCatchRand = UnityEngine.Random.Range(0, 150);
                        }
                    }

                    FoxVars.foxanimator.SetFloat("Vertical", FoxVars.rangeToTarget / 3);



                    FoxVars._velocity.y += FoxVars.Gravity * Time.deltaTime;
                    FoxVars.foxController.Move(FoxVars._velocity * Time.deltaTime);
                }
                else
                {
                    // MelonLogger.Log("Random: " + FoxVars.rabbidCatchRand);
                    //FoxVars.rabbidCatchRand <= Settings.options.foxCatchChance

                    if (FoxVars.rabbidCatchRand <= Settings.options.foxCalories / 10)
                    {
                        MelonLogger.Log("Killed the rabbit!");
                        FoxVars.foundRabbit = false;
                        FoxVars.foxJumping  = false;
                        //FoxVars.foxState_Movement = "idle";
                        FoxVars.targetHitObject.GetComponentInChildren <BaseAi>().ApplyDamage(200f, 0f, DamageSource.Unspecified, "null");
                        FoxVars.rabbidKilled = true;

                        GameObject foxJaw;
                        foxJaw = FoxVars.foxTransform.GetChild(0).GetChild(0).GetChild(0).GetChild(2).GetChild(0).GetChild(0).GetChild(0).GetChild(2).gameObject;
                        FoxVars.whiteRabbit.transform.SetParent(foxJaw.transform, true);

                        FoxVars.whiteRabbit.transform.localPosition = new Vector3(FoxVars.bunnyX, FoxVars.bunnyY, FoxVars.bunnyZ); //new Vector3(0.01f, 0.05f, 0.523f);
                        FoxVars.whiteRabbit.transform.localRotation = Quaternion.Euler(0, 0, 0.0f);
                        //child.transform.SetParent(null);
                        FoxVars.foxShouldFollowPlayer    = true;
                        FoxVars.foxShouldFollowSomething = false;
                    }
                    else
                    {
                        MelonLogger.Log("Rabbit evaded!");
                        FoxVars.rabbidEvaded             = true;
                        FoxVars.foundRabbit              = false;
                        FoxVars.foxJumping               = false;
                        FoxVars.foxShouldFollowSomething = false;
                        FoxVars.foxShouldFollowPlayer    = true;
                        FoxVars.sphereTargetObject       = 0;


                        FoxVars.targetHitObject.GetComponentInChildren <BaseAi>().ExitWanderPaused();
                        FoxVars.targetHitObject.GetComponentInChildren <BaseAi>().SetFleeReason(BaseAi.AiFleeReason.ThrownStone);
                        FoxVars.targetHitObject.GetComponentInChildren <BaseAi>().FleeFrom(FoxVars.foxTransform);
                        FoxVars.targetHitObject.GetComponentInChildren <BaseAi>().EnterFlee();
                    }
                }
            }
            else if (Settings.options.foxCalories < 300)
            {
                FoxVars.foundRabbit = false;
                FoxVars.foxShouldFollowSomething = false;

                if (Settings.options.settingDisplayMsg == true)
                {
                    HUDMessage.AddMessage("[The fox is too hungry to obey]", false);
                }
            }
        }
Example #28
0
        public static void SnowFoxInputsUpdate()
        {
            if (InputManager.GetKeyDown(InputManager.m_CurrentContext, Settings.GetInputKeyFromString(Settings.options.buttonFollowPlayer)) && FoxVars.foxactive == true && FoxVars.foxSpawned == true)
            {
                // Toggle following player
                if (FoxVars.foxShouldFollowPlayer == false)
                {
                    //MelonLogger.Log("Fox is now following player");
                    FoxVars.foxShouldFollowPlayer    = true;
                    FoxVars.foxShouldFollowSomething = false;
                    if (Settings.options.settingDisplayMsg == true)
                    {
                        HUDMessage.AddMessage("[Fox] Follow mode enabled", false);
                    }
                }
                else if (FoxVars.foxShouldFollowPlayer == true)
                {
                    //MelonLogger.Log("Fox is now waiting");
                    FoxVars.foxShouldFollowPlayer = false;
                    FoxVars.foxState_Movement     = "idle";
                    if (Settings.options.settingDisplayMsg == true)
                    {
                        HUDMessage.AddMessage("[Fox] Follow mode disabled", false);
                    }
                    FoxVars.idleStateChangeTimer = 0;
                }
            }

            // Teleport fox to player
            if (InputManager.GetKeyDown(InputManager.m_CurrentContext, Settings.GetInputKeyFromString(Settings.options.buttonTeleport)) && FoxVars.foxactive == true && FoxVars.foxSpawned == true) // Teleport fox to player
            {
                SnowFoxTeleportFoxMain.TeleportFoxToTarget(FoxVars.playerTransform);

                if (Settings.options.settingDisplayMsg == true)
                {
                    HUDMessage.AddMessage("[Fox] Teleport to player", false);
                }
            }


            if (InputManager.GetKeyDown(InputManager.m_CurrentContext, Settings.GetInputKeyFromString(Settings.options.buttonCommandMode)) && FoxVars.foxactive == true && FoxVars.foxSpawned == true && FoxVars.targetsphereActive == false) // Enable targeting mode
            {
                //FoxVars.showCrosshair = true;
                //Settings.options.foxCalories = Settings.options.foxCalories - 100;

                FoxVars.targetsphereActive = true;

                GameManager.GetPlayerManagerComponent().SetControlMode(PlayerControlMode.BearSpear);

                if (GameManager.GetPlayerAnimationComponent().m_State != PlayerAnimation.State.Aiming)
                {
                    FoxVars.tempPlayerState = GameManager.GetPlayerAnimationComponent().m_State;
                }
                //GameManager.GetPlayerAnimationComponent().m_State = PlayerAnimation.State.Aiming;
                //GameManager.GetPlayerAnimationComponent().MaybeSetState(PlayerAnimation.State.Aiming);
            }

            if (InputManager.GetMouseButtonDown(InputManager.m_CurrentContext, 0) && FoxVars.foxactive == true && FoxVars.foxSpawned == true && FoxVars.targetsphereActive == true)
            {
                if (FoxVars.targetsphereActive == true)
                {
                    //GameManager.GetPlayerManagerComponent().SetControlMode(PlayerControlMode.Normal);
                    //GameManager.GetPlayerAnimationComponent().m_State = FoxVars.tempPlayerState;
                    //GameManager.GetPlayerAnimationComponent().m_State = PlayerAnimation.State.Hidden;
                    GameManager.GetPlayerManagerComponent().SetControlMode(PlayerControlMode.Normal);
                    if (FoxVars.sphereTargetObject == 1)
                    {
                        FoxVars.targetHitObject = FoxVars.sphereLastHitObj;

                        FoxVars.targetTransform = FoxVars.sphereLastHitObj.transform;

                        FoxVars.foxShouldFollowPlayer    = false;
                        FoxVars.foxShouldFollowSomething = false;
                        FoxVars.rabbidKilled             = false;
                        FoxVars.rabbidEvaded             = false;

                        FoxVars.ringred.transform.position   = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringgreen.transform.position = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringblue.transform.position  = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringwhite.transform.position = new Vector3(-1000, -1000, -1000);
                    }

                    if (FoxVars.sphereTargetObject == 2 && FoxVars.foundRabbit == true)
                    {
                        FoxVars.targetHitObject = FoxVars.sphereLastHitObj;

                        FoxVars.targetTransform = FoxVars.sphereLastHitObj.transform;

                        FoxVars.foxShouldFollowPlayer    = false;
                        FoxVars.foxShouldFollowSomething = true;
                        FoxVars.rabbidKilled             = false;
                        FoxVars.rabbidEvaded             = false;

                        //MelonLogger.Log("Found the rabbit! " + FoxVars.whiteRabbit.name);

                        FoxVars.ringred.transform.position   = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringgreen.transform.position = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringblue.transform.position  = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringwhite.transform.position = new Vector3(-1000, -1000, -1000);
                    }

                    if (FoxVars.sphereTargetObject == 3)
                    {
                        FoxVars.targetHitObject = FoxVars.sphereLastHitObj;

                        FoxVars.targetTransform = FoxVars.sphereLastHitObj.transform;

                        FoxVars.foxShouldFollowPlayer    = false;
                        FoxVars.foxShouldFollowSomething = true;
                        FoxVars.rabbidKilled             = false;
                        FoxVars.rabbidEvaded             = false;

                        FoxVars.ringred.transform.position   = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringgreen.transform.position = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringblue.transform.position  = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringwhite.transform.position = new Vector3(-1000, -1000, -1000);
                    }

                    if (FoxVars.sphereTargetObject == 4)
                    {
                        FoxVars.targetHitObject = FoxVars.sphereLastHitObj;

                        FoxVars.targetTransform = FoxVars.sphereLastHitObj.transform;

                        FoxVars.foxShouldFollowPlayer    = false;
                        FoxVars.foxShouldFollowSomething = true;

                        FoxVars.ringred.transform.position   = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringgreen.transform.position = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringblue.transform.position  = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringwhite.transform.position = new Vector3(-1000, -1000, -1000);
                    }

                    FoxVars.targetsphereActive = false;
                }
            }

            if (InputManager.GetMouseButtonDown(InputManager.m_CurrentContext, 1) && FoxVars.foxactive == true && FoxVars.foxSpawned == true)
            {
                if (FoxVars.targetsphereActive == true)
                {
                    //GameManager.GetPlayerAnimationComponent().m_State = FoxVars.tempPlayerState;
                    //GameManager.GetPlayerAnimationComponent().m_State = PlayerAnimation.State.Hidden;
                    //GameManager.GetPlayerManagerComponent().SetControlMode(PlayerControlMode.Normal);
                    GameManager.GetPlayerManagerComponent().SetControlMode(PlayerControlMode.Normal);
                }
                //GameManager.GetPlayerAnimationComponent().MaybeSetState(PlayerAnimation.State.Aiming);

                FoxVars.targetsphereActive = false;
                FoxVars.foundRabbit        = false;
                FoxVars.foundBed           = false;
                FoxVars.foundItem          = false;

                FoxVars.ringred.transform.position   = new Vector3(-1000, -1000, -1000);
                FoxVars.ringgreen.transform.position = new Vector3(-1000, -1000, -1000);
                FoxVars.ringblue.transform.position  = new Vector3(-1000, -1000, -1000);
                FoxVars.ringwhite.transform.position = new Vector3(-1000, -1000, -1000);
            }
        }
Example #29
0
        public static void SnowFoxTargeting()
        {
            if (FoxVars.targetsphereActive == true)
            {
                int layerMask = 0;

                layerMask |= 1 << 16;                                                                                                                                                                               // NPC layer
                layerMask |= 1 << 17;                                                                                                                                                                               // gear layer
                layerMask |= 1 << 19;                                                                                                                                                                               // gear layer
                layerMask |= 1 << 14;                                                                                                                                                                               // player layer

                FoxVars.sphereTargethit = Physics.SphereCastAll(GameManager.GetMainCamera().transform.position, 0.35f, GameManager.GetMainCamera().transform.TransformDirection(Vector3.forward), 200f, layerMask); // spherecast to find a rabbit.

                foreach (RaycastHit foo in FoxVars.sphereTargethit)
                {
                    if ((foo.transform.gameObject.name != null) && foo.transform.gameObject.name.Contains("GEAR_RawMeatRabbit") == true || foo.transform.gameObject.name.Contains("GEAR_Raw") == true && foo.transform.gameObject.activeSelf)
                    {
                        FoxVars.sphereLastHit    = foo.transform.gameObject.transform;
                        FoxVars.sphereLastHitObj = foo.transform.gameObject;
                        if (Settings.options.settingDisplayMsg == true)
                        {
                            HUDMessage.AddMessage("[Fox] Eat raw food", false);
                        }

                        FoxVars.sphereTargetObject = 4;
                        //MelonLogger.Log("Target sphere: " + foo.transform.gameObject.name);

                        FoxVars.foundRabbit = false;
                        FoxVars.foundItem   = false;
                        FoxVars.foundBed    = false;
                        FoxVars.foundFood   = true;
                        //MelonLogger.Log("Found food: " + foo.transform.gameObject.name);
                    }
                    else if ((foo.transform.gameObject.name != null) && foo.transform.gameObject.name.Contains("WILDLIFE_Rabbit") == true && foo.transform.gameObject.activeSelf)
                    {
                        FoxVars.sphereLastHit      = foo.transform.gameObject.transform;
                        FoxVars.sphereLastHitObj   = foo.transform.gameObject;
                        FoxVars.sphereTargetObject = 2;
                        //MelonLogger.Log("Target sphere: " + foo.transform.gameObject.name);
                        FoxVars.whiteRabbit = foo.transform.gameObject;
                        if (Settings.options.settingDisplayMsg == true)
                        {
                            HUDMessage.AddMessage("[Fox] Hunt rabbit", false);
                        }

                        FoxVars.foundRabbit = true;
                        FoxVars.foundBed    = false;
                        FoxVars.foundItem   = false;
                        FoxVars.foundFood   = false;
                    }
                    else if ((foo.transform.gameObject.name != null) && foo.transform.gameObject.name.Contains("GEAR_") == true && foo.transform.gameObject.activeSelf)
                    {
                        FoxVars.sphereLastHit      = foo.transform.gameObject.transform;
                        FoxVars.sphereLastHitObj   = foo.transform.gameObject;
                        FoxVars.carryLantern       = foo.transform.gameObject;
                        FoxVars.sphereTargetObject = 3;
                        //MelonLogger.Log("Target sphere: " + foo.transform.gameObject.name);
                        if (Settings.options.settingDisplayMsg == true)
                        {
                            HUDMessage.AddMessage("[Fox] Fetch item", false);
                        }

                        FoxVars.foundRabbit = false;
                        FoxVars.foundItem   = true;
                        FoxVars.foundBed    = false;
                        FoxVars.foundFood   = false;
                        //MelonLogger.Log("Found item: " + foo.transform.gameObject.name);
                    }
                    else if (foo.transform.gameObject.name != null && foo.transform.gameObject.name.Contains("Fox") == true)
                    {
                        FoxVars.sphereLastHit      = foo.transform.gameObject.transform;
                        FoxVars.sphereLastHitObj   = foo.transform.gameObject;
                        FoxVars.sphereTargetObject = 1;
                        FoxVars.foundBed           = false;
                        FoxVars.foundFood          = false;
                        FoxVars.foundItem          = false;
                        FoxVars.foundRabbit        = false;

                        if (Settings.options.settingDisplayMsg == true)
                        {
                            if (Settings.options.foxCalories > 9000)
                            {
                                HUDMessage.AddMessage("[Please ... no more ... food]", false);
                            }
                            else if (Settings.options.foxCalories > 6000)
                            {
                                HUDMessage.AddMessage("[What are you doing?]", false);
                            }
                            else if (Settings.options.foxCalories > 3000)
                            {
                                HUDMessage.AddMessage("[Please stop feeding the fox]", false);
                            }
                            else if (Settings.options.foxCalories > 2000)
                            {
                                HUDMessage.AddMessage("[The fox is overfed]", false);
                            }
                            else if (Settings.options.foxCalories > 1000)
                            {
                                HUDMessage.AddMessage("[The fox is not hungry]", false);
                            }
                            else if (Settings.options.foxCalories > 600)
                            {
                                HUDMessage.AddMessage("[The fox is a bit hungry]", false);
                            }
                            else if (Settings.options.foxCalories > 150)
                            {
                                HUDMessage.AddMessage("[The fox is a very hungry]", false);
                            }
                            else if (Settings.options.foxCalories <= 150)
                            {
                                HUDMessage.AddMessage("[The fox is starving]", false);
                            }
                        }
                    }
                    else
                    {
                    }
                }

                if (FoxVars.sphereLastHit != null)
                {
                    if (FoxVars.sphereTargetObject == 1) //fox
                    {
                        FoxVars.ringred.transform.position   = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringgreen.transform.position = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringblue.transform.position  = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringwhite.transform.position = new Vector3(FoxVars.sphereLastHit.position.x, FoxVars.sphereLastHit.position.y + 0.09f, FoxVars.sphereLastHit.position.z - 0.12f);
                    }
                    else if (FoxVars.sphereTargetObject == 2) //rabbit
                    {
                        FoxVars.ringgreen.transform.position = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringwhite.transform.position = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringblue.transform.position  = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringred.transform.position   = new Vector3(FoxVars.sphereLastHit.position.x, FoxVars.sphereLastHit.position.y + 0.055f, FoxVars.sphereLastHit.position.z);
                    }
                    else if (FoxVars.sphereTargetObject == 3) // GEAR
                    {
                        FoxVars.ringred.transform.position   = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringwhite.transform.position = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringblue.transform.position  = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringgreen.transform.position = new Vector3(FoxVars.sphereLastHit.position.x, FoxVars.sphereLastHit.position.y + 0.055f, FoxVars.sphereLastHit.position.z);
                    }
                    else if (FoxVars.sphereTargetObject == 4) // Food
                    {
                        FoxVars.ringred.transform.position   = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringwhite.transform.position = new Vector3(-1000, -1000, -1000);
                        FoxVars.ringblue.transform.position  = new Vector3(FoxVars.sphereLastHit.position.x, FoxVars.sphereLastHit.position.y + 0.055f, FoxVars.sphereLastHit.position.z);
                        FoxVars.ringgreen.transform.position = new Vector3(-1000, -1000, -1000);
                    }
                }
            }
        }
Example #30
0
        private static void CopyToClipboard(string line, string informationType)
        {
            GUIUtility.systemCopyBuffer = line;

            HUDMessage.AddMessage(informationType + " copied to clipboard");
        }