public void DisplayWeather(TV tv, TemporaryAnimatedSprite sprite, Farmer who, string answer)
        {
            TemporaryAnimatedSprite BackgroundSprite = new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(497, 305, 42, 28), 9999f, 1, 999999, tv.getScreenPosition(), false, false, (float)((tv.boundingBox.Bottom - 1) / 10000.0 + 9.99999974737875E-06), 0.0f, Color.White, tv.getScreenSizeModifier(), 0.0f, 0.0f, 0.0f, false);
            TemporaryAnimatedSprite WeatherSprite    = DescriptionEngine.GetWeatherOverlay(Conditions, tv);

            string OnScreenText = "";

            if (BackgroundSprite is null)
            {
                Monitor.Log("Background Sprite is null");
            }
            if (WeatherSprite is null)
            {
                Monitor.Log("Weather Sprite is null");
            }

            string MoonPhase = "";
            bool   MoonIsUp  = false;

            if (UseLunarDisturbancesApi)
            {
                MoonPhase = MoonAPI.GetCurrentMoonPhase();
                MoonIsUp  = MoonAPI.IsMoonUp(Game1.timeOfDay);
            }

            double fog = ClimatesOfFerngill.GetClimateForDay(SDate.Now().AddDays(1)).RetrieveOdds(Dice, "fog", SDate.Now().AddDays(1).Day);

            OnScreenText += DescriptionEngine.GenerateTVForecast(Conditions, ClimatesOfFerngill.Dice, fog, MoonPhase, MoonIsUp);

            CustomTVMod.showProgram(BackgroundSprite, OnScreenText, CustomTVMod.endProgram, WeatherSprite);
        }
Exemple #2
0
        public void DisplayWeather(TV tv, TemporaryAnimatedSprite sprite, Farmer who, string answer)
        {
            TemporaryAnimatedSprite BackgroundSprite = new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(497, 305, 42, 28), 9999f, 1, 999999, tv.getScreenPosition(), false, false, (float)((tv.boundingBox.Bottom - 1) / 10000.0 + 9.99999974737875E-06), 0.0f, Color.White, tv.getScreenSizeModifier(), 0.0f, 0.0f, 0.0f, false);
            TemporaryAnimatedSprite WeatherSprite    = DescriptionEngine.GetWeatherOverlay(Conditions, tv);

            string OnScreenText = "";

            if (BackgroundSprite is null)
            {
                Monitor.Log("Background Sprite is null");
            }
            if (WeatherSprite is null)
            {
                Monitor.Log("Weather Sprite is null");
            }

            string MoonPhase = "";

            if (UseLunarDisturbancesApi)
            {
                MoonPhase = MoonAPI.GetCurrentMoonPhase();
            }

            OnScreenText += DescriptionEngine.GenerateTVForecast(Conditions, MoonPhase);

            CustomTVMod.showProgram(BackgroundSprite, OnScreenText, CustomTVMod.endProgram, WeatherSprite);
        }
        private void ContinueShow(TV tv, TvScript script, int index)
        {
            ScriptPage page = script.Pages[index];

            TemporaryAnimatedSprite BackgroundSprite = new TemporaryAnimatedSprite()
            {
                paused             = true,
                texture            = _spriteSheet,
                sourceRect         = new Rectangle(page.X, page.Y, 42, 28),
                interval           = 9999f,
                animationLength    = 999999,
                totalNumberOfLoops = 999999,
                position           = tv.getScreenPosition(),
                flicker            = false,
                flipped            = false,
                layerDepth         = (float)((tv.boundingBox.Bottom - 1) / 10000.0 + 9.99999974737875E-06),
                alphaFade          = 0f,
                color          = Color.White,
                scale          = tv.getScreenSizeModifier(),
                scaleChange    = 0.0f,
                rotation       = 0.0f,
                rotationChange = 0.0f,
                local          = false
            };

            if (index == script.Pages.Length - 1)
            {
                CustomTVMod.showProgram(BackgroundSprite, script.Pages[index].Text, CustomTVMod.endProgram, BackgroundSprite);
            }
            else
            {
                CustomTVMod.showProgram(BackgroundSprite, script.Pages[index].Text, () => ContinueShow(tv, script, ++index), BackgroundSprite);
            }
        }
Exemple #4
0
 public TVChannel(string id, string text, Action <TV, TemporaryAnimatedSprite, SFarmer, string> action = null, TemporaryAnimatedSprite sprite = null, Action afterDialogues = null, TemporaryAnimatedSprite overlay = null)
 {
     this.sprite         = sprite;
     this.overlay        = overlay;
     this.text           = text;
     this.id             = id;
     this.action         = (action == null) ? (tv, ta, sf, s) => CustomTVMod.showProgram(this) : action;
     this.afterDialogues = (afterDialogues == null) ? endProgram : afterDialogues;
 }
        public void CheckChannelDay()
        {
            CustomTVMod.removeKey(LivingWithTheAnimals);

            if (SDate.Now().DayOfWeek == DayOfWeek.Tuesday || SDate.Now().DayOfWeek == DayOfWeek.Saturday)
            {
                if (GetCurrentEpisode() != null)
                {
                    string name = DataLoader.i18n.Get("TV.LivingWithTheAnimals.ChannelDisplayName");
                    CustomTVMod.addChannel(LivingWithTheAnimals, name, ShowAnnouncement);
                }
            }
        }
        public override void Entry(IModHelper helper)
        {
            _helper  = helper;
            _monitor = Monitor;

            //testing();

            harmonyFix();

            registerConsoleCommands();
            CustomTVMod.load();
            SaveHandler.setUpEventHandlers();
        }
        public override void Entry(IModHelper helper)
        {
            _helper  = helper;
            _monitor = Monitor;

            //testing();

            harmonyFix();

            TimeEvents.AfterDayStarted += (a, b) => CustomObjectData.collection.useAll(k => k.Value.sdvId = k.Value.getNewSDVId());
            registerConsoleCommands();
            CustomTVMod.load();
            SaveHandler.setUpEventHandlers();
        }
Exemple #8
0
            internal static void Postfix(ref bool __result, ref TV __instance, SFarmer who, bool justCheckingForActivity)
            {
                if (CustomTVMod.channels.Count < 6 && !CustomTVMod.changed)
                {
                    return;
                }

                if (Game1.Date.Season == "fall" && Game1.Date.DayOfMonth == 26 && (Game1.stats.getStat("childrenTurnedToDoves") > 0U && !who.mailReceived.Contains("cursed_doll")))
                {
                    return;
                }

                CustomTVMod.checkForAction(__instance, who, justCheckingForActivity);
                __result = true;
            }
        public override void Entry(IModHelper helper)
        {
            _helper  = helper;
            _monitor = Monitor;

            //testing();

            harmonyFix();
            FormatManager.Instance.RegisterMapFormat(new NewTiledTmxFormat());

            SaveHandler.BeforeRebuilding += (a, b) => CustomObjectData.collection.useAll(k => k.Value.sdvId = k.Value.getNewSDVId());
            registerConsoleCommands();
            CustomTVMod.load();
            PyLua.init();
            SaveHandler.setUpEventHandlers();
        }
Exemple #10
0
        private void deliverNews(TV tv, TemporaryAnimatedSprite sprite, Farmer who, string answer)
        {
            Texture2D newsScreen = null;

            try  //Try to load news screen from .json file
            {
                newsScreen = Helper.Content.Load<Texture2D>(NewsItems[dailyNews].Texture);
            }
            catch  //If the load failed, just load the default newscaster.
            {
                Monitor.Log("Unable to load newscaster(" + NewsItems[dailyNews].Texture + ") defined in: " + NewsItems[dailyNews].Source, LogLevel.Error);
            }

            TemporaryAnimatedSprite newsSprite = new TemporaryAnimatedSprite(newsScreen, new Rectangle(0, 0, 42, 28), 150f, 2, 999999, tv.getScreenPosition(), false, false, (float)((double)(tv.boundingBox.Bottom - 1) / 10000.0 + 9.99999974737875E-06), 0.0f, Color.White, tv.getScreenSizeModifier(), 0.0f, 0.0f, 0.0f, false);
            string text = NewsItems[dailyNews].HeadlineText;
            CustomTVMod.showProgram(newsSprite, text, CustomTVMod.endProgram);
        }
        private void ShowPresentation()
        {
            string text = DataLoader.i18n.Get(_episodes[GetShowNumber()].Text);

            if (text.Contains("|"))
            {
                if (DataLoader.ModConfig.DisableMeat)
                {
                    text = text.Split('|')[1];
                }
                else
                {
                    text = text.Split('|')[0];
                }
            }
            CustomTVMod.showProgram(_showSprite, text, CustomTVMod.endProgram);
        }
Exemple #12
0
        public void CheckChannelDay()
        {
            CustomTVMod.removeKey(LivingWithTheAnimals);

            if (SDate.Now().DayOfWeek == DayOfWeek.Tuesday || SDate.Now().DayOfWeek == DayOfWeek.Saturday)
            {
                if (GetCurrentEpisode() is Episode episode)
                {
                    string name = DataLoader.i18n.Get("TV.LivingWithTheAnimals.ChannelDisplayName");
                    if (episode.Rerun)
                    {
                        name += " " + DataLoader.i18n.Get("TV.LivingWithTheAnimals.ReRunDisplaySuffix");;
                    }

                    CustomTVMod.addChannel(LivingWithTheAnimals, name, ShowAnnouncement);
                }
            }
        }
        private void AddRecipe()
        {
            string[] recipeSplit = _recipes[GetRecipeNumber()].Split('/');
            string   recipeKey   = recipeSplit[0];
            string   recipeName  = recipeSplit[2];
            string   addRecipeText;

            if (!Game1.player.cookingRecipes.ContainsKey(recipeKey))
            {
                addRecipeText = Game1.content.LoadString("Strings\\StringsFromCSFiles:TV.cs.13153", (object)recipeName);
                Game1.player.cookingRecipes.Add(recipeKey, 0);
            }
            else
            {
                addRecipeText = Game1.content.LoadString("Strings\\StringsFromCSFiles:TV.cs.13151", (object)recipeName);
            }
            CustomTVMod.showProgram(_queenSprite, addRecipeText, CustomTVMod.endProgram);
        }
Exemple #14
0
        private void checkIfNews()
        {
            CustomTVMod.removeChannel("News");

            Random randomNews = new Random();
            dailyNews = randomNews.Next(0, NewsItems.Count);

            string str = Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth);

            if (str.Equals("Tue") || str.Equals("Fri") || str.Equals("Sat"))
            {
                string season = Game1.currentSeason;
                CustomTVMod.addChannel("News", "News Report", deliverNews);

                if (config.showMessages)
                    showMessage("Breaking News for " + char.ToUpper(season[0]) + season.Substring(1) + " " + Game1.dayOfMonth, 2);
            }
        }
 private void CheckIfShowActiveAtCurrentTime()
 {
     if (_showToday)
     {
         if (Game1.timeOfDay < _todaysScript.EndTime && Game1.timeOfDay >= _todaysScript.StartTime)
         {
             if (!_showAdded)
             {
                 CustomTVMod.addChannel(_config.ShowId, _config.ShowTitle, BeginShow);
                 _showAdded = true;
             }
         }
         else if (_showAdded)
         {
             CustomTVMod.removeChannel(_config.ShowId);
             _showAdded = false;
         }
     }
 }
        /// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            CustomTVMod.changeAction("weather", DisplayWeather);

            if (Context.IsMainPlayer)
            {
                Conditions.trackerModel = Helper.Data.ReadSaveData <ClimateTracker>("climate-tracker");

                if (Conditions.trackerModel is null)
                {
                    Conditions.trackerModel = new ClimateTracker();
                }

                if (Conditions.trackerModel?.TempsOnNextDay != null || !Conditions.trackerModel.TempsOnNextDay.IsDefault())
                {
                    Conditions.SetTodayTemps(Conditions.trackerModel.TempsOnNextDay);
                }
            }
        }
        public void CheckChannelDay()
        {
            CustomTVMod.removeKey("MeatFriday");

            if (SDate.Now().DayOfWeek == DayOfWeek.Friday)
            {
                int recipe = GetRecipeNumber();
                if (recipe >= 2)
                {
                    Boolean rerun = Game1.stats.DaysPlayed % 2 == 0U;

                    string name = DataLoader.i18n.Get("TV.MeatFriday.ChannelDisplayName");
                    if (rerun)
                    {
                        name += " " + DataLoader.i18n.Get("TV.MeatFriday.ReRunDisplaySuffix");;
                    }
                    CustomTVMod.addChannel("MeatFriday", name, ShowQueenAnnouncement);
                }
            }
        }
Exemple #18
0
        public void DisplayWeather(TV tv, TemporaryAnimatedSprite sprite, StardewValley.Farmer who, string answer)
        {
            TemporaryAnimatedSprite BackgroundSprite = new TemporaryAnimatedSprite(Game1.mouseCursors, new Rectangle(497, 305, 42, 28), 9999f, 1, 999999, tv.getScreenPosition(), false, false, (float)((double)(tv.boundingBox.Bottom - 1) / 10000.0 + 9.99999974737875E-06), 0.0f, Color.White, tv.getScreenSizeModifier(), 0.0f, 0.0f, 0.0f, false);
            TemporaryAnimatedSprite WeatherSprite    = DescriptionEngine.GetWeatherOverlay(Conditions, tv);

            string OnScreenText = "";

            if (BackgroundSprite is null)
            {
                Monitor.Log("Background Sprite is null");
            }
            if (WeatherSprite is null)
            {
                Monitor.Log("Weather Sprite is null");
            }

            OnScreenText += DescriptionEngine.GenerateTVForecast(Conditions, OurMoon);

            CustomTVMod.showProgram(BackgroundSprite, OnScreenText, CustomTVMod.endProgram, WeatherSprite);
        }
Exemple #19
0
        public override void Entry(IModHelper helper)
        {
            _helper  = helper;
            _monitor = Monitor;

            //testing();
            //messageTest()

            harmonyFix();
            FormatManager.Instance.RegisterMapFormat(new NewTiledTmxFormat());

            SaveHandler.BeforeRebuilding += (a, b) => CustomObjectData.collection.useAll(k => k.Value.sdvId = k.Value.getNewSDVId());
            initializeResponders();
            startResponder();
            registerConsoleCommands();
            CustomTVMod.load();
            PyLua.init();
            SaveHandler.setUpEventHandlers();
            ContentSync.ContentSyncHandler.initialize();
            PlayerEvents.Warped += (s, e) => e.NewLocation?.Map.enableMoreMapLayers();
        }
Exemple #20
0
        public override void Entry(IModHelper helper)
        {
            _helper  = helper;
            _monitor = Monitor;

            harmonyFix();
            FormatManager.Instance.RegisterMapFormat(new NewTiledTmxFormat());

            SaveHandler.BeforeRebuilding += (a, b) => CustomObjectData.collection.useAll(k => k.Value.sdvId = k.Value.getNewSDVId());
            initializeResponders();
            startResponder();
            registerConsoleCommands();
            CustomTVMod.load();
            PyLua.init();
            registerTileActions();
            SaveHandler.setUpEventHandlers();
            CustomObjectData.CODSyncer.start();
            ContentSync.ContentSyncHandler.initialize();
            this.Helper.Events.Player.Warped                   += Player_Warped;
            this.Helper.Events.GameLoop.DayStarted             += OnDayStarted;
            this.Helper.Events.Multiplayer.PeerContextReceived += (s, e) =>
            {
                if (Game1.IsMasterGame && Game1.IsServer && CustomObjectData.collection.Values.Count > 0)
                {
                    List <CODSync> list = new List <CODSync>();
                    foreach (CustomObjectData data in CustomObjectData.collection.Values)
                    {
                        list.Add(new CODSync(data.id, data.sdvId));
                    }

                    PyNet.sendDataToFarmer(CustomObjectData.CODSyncerName, new CODSyncMessage(list), e.Peer.PlayerID, SerializationType.JSON);
                }
            };

            Helper.Events.Multiplayer.ModMessageReceived += PyNet.Multiplayer_ModMessageReceived;
        }
Exemple #21
0
 public static void endProgram()
 {
     CustomTVMod.endProgram();
 }
Exemple #22
0
 public void register()
 {
     CustomTVMod.addChannel(this);
 }
Exemple #23
0
        public override void Entry(IModHelper helper)
        {
            _instance = this;
            PostSerializer.Add(ModManifest, Rebuilder);
            PreSerializer.Add(ModManifest, Replacer);
            harmonyFix();

            FormatManager.Instance.RegisterMapFormat(new TMXTile.TMXFormat(Game1.tileSize / Game1.pixelZoom, Game1.tileSize / Game1.pixelZoom, Game1.pixelZoom, Game1.pixelZoom));

            initializeResponders();
            startResponder();
            registerConsoleCommands();
            CustomTVMod.load();
            PyLua.init();
            registerTileActions();
            registerEventPreconditions();
            SaveHandler.setUpEventHandlers();
            CustomObjectData.CODSyncer.start();
            ContentSync.ContentSyncHandler.initialize();

            helper.Events.GameLoop.DayStarted += (s, e) =>
            {
                if (ReInjectCustomObjects)
                {
                    ReInjectCustomObjects = false;
                    CustomObjectData.injector.Invalidate();
                    CustomObjectData.injectorBig.Invalidate();
                }
            };

            this.Helper.Events.Player.Warped                   += Player_Warped;
            this.Helper.Events.GameLoop.DayStarted             += OnDayStarted;
            this.Helper.Events.Multiplayer.PeerContextReceived += (s, e) =>
            {
                if (Game1.IsMasterGame && Game1.IsServer)
                {
                    if (CustomObjectData.collection.Values.Count > 0)
                    {
                        List <CODSync> list = new List <CODSync>();
                        foreach (CustomObjectData data in CustomObjectData.collection.Values)
                        {
                            list.Add(new CODSync(data.id, data.sdvId));
                        }

                        PyNet.sendDataToFarmer(CustomObjectData.CODSyncerName, new CODSyncMessage(list), e.Peer.PlayerID, SerializationType.JSON);
                    }

                    PyNet.sendDataToFarmer("PyTK.ModSavdDataReceiver", saveData, e.Peer.PlayerID, SerializationType.JSON);
                }
            };

            Helper.Events.Display.RenderingHud += (s, e) =>
            {
                if (Game1.displayHUD && Context.IsWorldReady)
                {
                    PyTK.PlatoUI.UIHelper.DrawHud(e.SpriteBatch, true);
                }
            };

            Helper.Events.Display.RenderedHud += (s, e) =>
            {
                if (Game1.displayHUD && Context.IsWorldReady)
                {
                    PyTK.PlatoUI.UIHelper.DrawHud(e.SpriteBatch, false);
                }
            };

            Helper.Events.Input.ButtonPressed += (s, e) =>
            {
                if (Game1.displayHUD && Context.IsWorldReady)
                {
                    if (e.Button == SButton.MouseLeft || e.Button == SButton.MouseRight)
                    {
                        PlatoUI.UIHelper.BaseHud.PerformClick(e.Cursor.ScreenPixels.toPoint(), e.Button == SButton.MouseRight, false, false);
                    }
                }
            };

            Helper.Events.Display.WindowResized += (s, e) =>
            {
                PlatoUI.UIElement.Viewportbase.UpdateBounds();
                PlatoUI.UIHelper.BaseHud.UpdateBounds();
            };

            Helper.Events.Multiplayer.ModMessageReceived += PyNet.Multiplayer_ModMessageReceived;
            helper.Events.GameLoop.Saving += (s, e) =>
            {
                if (Game1.IsMasterGame)
                {
                    try
                    {
                        helper.Data.WriteSaveData <PyTKSaveData>("PyTK.ModSaveData", saveData);
                    }
                    catch
                    {
                    }
                }
            };

            helper.Events.GameLoop.ReturnedToTitle += (s, e) =>
            {
                saveData = new PyTKSaveData();
            };

            helper.Events.GameLoop.SaveLoaded += (s, e) =>
            {
                if (Game1.IsMasterGame)
                {
                    try
                    {
                        saveData = helper.Data.ReadSaveData <PyTKSaveData>("PyTK.ModSaveData");
                    }
                    catch
                    {
                    }
                    if (saveData == null)
                    {
                        saveData = new PyTKSaveData();
                    }
                }
            };

            helper.Events.GameLoop.OneSecondUpdateTicked += (s, e) =>
            {
                if (Context.IsWorldReady && Game1.currentLocation is GameLocation location && location.Map is Map map)
                {
                    PyUtils.checkDrawConditions(map);
                }
            };


            helper.Events.GameLoop.GameLaunched += (s, e) =>
            {
                if (!Helper.ModRegistry.IsLoaded("spacechase0.GenericModConfigMenu"))
                {
                    return;
                }

                try
                {
                    registerCPTokens();
                }
                catch { }
            };

            helper.Events.GameLoop.DayStarted += (s, e) => UpdateLuaTokens = true;
        }
        public override void Entry(IModHelper helper)
        {
            _helper  = helper;
            _monitor = Monitor;

            harmonyFix();

            // Monitor.Log("Harmony Patching failed", LogLevel.Error);

            FormatManager.Instance.RegisterMapFormat(new NewTiledTmxFormat());

            SaveHandler.BeforeRebuilding += (a, b) => CustomObjectData.collection.useAll(k => k.Value.sdvId = k.Value.getNewSDVId());
            initializeResponders();
            startResponder();
            registerConsoleCommands();
            CustomTVMod.load();
            PyLua.init();
            registerTileActions();
            registerEventPreconditions();
            SaveHandler.setUpEventHandlers();
            CustomObjectData.CODSyncer.start();
            ContentSync.ContentSyncHandler.initialize();
            this.Helper.Events.Player.Warped                   += Player_Warped;
            this.Helper.Events.GameLoop.DayStarted             += OnDayStarted;
            this.Helper.Events.Multiplayer.PeerContextReceived += (s, e) =>
            {
                if (Game1.IsMasterGame && Game1.IsServer)
                {
                    if (CustomObjectData.collection.Values.Count > 0)
                    {
                        List <CODSync> list = new List <CODSync>();
                        foreach (CustomObjectData data in CustomObjectData.collection.Values)
                        {
                            list.Add(new CODSync(data.id, data.sdvId));
                        }

                        PyNet.sendDataToFarmer(CustomObjectData.CODSyncerName, new CODSyncMessage(list), e.Peer.PlayerID, SerializationType.JSON);
                    }

                    PyNet.sendDataToFarmer("PyTK.ModSavdDataReceiver", saveData, e.Peer.PlayerID, SerializationType.JSON);
                }
            };

            Helper.Events.Display.RenderingHud += (s, e) =>
            {
                if (Game1.displayHUD && Context.IsWorldReady)
                {
                    PyTK.PlatoUI.UIHelper.DrawHud(e.SpriteBatch, true);
                }
            };

            Helper.Events.Display.RenderedHud += (s, e) =>
            {
                if (Game1.displayHUD && Context.IsWorldReady)
                {
                    PyTK.PlatoUI.UIHelper.DrawHud(e.SpriteBatch, false);
                }
            };

            Helper.Events.Input.ButtonPressed += (s, e) =>
            {
                if (Game1.displayHUD && Context.IsWorldReady)
                {
                    if (e.Button == SButton.MouseLeft || e.Button == SButton.MouseRight)
                    {
                        PlatoUI.UIHelper.BaseHud.PerformClick(e.Cursor.ScreenPixels.toPoint(), e.Button == SButton.MouseRight, false, false);
                    }
                }
            };

            Helper.Events.Display.WindowResized += (s, e) =>
            {
                PlatoUI.UIElement.Viewportbase.UpdateBounds();
                PlatoUI.UIHelper.BaseHud.UpdateBounds();
            };

            Helper.Events.Multiplayer.ModMessageReceived += PyNet.Multiplayer_ModMessageReceived;
            helper.Events.GameLoop.Saving += (s, e) =>
            {
                if (Game1.IsMasterGame)
                {
                    try
                    {
                        helper.Data.WriteSaveData <PyTKSaveData>("PyTK.ModSaveData", saveData);
                    }
                    catch
                    {
                    }
                }
            };

            helper.Events.GameLoop.ReturnedToTitle += (s, e) =>
            {
                saveData = new PyTKSaveData();
            };

            helper.Events.GameLoop.SaveLoaded += (s, e) =>
            {
                if (Game1.IsMasterGame)
                {
                    try
                    {
                        saveData = helper.Data.ReadSaveData <PyTKSaveData>("PyTK.ModSaveData");
                    }
                    catch
                    {
                    }
                    if (saveData == null)
                    {
                        saveData = new PyTKSaveData();
                    }
                }
            };

            helper.Events.GameLoop.OneSecondUpdateTicked += (s, e) =>
            {
                if (Context.IsWorldReady && Game1.currentLocation is GameLocation location && location.Map is Map map)
                {
                    PyUtils.checkDrawConditions(map);
                }
            };
        }
Exemple #25
0
        public override void Entry(IModHelper helper)
        {
            _instance = this;

            if (xTile.Format.FormatManager.Instance.GetMapFormatByExtension("tmx") is TMXFormat tmxf)
            {
                tmxf.DrawImageLayer = PyMaps.drawImageLayer;
            }

            Game1.mapDisplayDevice = new PyDisplayDevice(Game1.content, Game1.graphics.GraphicsDevice);

            helper.Events.Display.RenderingWorld += (s, e) =>
            {
                if (Game1.currentLocation is GameLocation location && location.Map is Map map && map.GetBackgroundColor() is TMXColor tmxColor)
                {
                    Game1.graphics.GraphicsDevice.Clear(tmxColor.toColor());
                }
            };

            PostSerializer.Add(ModManifest, Rebuilder);
            PreSerializer.Add(ModManifest, Replacer);

            harmonyFix();

            initializeResponders();
            startResponder();
            registerConsoleCommands();
            CustomTVMod.load();
            PyLua.init();
            registerTileActions();
            registerEventPreconditions();
            SaveHandler.setUpEventHandlers();
            CustomObjectData.CODSyncer.start();
            ContentSync.ContentSyncHandler.initialize();

            helper.Events.GameLoop.DayStarted += (s, e) =>
            {
                if (ReInjectCustomObjects)
                {
                    ReInjectCustomObjects = false;
                    CustomObjectData.injector?.Invalidate();
                    CustomObjectData.injectorBig?.Invalidate();
                }
            };

            this.Helper.Events.Player.Warped                   += Player_Warped;
            this.Helper.Events.GameLoop.DayStarted             += OnDayStarted;
            this.Helper.Events.Multiplayer.PeerContextReceived += (s, e) =>
            {
                if (Game1.IsMasterGame && Game1.IsServer)
                {
                    if (CustomObjectData.collection.Values.Count > 0)
                    {
                        List <CODSync> list = new List <CODSync>();
                        foreach (CustomObjectData data in CustomObjectData.collection.Values)
                        {
                            list.Add(new CODSync(data.id, data.sdvId));
                        }

                        PyNet.sendDataToFarmer(CustomObjectData.CODSyncerName, new CODSyncMessage(list), e.Peer.PlayerID, SerializationType.JSON);
                    }

                    PyNet.sendDataToFarmer("PyTK.ModSavdDataReceiver", saveData, e.Peer.PlayerID, SerializationType.JSON);
                }
            };

            Helper.Events.Display.RenderingHud += (s, e) =>
            {
                if (Game1.displayHUD && Context.IsWorldReady)
                {
                    PyTK.PlatoUI.UIHelper.DrawHud(e.SpriteBatch, true);
                }
            };

            Helper.Events.Display.RenderedHud += (s, e) =>
            {
                if (Game1.displayHUD && Context.IsWorldReady)
                {
                    PyTK.PlatoUI.UIHelper.DrawHud(e.SpriteBatch, false);
                }
            };

            Helper.Events.Input.ButtonPressed += (s, e) =>
            {
                if (Game1.displayHUD && Context.IsWorldReady)
                {
                    if (e.Button == SButton.MouseLeft || e.Button == SButton.MouseRight)
                    {
                        PlatoUI.UIHelper.BaseHud.PerformClick(e.Cursor.ScreenPixels.toPoint(), e.Button == SButton.MouseRight, false, false);
                    }
                }
            };

            Helper.Events.Display.WindowResized += (s, e) =>
            {
                PlatoUI.UIElement.Viewportbase.UpdateBounds();
                PlatoUI.UIHelper.BaseHud.UpdateBounds();
            };

            Helper.Events.Multiplayer.ModMessageReceived += PyNet.Multiplayer_ModMessageReceived;
            helper.Events.GameLoop.Saving += (s, e) =>
            {
                if (Game1.IsMasterGame)
                {
                    try
                    {
                        helper.Data.WriteSaveData <PyTKSaveData>("PyTK.ModSaveData", saveData);
                    }
                    catch
                    {
                    }
                }
            };

            helper.Events.GameLoop.ReturnedToTitle += (s, e) =>
            {
                saveData = new PyTKSaveData();
            };

            helper.Events.GameLoop.SaveLoaded += (s, e) =>
            {
                CustomTVMod.reloadStrings();

                if (Game1.IsMasterGame)
                {
                    try
                    {
                        saveData = helper.Data.ReadSaveData <PyTKSaveData>("PyTK.ModSaveData");
                    }
                    catch
                    {
                    }
                    if (saveData == null)
                    {
                        saveData = new PyTKSaveData();
                    }
                }
            };

            helper.Events.GameLoop.OneSecondUpdateTicked += (s, e) =>
            {
                if (Context.IsWorldReady && Game1.currentLocation is GameLocation location && location.Map is Map map)
                {
                    PyUtils.checkDrawConditions(map);
                }
            };

            helper.Events.GameLoop.DayStarted += (s, e) =>
            {
                if (Game1.currentLocation is GameLocation loc)
                {
                    UpdateLuaTokens = true;
                }
            };

            helper.Events.GameLoop.UpdateTicked += (s, e) => AnimatedTexture2D.ticked = e.Ticks;
        }
        private void ShowRecipePresentation()
        {
            string text = _recipes[GetRecipeNumber()].Split('/')[1];

            CustomTVMod.showProgram(_queenSprite, text, AddRecipe);
        }
 private void ShowAnnouncement(TV tv, TemporaryAnimatedSprite sprite, StardewValley.Farmer farmer, string answer)
 {
     _showSprite = new TemporaryAnimatedSprite(DataLoader.LooseSpritesName, new Rectangle(0, 0, 42, 28), 150f, 2, 999999, tv.getScreenPosition(), false, false, (float)((double)(tv.boundingBox.Bottom - 1) / 10000.0 + 9.99999974737875E-06), 0.0f, Color.White, tv.getScreenSizeModifier(), 0.0f, 0.0f, 0.0f, false);
     CustomTVMod.showProgram(_showSprite, DataLoader.i18n.Get("TV.LivingWithTheAnimals.Announcement"), ShowPresentation);
 }
Exemple #28
0
 public override void Entry(IModHelper helper)
 {
     helper.Events.GameLoop.DayStarted += DayStarted;
     CustomTVMod.addChannel("fish", Helper.Translation.Get("fish_channel"), showFishChannel);
     CustomTVMod.changeAction("rerun", showRerun);
 }
Exemple #29
0
 internal static void Postfix(ref bool __result, ref TV __instance, SFarmer who, bool justCheckingForActivity)
 {
     CustomTVMod.checkForAction(__instance, who, justCheckingForActivity);
     __result = true;
 }
 private void ShowQueenAnnouncement(TV tv, TemporaryAnimatedSprite sprite, StardewValley.Farmer farmer, string answer)
 {
     _queenSprite = new TemporaryAnimatedSprite(Game1.mouseCursorsName, new Rectangle(602, 361, 42, 28), 150f, 2, 999999, tv.getScreenPosition(), false, false, (float)((double)(tv.boundingBox.Bottom - 1) / 10000.0 + 9.99999974737875E-06), 0.0f, Color.White, tv.getScreenSizeModifier(), 0.0f, 0.0f, 0.0f, false);
     CustomTVMod.showProgram(_queenSprite, DataLoader.i18n.Get("TV.MeatFriday.Announcement"), ShowRecipePresentation);
 }