Пример #1
0
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            Dice             = new MersenneTwister();
            Translation      = Helper.Translation;
            ModConfig        = Helper.ReadConfig <MoonConfig>();
            OurMoon          = new SDVMoon(ModConfig, Dice, Helper.Translation);
            ContentManager   = Helper.Content;
            OurIcons         = new Sprites.Icons(Helper.Content);
            queuedMsg        = null;
            BloodMoonTracker = new List <string>();

            helper.Events.GameLoop.GameLaunched          += OnGameLaunched;
            helper.Events.GameLoop.OneSecondUpdateTicked += OnOneSecondUpdateTicked;
            helper.Events.GameLoop.TimeChanged           += OnTimeChanged;
            helper.Events.GameLoop.DayStarted            += OnDayStarted;
            helper.Events.GameLoop.DayEnding             += GameLoop_DayEnding;
            helper.Events.GameLoop.Saving            += OnSaving;
            helper.Events.GameLoop.UpdateTicked      += OnUpdateTicked;
            helper.Events.Display.RenderedActiveMenu += OnRenderedActiveMenu;
            helper.Events.Display.MenuChanged        += OnMenuChanged;
            helper.Events.Player.Warped            += OnWarped;
            helper.Events.GameLoop.ReturnedToTitle += OnReturnedToTitle;

            helper.ConsoleCommands.Add("force_bloodmoon", "Forces a bloodmoon", ForceBloodMoon)
            .Add("force_bloodmoonoff", "Turns bloodmoon off.", TurnBloodMoonOff)
            .Add("force_eclipseOn", "Turns eclipse on.", TurnEclipseOn);
        }
Пример #2
0
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            Dice             = new Xoshiro.PRNG64.XoShiRo256starstar();
            Translation      = Helper.Translation;
            ModConfig        = Helper.ReadConfig <MoonConfig>();
            OurMoon          = new SDVMoon(ModConfig, Dice, Helper.Translation, Monitor);
            ContentManager   = Helper.Content;
            MPHandler        = Helper.Multiplayer;
            OurIcons         = new Sprites.Icons(Helper.Content);
            queuedMsg        = null;
            BloodMoonTracker = new List <string>();

            helper.Events.GameLoop.GameLaunched          += OnGameLaunched;
            helper.Events.GameLoop.OneSecondUpdateTicked += OnOneSecondUpdateTicked;
            helper.Events.GameLoop.TimeChanged           += OnTimeChanged;
            helper.Events.GameLoop.DayStarted            += OnDayStarted;
            helper.Events.GameLoop.DayEnding             += GameLoop_DayEnding;
            helper.Events.GameLoop.SaveLoaded            += GameLoop_SaveLoaded;
            helper.Events.GameLoop.Saving            += OnSaving;
            helper.Events.GameLoop.UpdateTicked      += OnUpdateTicked;
            helper.Events.Display.RenderedActiveMenu += OnRenderedActiveMenu;
            helper.Events.Display.MenuChanged        += OnMenuChanged;
            helper.Events.Player.Warped                  += OnWarped;
            helper.Events.GameLoop.ReturnedToTitle       += OnReturnedToTitle;
            helper.Events.Multiplayer.ModMessageReceived += OnModMessageRecieved;

            SpaceEvents.ChooseNightlyFarmEvent += SpaceEvents_ChooseNightlyFarmEvent;

            helper.ConsoleCommands.Add("force_bloodmoon", "Forces a bloodmoon", ForceBloodMoon)
            .Add("force_bloodmoonoff", "Turns bloodmoon off.", TurnBloodMoonOff)
            .Add("show_mooninfo", "Show moon info", ShowMoonInfo)
            .Add("force_eclipseOn", "Turns eclipse on.", OurMoon.TurnEclipseOn);
        }
Пример #3
0
        /// <summary>Raised after the game is launched, right before the first update tick. This happens once per game session (unrelated to loading saves). All mods are loaded and initialised at this point, so this is a good time to set up mod integrations.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            JAAPi = SDVUtilities.GetModApi <Integrations.IJsonAssetsApi>(Monitor, Helper, "spacechase0.JsonAssets", "1.1");

            if (JAAPi != null)
            {
                UseJsonAssetsApi        = true;
                JAAPi.AddedItemsToShop += JAAPi_AddedItemsToShop;
                //Monitor.Log("JsonAssets Integration enabled", LogLevel.Info);
            }

            var api = Helper.ModRegistry.GetApi <Integrations.GenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api != null)
            {
                api.RegisterModConfig(ModManifest, () => ModConfig = new MoonConfig(), () => Helper.WriteConfig(ModConfig));
                api.RegisterClampedOption(ModManifest, "Blood Moon Chances", "The chance for a blood moon rising. There's a bad moon on the rise.", () => (float)ModConfig.BadMoonRising, (float val) => ModConfig.BadMoonRising = val, 0f, 1f);
                api.RegisterSimpleOption(ModManifest, "Allow Eclipse", "This option controls if eclipses will happen", () => ModConfig.EclipseOn, (bool val) => ModConfig.EclipseOn = val);
                api.RegisterSimpleOption(ModManifest, "Show Moon Phase", "Show the moon phase popups on moon rise and set", () => ModConfig.ShowMoonPhase, (bool val) => ModConfig.ShowMoonPhase = val);
                api.RegisterSimpleOption(ModManifest, "Spawn Monsters", "This option controls if monsters spawn during eclipses on a wilderness farm. NOTE: They don't spawn if you've turned off monster spawns in game.", () => ModConfig.SpawnMonsters, (bool val) => ModConfig.SpawnMonsters = val);
                api.RegisterSimpleOption(ModManifest, "Hazardous Moon Events", "This controls the moon events that can hinder the player, or spawn monsters. No monsters will spawn ( the blood moon won't even happen) while this is false. This also stops the crop deadvancement on the new moon.", () => ModConfig.HazardousMoonEvents, (bool val) => ModConfig.HazardousMoonEvents = val);
                api.RegisterSimpleOption(ModManifest, "Verbose Logging", "This controls if the mod is verbose to the content.", () => ModConfig.Verbose, (bool val) => ModConfig.Verbose = val);
                api.RegisterClampedOption(ModManifest, "Eclipse Chance", "The chance for an eclipse", () => (float)ModConfig.EclipseChance, (float val) => ModConfig.EclipseChance       = val, 0f, 1f);
                api.RegisterClampedOption(ModManifest, "Crop Growth Chance", "The chance for crops to grow on a full moon", () => (float)ModConfig.CropGrowthChance, (float val) => ModConfig.CropGrowthChance = val, 0f, 1f);
                api.RegisterClampedOption(ModManifest, "Crop Halt Chance", "The chance for crops to not grow on a new moon", () => (float)ModConfig.CropHaltChance, (float val) => ModConfig.CropHaltChance    = val, 0f, 1f);
                api.RegisterClampedOption(ModManifest, "Beach Removal Chance", "The chance for items on the beach to be removed on a new moon", () => (float)ModConfig.BeachRemovalChance, (float val) => ModConfig.BeachRemovalChance = val, 0f, 1f);
                api.RegisterClampedOption(ModManifest, "Beach Spawn Chance", "The chance for items on the beach to be spawned on a full moon", () => (float)ModConfig.BeachSpawnChance, (float val) => ModConfig.BeachSpawnChance      = val, 0f, 1f);
                api.RegisterClampedOption(ModManifest, "Ghost Spawn Chance", "The chance for ghosts to spawn on a full moon", () => (float)ModConfig.GhostSpawnChance, (float val) => ModConfig.GhostSpawnChance = val, 0f, 1f);
            }
        }
Пример #4
0
 public SDVMoon(MoonConfig config, MersenneTwister rng, ITranslationHelper Trans)
 {
     Dice         = rng;
     ModConfig    = config;
     IsBloodMoon  = false;
     Translations = Trans;
 }
Пример #5
0
 public SDVMoon(MoonConfig config, MersenneTwister rng, ITranslationHelper Trans, IMonitor Logger)
 {
     Dice          = rng;
     ModConfig     = config;
     Monitor       = Logger;
     IsBloodMoon   = false;
     IsSuperMoon   = false;
     IsBlueMoon    = false;
     IsHarvestMoon = false;
     Translations  = Trans;
 }
Пример #6
0
        public SDVMoon(MoonConfig config, MersenneTwister rng, ITranslationHelper Trans)
        {
            Dice         = rng;
            ModConfig    = config;
            IsBloodMoon  = false;
            Translations = Trans;

            //set chances.
            CropGrowthChance   = .09;
            CropNoGrowthChance = .09;
            BeachRemovalChance = .09;
            BeachSpawnChance   = .35;
            GhostChance        = .02;
        }
Пример #7
0
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            Dice        = new MersenneTwister();
            Translation = Helper.Translation;
            ModConfig   = Helper.ReadConfig <MoonConfig>();
            OurMoon     = new SDVMoon(ModConfig, Dice, Helper.Translation);
            OurIcons    = new Sprites.Icons(Helper.Content);

            helper.Events.GameLoop.GameLaunched          += OnGameLaunched;
            helper.Events.GameLoop.OneSecondUpdateTicked += OnOneSecondUpdateTicked;
            helper.Events.GameLoop.TimeChanged           += OnTimeChanged;
            helper.Events.GameLoop.DayStarted            += OnDayStarted;
            helper.Events.GameLoop.Saving            += OnSaving;
            helper.Events.GameLoop.UpdateTicked      += OnUpdateTicked;
            helper.Events.Display.RenderedActiveMenu += OnRenderedActiveMenu;
            helper.Events.Display.MenuChanged        += OnMenuChanged;
            helper.Events.Player.Warped            += OnWarped;
            helper.Events.GameLoop.ReturnedToTitle += OnReturnedToTitle;
        }
Пример #8
0
        /// <summary>Raised after the game is launched, right before the first update tick. This happens once per game session (unrelated to loading saves). All mods are loaded and initialised at this point, so this is a good time to set up mod integrations.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            JAAPi = SDVUtilities.GetModApi <Integrations.IJsonAssetsApi>(Monitor, Helper, "spacechase0.JsonAssets", "1.1");

            if (JAAPi != null)
            {
                UseJsonAssetsApi        = true;
                JAAPi.AddedItemsToShop += JAAPi_AddedItemsToShop;
            }

            var api = Helper.ModRegistry.GetApi <Integrations.IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api != null)
            {
                api.RegisterModConfig(ModManifest, () => ModConfig = new MoonConfig(), () => Helper.WriteConfig(ModConfig));
                api.RegisterClampedOption(ModManifest, "Blood Moon Chances", "The chance for a blood moon rising. There's a bad moon on the rise.", () => (float)ModConfig.BadMoonRising, (float val) => ModConfig.BadMoonRising = val, 0f, 1f);
                api.RegisterSimpleOption(ModManifest, "Allow Eclipse", "This option controls if eclipses will happen", () => ModConfig.EclipseOn, (bool val) => ModConfig.EclipseOn = val);
                api.RegisterSimpleOption(ModManifest, "Show Moon Phase", "Show the moon phase popups on moon rise and set", () => ModConfig.ShowMoonPhase, (bool val) => ModConfig.ShowMoonPhase = val);
                api.RegisterSimpleOption(ModManifest, "Spawn Monsters", "This option controls if monsters spawn during eclipses on a wilderness farm. NOTE: They don't spawn if you've turned off monster spawns in game.", () => ModConfig.SpawnMonsters, (bool val) => ModConfig.SpawnMonsters = val);
                api.RegisterSimpleOption(ModManifest, "Hazardous Moon Events", "This controls the moon events that can hinder the player, or spawn monsters. No monsters will spawn ( the blood moon won't even happen) while this is false. This also stops the crop de advancement on the new moon.", () => ModConfig.HazardousMoonEvents, (bool val) => ModConfig.HazardousMoonEvents = val);
                api.RegisterSimpleOption(ModManifest, "Verbose Logging", "This controls if the mod is verbose when logging for debug purposes", () => ModConfig.Verbose, (bool val) => ModConfig.Verbose    = val);
                api.RegisterSimpleOption(ModManifest, "Use More Monthly Cycle", "When true, the mod uses a 25-day cycle.", () => ModConfig.UseMoreMonthlyCycle, (bool val) => ModConfig.UseMoreMonthlyCycle = val);
                api.RegisterClampedOption(ModManifest, "Eclipse Chance", "The chance for an eclipse", () => (float)ModConfig.EclipseChance, (float val) => ModConfig.EclipseChance             = val, 0f, 1f);
                api.RegisterClampedOption(ModManifest, "Super Moon Chances", "The chance for a super moon", () => (float)ModConfig.SuperMoonChances, (float val) => ModConfig.SuperMoonChances = val, 0f, 1f);
                api.RegisterClampedOption(ModManifest, "Harvest Moon Double Grow Chance", "The chance for a crop double growth on a harvest moon", () => (float)ModConfig.HarvestMoonDoubleGrowChance, (float val) => ModConfig.HarvestMoonDoubleGrowChance = val, 0f, 1f);
                api.RegisterClampedOption(ModManifest, "Crop Growth Chance", "The chance for crops to grow on a full moon", () => (float)ModConfig.CropGrowthChance, (float val) => ModConfig.CropGrowthChance = val, 0f, 1f);
                api.RegisterClampedOption(ModManifest, "Crop Halt Chance", "The chance for crops to not grow on a new moon", () => (float)ModConfig.CropHaltChance, (float val) => ModConfig.CropHaltChance    = val, 0f, 1f);
                api.RegisterClampedOption(ModManifest, "Beach Removal Chance", "The chance for items on the beach to be removed on a new moon", () => (float)ModConfig.BeachRemovalChance, (float val) => ModConfig.BeachRemovalChance = val, 0f, 1f);
                api.RegisterClampedOption(ModManifest, "Beach Spawn Chance", "The chance for items on the beach to be spawned on a full moon", () => (float)ModConfig.BeachSpawnChance, (float val) => ModConfig.BeachSpawnChance      = val, 0f, 1f);
                api.RegisterClampedOption(ModManifest, "Ghost Spawn Chance", "The chance for ghosts to spawn on a full moon", () => (float)ModConfig.GhostSpawnChance, (float val) => ModConfig.GhostSpawnChance = val, 0f, 1f);
            }

            var cpAPI = this.Helper.ModRegistry.GetApi <IContentPatcherAPI>("Pathoschild.ContentPatcher");

            if (cpAPI != null)
            {
                cpAPI.RegisterToken(this.ModManifest, "MoonPhase", () => new[] { OurMoon.SimpleMoonPhase() });
                cpAPI.RegisterToken(this.ModManifest, "MoonRise", () => new[] { OurMoon.GetMoonRiseTime().ToString() });
                cpAPI.RegisterToken(this.ModManifest, "MoonSet", () => new[] { OurMoon.GetMoonSetTime().ToString() });
                cpAPI.RegisterToken(this.ModManifest, name: "IsEclipse", () => new[] { OurMoon.IsEclipse.ToString() });
            }
        }