Example #1
0
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides methods for interacting with the mod directory, such as read/writing a config file or custom JSON files.</param>
        public override void Entry(IModHelper helper)
        {
            ModConfig = helper.ReadConfig <RngConfig>();

            RandomFloats = new float[256];
            Twister      = new MersenneTwister();

            //Destroys the game's built-in random number generator for Twister.
            Game1.random = Twister;

            //Just fills the buffer with junk so that we know everything is good and random.
            RandomFloats.FillFloats();

            //Define base randoms
            OneToTen = new List <WeightedGeneric <int> >()
            {
                WeightedGeneric <int> .Create(75, 1), WeightedGeneric <int> .Create(50, 2), WeightedGeneric <int> .Create(25, 3), WeightedGeneric <int> .Create(15, 4), WeightedGeneric <int> .Create(11, 5), WeightedGeneric <int> .Create(9, 6), WeightedGeneric <int> .Create(7, 7), WeightedGeneric <int> .Create(5, 8), WeightedGeneric <int> .Create(3, 9), WeightedGeneric <int> .Create(1, 10)
            };
            Weather = new List <WeightedGeneric <int> >()
            {
                WeightedGeneric <int> .Create(ModConfig.SunnyChance, 0), WeightedGeneric <int> .Create(ModConfig.CloudySnowyChance, 2), WeightedGeneric <int> .Create(ModConfig.RainyChance, 1), WeightedGeneric <int> .Create(ModConfig.StormyChance, 3), WeightedGeneric <int> .Create(ModConfig.HarshSnowyChance, 5)
            };

            /*
             * //Debugging for my randoms
             * while (true)
             * {
             *  List<int> got = new List<int>();
             *  int v = 0;
             *  int gen = 1024;
             *  float genf = gen;
             *  for (int i = 0; i < gen; i++)
             *  {
             *      v = Weighted.ChooseRange(OneToTen, 1, 5).TValue;
             *      got.Add(v);
             *
             *      if (gen <= 1024)
             *          Console.Write(v + ", ");
             *  }
             *  Console.Write("\n");
             *  Console.WriteLine("Generated {0} Randoms", got.Count);
             *  Console.WriteLine("1: {0} | 2: {1} | 3: {2} | 4: {3} | 5: {4} | 6: {5} | 7: {6} | 8: {7} | 9: {8} | 10: {9} | ?: {10}", got.Count(x => x == 1), got.Count(x => x == 2), got.Count(x => x == 3), got.Count(x => x == 4), got.Count(x => x == 5), got.Count(x => x == 6), got.Count(x => x == 7), got.Count(x => x == 8), got.Count(x => x == 9), got.Count(x => x == 10), got.Count(x => x > 10));
             *  Console.WriteLine("{0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9}", got.Count(x => x == 1) / genf * 100 + "%", got.Count(x => x == 2) / genf * 100 + "%", got.Count(x => x == 3) / genf * 100 + "%", got.Count(x => x == 4) / genf * 100 + "%", got.Count(x => x == 5) / genf * 100 + "%", got.Count(x => x == 6) / genf * 100 + "%", got.Count(x => x == 7) / genf * 100 + "%", got.Count(x => x == 8) / genf * 100 + "%", got.Count(x => x == 9) / genf * 100 + "%", got.Count(x => x == 10) / genf * 100 + "%");
             *
             *  //Console.WriteLine(OneToTen.ChooseRange(0, 10).TValue);
             *
             *  Console.ReadKey();
             * }
             */

            //Determine base RNG to get everything up and running.
            DetermineRng();

            PlayerEvents.FarmerChanged += PlayerEvents_FarmerChanged;
            GameEvents.UpdateTick      += GameEvents_UpdateTick;
            PlayerEvents.LoadedGame    += PlayerEvents_LoadedGame;
            ControlEvents.KeyPressed   += ControlEvents_KeyPressed;

            this.Monitor.Log("Initialized (press F5 to reload config)");
        }
Example #2
0
        /*********
        ** Public methods
        *********/
        /// <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)
        {
            this.Config = helper.ReadConfig <ModConfig>();

            this.RandomFloats = new float[256];
            ModEntry.Twister  = new MersenneTwister();

            //Destroys the game's built-in random number generator for Twister.
            Game1.random = ModEntry.Twister;

            //Just fills the buffer with junk so that we know everything is good and random.
            this.RandomFloats.FillFloats();

            //Define base randoms
            this.Weather = new[]
            {
                WeightedGeneric <int> .Create(this.Config.SunnyChance, Game1.weather_sunny),
                WeightedGeneric <int> .Create(this.Config.CloudySnowyChance, Game1.weather_debris),
                WeightedGeneric <int> .Create(this.Config.RainyChance, Game1.weather_rain),
                WeightedGeneric <int> .Create(this.Config.StormyChance, Game1.weather_lightning),
                WeightedGeneric <int> .Create(this.Config.HarshSnowyChance, Game1.weather_snow)
            };

            /*
             * //Debugging for my randoms
             * while (true)
             * {
             *  List<int> got = new List<int>();
             *  int v = 0;
             *  int gen = 1024;
             *  float genf = gen;
             *  for (int i = 0; i < gen; i++)
             *  {
             *      v = Weighted.ChooseRange(OneToTen, 1, 5).TValue;
             *      got.Add(v);
             *
             *      if (gen <= 1024)
             *          Console.Write(v + ", ");
             *  }
             *  Console.Write("\n");
             *  Console.WriteLine("Generated {0} Randoms", got.Count);
             *  Console.WriteLine("1: {0} | 2: {1} | 3: {2} | 4: {3} | 5: {4} | 6: {5} | 7: {6} | 8: {7} | 9: {8} | 10: {9} | ?: {10}", got.Count(x => x == 1), got.Count(x => x == 2), got.Count(x => x == 3), got.Count(x => x == 4), got.Count(x => x == 5), got.Count(x => x == 6), got.Count(x => x == 7), got.Count(x => x == 8), got.Count(x => x == 9), got.Count(x => x == 10), got.Count(x => x > 10));
             *  Console.WriteLine("{0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9}", got.Count(x => x == 1) / genf * 100 + "%", got.Count(x => x == 2) / genf * 100 + "%", got.Count(x => x == 3) / genf * 100 + "%", got.Count(x => x == 4) / genf * 100 + "%", got.Count(x => x == 5) / genf * 100 + "%", got.Count(x => x == 6) / genf * 100 + "%", got.Count(x => x == 7) / genf * 100 + "%", got.Count(x => x == 8) / genf * 100 + "%", got.Count(x => x == 9) / genf * 100 + "%", got.Count(x => x == 10) / genf * 100 + "%");
             *
             *  //Console.WriteLine(OneToTen.ChooseRange(0, 10).TValue);
             *
             *  Console.ReadKey();
             * }
             */

            //Determine base RNG to get everything up and running.
            this.DetermineRng();

            SaveEvents.AfterLoad     += this.SaveEvents_AfterLoad;
            ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;

            this.Monitor.Log("Initialized (press F5 to reload config)");
        }
Example #3
0
        /*********
        ** Public methods
        *********/
        /// <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)
        {
            // read config
            this.Config = helper.ReadConfig <ModConfig>();

            // init randomness
            Game1.random      = ModEntry.Twister = new MersenneTwister();
            this.RandomFloats = new float[256];
            this.RandomFloats.FillFloats(); // fill buffer with junk so everything is good and random
            this.Weather = new[]
            {
                WeightedGeneric <int> .Create(this.Config.SunnyChance, Game1.weather_sunny),
                WeightedGeneric <int> .Create(this.Config.CloudySnowyChance, Game1.weather_debris),
                WeightedGeneric <int> .Create(this.Config.RainyChance, Game1.weather_rain),
                WeightedGeneric <int> .Create(this.Config.StormyChance, Game1.weather_lightning),
                WeightedGeneric <int> .Create(this.Config.HarshSnowyChance, Game1.weather_snow)
            };
            this.DetermineRng();

            /*
             * //Debugging for my randoms
             * while (true)
             * {
             *  List<int> got = new List<int>();
             *  int v = 0;
             *  int gen = 1024;
             *  float genf = gen;
             *  for (int i = 0; i < gen; i++)
             *  {
             *      v = Weighted.ChooseRange(OneToTen, 1, 5).TValue;
             *      got.Add(v);
             *
             *      if (gen <= 1024)
             *          Console.Write(v + ", ");
             *  }
             *  Console.Write("\n");
             *  Console.WriteLine("Generated {0} Randoms", got.Count);
             *  Console.WriteLine("1: {0} | 2: {1} | 3: {2} | 4: {3} | 5: {4} | 6: {5} | 7: {6} | 8: {7} | 9: {8} | 10: {9} | ?: {10}", got.Count(x => x == 1), got.Count(x => x == 2), got.Count(x => x == 3), got.Count(x => x == 4), got.Count(x => x == 5), got.Count(x => x == 6), got.Count(x => x == 7), got.Count(x => x == 8), got.Count(x => x == 9), got.Count(x => x == 10), got.Count(x => x > 10));
             *  Console.WriteLine("{0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} | {9}", got.Count(x => x == 1) / genf * 100 + "%", got.Count(x => x == 2) / genf * 100 + "%", got.Count(x => x == 3) / genf * 100 + "%", got.Count(x => x == 4) / genf * 100 + "%", got.Count(x => x == 5) / genf * 100 + "%", got.Count(x => x == 6) / genf * 100 + "%", got.Count(x => x == 7) / genf * 100 + "%", got.Count(x => x == 8) / genf * 100 + "%", got.Count(x => x == 9) / genf * 100 + "%", got.Count(x => x == 10) / genf * 100 + "%");
             *
             *  //Console.WriteLine(OneToTen.ChooseRange(0, 10).TValue);
             *
             *  Console.ReadKey();
             * }
             */

            // hook events
            helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
            helper.Events.Input.ButtonPressed += this.OnButtonPressed;

            this.Monitor.Log("Initialized (press F5 to reload config)");
        }
Example #4
0
        /*********
        ** Public methods
        *********/
        /// <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)
        {
            // read config
            this.Config = helper.ReadConfig <ModConfig>();

            // init randomness
            Game1.random = ModEntry.Twister = new MersenneTwister();
            this.Weather = new[]
            {
                WeightedGeneric <int> .Create(this.Config.SunnyChance, Game1.weather_sunny),
                WeightedGeneric <int> .Create(this.Config.CloudySnowyChance, Game1.weather_debris),
                WeightedGeneric <int> .Create(this.Config.RainyChance, Game1.weather_rain),
                WeightedGeneric <int> .Create(this.Config.StormyChance, Game1.weather_lightning),
                WeightedGeneric <int> .Create(this.Config.HarshSnowyChance, Game1.weather_snow)
            };

            // hook events
            helper.Events.GameLoop.DayStarted  += this.OnDayStarted;
            helper.Events.Input.ButtonsChanged += this.OnButtonsChanged;
        }