Example #1
0
        /// <summary>
        /// Sends an already constructed HUDMessage, if HUDMessage has an ID of 0 it will pick the next ID.
        /// </summary>
        /// <param name="message">HUDMessage being sent or resent.</param>
        /// <returns>Returns HUDMessage with populated ID</returns>
        public HUDMessage Send(HUDMessage message)
        {
            var msg = Encode(ref message);

            MyAPIGateway.Multiplayer.SendMessageTo(HUDAPI_ADVMSG, msg, MyAPIGateway.Multiplayer.MyId, true);
            return(message);
        }
        private void GameLoop_DayStarted(object sender, DayStartedEventArgs e)
        {
            //chance a message will appear, editable in config.json
            if (Config.msgChance < new Random().Next(1, 99))
            {
                return;
            }

            /*
             * The below script will generate a string from the NiceMessages object, make it into a HUDmessage object,
             * then it will change the timeLeft (in miliseconds) attribute of that object according to the user's setting
             * loaded form the config.json file.
             */
            try
            {
                HUDMessage morningMsg = new HUDMessage
                                            (niceMessages.getMorningMessage(Game1.currentSeason, Game1.weatherIcon), "");
                morningMsg.timeLeft = Config.msgFadeOutTimer;
                Game1.addHUDMessage(morningMsg);
            }

            //Catch a bad formatting excption
            catch (System.Collections.Generic.KeyNotFoundException) {
                Monitor.Log("Invalid key: Make sure there are no spelling errors in the keys in unifiedMessages.json\n" +
                            "For a list of valid keys, please see the README", LogLevel.Error);
            }
        }
Example #3
0
        private bool PyTKTileAction_Action(string key, string values, GameLocation location, Vector2 position, string layer)
        {
            HUDMessage hudMessage = new HUDMessage($"{values} (X{(int)position.X} Y{(int)position.Y})", config.messageType);

            Game1.hudMessages.Add(hudMessage);

            return(true);
        }
        /// <summary>
        /// Displays a HUD message to all clients and server containing this information.
        /// </summary>
        /// <param name="data"></param>
        public static void SendHUDMessageWithIcon(object data)
        {
            DataInfo   obj     = (DataInfo)data;
            string     type    = obj.type;
            HUDMessage message = (HUDMessage)obj.data;

            Game1.addHUDMessage(message);
        }
Example #5
0
        private void ShowHUDMessage(string message, int duration = 3500)
        {
            HUDMessage hudMessage = new HUDMessage(message, 3);

            hudMessage.noIcon   = true;
            hudMessage.timeLeft = duration;
            Game1.addHUDMessage(hudMessage);
        }
Example #6
0
        public void NotifyHUD(string text)
        {
            var msg = new HUDMessage(text);

            msg.noIcon = true;
            Game1.addHUDMessage(msg);
            msg.timeLeft = 500 * msg.message.Length;
        }
Example #7
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 #8
0
        /**************************************************
        * EVENT HANDLERS
        **************************************************/

        public void OnButtonsChanged(object sender, ButtonsChangedEventArgs args)
        {
            if (!DisableUntilHPChanges && Config.temp_hide_hotkey.JustPressed())
            {
                var hudmsg = new HUDMessage(Helper.Translation.Get("do_hidden_temp"), "");
                Game1.addHUDMessage(hudmsg);
                DisableUntilHPChanges = true;
            }
        }
Example #9
0
        public static void ShowMessage(string msg, int whatType)
        {
            var hudmsg = new HUDMessage(msg, Color.SeaGreen, 5250f, true)
            {
                whatType = whatType
            };

            Game1.addHUDMessage(hudmsg);
        }
Example #10
0
        public static void ShowMessage(string msg)
        {
            var hudmsg = new HUDMessage(msg, Color.SeaGreen, StardewNotification.Config.NotificationDuration, true)
            {
                whatType = 2
            };

            Game1.addHUDMessage(hudmsg);
        }
Example #11
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 #12
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 #13
0
        private void DayStarted(object sender, EventArgs e)
        {
            //Game1.addHUDMessage(new HUDMessage(text, 0));
            //HUDMessage icon types:
            //1 = yellow star
            //2 = yellow "!"
            //3 = red "X"
            //4 = energy symbol
            //5 = health symbol

            int maxTextLength = 100;    //long weather reports can run off the screen, so truncate them

            if (Config.ShowDailyLuck)
            {
                //Farmer farmer = Game1.getPlayerOrEventFarmer();
                string fortune = this.Helper.Reflection.GetMethod(new TV(), "getFortuneForecast").Invoke <string>(Game1.player);
                fortune = fortune.Substring(0, Math.Min(maxTextLength, fortune.Length));
                if (Config.ShowDailyLuckNumber)
                {
                    if (Game1.player.DailyLuck > 0)
                    {
                        fortune += " (+" + Game1.player.DailyLuck + ")";
                    }
                    else
                    {
                        fortune += " (" + Game1.player.DailyLuck + ")";
                    }
                }

                HUDMessage fortuneMessage = new HUDMessage(fortune, new Color(), Config.NotificationDuration, true);    //the Color variable does nothing
                fortuneMessage.noIcon = true;
                Game1.addHUDMessage(fortuneMessage);
            }


            if (Config.ShowQueenOfSauce)
            {
                string recipe = getTheQueenOfSauceRecipeToday();
                if (recipe != null)
                {
                    HUDMessage recipeMessage = new HUDMessage(recipe + " is on today!", new Color(), Config.NotificationDuration, true);    //the Color variable does nothing
                    recipeMessage.noIcon = true;
                    Game1.addHUDMessage(recipeMessage);
                }
            }


            if (Config.ShowWeatherForcast)
            {
                string forcast = this.Helper.Reflection.GetMethod(new TV(), "getWeatherForecast").Invoke <string>();
                forcast = forcast.Substring(0, Math.Min(maxTextLength, forcast.Length));
                HUDMessage forcastMessage = new HUDMessage(forcast, new Color(), Config.NotificationDuration, true);    //the Color variable does nothing
                forcastMessage.noIcon = true;
                Game1.addHUDMessage(forcastMessage);
            }
        }
Example #14
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 #15
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 #16
0
        public static void ShowHudMessage(string message, int duration = 3500)
        {
            HUDMessage hudMessage = new HUDMessage(message, 3)
            {
                noIcon   = true,
                timeLeft = duration
            };

            addHUDMessage(hudMessage);
        }
        public void AddHudMessage(string message)
        {
            if (this.currentMessage != null && Game1.hudMessages.Contains(this.currentMessage))
            {
                Game1.hudMessages.Remove(this.currentMessage);
            }

            this.currentMessage = new HUDMessage("Range Display: " + message, "");
            Game1.addHUDMessage(this.currentMessage);
        }
Example #18
0
 private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
 {
     if (QueuedMessage != null)
     {
         Game1.addHUDMessage(QueuedMessage);
         QueuedMessage = null;
     }
     Routing.Reset();
     this.speechEngine.SendEvent("SAVE_LOADED");
 }
Example #19
0
 private static bool Prefix()
 {
     if (PlayerIsCarryingCarcass)
     {
         HUDMessage.AddMessage("CANNOT EQUIP ITEM WHILE CARRYING CARCASS", false);
         GameAudioManager.PlayGUIError();
         return(false);
     }
     return(true);
 }
Example #20
0
        //Event handler method
        private void dayStartedEvents(object sender, DayStartedEventArgs e)
        {
            bool hasSilo = Game1.getFarm().buildings.Any(b => b.buildingType.Value == "Silo");

            //Chat Mode
            if (config.notificationMode == notificationModes.ChatMode)
            {
                //If multiple people have the mod installed on a server the chat would get a per player message. This checks to see if you're the master player and if not returns.
                //Can be overridden by config
                if (config.checkMasterPlayer)
                {
                    if (Game1.player != Game1.MasterPlayer)
                    {
                        return;
                    }
                }

                //Send chat logic
                if (hasSilo)
                {
                    //Scrapped, SMAPI overrides Game1.multiplayer in SGame.CS line 171
                    //Multiplayer multiplayer = this.Helper.Reflection.GetField<Multiplayer>(Game1.game1, "Multiplayer").GetValue();
                    //multiplayer.sendChatMessage(LocalizedContentManager.LanguageCode.en, $"Hay left: {Game1.getFarm().piecesOfHay}");

                    //Thank you Pathoschild for the workaround
                    Game1.chatBox.activate();
                    Game1.chatBox.setText($"Hay left: {Game1.getFarm().piecesOfHay}");
                    Game1.chatBox.chatBox.RecieveCommandInput('\r');
                }

                //Called if Farmer doesn't have silo
                else
                {
                    this.Monitor.VerboseLog("You do not have a Silo, build Silo to get report.");
                }
            }

            //UI Mode
            else if (config.notificationMode == notificationModes.UIMode)
            {
                //UI Message logic
                if (hasSilo)
                {
                    HUDMessage report = new HUDMessage($"Hay left: {Game1.getFarm().piecesOfHay}", (String)null);
                    Game1.addHUDMessage(report);
                }

                //Called if Farmer doesn't have silo
                else
                {
                    HUDMessage report = new HUDMessage("You do not have a silo built, build one to receive messages", 3);
                    Game1.addHUDMessage(report);
                }
            }
        }
Example #21
0
        private void InputEvents_ButtonPressed(object sender, EventArgsInput e)
        {
            if (Context.IsWorldReady && Game1.player.CurrentTool is Hoe && treasure && e.IsUseToolButton && e.Cursor.GrabTile == tile) // save is loaded
            {
                //this.Monitor.Log($"Treasure Params: {e.Cursor.GrabTile + ", " + tile + ", " + Game1.player.Position}");

                var data = Game1.content.Load <Dictionary <int, string> >("Data\\ObjectInformation");

                item = new StardewValley.Object(rand(data.Count - 1, 0), 1);

                if (clue == clueTypes[0])
                {
                    while (item.Category == -4 || item.Category == -9 || item.Category == -7 || item.Category == -12 || item.DisplayName.ToLower().Contains("error"))
                    {
                        item = new StardewValley.Object(rand(data.Count - 1, 0), 1);
                    }
                }
                else
                {   //weap, ring, equipment, tools (HARD)
                    while ((item.Category != -98 && item.Category != -29 && item.Category != -96 && item.Category != -99) || item.DisplayName.ToLower().Contains("error"))
                    {
                        item = new StardewValley.Object(rand(data.Count - 1, 0), 1);
                    }
                }


                List <Item> l = new List <Item>();
                l.Add(item);
                curr = new Chest(rand(200, 0), l, tile);


                while (!loc.isTileLocationTotallyClearAndPlaceable(tile) || !loc.isTileOnMap(tile))
                {
                    tile = loc.getRandomTile();
                }
                loc.objects.Add(tile, curr);

                HUDMessage message = new HUDMessage($"You find a hidden chest.");

                Game1.addHUDMessage(message);

                message.color     = new Color(218, 165, 32);
                message.timeLeft += 2000.0f;
                message.noIcon    = true;

                message.update(Game1.currentGameTime);


                treasure = false;

                SetTimer2(5000, 1);

                SetTimer(15000, 1);
            }
        }
Example #22
0
        /// <summary>Raised after the game begins a new day (including when the player loads a save).</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnDayStarted(object sender, DayStartedEventArgs e)
        {
            Helper.Content.InvalidateCache("LooseSprites/Cursors");
            if (OurMoon.GetMoonRiseTime() <= 0600 || OurMoon.GetMoonRiseTime() >= 2600 && ModConfig.ShowMoonPhase)
            {
                Game1.addHUDMessage(new TCHUDMessage(
                                        Helper.Translation.Get("moon-text.moonriseBefore6",
                                                               new { moonPhase = OurMoon.DescribeMoonPhase(), riseTime = OurMoon.GetMoonRiseDisplayTime() }),
                                        OurMoon.CurrentPhase()));
            }

            if (OurMoon == null)
            {
                Monitor.Log("OurMoon is null");
                return;
            }

            if (queuedMsg != null)
            {
                Game1.addHUDMessage(queuedMsg);
                queuedMsg = null;
            }

            if (Context.IsMainPlayer)
            {
                if (OurMoon.MoonTracker.CurrentSeason != Game1.currentSeason)
                {
                    OurMoon.MoonTracker.CurrentSeason      = Game1.currentSeason;
                    OurMoon.MoonTracker.FullMoonThisSeason = false;
                }
            }

            if (ModConfig.EclipseOn && OurMoon.MoonTracker.IsEclipseTomorrow)
            {
                OurMoon.IsEclipse = true;
                var n = new HUDMessage(Helper.Translation.Get("moon-text.solareclipse"))
                {
                    color    = Color.SeaGreen,
                    fadeIn   = true,
                    timeLeft = 4000,
                    noIcon   = true
                };
                Game1.addHUDMessage(n);
                MoonMessage message = GenerateLunarSync();
                MPHandler.SendMessage <MoonMessage>(message, "MoonMessage", new[] { "KoihimeNakamura.LunarDisturbances" });
                Monitor.Log("There's a solar eclipse today!", LogLevel.Info);
                OurMoon.MoonTracker.IsEclipseTomorrow = false;
            }


            OurMoon.UpdateForBloodMoon();
            OurMoon.OnNewDay();
            OurMoon.HandleMoonAfterWake();
        }
Example #23
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 #24
0
 public static void LogHUD(string text, bool isDebug = false)
 {
     if (isDebug && !AmbientLights.debugVer)
     {
         return;
     }
     else
     {
         HUDMessage.AddMessage(text, false, false);
     }
 }
Example #25
0
        public static void SendBirthdayMessageToOtherPlayers()
        {
            HUDMessage message = new HUDMessage("It's " + Game1.player.Name + "'s birthday! Happy birthday to them!", 1);


            foreach (KeyValuePair <long, Farmer> f in Game1.otherFarmers)
            {
                HappyBirthday.ModHelper.Multiplayer.SendMessage <string>(message.message, FSTRING_SendBirthdayMessageToOthers, new string[] { HappyBirthday.ModHelper.Multiplayer.ModID }, new long[] { f.Key });
                //ModdedUtilitiesNetworking.ModCore.multiplayer.sendMessage(FSTRING_SendBirthdayMessageToOthers, ModdedUtilitiesNetworking.Framework.Extentions.StrardewValleyExtentions.MessagesExtentions.HUDMessageIconIdentifier, message, ModdedUtilitiesNetworking.Framework.Enums.MessageTypes.messageTypes.SendToSpecific, f);
            }
        }
Example #26
0
        public static void SendBirthdayMessageToOtherPlayers()
        {
            string str = BirthdayMessages.GetTranslatedString("Happy Birthday: Farmhand Birthday Message");

            str.Replace("@", Game1.player.name);
            HUDMessage message = new HUDMessage(str, 1);

            foreach (KeyValuePair <long, Farmer> f in Game1.otherFarmers)
            {
                HappyBirthday.ModHelper.Multiplayer.SendMessage <string>(message.message, FSTRING_SendBirthdayMessageToOthers, new string[] { HappyBirthday.ModHelper.Multiplayer.ModID }, new long[] { f.Key });
            }
        }
Example #27
0
 // this is for removing the "Only usable in Cellar" message
 private void GameEvents_UpdateTick(object sender, EventArgs e)
 {
     if (suppressCaskMessage == true)
     {
         string     text    = Game1.content.LoadString("Strings\\Objects:CaskNoCellar");
         HUDMessage message = Game1.hudMessages.FirstOrDefault(p => p.message == text);
         if (message != null)
         {
             Game1.hudMessages.Remove(message);
         }
     }
 }
Example #28
0
 private static void Postfix()
 {
     try
     {
         Implementation.Initialize();
     }
     catch (System.Exception e)
     {
         HUDMessage.AddMessage("[" + Implementation.NAME + "] Could not initialize.");
         UnityEngine.Debug.LogException(e);
     }
 }
        /*
         * the idea was to use a single function to display messages in both cases, but the signature isn't the same
         * IE: morning looks for season and curr weather icon, where town would be looking at location
         * I mean, I guess I could put it all into one object and load all the logic in there, but I don't like that
         * In main I can just access the game stuff and pass it in,
         * private HUDMessage getMsgToDisplay(Object messageObject) {
         *  return new HUDMessage("message", "");
         * }*/
        private void Player_Warped(object sender, WarpedEventArgs e)
        {
            //if (Context.CanPlayerMove) { return; }   revisit later  //if there's a cutscene, do nothing
            if (Config.twnMsgChance < new Random().Next(1, 60))
            {
                return;
            }                                                               //set to 60 for testings, 100 percet chance

            GameLocation newLoc = Game1.currentLocation;


            //If there's an event, set the flag and then check it. true means that this is the 1st warp so return,
            //then reset the flag and now that it's false, we can safely do the correct warp/message display.
            if (Game1.CurrentEvent != null)
            {
                townMessages.dubWarpFlagSet();
                if (townMessages.doubleWarpFlag == true)
                {
                    return;
                }

                //impliment the fest messages in this block.
                //      townMessages.getFestMsg(whichFest);
            }

            ////////testblock///////////
            Monitor.Log("Current Location: " + newLoc.Name, LogLevel.Info);
            Monitor.Log(townMessages.getTownMessage(newLoc.Name) ?? "not in list.", LogLevel.Warn);
            ////////testblock///////////

            //let's just do some dumb code.

            String msgToDisplay = townMessages.getTownMessage(newLoc.Name);

            if (msgToDisplay == null)
            {
                return;
            }

            HUDMessage townMsg = new HUDMessage(msgToDisplay, "");

            townMsg.timeLeft = Config.townMsgFadeOut;
            Game1.addHUDMessage(townMsg);

            ////////////////////////////block for testing, delete later////////////////////////////////////////////////

            Monitor.Log("Current location: " + newLoc.Name, LogLevel.Info);
            try
            {
                Monitor.Log("Current Fest: " + newLoc.currentEvent.FestivalName, LogLevel.Info);
            }
            catch (System.NullReferenceException) { Monitor.Log("Fest Name Null", LogLevel.Info); }
        }
Example #30
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 #31
0
        private byte[] Encode(ref HUDMessage message)
        {
            ushort msgtype = 3;
            if (message.id == 0)
            {

                message.id = GetNextID();
            }

            byte[] ver = BitConverter.GetBytes(MOD_VER);
            byte[] type = BitConverter.GetBytes(msgtype);
            byte[] modid = BitConverter.GetBytes(m_modId);
            byte[] mid = BitConverter.GetBytes(message.id);
            byte[] ttl = BitConverter.GetBytes(message.ttl);
            byte[] vx = BitConverter.GetBytes(message.origin.X);
            byte[] vy = BitConverter.GetBytes(message.origin.Y);
            byte[] options = new byte[1] { (byte)message.options };
            byte[] cx = BitConverter.GetBytes(message.shadowcolor.X);
            byte[] cy = BitConverter.GetBytes(message.shadowcolor.Y);
            byte[] cz = BitConverter.GetBytes(message.shadowcolor.Z);
            byte[] cw = BitConverter.GetBytes(message.shadowcolor.W);
            byte[] scale = BitConverter.GetBytes(message.scale);
            byte[] encode = Encoding.UTF8.GetBytes(message.message);
            byte[] msg = new byte[ver.Length + type.Length + cx.Length * 4 + scale.Length + modid.Length + mid.Length + ttl.Length + vx.Length + vy.Length + encode.Length + options.Length];
            int lth = 0;
            Copy(ref msg, ref ver, ref lth);
            Copy(ref msg, ref type, ref lth);
            Copy(ref msg, ref modid, ref lth);
            Copy(ref msg, ref mid, ref lth);
            Copy(ref msg, ref ttl, ref lth);
            Copy(ref msg, ref vx, ref lth);
            Copy(ref msg, ref vy, ref lth);
            Copy(ref msg, ref options, ref lth);
            Copy(ref msg, ref cx, ref lth);
            Copy(ref msg, ref cy, ref lth);
            Copy(ref msg, ref cz, ref lth);
            Copy(ref msg, ref cw, ref lth);
            Copy(ref msg, ref scale, ref lth);
            Copy(ref msg, ref encode, ref lth);
            return msg;
        }
Example #32
0
 /// <summary>
 /// Send already constructed HUDMessage to others. If the HUDMessage has an ID of 0 it will pick the next ID.
 /// </summary>
 /// <param name="message">HUDMessage being sent or resent.</param>
 /// <returns>Returns HUDMessage with populated ID</returns>
 public HUDMessage SendToOthers(HUDMessage message)
 {
     var msg = Encode(ref message);
     MyAPIGateway.Multiplayer.SendMessageToOthers(HUDAPI_ADVMSG, msg, true);
     return message;
 }
Example #33
0
 /// <summary>
 /// Creates and Sends a HUDMessage
 /// </summary>
 /// <param name="id">ID of the HUDMessage, if 0 it will choose the next ID.</param>
 /// <param name="timetolive">Time in frames until HUD element expires, not recommended to set this to 1 as it can lead to flicker.</param>
 /// <param name="origin">Vector2D between 1,1 and -1,-1.</param>
 /// <param name="message">Actual message you want to send.&lt;color=colorname&gt; to change the color of the text.</param>
 /// <returns>HUDMessage that can be resent.</returns>
 public HUDMessage CreateAndSend(long id, int timetolive, Vector2D origin, string message)
 {
     HUDMessage Hmessage = new HUDMessage(id, timetolive, origin, message);
     return Send(Hmessage);
 }