private void CarpenterMenu_ButtonReleased(object sender, ButtonReleasedEventArgs e) { if (Game1.activeClickableMenu is CarpenterMenu menu && Composting.IsComposterBlueprint(menu.CurrentBlueprint)) { Helper.Reflection.GetField <Building>(menu, "currentBuilding").SetValue(new CompostingBin(menu.CurrentBlueprint, Vector2.Zero)); } }
public static bool HighlightMethod(Item item) { int brown = Composting.GetBrown(item); int green = Composting.GetGreen(item); return(brown > 0 || green > 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(); }); }
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" }); * */ }
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(); } }
private static int GetSpeed(Vector2 tile, List <CropTrait> traits, bool greenhouse) { int level = 0; if (greenhouse || Composting.AffectedByCompost(tile)) { level += 1; } if (traits.Contains(CropTrait.SpeedI)) { level += 1; } if (traits.Contains(CropTrait.SpeedII)) { level += 1; } return(level); }
private static int GetWater(Vector2 tile, List <CropTrait> traits) { int level = 0; if (Composting.AffectedByCompost(tile)) { level += 1; } if (traits.Contains(CropTrait.WaterI)) { level += 1; } if (traits.Contains(CropTrait.WaterII)) { level += 1; } return(level); }
public static int GetPestRes(Vector2 tile, List <CropTrait> traits, bool greenhouse) { int level = 0; if (greenhouse || Composting.AffectedByCompost(tile)) { level += 1; } if (greenhouse || traits.Contains(CropTrait.PestResistanceI)) { level += 1; } if (traits.Contains(CropTrait.PestResistanceII) && level <= 1) { level += 1; } return(level); }
/* * private static void AddToTempDic(string s, Vector2 vec, Dictionary<string, List<Vector2>> dic) * { * dic[s].Add(vec); * } * * private static List<Vector2> GetFromTempDic(string s, Dictionary<string, List<Vector2>> dic) => * dic[s]; * * private static void ClearTempDic(string s, Dictionary<string, List<Vector2>> dic) * { * dic[s].Clear(); * } */ private static int GetQuality(Vector2 tile, List <CropTrait> traits, bool greenhouse) { int level = 0; if (!greenhouse && Composting.AffectedByCompost(tile)) { level += 1; } if (traits.Contains(CropTrait.QualityI)) { level += 1; } if (traits.Contains(CropTrait.QualityII) && level <= 1) { level += 1; } return(level); }
void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e) { if (e.NewMenu is CarpenterMenu menu) { Helper.Events.Input.ButtonReleased += CarpenterMenu_ButtonReleased; Composting.AddBlueprint(menu); } else if (e.OldMenu is CarpenterMenu oldmenu) { Helper.Events.Input.ButtonReleased -= CarpenterMenu_ButtonReleased; Game1.getFarm().buildings.Set(new List <Building>(Game1.getFarm().buildings).Select((Building building) => building is ShippingBin bin && Composting.IsComposter(bin) ? CompostingBin.FromShippingBin(bin) : building).ToList()); } if (e.NewMenu is ComposterMenu compMenu) { } else if (e.OldMenu is ComposterMenu oldCompMenu) { oldCompMenu.SaveCompostItems(); } }
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); } }
public override void receiveLeftClick(int x, int y, bool playSound = true) { Vector2 vec = new Vector2((Game1.viewport.X + x) / 64, (Game1.viewport.Y + y) / 64); if (!applyMode) { compostInventoryMenu.receiveLeftClick(x, y, playSound); playerInventoryMenu.receiveLeftClick(x, y, playSound); if (state == State.ready && applyButton.containsPoint(x, y)) { applyMode = true; } else if (state == State.fill && nutritionsComponent.GoodDistribution() && activateButton.containsPoint(x, y)) { MakeActive(); } base.receiveLeftClick(x, y, playSound); } else if (Game1.currentLocation is Farm farm && !Composting.AffectedByCompost(vec) && farm.terrainFeatures.ContainsKey(vec) && farm.terrainFeatures[vec] is HoeDirt) { Composting.CompostApplied.Add(vec); }
public static CompostingBin FromShippingBin(ShippingBin bin) => new CompostingBin(Composting.GetComposterBlueprint(), new Vector2(bin.tileX, bin.tileY));
void GameLoop_Saving(object sender, StardewModdingAPI.Events.SavingEventArgs e) { Pests.Save(); Cultivation.Save(); Composting.Save(); }
void GameLoop_DayStarted(object sender, StardewModdingAPI.Events.DayStartedEventArgs e) { Composting.OnNewDay(); Pests.OnNewDay(); Cultivation.OnNewDay(); }
public static int Greens(Item item) => item == null ? 0 : Composting.GetGreen(item) * item.Stack;
public static int Browns(Item item) => item == null ? 0 : Composting.GetBrown(item) * item.Stack;
public static void SetCompostingBins() { Game1.getFarm().buildings.Set(new List <Building>(Game1.getFarm().buildings).Select((Building building) => building is ShippingBin bin && Composting.IsComposter(bin) ? CompostingBin.FromShippingBin(bin) : building).ToList()); }
public override void receiveLeftClick(int x, int y, bool playSound = true) { Game1.player.Halt(); Vector2 vec = new Vector2((Game1.viewport.X + x) / 64, (Game1.viewport.Y + y) / 64); if (!applyMode) { compostInventoryMenu.receiveLeftClick(x, y, playSound); playerInventoryMenu.receiveLeftClick(x, y, playSound); if (applyButton.containsPoint(x, y)) { ApplyMode(true); } else if (state == State.fill && nutritionsComponent.GoodDistribution() && activateButton.containsPoint(x, y)) { MakeActive(); } base.receiveLeftClick(x, y, playSound); } else if (applyMode && Game1.currentLocation is Farm farm) { if (cancelButton.bounds.Contains(x, y)) { ApplyMode(false); } else if (!Composting.AffectedByCompost(vec) && farm.terrainFeatures.ContainsKey(vec) && farm.terrainFeatures[vec] is HoeDirt && Composting.ComposterCompostLeft[BinPos] > 0) { void apply() { Composting.ComposterCompostLeft[BinPos]--; if (Composting.ComposterCompostLeft[BinPos] <= 0) { MakeInactive(); } UpdateGreenTiles(); Game1.playSound("grassyStep"); //greenTiles.Add(vec); //greenTiles.AddRange(ModComponent.GetAdjacentTiles(vec)); } if (Composting.CompostAppliedDays.ContainsKey(vec)) { if (Composting.CompostAppliedDays[vec] <= 0) { Composting.CompostAppliedDays[vec] = Composting.config.compost_last_for_days; apply(); } else { ShowError("composter.msg.error_already_affected"); } } else { Composting.CompostAppliedDays.Add(vec, Composting.config.compost_last_for_days); apply(); } } else if (Composting.ComposterCompostLeft[BinPos] <= 0) { ShowError("composter.msg.error_no_compost_left"); } else if (!farm.terrainFeatures.ContainsKey(vec) || !(farm.terrainFeatures[vec] is HoeDirt)) { ShowError("composter.msg.error_no_tilled_dirt"); } else if (Composting.AffectedByCompost(vec)) { ShowError("composter.msg.error_already_affected"); } } }
public static void OnNewDay() { //if (Game1.getFarm().buildings.ToList().Exists((Building obj) => Composting.IsComposter(obj))) // ModEntry.GetMonitor().Log("Found Composter", StardewModdingAPI.LogLevel.Alert); Game1.getFarm().buildings.Set(new List <Building>(Game1.getFarm().buildings).Select((Building building) => building is ShippingBin bin && Composting.IsComposter(bin) ? CompostingBin.FromShippingBin(bin) : building).ToList()); //if (Game1.getFarm().buildings.ToList().Exists((Building obj) => obj is CompostingBin)) // ModEntry.GetMonitor().Log("transformed composter", StardewModdingAPI.LogLevel.Alert); }