Beispiel #1
0
        public Pest(Vector2 pos, HoeDirt hd)
        {
            this.pos = pos;
            this.hd  = hd;

            /*
             * this.adjacentTiles.Add(new Vector2(pos.X - 1, pos.Y));
             * this.adjacentTiles.Add(new Vector2(pos.X - 1, pos.Y - 1));
             * this.adjacentTiles.Add(new Vector2(pos.X - 1, pos.Y + 1));
             * this.adjacentTiles.Add(new Vector2(pos.X, pos.Y - 1));
             * this.adjacentTiles.Add(new Vector2(pos.X, pos.Y + 1));
             * this.adjacentTiles.Add(new Vector2(pos.X + 1, pos.Y));
             * this.adjacentTiles.Add(new Vector2(pos.X + 1, pos.Y - 1));
             * this.adjacentTiles.Add(new Vector2(pos.X + 1, pos.Y + 1));
             */
            this.adjacentTiles = ModComponent.GetAdjacentTiles(pos);

            bfList = new List <PestFly>();
            bfList.Add(new PestFly(pos));
            if (Pests.CheckChance(50))
            {
                bfList.Add(new PestFly(pos));
            }
            if (Pests.CheckChance(50))
            {
                bfList.Add(new PestFly(pos));
            }
            //ModEntry.GetMonitor().Log("pos is " + pos + " and pestfly pos is" + pos * Game1.tileSize);
        }
Beispiel #2
0
        public Pest(Vector2 pos, HoeDirt hd)
        {
            this.pos = pos;
            this.hd  = hd;

            this.adjacentTiles.Add(new Vector2(pos.X - 1, pos.Y));
            this.adjacentTiles.Add(new Vector2(pos.X - 1, pos.Y - 1));
            this.adjacentTiles.Add(new Vector2(pos.X - 1, pos.Y + 1));
            this.adjacentTiles.Add(new Vector2(pos.X, pos.Y - 1));
            this.adjacentTiles.Add(new Vector2(pos.X, pos.Y + 1));
            this.adjacentTiles.Add(new Vector2(pos.X + 1, pos.Y));
            this.adjacentTiles.Add(new Vector2(pos.X + 1, pos.Y - 1));
            this.adjacentTiles.Add(new Vector2(pos.X + 1, pos.Y + 1));

            bfList = new List <PestFly>();
            bfList.Add(new PestFly(pos));
            if (Pests.GetRandom() >= 50)
            {
                bfList.Add(new PestFly(pos));
            }
            if (Pests.GetRandom() >= 50)
            {
                bfList.Add(new PestFly(pos));
            }
            //ModEntry.GetMonitor().Log("pos is " + pos + " and pestfly pos is" + pos * Game1.tileSize);
        }
Beispiel #3
0
        public override void Entry(IModHelper helper)
        {
            _Monitor = Monitor;
            _Helper  = helper;

            Config conf = helper.ReadConfig <Config>();

            Pests.Init(conf);
            Cultivation.Init(conf);
            Composting.Init(conf);

            SMC = new SeedMakerController(helper, Monitor);
            SMC.HeldItemRemoved += SeedMakerController_HeldItemRemoved;


            helper.Events.Display.RenderingHud  += Display_RenderingHud;
            helper.Events.GameLoop.DayStarted   += GameLoop_DayStarted;
            helper.Events.Input.ButtonPressed   += Input_ButtonPressed;
            helper.Events.GameLoop.UpdateTicked += GameLoop_UpdateTicked;


            helper.Events.GameLoop.Saving     += GameLoop_Saving;
            helper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded;

            helper.Events.GameLoop.DayEnding += GameLoop_DayEnding;

            helper.Events.Display.MenuChanged += Display_MenuChanged;

            helper.Events.World.BuildingListChanged += World_BuildingListChanged;

            //helper.Events.Player.Warped += Player_Warped;

            Helper.ConsoleCommands.Add("cpc_clearcompost", "", (string arg1, string[] arg2) =>
            {
                Composting.CompostAppliedDays.Clear();
                Composting.ComposterDaysLeft.Clear();
                Composting.ComposterCompostLeft.Clear();
            });
            Helper.ConsoleCommands.Add("cpc_clearcomposterinv", "", (string arg1, string[] arg2) =>
            {
                Composting.ComposterContents.Clear();
            });
            Helper.ConsoleCommands.Add("cpc_clearpests", "", (string arg1, string[] arg2) =>
            {
                Pests.pests.Clear();
            });
            Helper.ConsoleCommands.Add("cpc_cleartraits", "", (string arg1, string[] arg2) =>
            {
                Cultivation.CropSeeds.Clear();
                Cultivation.CropTraits.Clear();
            });
        }
Beispiel #4
0
        void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e)
        {
            Composting.Load();
            Cultivation.Load();
            Pests.Load();

            /*
             * for (int i = 0; i < 10; i++)
             *  Helper.ConsoleCommands.Trigger("player_add", new string[2] { "name", "Seed Maker" });
             * Helper.ConsoleCommands.Trigger("player_add", new string[3] { "name", "Melon", "100" });
             *
             */
        }
Beispiel #5
0
 void GameLoop_Saving(object sender, StardewModdingAPI.Events.SavingEventArgs e)
 {
     try
     {
         SaveData data = new SaveData();
         Pests.Save(data);
         Cultivation.Save(data);
         Composting.Save(data);
         ModEntry.GetHelper().Data.WriteSaveData <SaveData>(nameof(SaveData), data);
     }
     finally
     {
         Composting.ResetCompostingBins();
     }
 }
Beispiel #6
0
        public List <Pest> InfestAdjacent(double chance)
        {
            List <Pest> pests = new List <Pest>();

            foreach (KeyValuePair <Vector2, TerrainFeature> pair in GetAdjacentCrops())
            {
                if (pair.Key is Vector2 vec && pair.Value is HoeDirt hd && Pests.CheckChance(chance))
                {
                    Pest pest = Pests.TryInfestCrop(vec, hd);
                    if (pest != null)
                    {
                        ModEntry.GetMonitor().Log("Infested adjacent crop at " + vec, LogLevel.Trace);
                        pests.Add(pest);
                    }
                }
            }
            return(pests);
        }
Beispiel #7
0
        public override void Entry(IModHelper helper)
        {
            _Monitor = Monitor;
            _Helper  = helper;

            Config conf = helper.ReadConfig <Config>();

            Pests.Init(conf);
            Cultivation.Init(conf);

            helper.Events.Display.RenderingHud += Display_RenderingHud;
            helper.Events.GameLoop.DayStarted  += GameLoop_DayStarted;
            helper.Events.Input.ButtonPressed  += Input_ButtonPressed;


            helper.Events.GameLoop.Saving     += GameLoop_Saving;
            helper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded;

            helper.Events.GameLoop.DayEnding += GameLoop_DayEnding;
        }
Beispiel #8
0
        void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e)
        {
            SaveData data = null;

            try
            {
                data = Helper.Data.ReadSaveData <SaveData>(nameof(SaveData));
            }
            finally
            {
                if (data == null)
                {
                    Monitor.Log($"No save data with key '{nameof(SaveData)}' found");
                    data = new SaveData();
                }
                data.InitNullValues();

                Composting.Load(data);
                Cultivation.Load(data);
                Pests.Load(data);
            }
        }
Beispiel #9
0
 void Display_RenderingHud(object sender, StardewModdingAPI.Events.RenderingHudEventArgs e)
 {
     Pests.DrawPests(e.SpriteBatch);
 }
Beispiel #10
0
 void GameLoop_DayStarted(object sender, StardewModdingAPI.Events.DayStartedEventArgs e)
 {
     Pests.OnNewDay();
 }
Beispiel #11
0
 void GameLoop_Saving(object sender, StardewModdingAPI.Events.SavingEventArgs e)
 {
     Pests.Save();
     Cultivation.Save();
 }
Beispiel #12
0
 void GameLoop_DayStarted(object sender, StardewModdingAPI.Events.DayStartedEventArgs e)
 {
     Composting.OnNewDay();
     Pests.OnNewDay();
     Cultivation.OnNewDay();
 }