public static void TryRefillWater(this SlimeHutch hutch) { if (hutch.numberOfObjectsWithName("Slime Waterer") > 0) { hutch.waterSpots.Set(new[] { true, true, true, true }); } }
public static void SlimeHutchDayUpdate_Post(SlimeHutch __instance, ref List <Monster> __state) { try { // there is no AddRange for NetCollections foreach (var item in __state) { __instance.characters.Add(item); } } catch (Exception e) { mod.ErrorLog("There was an exception in a patch", e); } }
public static void Postfix(SlimeHutch __instance) { __instance.TryRefillWater(); }
private static void SlimeHutch_DayUpdate_Prefix(SlimeHutch __instance) { CurrentLocation = __instance; }
public static bool SlimeHutchDayUpdate_Pre(SlimeHutch __instance, ref List <Monster> __state) { try { var spritesCount = 0; var fakeCapsCount = 0; // we collect and remove the non slimes, so we can run the base implementation for the slimes __state = new List <Monster>(); for (int i = __instance.characters.Count - 1; i >= 0; i--) { if (__instance.characters[i] is DustSpirit dust) { spritesCount++; __state.Add(dust); __instance.characters.RemoveAt(i); } else if (__instance.characters[i] is RockCrab crab && __instance.characters[i].Name.Equals("False Magma Cap")) { fakeCapsCount++; __state.Add(crab); __instance.characters.RemoveAt(i); } } int waters = 0; int startIndex = Game1.random.Next(__instance.waterSpots.Length); for (int i = 0; i < __instance.waterSpots.Length; i++) { if (__instance.waterSpots[(i + startIndex) % __instance.waterSpots.Length] && waters * 5 < spritesCount + fakeCapsCount) { waters++; __instance.waterSpots[(i + startIndex) % __instance.waterSpots.Length] = false; } } for (int numMushrooms = Math.Min((int)Math.Round(spritesCount / 2.5f, MidpointRounding.AwayFromZero), waters * 2); numMushrooms > 0; numMushrooms--) { if (numMushrooms % 2 == 0) { waters--; } int tries = 50; Vector2 tile = __instance.getRandomTile(); while ((!__instance.isTileLocationTotallyClearAndPlaceable(tile) || __instance.doesTileHaveProperty((int)tile.X, (int)tile.Y, "NPCBarrier", "Back") != null || tile.Y >= 12f) && tries > 0) { tile = __instance.getRandomTile(); tries--; } if (tries > 0) { __instance.Objects.Add(tile, new StardewObject(MushroomRancher.purpleMushroomId, 1, false, -1, 0) { IsSpawnedObject = true }); } } for (int numMushrooms = Math.Min((int)Math.Round(fakeCapsCount / 2.5f, MidpointRounding.AwayFromZero), waters * 2); numMushrooms > 0; numMushrooms--) { if (numMushrooms % 2 == 0) { waters--; } int tries = 50; Vector2 tile = __instance.getRandomTile(); while ((!__instance.isTileLocationTotallyClearAndPlaceable(tile) || __instance.doesTileHaveProperty((int)tile.X, (int)tile.Y, "NPCBarrier", "Back") != null || tile.Y >= 12f) && tries > 0) { tile = __instance.getRandomTile(); tries--; } if (tries > 0) { __instance.Objects.Add(tile, new StardewObject(MushroomRancher.magmaCapId, 1, false, -1, 0) { IsSpawnedObject = true }); } } return(true); } catch (Exception e) { mod.ErrorLog("There was an exception in a patch", e); __state = new(); return(true); } }
protected virtual GameLocation getIndoors() { if (this.buildingType.Equals("Slime Hutch")) { if (this.indoors != null) { this.nameOfIndoorsWithoutUnique = this.indoors.name; } string a = this.nameOfIndoorsWithoutUnique; if (a == "Slime Hutch") { this.nameOfIndoorsWithoutUnique = "SlimeHutch"; } GameLocation gameLocation = new SlimeHutch(Game1.game1.xTileContent.Load <Map>("Maps\\" + this.nameOfIndoorsWithoutUnique), this.buildingType); gameLocation.IsFarm = true; gameLocation.isStructure = true; foreach (Warp expr_9B in gameLocation.warps) { expr_9B.TargetX = this.humanDoor.X + this.tileX; expr_9B.TargetY = this.humanDoor.Y + this.tileY + 1; } return(gameLocation); } if (this.buildingType.Equals("Shed")) { if (this.indoors != null) { this.nameOfIndoorsWithoutUnique = this.indoors.name; } string a = this.nameOfIndoorsWithoutUnique; if (a == "Shed") { this.nameOfIndoorsWithoutUnique = "Shed"; } GameLocation gameLocation2 = new Shed(Game1.game1.xTileContent.Load <Map>("Maps\\" + this.nameOfIndoorsWithoutUnique), this.buildingType); gameLocation2.IsFarm = true; gameLocation2.isStructure = true; foreach (Warp expr_182 in gameLocation2.warps) { expr_182.TargetX = this.humanDoor.X + this.tileX; expr_182.TargetY = this.humanDoor.Y + this.tileY + 1; } return(gameLocation2); } if (this.nameOfIndoorsWithoutUnique != null && this.nameOfIndoorsWithoutUnique.Length > 0 && !this.nameOfIndoorsWithoutUnique.Equals("null")) { GameLocation gameLocation3 = new GameLocation(Game1.game1.xTileContent.Load <Map>("Maps\\" + this.nameOfIndoorsWithoutUnique), this.buildingType); gameLocation3.IsFarm = true; gameLocation3.isStructure = true; if (gameLocation3.name.Equals("Greenhouse")) { gameLocation3.terrainFeatures = new SerializableDictionary <Vector2, TerrainFeature>(); } foreach (Warp expr_270 in gameLocation3.warps) { expr_270.TargetX = this.humanDoor.X + this.tileX; expr_270.TargetY = this.humanDoor.Y + this.tileY + 1; } if (gameLocation3 is AnimalHouse) { AnimalHouse animalHouse = gameLocation3 as AnimalHouse; string a = this.buildingType.Split(new char[] { ' ' })[0]; if (!(a == "Big")) { if (!(a == "Deluxe")) { animalHouse.animalLimit = 4; } else { animalHouse.animalLimit = 12; } } else { animalHouse.animalLimit = 8; } } return(gameLocation3); } return(null); }