diff --git a/BetterMeteorites/Mod.cs b/BetterMeteorites/Mod.cs index 241bf0784..0ed3dc9f9 100644 --- a/BetterMeteorites/Mod.cs +++ b/BetterMeteorites/Mod.cs @@ -31,7 +31,7 @@ private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) private void OnClumpRemoved(ResourceClump value) { - if (value.parentSheetIndex == ResourceClump.meteoriteIndex) + if (value.parentSheetIndex.Value == ResourceClump.meteoriteIndex) { Random r = new Random((int)value.tile.X * 1000 + (int)value.tile.Y); Game1.createMultipleObjectDebris(StardewValley.Object.stone, (int)value.tile.X, (int)value.tile.Y, 75 + r.Next(175)); diff --git a/BiggerCraftables/Patches/UtilityPatcher.cs b/BiggerCraftables/Patches/UtilityPatcher.cs index 23367ba93..9be268deb 100644 --- a/BiggerCraftables/Patches/UtilityPatcher.cs +++ b/BiggerCraftables/Patches/UtilityPatcher.cs @@ -46,7 +46,7 @@ private static bool Before_PlayersCanPlaceItemHere(GameLocation location, Item i __result = false; return false; } - if (item == null || item is Tool || Game1.eventUp || (bool)f.bathingClothes || f.onBridge.Value) + if (item == null || item is Tool || Game1.eventUp || f.bathingClothes.Value || f.onBridge.Value) { __result = false; return false; diff --git a/BugNet/BugNetTool.cs b/BugNet/BugNetTool.cs index 35ce6d499..254a8be95 100644 --- a/BugNet/BugNetTool.cs +++ b/BugNet/BugNetTool.cs @@ -17,7 +17,7 @@ public class BugNetTool : MeleeWeapon, ICustomWeaponDraw public BugNetTool() { - this.category.Value = StardewValley.Object.toolCategory; + this.Category = StardewValley.Object.toolCategory; this.Name = "Bug Net"; this.ParentSheetIndex = MeleeWeapon.scythe; // Gets us out of annoying stuff @@ -59,7 +59,7 @@ public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float float num2 = Mod.Instance.Helper.Reflection.GetField(typeof(MeleeWeapon), "addedSwordScale").GetValue(); if (!drawShadow) num2 = 0; - spriteBatch.Draw(BugNetTool.Texture, location + (this.type == 1 ? new Vector2(Game1.tileSize * 2 / 3, Game1.tileSize / 3) : new Vector2(Game1.tileSize / 2, Game1.tileSize / 2)), new Rectangle(0, 0, 16, 16), Color.White * transparency, 0.0f, new Vector2(8f, 8f), Game1.pixelZoom * (scaleSize + num2), SpriteEffects.None, layerDepth); + spriteBatch.Draw(BugNetTool.Texture, location + (this.type.Value == 1 ? new Vector2(Game1.tileSize * 2 / 3, Game1.tileSize / 3) : new Vector2(Game1.tileSize / 2, Game1.tileSize / 2)), new Rectangle(0, 0, 16, 16), Color.White * transparency, 0.0f, new Vector2(8f, 8f), Game1.pixelZoom * (scaleSize + num2), SpriteEffects.None, layerDepth); if (num1 <= 0.0 || drawShadow) return; spriteBatch.Draw(Game1.staminaRect, new Rectangle((int)location.X, (int)location.Y + (Game1.tileSize - (int)(num1 * (double)Game1.tileSize)), Game1.tileSize, (int)(num1 * (double)Game1.tileSize)), Color.Red * 0.66f); diff --git a/BuildableLocationsFramework/Framework/BuildableAnimalLocation.cs b/BuildableLocationsFramework/Framework/BuildableAnimalLocation.cs index 46d7ce74f..1d4506bea 100644 --- a/BuildableLocationsFramework/Framework/BuildableAnimalLocation.cs +++ b/BuildableLocationsFramework/Framework/BuildableAnimalLocation.cs @@ -15,14 +15,15 @@ internal class BuildableAnimalLocation : BuildableGameLocation, IAnimalLocation { public NetLongDictionary> Animals { get; } = new(); - private void MyWarpHome(FarmAnimal farmAnimal, FarmAnimal a) + private void MyWarpHome(FarmAnimal farmAnimal) { - if (farmAnimal.home == null) + if (farmAnimal.home?.indoors.Value is not AnimalHouse animalHouse) return; - (farmAnimal.home.indoors.Value as AnimalHouse).animals.Add((long)farmAnimal.myID, farmAnimal); - this.Animals.Remove((long)farmAnimal.myID); + + animalHouse.animals.Add(farmAnimal.myID.Value, farmAnimal); + this.Animals.Remove(farmAnimal.myID.Value); farmAnimal.controller = null; - farmAnimal.setRandomPosition(farmAnimal.home.indoors); + farmAnimal.setRandomPosition(animalHouse); ++farmAnimal.home.currentOccupants.Value; } @@ -70,7 +71,7 @@ public override void timeUpdate(int timeElapsed) foreach (Building building in this.buildings) { - if ((int)building.daysOfConstructionLeft <= 0) + if (building.daysOfConstructionLeft.Value <= 0) { building.performTenMinuteAction(timeElapsed); if (building.indoors.Value != null && !Game1.locations.Contains(building.indoors.Value) && timeElapsed >= 10) @@ -117,7 +118,7 @@ public bool CheckPetAnimal(Vector2 position, Farmer who) { foreach (KeyValuePair pair in this.Animals.Pairs) { - if (!(bool)pair.Value.wasPet && pair.Value.GetCursorPetBoundingBox().Contains((int)position.X, (int)position.Y)) + if (!pair.Value.wasPet.Value && pair.Value.GetCursorPetBoundingBox().Contains((int)position.X, (int)position.Y)) { pair.Value.pet(who); return true; @@ -130,7 +131,7 @@ public bool CheckPetAnimal(Rectangle rect, Farmer who) { foreach (KeyValuePair pair in this.Animals.Pairs) { - if (!(bool)pair.Value.wasPet && pair.Value.GetBoundingBox().Intersects(rect)) + if (!pair.Value.wasPet.Value && pair.Value.GetBoundingBox().Intersects(rect)) { pair.Value.pet(who); return true; @@ -143,7 +144,7 @@ public bool CheckInspectAnimal(Vector2 position, Farmer who) { foreach (KeyValuePair pair in this.Animals.Pairs) { - if ((bool)pair.Value.wasPet && pair.Value.GetCursorPetBoundingBox().Contains((int)position.X, (int)position.Y)) + if (pair.Value.wasPet.Value && pair.Value.GetCursorPetBoundingBox().Contains((int)position.X, (int)position.Y)) { pair.Value.pet(who); return true; @@ -156,7 +157,7 @@ public bool CheckInspectAnimal(Rectangle rect, Farmer who) { foreach (KeyValuePair pair in this.Animals.Pairs) { - if ((bool)pair.Value.wasPet && pair.Value.GetBoundingBox().Intersects(rect)) + if (pair.Value.wasPet.Value && pair.Value.GetBoundingBox().Intersects(rect)) { pair.Value.pet(who); return true; @@ -188,23 +189,21 @@ protected override void resetLocalState() { KeyValuePair keyValuePair = this.Animals.Pairs.ElementAt(index); FarmAnimal farmAnimal = keyValuePair.Value; - keyValuePair = this.Animals.Pairs.ElementAt(index); - FarmAnimal a = keyValuePair.Value; - this.MyWarpHome(farmAnimal, a); + this.MyWarpHome(farmAnimal); } } - if (this.isThereABuildingUnderConstruction() && (int)this.getBuildingUnderConstruction().daysOfConstructionLeft > 0 && Game1.getCharacterFromName("Robin").currentLocation.Equals(this)) + Building underConstruction = this.getBuildingUnderConstruction(); + if (underConstruction?.daysOfConstructionLeft.Value > 0 && Game1.getCharacterFromName("Robin").currentLocation.Equals(this)) { - Building underConstruction = this.getBuildingUnderConstruction(); - this.temporarySprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(399, 262, (int)(NetFieldBase)underConstruction.daysOfConstructionLeft == 1 ? 29 : 9, 43), new Vector2((int)underConstruction.tileX + (int)underConstruction.tilesWide / 2, (int)underConstruction.tileY + (int)underConstruction.tilesHigh / 2) * 64f + new Vector2(-16f, -144f), false, 0.0f, Color.White) + this.temporarySprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(399, 262, underConstruction.daysOfConstructionLeft.Value == 1 ? 29 : 9, 43), new Vector2(underConstruction.tileX.Value + underConstruction.tilesWide.Value / 2, underConstruction.tileY.Value + underConstruction.tilesHigh.Value / 2) * 64f + new Vector2(-16f, -144f), false, 0.0f, Color.White) { id = 16846f, scale = 4f, interval = 999999f, animationLength = 1, totalNumberOfLoops = 99999, - layerDepth = (((int)underConstruction.tileY + (int)underConstruction.tilesHigh / 2) * 64 + 32) / 10000f + layerDepth = ((underConstruction.tileY.Value + underConstruction.tilesHigh.Value / 2) * 64 + 32) / 10000f }); } else diff --git a/BuildableLocationsFramework/Patches/CarpenterMenuPatcher.cs b/BuildableLocationsFramework/Patches/CarpenterMenuPatcher.cs index c4a342570..9fdf81efa 100644 --- a/BuildableLocationsFramework/Patches/CarpenterMenuPatcher.cs +++ b/BuildableLocationsFramework/Patches/CarpenterMenuPatcher.cs @@ -118,21 +118,21 @@ public static bool Before_ReceiveLeftClick(CarpenterMenu __instance, int x, int } if (!__instance_onFarm.GetValue() && __instance.demolishButton.containsPoint(x, y) && __instance.demolishButton.visible) { - Game1.globalFadeToBlack(new Game1.afterFadeFunction(__instance.setUpForBuildingPlacement)); + Game1.globalFadeToBlack(__instance.setUpForBuildingPlacement); Game1.playSound("smallSelect"); __instance_onFarm.SetValue(true); __instance_demolishing.SetValue(true); } if (!__instance_onFarm.GetValue() && __instance.moveButton.containsPoint(x, y) && __instance.moveButton.visible) { - Game1.globalFadeToBlack(new Game1.afterFadeFunction(__instance.setUpForBuildingPlacement)); + Game1.globalFadeToBlack(__instance.setUpForBuildingPlacement); Game1.playSound("smallSelect"); __instance_onFarm.SetValue(true); __instance_moving.SetValue(true); } if (__instance.okButton.containsPoint(x, y) && !__instance_onFarm.GetValue() && (Game1.player.Money >= __instance_price.GetValue() && __instance_blueprints.GetValue()[__instance_currentBlueprintIndex.GetValue()].doesFarmerHaveEnoughResourcesToBuild())) { - Game1.globalFadeToBlack(new Game1.afterFadeFunction(__instance.setUpForBuildingPlacement)); + Game1.globalFadeToBlack(__instance.setUpForBuildingPlacement); Game1.playSound("smallSelect"); __instance_onFarm.SetValue(true); } @@ -155,7 +155,7 @@ void ContinueDemolish() { if (!__instance_demolishing.GetValue() || destroyed == null || !farm.buildings.Contains(destroyed)) return; - if ((int)destroyed.daysOfConstructionLeft > 0 || (int)destroyed.daysUntilUpgrade > 0) + if (destroyed.daysOfConstructionLeft.Value > 0 || destroyed.daysUntilUpgrade.Value > 0) Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_DuringConstruction"), Color.Red, 3500f)); else if (destroyed.indoors.Value is AnimalHouse house && house.animalsThatLiveHere.Count > 0) Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_AnimalsHere"), Color.Red, 3500f)); @@ -206,7 +206,7 @@ void ContinueDemolish() __instance_freeze.SetValue(true); if (chest == null) return; - farm.objects[new Vector2((int)destroyed.tileX + (int)destroyed.tilesWide / 2, (int)destroyed.tileY + (int)destroyed.tilesHigh / 2)] = chest; + farm.objects[new Vector2(destroyed.tileX.Value + destroyed.tilesWide.Value / 2, destroyed.tileY.Value + destroyed.tilesHigh.Value / 2)] = chest; } } } @@ -227,7 +227,7 @@ void ContinueDemolish() } if (destroyed?.indoors.Value is Cabin cabinB) { - if (cabinB.farmhand.Value != null && (bool)cabinB.farmhand.Value.isCustomized) + if (cabinB.farmhand.Value != null && cabinB.farmhand.Value.isCustomized.Value) { Game1.currentLocation.createQuestionDialogue(Game1.content.LoadString("Strings\\UI:Carpenter_DemolishCabinConfirm", cabinB.farmhand.Value.Name), Game1.currentLocation.createYesNoResponses(), (f, answer) => { @@ -237,7 +237,7 @@ void ContinueDemolish() Game1.player.team.demolishLock.RequestLock(ContinueDemolish, BuildingLockFailed); } else - DelayedAction.functionAfterDelay(new DelayedAction.delayedBehavior(__instance.returnToCarpentryMenu), 500); + DelayedAction.functionAfterDelay(__instance.returnToCarpentryMenu, 500); }); goto ret; } @@ -255,7 +255,7 @@ void ContinueDemolish() buildingAt.daysUntilUpgrade.Value = 2; buildingAt.showUpgradeAnimation(Game1.getFarm()); Game1.playSound("axe"); - DelayedAction.functionAfterDelay(new DelayedAction.delayedBehavior(__instance.returnToCarpentryMenuAfterSuccessfulBuild), 1500); + DelayedAction.functionAfterDelay(__instance.returnToCarpentryMenuAfterSuccessfulBuild, 1500); __instance_freeze.SetValue(true); } else @@ -272,7 +272,7 @@ void ContinueDemolish() __instance_buildingToMove.SetValue(((BuildableGameLocation)CarpenterMenuPatcher.ReturnCurrentLocationAnyways("Farm")).getBuildingAt(new Vector2((Game1.viewport.X + Game1.getMouseX()) / 64, (Game1.viewport.Y + Game1.getMouseY()) / 64))); if (__instance_buildingToMove.GetValue() == null) goto ret; - if ((int)__instance_buildingToMove.GetValue().daysOfConstructionLeft > 0) + if (__instance_buildingToMove.GetValue().daysOfConstructionLeft.Value > 0) __instance_buildingToMove.SetValue(null); else if (!Game1.IsMasterGame && !__instance.hasPermissionsToMove(__instance_buildingToMove.GetValue())) { @@ -306,7 +306,7 @@ void ContinueDemolish() if (__instance.tryToBuild()) { __instance.CurrentBlueprint.consumeResources(); - DelayedAction.functionAfterDelay(new DelayedAction.delayedBehavior(__instance.returnToCarpentryMenuAfterSuccessfulBuild), 2000); + DelayedAction.functionAfterDelay(__instance.returnToCarpentryMenuAfterSuccessfulBuild, 2000); __instance_freeze.SetValue(true); } else diff --git a/BuildableLocationsFramework/Patches/FarmAnimalPatcher.cs b/BuildableLocationsFramework/Patches/FarmAnimalPatcher.cs index ba68b3fcb..6b5221ba3 100644 --- a/BuildableLocationsFramework/Patches/FarmAnimalPatcher.cs +++ b/BuildableLocationsFramework/Patches/FarmAnimalPatcher.cs @@ -50,35 +50,35 @@ private static bool Before_UpdateWhenNotCurrentLocation(FarmAnimal __instance, B Mod.Instance.Helper.Reflection.GetField(__instance, "doBuildingPokeEvent").GetValue().Poll(); if (!Game1.shouldTimePass()) return false; - __instance.update(time, environment, (long)__instance.myID, false); + __instance.update(time, environment, __instance.myID.Value, false); if (!Game1.IsMasterGame) return false; - if (currentBuilding != null && Game1.random.NextDouble() < 0.002 && ((bool)currentBuilding.animalDoorOpen && Game1.timeOfDay < 1630) && (!Game1.isRaining && !Game1.currentSeason.Equals("winter") && environment.farmers.Count == 0)) + if (currentBuilding != null && Game1.random.NextDouble() < 0.002 && (currentBuilding.animalDoorOpen.Value && Game1.timeOfDay < 1630) && (!Game1.isRaining && !Game1.currentSeason.Equals("winter") && environment.farmers.Count == 0)) { GameLocation locationFromName = Mod.FindOutdoorsOf(currentBuilding); IAnimalLocation locationFromName_animals = (IAnimalLocation)locationFromName; - if (locationFromName.isCollidingPosition(new Rectangle(((int)currentBuilding.tileX + currentBuilding.animalDoor.X) * 64 + 2, ((int)currentBuilding.tileY + currentBuilding.animalDoor.Y) * 64 + 2, (__instance.isCoopDweller() ? 64 : 128) - 4, 60), Game1.viewport, false, 0, false, __instance, false) || locationFromName.isCollidingPosition(new Rectangle(((int)currentBuilding.tileX + currentBuilding.animalDoor.X) * 64 + 2, ((int)currentBuilding.tileY + currentBuilding.animalDoor.Y + 1) * 64 + 2, (__instance.isCoopDweller() ? 64 : 128) - 4, 60), Game1.viewport, false, 0, false, __instance, false)) + if (locationFromName.isCollidingPosition(new Rectangle((currentBuilding.tileX.Value + currentBuilding.animalDoor.X) * 64 + 2, (currentBuilding.tileY.Value + currentBuilding.animalDoor.Y) * 64 + 2, (__instance.isCoopDweller() ? 64 : 128) - 4, 60), Game1.viewport, false, 0, false, __instance, false) || locationFromName.isCollidingPosition(new Rectangle((currentBuilding.tileX.Value + currentBuilding.animalDoor.X) * 64 + 2, (currentBuilding.tileY.Value + currentBuilding.animalDoor.Y + 1) * 64 + 2, (__instance.isCoopDweller() ? 64 : 128) - 4, 60), Game1.viewport, false, 0, false, __instance, false)) return false; - if (locationFromName_animals.Animals.ContainsKey((long)__instance.myID)) + if (locationFromName_animals.Animals.ContainsKey(__instance.myID.Value)) { for (int index = locationFromName_animals.Animals.Count() - 1; index >= 0; --index) { - if (locationFromName_animals.Animals.Pairs.ElementAt(index).Key.Equals((long)__instance.myID)) + if (locationFromName_animals.Animals.Pairs.ElementAt(index).Key.Equals(__instance.myID.Value)) { - locationFromName_animals.Animals.Remove((long)__instance.myID); + locationFromName_animals.Animals.Remove(__instance.myID.Value); break; } } } - (currentBuilding.indoors.Value as AnimalHouse).animals.Remove((long)__instance.myID); - locationFromName_animals.Animals.Add((long)__instance.myID, __instance); + (currentBuilding.indoors.Value as AnimalHouse).animals.Remove(__instance.myID.Value); + locationFromName_animals.Animals.Add(__instance.myID.Value, __instance); __instance.faceDirection(2); __instance.SetMovingDown(true); - __instance.Position = new Vector2(currentBuilding.getRectForAnimalDoor().X, ((int)currentBuilding.tileY + currentBuilding.animalDoor.Y) * 64 - (__instance.Sprite.getHeight() * 4 - __instance.GetBoundingBox().Height) + 32); + __instance.Position = new Vector2(currentBuilding.getRectForAnimalDoor().X, (currentBuilding.tileY.Value + currentBuilding.animalDoor.Y) * 64 - (__instance.Sprite.getHeight() * 4 - __instance.GetBoundingBox().Height) + 32); if (FarmAnimal.NumPathfindingThisTick < FarmAnimal.MaxPathfindingPerTick) { ++FarmAnimal.NumPathfindingThisTick; - __instance.controller = new PathFindController(__instance, locationFromName, new PathFindController.isAtEnd(FarmAnimal.grassEndPointFunction), Game1.random.Next(4), false, new PathFindController.endBehavior(FarmAnimal.behaviorAfterFindingGrassPatch), 200, Point.Zero); + __instance.controller = new PathFindController(__instance, locationFromName, FarmAnimal.grassEndPointFunction, Game1.random.Next(4), false, FarmAnimal.behaviorAfterFindingGrassPatch, 200, Point.Zero); } if (__instance.controller?.pathToEndPoint == null || __instance.controller.pathToEndPoint.Count < 3) { @@ -119,7 +119,7 @@ private static bool Before_UpdateWhenCurrentLocation(FarmAnimal __instance, Game __instance.Sprite.CurrentAnimation = null; return false; } - __instance.update(time, location, (long)__instance.myID, false); + __instance.update(time, location, __instance.myID.Value, false); if (Game1.IsMasterGame && Mod.Instance.Helper.Reflection.GetMethod(__instance, "behaviors").Invoke(time, location) || __instance.Sprite.CurrentAnimation != null) return false; if (__instance.controller != null && __instance.controller.timerSinceLastCheckPoint > 10000) @@ -134,9 +134,9 @@ private static bool Before_UpdateWhenCurrentLocation(FarmAnimal __instance, Game { if (Utility.isOnScreen(__instance.getTileLocationPoint(), 192, location)) location.localSound("dwoop"); - animalLocation.Animals.Remove((long)__instance.myID); - (building.indoors.Value as AnimalHouse).animals[(long)__instance.myID] = __instance; - __instance.setRandomPosition(building.indoors); + animalLocation.Animals.Remove(__instance.myID.Value); + (building.indoors.Value as AnimalHouse).animals[__instance.myID.Value] = __instance; + __instance.setRandomPosition(building.indoors.Value); __instance.faceDirection(Game1.random.Next(4)); __instance.controller = null; return true; @@ -155,7 +155,7 @@ private static bool Before_UpdateWhenCurrentLocation(FarmAnimal __instance, Game } else if (__instance.pauseTimer <= 0) { - if (Game1.random.NextDouble() < 0.001 && (int)__instance.age >= (byte)__instance.ageWhenMature && (Game1.gameMode == 3 && __instance.sound.Value != null) && Utility.isOnScreen(__instance.Position, 192)) + if (Game1.random.NextDouble() < 0.001 && __instance.age.Value >= __instance.ageWhenMature.Value && (Game1.gameMode == 3 && __instance.sound.Value != null) && Utility.isOnScreen(__instance.Position, 192)) __instance.makeSound(); if (!Game1.IsClient && Game1.random.NextDouble() < 0.007 && __instance.uniqueFrameAccumulator == -1) { @@ -166,7 +166,7 @@ private static bool Before_UpdateWhenCurrentLocation(FarmAnimal __instance, Game { int facingDirection = __instance.FacingDirection; __instance.faceDirection(direction); - if (!(bool)location.isOutdoors && location.isCollidingPosition(__instance.nextPosition(direction), Game1.viewport, __instance)) + if (!location.IsOutdoors && location.isCollidingPosition(__instance.nextPosition(direction), Game1.viewport, __instance)) { __instance.faceDirection(facingDirection); return false; @@ -287,18 +287,17 @@ private static bool Before_UpdateWhenCurrentLocation(FarmAnimal __instance, Game /// The method to call before . public static bool Before_Behaviors(FarmAnimal __instance, GameTime time, GameLocation location, ref bool __result) { - NetBool isEating = __instance.isEating; if (__instance.home == null) { __result = false; return false; } - if ((bool)isEating) + if (__instance.isEating.Value) { if (__instance.home != null && __instance.home.getRectForAnimalDoor().Intersects(__instance.GetBoundingBox())) { FarmAnimal.behaviorAfterFindingGrassPatch(__instance, location); - isEating.Value = false; + __instance.isEating.Value = false; __instance.Halt(); __result = false; return false; @@ -308,7 +307,7 @@ public static bool Before_Behaviors(FarmAnimal __instance, GameTime time, GameLo __instance.Sprite.Animate(time, 16, 4, 100f); if (__instance.Sprite.currentFrame >= 20) { - isEating.Value = false; + __instance.isEating.Value = false; __instance.Sprite.loop = true; __instance.Sprite.currentFrame = 0; __instance.faceDirection(2); @@ -319,7 +318,7 @@ public static bool Before_Behaviors(FarmAnimal __instance, GameTime time, GameLo __instance.Sprite.Animate(time, 24, 4, 100f); if (__instance.Sprite.currentFrame >= 28) { - isEating.Value = false; + __instance.isEating.Value = false; __instance.Sprite.loop = true; __instance.Sprite.currentFrame = 0; __instance.faceDirection(2); @@ -335,18 +334,18 @@ public static bool Before_Behaviors(FarmAnimal __instance, GameTime time, GameLo __result = true; return false; } - if (location.IsOutdoors && (byte)__instance.fullness < 195 && (Game1.random.NextDouble() < 0.002 && FarmAnimal.NumPathfindingThisTick < FarmAnimal.MaxPathfindingPerTick)) + if (location.IsOutdoors && __instance.fullness.Value < 195 && (Game1.random.NextDouble() < 0.002 && FarmAnimal.NumPathfindingThisTick < FarmAnimal.MaxPathfindingPerTick)) { ++FarmAnimal.NumPathfindingThisTick; - __instance.controller = new PathFindController(__instance, location, new PathFindController.isAtEnd(FarmAnimal.grassEndPointFunction), -1, false, new PathFindController.endBehavior(FarmAnimal.behaviorAfterFindingGrassPatch), 200, Point.Zero); + __instance.controller = new PathFindController(__instance, location, FarmAnimal.grassEndPointFunction, -1, false, FarmAnimal.behaviorAfterFindingGrassPatch, 200, Point.Zero); } if (Game1.timeOfDay >= 1700 && location.IsOutdoors && (__instance.controller == null && Game1.random.NextDouble() < 0.002)) { if (location.farmers.Count == 0) { - (location as Farm).animals.Remove((long)__instance.myID); - (__instance.home.indoors.Value as AnimalHouse).animals.Add((long)__instance.myID, __instance); - __instance.setRandomPosition(__instance.home.indoors); + (location as Farm).animals.Remove(__instance.myID.Value); + (__instance.home.indoors.Value as AnimalHouse).animals.Add(__instance.myID.Value, __instance); + __instance.setRandomPosition(__instance.home.indoors.Value); __instance.faceDirection(Game1.random.Next(4)); __instance.controller = null; __result = true; @@ -355,10 +354,10 @@ public static bool Before_Behaviors(FarmAnimal __instance, GameTime time, GameLo if (FarmAnimal.NumPathfindingThisTick < FarmAnimal.MaxPathfindingPerTick) { ++FarmAnimal.NumPathfindingThisTick; - __instance.controller = new PathFindController(__instance, location, new PathFindController.isAtEnd(PathFindController.isAtEndPoint), 0, false, null, 200, new Point((int)__instance.home.tileX + __instance.home.animalDoor.X, (int)__instance.home.tileY + __instance.home.animalDoor.Y)); + __instance.controller = new PathFindController(__instance, location, PathFindController.isAtEndPoint, 0, false, null, 200, new Point(__instance.home.tileX.Value + __instance.home.animalDoor.X, __instance.home.tileY.Value + __instance.home.animalDoor.Y)); } } - if (location.IsOutdoors && !Game1.isRaining && (!Game1.currentSeason.Equals("winter") && (int)__instance.currentProduce != -1) && ((int)__instance.age >= (byte)__instance.ageWhenMature && __instance.type.Value.Contains("Pig") && Game1.random.NextDouble() < 0.0002)) + if (location.IsOutdoors && !Game1.isRaining && (!Game1.currentSeason.Equals("winter") && __instance.currentProduce.Value != -1) && (__instance.age.Value >= __instance.ageWhenMature.Value && __instance.type.Value.Contains("Pig") && Game1.random.NextDouble() < 0.0002)) { Rectangle boundingBox = __instance.GetBoundingBox(); for (int corner = 0; corner < 4; ++corner) diff --git a/BuildableLocationsFramework/Patches/MilkPailPatcher.cs b/BuildableLocationsFramework/Patches/MilkPailPatcher.cs index 50c0468ee..1d05b7efc 100644 --- a/BuildableLocationsFramework/Patches/MilkPailPatcher.cs +++ b/BuildableLocationsFramework/Patches/MilkPailPatcher.cs @@ -36,26 +36,32 @@ private static bool Before_BeginUsing(Shears __instance, GameLocation location, x = (int)who.GetToolLocation().X; y = (int)who.GetToolLocation().Y; Rectangle toolRect = new Rectangle(x - 32, y - 32, 64, 64); - var __instance_animal = Mod.Instance.Helper.Reflection.GetField(__instance, "animal"); + + var animalField = Mod.Instance.Helper.Reflection.GetField(__instance, "animal"); + var animal = animalField.GetValue(); + if (location is IAnimalLocation animalLoc) - __instance_animal.SetValue(Utility.GetBestHarvestableFarmAnimal(animalLoc.Animals.Values, __instance, toolRect)); - if (__instance_animal.GetValue() != null && (int)__instance_animal.GetValue().currentProduce > 0 && ((int)__instance_animal.GetValue().age >= (byte)__instance_animal.GetValue().ageWhenMature && __instance_animal.GetValue().toolUsedForHarvest.Equals(__instance.BaseName)) && who.couldInventoryAcceptThisObject((int)__instance_animal.GetValue().currentProduce, 1)) { - __instance_animal.GetValue().doEmote(20); - __instance_animal.GetValue().friendshipTowardFarmer.Value = Math.Min(1000, (int)__instance_animal.GetValue().friendshipTowardFarmer + 5); + animalField.SetValue(animal = Utility.GetBestHarvestableFarmAnimal(animalLoc.Animals.Values, __instance, toolRect)); + } + + if (animal != null && animal.currentProduce.Value > 0 && (animal.age.Value >= animal.ageWhenMature.Value && animal.toolUsedForHarvest.Value.Equals(__instance.BaseName)) && who.couldInventoryAcceptThisObject(animal.currentProduce.Value, 1)) + { + animal.doEmote(20); + animal.friendshipTowardFarmer.Value = Math.Min(1000, animal.friendshipTowardFarmer.Value + 5); who.currentLocation.localSound("Milking"); - __instance_animal.GetValue().pauseTimer = 1500; + animal.pauseTimer = 1500; } - else if (__instance_animal.GetValue() != null && (int)__instance_animal.GetValue().currentProduce > 0 && (int)__instance_animal.GetValue().age >= (byte)__instance_animal.GetValue().ageWhenMature) + else if (animal != null && animal.currentProduce.Value > 0 && animal.age.Value >= animal.ageWhenMature.Value) { if (who != null && Game1.player.Equals(who)) { - if (!__instance_animal.GetValue().toolUsedForHarvest.Equals(__instance.BaseName)) + if (!animal.toolUsedForHarvest.Value.Equals(__instance.BaseName)) { - if (!(__instance_animal.GetValue().toolUsedForHarvest == null) && !__instance_animal.GetValue().toolUsedForHarvest.Equals("null")) - Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:MilkPail.cs.14167", __instance_animal.GetValue().toolUsedForHarvest)); + if (animal.toolUsedForHarvest.Value != null && !animal.toolUsedForHarvest.Value.Equals("null")) + Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:MilkPail.cs.14167", animal.toolUsedForHarvest.Value)); } - else if (!who.couldInventoryAcceptThisObject((int)__instance_animal.GetValue().currentProduce, 1)) + else if (!who.couldInventoryAcceptThisObject(animal.currentProduce.Value, 1)) Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588")); } } @@ -64,12 +70,12 @@ private static bool Before_BeginUsing(Shears __instance, GameLocation location, DelayedAction.playSoundAfterDelay("fishingRodBend", 300); DelayedAction.playSoundAfterDelay("fishingRodBend", 1200); string dialogue = ""; - if (__instance_animal.GetValue() != null && !__instance_animal.GetValue().toolUsedForHarvest.Equals(__instance.BaseName)) - dialogue = Game1.content.LoadString("Strings\\StringsFromCSFiles:MilkPail.cs.14175", __instance_animal.GetValue().displayName); - if (__instance_animal.GetValue() != null && __instance_animal.GetValue().isBaby() && __instance_animal.GetValue().toolUsedForHarvest.Equals(__instance.BaseName)) - dialogue = Game1.content.LoadString("Strings\\StringsFromCSFiles:MilkPail.cs.14176", __instance_animal.GetValue().displayName); - if (__instance_animal.GetValue() != null && (int)__instance_animal.GetValue().age >= (byte)__instance_animal.GetValue().ageWhenMature && __instance_animal.GetValue().toolUsedForHarvest.Equals(__instance.BaseName)) - dialogue = Game1.content.LoadString("Strings\\StringsFromCSFiles:MilkPail.cs.14177", __instance_animal.GetValue().displayName); + if (animal != null && !animal.toolUsedForHarvest.Value.Equals(__instance.BaseName)) + dialogue = Game1.content.LoadString("Strings\\StringsFromCSFiles:MilkPail.cs.14175", animal.displayName); + if (animal != null && animal.isBaby() && animal.toolUsedForHarvest.Value.Equals(__instance.BaseName)) + dialogue = Game1.content.LoadString("Strings\\StringsFromCSFiles:MilkPail.cs.14176", animal.displayName); + if (animal != null && animal.age.Value >= animal.ageWhenMature.Value && animal.toolUsedForHarvest.Value.Equals(__instance.BaseName)) + dialogue = Game1.content.LoadString("Strings\\StringsFromCSFiles:MilkPail.cs.14177", animal.displayName); if (dialogue.Length > 0) DelayedAction.showDialogueAfterDelay(dialogue, 1000); } diff --git a/BuildableLocationsFramework/Patches/SaveGamePatcher.cs b/BuildableLocationsFramework/Patches/SaveGamePatcher.cs index a913718c8..764b09209 100644 --- a/BuildableLocationsFramework/Patches/SaveGamePatcher.cs +++ b/BuildableLocationsFramework/Patches/SaveGamePatcher.cs @@ -48,7 +48,7 @@ private static void Before_LoadDataToLocations(List gamelocations) continue; if (gamelocation is BuildableGameLocation buildableGameLocation) { - BuildableGameLocation locationFromName = (BuildableGameLocation)Game1.getLocationFromName(gamelocation.name); + BuildableGameLocation locationFromName = (BuildableGameLocation)Game1.getLocationFromName(gamelocation.Name); foreach (Building building in buildableGameLocation.buildings) building.load(); locationFromName.buildings.Set(buildableGameLocation.buildings); diff --git a/BuildableLocationsFramework/Patches/UtilityPatcher.cs b/BuildableLocationsFramework/Patches/UtilityPatcher.cs index 2afae695d..796f53c9d 100644 --- a/BuildableLocationsFramework/Patches/UtilityPatcher.cs +++ b/BuildableLocationsFramework/Patches/UtilityPatcher.cs @@ -55,9 +55,9 @@ private static bool Before_AreThereAnyOtherAnimalsWithThisName(string name, ref var locs = Mod.GetAllLocations(); foreach (var loc in locs) { - if (loc is IAnimalLocation aloc) + if (loc is IAnimalLocation animalLocation) { - foreach (var animal in aloc.Animals.Values) + foreach (var animal in animalLocation.Animals.Values) { if (animal.displayName == name) { @@ -110,13 +110,13 @@ private static bool Before_FixAllAnimals() if (animal != null) { animal.home = building; - animal.homeLocation.Value = new Vector2((int)building.tileX, (int)building.tileY); + animal.homeLocation.Value = new Vector2(building.tileX.Value, building.tileY.Value); } } } } List farmAnimalList1 = new List(); - foreach (FarmAnimal allFarmAnimal in UtilityPatcher.getAllFarmAnimals(farm)) + foreach (FarmAnimal allFarmAnimal in UtilityPatcher.GetAllFarmAnimals(farm)) { if (allFarmAnimal.home == null) farmAnimalList1.Add(allFarmAnimal); @@ -173,13 +173,13 @@ private static bool Before_FixAllAnimals() { foreach (Building building in farm.buildings) { - if (building.buildingType.Contains(farmAnimal.buildingTypeILiveIn) && building.indoors.Value is AnimalHouse house && !house.isFull()) + if (building.buildingType.Contains(farmAnimal.buildingTypeILiveIn.Value) && building.indoors.Value is AnimalHouse house && !house.isFull()) { farmAnimal.home = building; - farmAnimal.homeLocation.Value = new Vector2((int)building.tileX, (int)building.tileY); - farmAnimal.setRandomPosition(farmAnimal.home.indoors); - (farmAnimal.home.indoors.Value as AnimalHouse).animals.Add((long)farmAnimal.myID, farmAnimal); - (farmAnimal.home.indoors.Value as AnimalHouse).animalsThatLiveHere.Add((long)farmAnimal.myID); + farmAnimal.homeLocation.Value = new Vector2(building.tileX.Value, building.tileY.Value); + farmAnimal.setRandomPosition(farmAnimal.home.indoors.Value); + (farmAnimal.home.indoors.Value as AnimalHouse).animals.Add(farmAnimal.myID.Value, farmAnimal); + (farmAnimal.home.indoors.Value as AnimalHouse).animalsThatLiveHere.Add(farmAnimal.myID.Value); break; } } @@ -193,8 +193,8 @@ private static bool Before_FixAllAnimals() foreach (FarmAnimal farmAnimal in farmAnimalList2) { farmAnimal.Position = Utility.recursiveFindOpenTileForCharacter(farmAnimal, farm, new Vector2(40f, 40f), 200) * 64f; - if (!farm_animals.Animals.ContainsKey((long)farmAnimal.myID)) - farm_animals.Animals.Add((long)farmAnimal.myID, farmAnimal); + if (!farm_animals.Animals.ContainsKey(farmAnimal.myID.Value)) + farm_animals.Animals.Add(farmAnimal.myID.Value, farmAnimal); } } } @@ -204,9 +204,10 @@ private static bool Before_FixAllAnimals() /// The method to call after . private static void After_NumSilos(ref int __result) { + Farm farm = Game1.getFarm(); foreach (var loc in Mod.GetAllLocations()) { - if (loc != Game1.getFarm() && loc is BuildableGameLocation bgl) + if (loc != farm && loc is BuildableGameLocation bgl) { foreach (var building in bgl.buildings) { @@ -217,16 +218,19 @@ private static void After_NumSilos(ref int __result) } } - private static List getAllFarmAnimals(BuildableGameLocation loc) + private static List GetAllFarmAnimals(BuildableGameLocation loc) { List list = new List(); - if (loc is IAnimalLocation loca) - list = loca.Animals.Values.ToList(); + + if (loc is IAnimalLocation animalLocation) + list = animalLocation.Animals.Values.ToList(); + foreach (Building building in loc.buildings) { - if (building.indoors.Value is AnimalHouse) - list.AddRange(((AnimalHouse)building.indoors).animals.Values.ToList()); + if (building.indoors.Value is AnimalHouse animalHouse) + list.AddRange(animalHouse.animals.Values); } + return list; } } diff --git a/CaveFarm/CaveWall.cs b/CaveFarm/CaveWall.cs index 5bd21e2a2..447b202d8 100644 --- a/CaveFarm/CaveWall.cs +++ b/CaveFarm/CaveWall.cs @@ -35,7 +35,7 @@ public override bool performToolAction(Tool t, int damage, Vector2 tileLocation, this.Health.Value -= damage; } - if (this.Health > 0) + if (this.Health.Value > 0) return true; return false; } diff --git a/CookingSkill/Framework/NewCraftingPage.cs b/CookingSkill/Framework/NewCraftingPage.cs index 8a5642eb9..2a9f16d14 100644 --- a/CookingSkill/Framework/NewCraftingPage.cs +++ b/CookingSkill/Framework/NewCraftingPage.cs @@ -387,7 +387,7 @@ private void clickCraftingRecipe(ClickableTextureComponent c, bool playSound = t Game1.player.craftingRecipes[this.pagesOfCraftingRecipes[this.currentCraftingPage][c].name] += this.pagesOfCraftingRecipes[this.currentCraftingPage][c].numberProducedPerCraft; if (this.cooking) { - Game1.player.cookedRecipe((int)this.heldItem.parentSheetIndex); + Game1.player.cookedRecipe(this.heldItem.ParentSheetIndex); ///// Game1.player.AddCustomSkillExperience(Mod.Skill, itemObj.Edibility); ///// @@ -537,11 +537,11 @@ public override void draw(SpriteBatch b) int yOffset = this.heldItem != null ? 48 : 0; string displayName = this.hoverRecipe.DisplayName; string[] buffIconsToDisplay; - if (this.cooking && this.lastCookingHover != null) + if (this.cooking && this.lastCookingHover is SObject lastCookingObj) { - if (Game1.objectInformation[(int)(this.lastCookingHover as StardewValley.Object).parentSheetIndex].Split('/').Length > 7) + if (Game1.objectInformation[lastCookingObj.ParentSheetIndex].Split('/').Length > 7) { - buffIconsToDisplay = Game1.objectInformation[(int)(this.lastCookingHover as StardewValley.Object).parentSheetIndex].Split('/')[7].Split(' '); + buffIconsToDisplay = Game1.objectInformation[lastCookingObj.ParentSheetIndex].Split('/')[7].Split(' '); goto label_35; } } @@ -590,19 +590,19 @@ public static void myConsumeIngredients(CraftingRecipe recipe, List addit { int recipe1 = recipeList[recipeList.Keys.ElementAt(index1)]; bool flag = false; - for (int index2 = Game1.player.items.Count - 1; index2 >= 0; --index2) + for (int index2 = Game1.player.Items.Count - 1; index2 >= 0; --index2) { - if (Game1.player.items[index2] != null && Game1.player.items[index2] is StardewValley.Object && !(bool)(Game1.player.items[index2] as StardewValley.Object).bigCraftable && ((int)Game1.player.items[index2].parentSheetIndex == recipeList.Keys.ElementAt(index1) || Game1.player.items[index2].Category == recipeList.Keys.ElementAt(index1) || CraftingRecipe.isThereSpecialIngredientRule((StardewValley.Object)Game1.player.items[index2], recipeList.Keys.ElementAt(index1)))) + if (Game1.player.Items[index2] is SObject obj && !obj.bigCraftable.Value && (obj.ParentSheetIndex == recipeList.Keys.ElementAt(index1) || obj.Category == recipeList.Keys.ElementAt(index1) || CraftingRecipe.isThereSpecialIngredientRule(obj, recipeList.Keys.ElementAt(index1)))) { int recipe2 = recipeList[recipeList.Keys.ElementAt(index1)]; - recipe1 -= Game1.player.items[index2].Stack; + recipe1 -= obj.Stack; ///// - used?.Add(new ConsumedItem(Game1.player.items[index2] as SObject)); + used?.Add(new ConsumedItem(obj)); if (actuallyConsume) ///// - Game1.player.items[index2].Stack -= recipe2; - if (Game1.player.items[index2].Stack <= 0) - Game1.player.items[index2] = null; + obj.Stack -= recipe2; + if (obj.Stack <= 0) + Game1.player.Items[index2] = null; if (recipe1 <= 0) { flag = true; @@ -619,7 +619,7 @@ public static void myConsumeIngredients(CraftingRecipe recipe, List addit for (int index3 = additionalMaterial.items.Count - 1; index3 >= 0; --index3) { - if (additionalMaterial.items[index3] != null && additionalMaterial.items[index3] is SObject && ((int)additionalMaterial.items[index3].parentSheetIndex == recipeList.Keys.ElementAt(index1) || additionalMaterial.items[index3].Category == recipeList.Keys.ElementAt(index1) || CraftingRecipe.isThereSpecialIngredientRule((SObject)additionalMaterial.items[index3], recipeList.Keys.ElementAt(index1)))) + if (additionalMaterial.items[index3] != null && additionalMaterial.items[index3] is SObject && (additionalMaterial.items[index3].ParentSheetIndex == recipeList.Keys.ElementAt(index1) || additionalMaterial.items[index3].Category == recipeList.Keys.ElementAt(index1) || CraftingRecipe.isThereSpecialIngredientRule((SObject)additionalMaterial.items[index3], recipeList.Keys.ElementAt(index1)))) { int num = Math.Min(recipe1, additionalMaterial.items[index3].Stack); recipe1 -= num; diff --git a/CustomBuildings/Mod.cs b/CustomBuildings/Mod.cs index 8da9db03a..3fb151b39 100644 --- a/CustomBuildings/Mod.cs +++ b/CustomBuildings/Mod.cs @@ -55,12 +55,12 @@ public override void Entry(IModHelper helper) foreach (var dir in buildingsDir.EnumerateDirectories()) { string relDir = $"Buildings/{dir.Name}"; - BuildingData binfo = cp.ReadJsonFile(Path.Combine(relDir, "building.json")); - if (binfo == null) + BuildingData buildingData = cp.ReadJsonFile(Path.Combine(relDir, "building.json")); + if (buildingData == null) continue; - binfo.Texture = cp.LoadAsset(Path.Combine(relDir, "building.png")); - binfo.MapLoader = () => cp.LoadAsset(Path.Combine(relDir, "building.tbin")); - this.Buildings.Add(binfo.Id, binfo); + buildingData.Texture = cp.LoadAsset(Path.Combine(relDir, "building.png")); + buildingData.MapLoader = () => cp.LoadAsset(Path.Combine(relDir, "building.tbin")); + this.Buildings.Add(buildingData.Id, buildingData); } } } @@ -93,7 +93,7 @@ private void OnWarped(object sender, WarpedEventArgs e) // This is probably a new building if it hasn't been converted yet. if (this.Buildings.TryGetValue(b.buildingType.Value, out BuildingData buildingData) && !(b is Coop)) { - farm.buildings[i] = new Coop(new BluePrint(b.buildingType), new Vector2(b.tileX, b.tileY)); + farm.buildings[i] = new Coop(new BluePrint(b.buildingType.Value), new Vector2(b.tileX.Value, b.tileY.Value)); farm.buildings[i].indoors.Value = b.indoors.Value; farm.buildings[i].load(); (farm.buildings[i].indoors.Value as AnimalHouse).animalLimit.Value = buildingData.MaxOccupants; @@ -121,7 +121,7 @@ public T Load(IAssetInfo asset) else if (asset.AssetNameEquals("Maps\\" + building.Key)) return (T)(object)building.Value.MapLoader(); } - return default(T); + return default; } public bool CanEdit(IAssetInfo asset) diff --git a/CustomBuildings/Patches/CoopPatcher.cs b/CustomBuildings/Patches/CoopPatcher.cs index c0765a433..101aae6e6 100644 --- a/CustomBuildings/Patches/CoopPatcher.cs +++ b/CustomBuildings/Patches/CoopPatcher.cs @@ -69,7 +69,7 @@ private static bool Before_GetIndoors(Coop __instance, string nameOfIndoorsWitho if (!Mod.Instance.Buildings.TryGetValue(nameOfIndoorsWithoutUnique, out BuildingData buildingData)) return true; - AnimalHouse loc = new AnimalHouse($"Maps\\{buildingData.Id}", __instance.buildingType) + AnimalHouse loc = new AnimalHouse($"Maps\\{buildingData.Id}", __instance.buildingType.Value) { IsFarm = true }; @@ -78,8 +78,8 @@ private static bool Before_GetIndoors(Coop __instance, string nameOfIndoorsWitho loc.animalLimit.Value = buildingData.MaxOccupants; foreach (var warp in loc.warps) { - warp.TargetX = __instance.humanDoor.X + __instance.tileX; - warp.TargetY = __instance.humanDoor.Y + __instance.tileY + 1; + warp.TargetX = __instance.humanDoor.X + __instance.tileX.Value; + warp.TargetY = __instance.humanDoor.Y + __instance.tileY.Value + 1; } __result = loc; return false; @@ -88,12 +88,14 @@ private static bool Before_GetIndoors(Coop __instance, string nameOfIndoorsWitho /// The method to call after . private static void After_PerformActionOnConstruction(Coop __instance, GameLocation location) { - if (!Mod.Instance.Buildings.TryGetValue(__instance.buildingType, out BuildingData buildingData)) + if (!Mod.Instance.Buildings.TryGetValue(__instance.buildingType.Value, out BuildingData buildingData)) return; __instance.indoors.Value.objects.Remove(new Vector2(3, 3)); - StardewValley.Object @object = new StardewValley.Object(new Vector2(buildingData.FeedHopperX, buildingData.FeedHopperY), 99); - @object.fragility.Value = 2; + StardewValley.Object @object = new StardewValley.Object(new Vector2(buildingData.FeedHopperX, buildingData.FeedHopperY), 99) + { + Fragility = 2 + }; __instance.indoors.Value.objects.Add(new Vector2(buildingData.FeedHopperX, buildingData.FeedHopperY), @object); __instance.daysOfConstructionLeft.Value = buildingData.DaysToConstruct; } @@ -101,19 +103,21 @@ private static void After_PerformActionOnConstruction(Coop __instance, GameLocat /// The method to call before . private static bool Before_PerformActionOnUpgrade(Coop __instance, GameLocation location) { - return !Mod.Instance.Buildings.ContainsKey(__instance.buildingType); + return !Mod.Instance.Buildings.ContainsKey(__instance.buildingType.Value); } /// The method to call after . private static void After_DayUpdate(Coop __instance, int dayOfMonth) { - if (!Mod.Instance.Buildings.TryGetValue(__instance.buildingType, out BuildingData buildingData)) + if (!Mod.Instance.Buildings.TryGetValue(__instance.buildingType.Value, out BuildingData buildingData)) return; - if (buildingData.AutoFeedsAnimals) + if (buildingData.AutoFeedsAnimals && __instance.indoors.Value is AnimalHouse animalHouse) { - int num = Math.Min((__instance.indoors.Value as AnimalHouse).animals.Count() - __instance.indoors.Value.numberOfObjectsWithName("Hay"), (Game1.getLocationFromName("Farm") as Farm).piecesOfHay); - (Game1.getLocationFromName("Farm") as Farm).piecesOfHay.Value -= num; + Farm farm = Game1.getFarm(); + + int num = Math.Min(animalHouse.animals.Count() - __instance.indoors.Value.numberOfObjectsWithName("Hay"), farm.piecesOfHay.Value); + farm.piecesOfHay.Value -= num; for (int ix = 0; ix < __instance.indoors.Value.map.Layers[0].LayerWidth && num > 0; ++ix) { for (int iy = 0; iy < __instance.indoors.Value.map.Layers[0].LayerHeight && num > 0; ++iy) @@ -131,14 +135,16 @@ private static void After_DayUpdate(Coop __instance, int dayOfMonth) /// The method to call before . private static bool Before_Upgrade(Coop __instance) { - if (!Mod.Instance.Buildings.TryGetValue(__instance.buildingType, out BuildingData buildingData)) + if (!Mod.Instance.Buildings.TryGetValue(__instance.buildingType.Value, out BuildingData buildingData) || __instance.indoors.Value is not AnimalHouse animalHouse) return true; - (__instance.indoors.Value as AnimalHouse).animalLimit.Value = buildingData.MaxOccupants; + animalHouse.animalLimit.Value = buildingData.MaxOccupants; if (buildingData.IncubatorX != -1) { - StardewValley.Object @object = new StardewValley.Object(new Vector2(buildingData.IncubatorX, buildingData.IncubatorY), 104); - @object.fragility.Value = 2; + StardewValley.Object @object = new StardewValley.Object(new Vector2(buildingData.IncubatorX, buildingData.IncubatorY), 104) + { + Fragility = 2 + }; __instance.indoors.Value.objects.Add(new Vector2(buildingData.IncubatorX, buildingData.IncubatorY), @object); } @@ -160,8 +166,8 @@ private static bool Before_Upgrade(Coop __instance) foreach (var warp in __instance.indoors.Value.warps) { - warp.TargetX = __instance.humanDoor.X + __instance.tileX; - warp.TargetY = __instance.humanDoor.Y + __instance.tileY + 1; + warp.TargetX = __instance.humanDoor.X + __instance.tileX.Value; + warp.TargetY = __instance.humanDoor.Y + __instance.tileY.Value + 1; } return false; @@ -184,7 +190,7 @@ private static bool After_GetUpgradeSignLocation(Coop __instance, ref Vector2 __ /// The method to call before . private static bool Before_Draw(Coop __instance, SpriteBatch b) { - if (__instance.isMoving || !Mod.Instance.Buildings.TryGetValue(__instance.buildingType, out BuildingData buildingData)) + if (__instance.isMoving || !Mod.Instance.Buildings.TryGetValue(__instance.buildingType.Value, out BuildingData buildingData)) return false; if (__instance.daysOfConstructionLeft.Value > 0) diff --git a/CustomNPCFixes/Mod.cs b/CustomNPCFixes/Mod.cs index 09e371130..a40869531 100644 --- a/CustomNPCFixes/Mod.cs +++ b/CustomNPCFixes/Mod.cs @@ -67,7 +67,7 @@ private void SpawnNpcs() continue; } found = true; - if ((bool)n2.datable && n2.getSpouse() == null) + if (n2.datable.Value && n2.getSpouse() == null) { string defaultMap = npcDispositions[s].Split('/')[10].Split(' ')[0]; if (n2.DefaultMap != defaultMap && (n2.DefaultMap.ToLower().Contains("cabin") || n2.DefaultMap.Equals("FarmHouse"))) diff --git a/Displays/Mannequin.cs b/Displays/Mannequin.cs index e7cfc5fa5..60ddfd277 100644 --- a/Displays/Mannequin.cs +++ b/Displays/Mannequin.cs @@ -78,8 +78,8 @@ protected override void initNetFields() private void CacheFarmerSprite() { this.FarmerForRendering ??= new Farmer(); - this.FarmerForRendering.changeGender(this.MannGender == MannequinGender.Male); - if (this.MannGender == MannequinGender.Female) + this.FarmerForRendering.changeGender(this.MannGender.Value == MannequinGender.Male); + if (this.MannGender.Value == MannequinGender.Female) this.FarmerForRendering.changeHairStyle(16); this.FarmerForRendering.faceDirection(this.Facing.Value); this.FarmerForRendering.hat.Value = this.Hat.Value; @@ -101,7 +101,7 @@ private void CacheFarmerSprite() { this.FarmerForRendering.changeShoeColor(this.Boots.Value.indexInColorSheet.Value); } - if (this.MannType == MannequinType.Plain) + if (this.MannType.Value == MannequinType.Plain) { this.FarmerForRendering.changeHairColor(Color.Transparent); this.FarmerForRendering.FarmerRenderer.textureName.Value = "Characters\\Farmer\\farmer_transparent"; diff --git a/JsonAssets/Mod.cs b/JsonAssets/Mod.cs index e439b06a6..6a691fe62 100644 --- a/JsonAssets/Mod.cs +++ b/JsonAssets/Mod.cs @@ -2006,9 +2006,9 @@ internal void FixItemList(IList items) if (attached == null) continue; - if (attached.GetType() != typeof(StardewValley.Object) || attached.bigCraftable) + if (attached.GetType() != typeof(SObject) || attached.bigCraftable.Value) { - Log.Warn("Unsupported attachment types! Let spacechase0 know he needs to support " + attached.bigCraftable.Value + " " + attached); + Log.Warn($"Unsupported attachment types! Let spacechase0 know he needs to support {attached.bigCraftable.Value} {attached}"); } else { diff --git a/JsonAssets/Patches/FencePatcher.cs b/JsonAssets/Patches/FencePatcher.cs index 2449c44f4..4d648971a 100644 --- a/JsonAssets/Patches/FencePatcher.cs +++ b/JsonAssets/Patches/FencePatcher.cs @@ -5,7 +5,6 @@ using SpaceShared; using StardewModdingAPI; using StardewValley; -using StardewValley.Network; using StardewValley.Tools; using SObject = StardewValley.Object; @@ -130,16 +129,16 @@ private static bool Before_PerformToolAction(Fence __instance, Tool t, GameLocat else return false; location.playSound(t is Axe ? "axchop" : "hammer"); - location.objects.Remove(__instance.tileLocation.Value); + location.objects.Remove(__instance.TileLocation); for (int i = 0; i < 4; ++i) { location.temporarySprites.Add(new CosmeticDebris( __instance.fenceTexture.Value, - new Vector2(__instance.tileLocation.X * 64 + 32, __instance.tileLocation.Y * 64 + 32), + new Vector2(__instance.TileLocation.X * 64 + 32, __instance.TileLocation.Y * 64 + 32), Game1.random.Next(-5, 5) / 100f, Game1.random.Next(-64, 64) / 30f, Game1.random.Next(-800, -100) / 100f, - (int)((__instance.tileLocation.Y + 1) * 64), + (int)((__instance.TileLocation.Y + 1) * 64), new Rectangle(32 + Game1.random.Next(2) * 16 / 2, 96 + Game1.random.Next(2) * 16 / 2, 8, 8), Color.White, Game1.soundBank != null ? Game1.soundBank.GetCue("shiny4") : null, @@ -148,15 +147,13 @@ private static bool Before_PerformToolAction(Fence __instance, Tool t, GameLocat 200 )); } - Game1.createRadialDebris(location, t is Axe ? 12 : 14, (int)__instance.tileLocation.X, (int)__instance.tileLocation.Y, 6, false); - Mod.instance.Helper.Reflection.GetField(typeof(Game1), "multiplayer").GetValue() - .broadcastSprites(location, new TemporaryAnimatedSprite(12, new Vector2(__instance.tileLocation.X * 64, __instance.tileLocation.Y * 64), - Color.White, 8, Game1.random.NextDouble() < 0.5, 50)); + Game1.createRadialDebris(location, t is Axe ? 12 : 14, (int)__instance.TileLocation.X, (int)__instance.TileLocation.Y, 6, false); + Mod.instance.Helper.Reflection + .GetField(typeof(Game1), "multiplayer").GetValue() + .broadcastSprites(location, new TemporaryAnimatedSprite(12, new Vector2(__instance.TileLocation.X * 64, __instance.TileLocation.Y * 64), Color.White, 8, Game1.random.NextDouble() < 0.5, 50)); + if (__instance.maxHealth.Value - __instance.health.Value < 0.5) - { - location.debris.Add(new Debris(new SObject(fence.correspondingObject.GetObjectId(), 1), - __instance.tileLocation.Value * 64 + new Vector2(32, 32))); - } + location.debris.Add(new Debris(new SObject(fence.correspondingObject.GetObjectId(), 1), __instance.TileLocation * 64 + new Vector2(32, 32))); return false; } } diff --git a/JsonAssets/Patches/RingPatcher.cs b/JsonAssets/Patches/RingPatcher.cs index 7ec6461c7..290d9f474 100644 --- a/JsonAssets/Patches/RingPatcher.cs +++ b/JsonAssets/Patches/RingPatcher.cs @@ -38,12 +38,12 @@ public static bool Before_LoadDisplayFields(Ring __instance, ref bool __result) // the game will still run. try { - if (Game1.objectInformation == null || __instance.indexInTileSheet == null) + if (Game1.objectInformation == null || __instance.indexInTileSheet.Value == null) { __result = false; return false; } - string[] strArray = Game1.objectInformation[__instance.indexInTileSheet].Split('/'); + string[] strArray = Game1.objectInformation[__instance.indexInTileSheet.Value].Split('/'); __instance.displayName = strArray[4]; __instance.description = strArray[5]; __result = true; diff --git a/Magic/Framework/Game/CloudMount.cs b/Magic/Framework/Game/CloudMount.cs index 36a365be8..6792432d5 100644 --- a/Magic/Framework/Game/CloudMount.cs +++ b/Magic/Framework/Game/CloudMount.cs @@ -27,7 +27,7 @@ public override void update(GameTime time, GameLocation location) dismountedOnce = true; } else*/ - if (!this.dismounting) + if (!this.dismounting.Value) this.currentLocation.characters.Remove(this); return; } diff --git a/Magic/Framework/Game/SpellProjectile.cs b/Magic/Framework/Game/SpellProjectile.cs index 3426d951d..bf51d567a 100644 --- a/Magic/Framework/Game/SpellProjectile.cs +++ b/Magic/Framework/Game/SpellProjectile.cs @@ -16,9 +16,9 @@ internal class SpellProjectile : Projectile private readonly Farmer Source; private readonly ProjectileSpell Spell; private readonly NetInt Damage = new(); - private readonly NetFloat Dir = new(); - private readonly NetFloat Vel = new(); - private readonly NetBool Seeking = new(); + private readonly NetFloat Direction = new(); + private readonly NetFloat Velocity = new(); + private readonly NetBool IsSeeking = new(); private Texture2D Tex; private readonly NetString TexId = new(); @@ -27,37 +27,37 @@ internal class SpellProjectile : Projectile public SpellProjectile() { - this.NetFields.AddFields(this.Damage, this.Dir, this.Vel, this.Seeking, this.TexId); + this.NetFields.AddFields(this.Damage, this.Direction, this.Velocity, this.IsSeeking, this.TexId); } - public SpellProjectile(Farmer theSource, ProjectileSpell theSpell, int dmg, float theDir, float theVel, bool theSeeking) + public SpellProjectile(Farmer source, ProjectileSpell spell, int damage, float direction, float velocity, bool isSeeking) : this() { - this.Source = theSource; - this.Spell = theSpell; - this.Damage.Value = dmg; - this.Dir.Value = theDir; - this.Vel.Value = theVel; - this.Seeking.Value = theSeeking; + this.Source = source; + this.Spell = spell; + this.Damage.Value = damage; + this.Direction.Value = direction; + this.Velocity.Value = velocity; + this.IsSeeking.Value = isSeeking; - this.theOneWhoFiredMe.Set(theSource.currentLocation, this.Source); + this.theOneWhoFiredMe.Set(source.currentLocation, this.Source); this.position.Value = this.Source.getStandingPosition(); this.position.X += this.Source.GetBoundingBox().Width; this.position.Y += this.Source.GetBoundingBox().Height; - this.rotation = theDir; - this.xVelocity.Value = (float)Math.Cos(this.Dir) * this.Vel; - this.yVelocity.Value = (float)Math.Sin(this.Dir) * this.Vel; + this.rotation = direction; + this.xVelocity.Value = (float)Math.Cos(this.Direction.Value) * this.Velocity.Value; + this.yVelocity.Value = (float)Math.Sin(this.Direction.Value) * this.Velocity.Value; this.damagesMonsters.Value = true; this.Tex = Content.LoadTexture("magic/" + this.Spell.ParentSchoolId + "/" + this.Spell.Id + "/projectile.png"); this.TexId.Value = Content.LoadTextureKey("magic/" + this.Spell.ParentSchoolId + "/" + this.Spell.Id + "/projectile.png"); - if (this.Seeking) + if (this.IsSeeking.Value) { float nearestDist = float.MaxValue; Monster nearestMob = null; - foreach (var character in theSource.currentLocation.characters) + foreach (var character in source.currentLocation.characters) { if (character is Monster mob) { @@ -84,15 +84,15 @@ public override void behaviorOnCollisionWithMonster(NPC npc, GameLocation loc) if (!(npc is Monster)) return; - bool didDmg = loc.damageMonster(npc.GetBoundingBox(), this.Damage, this.Damage + 1, false, this.Source); + bool didDmg = loc.damageMonster(npc.GetBoundingBox(), this.Damage.Value, this.Damage.Value + 1, false, this.Source); if (this.Source != null && didDmg) - this.Source.AddCustomSkillExperience(Magic.Skill, this.Damage / ((this.theOneWhoFiredMe.Get(loc) as Farmer).CombatLevel + 1)); + this.Source.AddCustomSkillExperience(Magic.Skill, this.Damage.Value / ((this.theOneWhoFiredMe.Get(loc) as Farmer).CombatLevel + 1)); this.Disappear(loc); } public override void behaviorOnCollisionWithOther(GameLocation loc) { - if (!this.Seeking) + if (!this.IsSeeking.Value) this.Disappear(loc); } @@ -102,13 +102,13 @@ public override void behaviorOnCollisionWithPlayer(GameLocation loc, Farmer farm public override void behaviorOnCollisionWithTerrainFeature(TerrainFeature t, Vector2 tileLocation, GameLocation loc) { - if (!this.Seeking) + if (!this.IsSeeking.Value) this.Disappear(loc); } public override bool isColliding(GameLocation location) { - if (this.Seeking) + if (this.IsSeeking.Value) { return location.doesPositionCollideWithCharacter(this.getBoundingBox()) != null; } @@ -122,7 +122,7 @@ public override Rectangle getBoundingBox() public override bool update(GameTime time, GameLocation location) { - if (this.Seeking) + if (this.IsSeeking.Value) { if (this.SeekTarget == null || this.SeekTarget.Health <= 0 || this.SeekTarget.currentLocation == null) { @@ -134,8 +134,8 @@ public override bool update(GameTime time, GameLocation location) Vector2 unit = new Vector2(this.SeekTarget.GetBoundingBox().Center.X + 32, this.SeekTarget.GetBoundingBox().Center.Y + 32) - this.position; unit.Normalize(); - this.xVelocity.Value = unit.X * this.Vel; - this.yVelocity.Value = unit.Y * this.Vel; + this.xVelocity.Value = unit.X * this.Velocity.Value; + this.yVelocity.Value = unit.Y * this.Velocity.Value; } } @@ -145,8 +145,8 @@ public override bool update(GameTime time, GameLocation location) public override void updatePosition(GameTime time) { //if (true) return; - this.position.X += this.xVelocity; - this.position.Y += this.yVelocity; + this.position.X += this.xVelocity.Value; + this.position.Y += this.yVelocity.Value; } /* public override bool isColliding(GameLocation location) @@ -164,7 +164,7 @@ public override void draw(SpriteBatch b) { this.Tex ??= Game1.content.Load(this.TexId.Value); Vector2 drawPos = Game1.GlobalToLocal(new Vector2(this.getBoundingBox().X + this.getBoundingBox().Width / 2, this.getBoundingBox().Y + this.getBoundingBox().Height / 2)); - b.Draw(this.Tex, drawPos, new Rectangle(0, 0, this.Tex.Width, this.Tex.Height), Color.White, this.Dir, new Vector2(this.Tex.Width / 2, this.Tex.Height / 2), 2, SpriteEffects.None, (float)((this.position.Y + (double)(Game1.tileSize * 3 / 2)) / 10000.0)); + b.Draw(this.Tex, drawPos, new Rectangle(0, 0, this.Tex.Width, this.Tex.Height), Color.White, this.Direction.Value, new Vector2(this.Tex.Width / 2, this.Tex.Height / 2), 2, SpriteEffects.None, (float)((this.position.Y + (double)(Game1.tileSize * 3 / 2)) / 10000.0)); //Vector2 bdp = Game1.GlobalToLocal(new Vector2(getBoundingBox().X, getBoundingBox().Y)); //b.Draw(Mod.instance.manaFg, new Rectangle((int)bdp.X, (int)bdp.Y, getBoundingBox().Width, getBoundingBox().Height), Color.White); } @@ -175,7 +175,7 @@ private void Disappear(GameLocation loc) if (this.Spell.SoundHit != null) Game1.playSound(this.Spell.SoundHit); //Game1.createRadialDebris(loc, 22 + rand.Next( 2 ), ( int ) position.X / Game1.tileSize, ( int ) position.Y / Game1.tileSize, 3 + rand.Next(5), false); - Game1.createRadialDebris(loc, this.TexId, Game1.getSourceRectForStandardTileSheet(Projectile.projectileSheet, 0), 4, (int)this.position.X, (int)this.position.Y, 6 + SpellProjectile.Rand.Next(10), (int)(this.position.Y / (double)Game1.tileSize) + 1, new Color(255, 255, 255, 8 + SpellProjectile.Rand.Next(64)), 2.0f); + Game1.createRadialDebris(loc, this.TexId.Value, Game1.getSourceRectForStandardTileSheet(Projectile.projectileSheet, 0), 4, (int)this.position.X, (int)this.position.Y, 6 + SpellProjectile.Rand.Next(10), (int)(this.position.Y / (double)Game1.tileSize) + 1, new Color(255, 255, 255, 8 + SpellProjectile.Rand.Next(64)), 2.0f); //Game1.createRadialDebris(loc, tex, new Rectangle(0, 0, tex.Width, tex.Height), 0, ( int ) position.X, ( int ) position.Y, 3 + rand.Next(5), ( int ) position.Y / Game1.tileSize, Color.White, 5.0f); this.destroyMe = true; } diff --git a/MoreBuildings/Buildings/BigShed/BigShedBuilding.cs b/MoreBuildings/Buildings/BigShed/BigShedBuilding.cs index 21e6657aa..96c59b35c 100644 --- a/MoreBuildings/Buildings/BigShed/BigShedBuilding.cs +++ b/MoreBuildings/Buildings/BigShed/BigShedBuilding.cs @@ -20,7 +20,7 @@ protected override GameLocation getIndoors(string nameOfIndoorsWithoutUnique) public object getReplacement() { - Mill building = new Mill(new BluePrint("Mill"), new Vector2(this.tileX, this.tileY)); + Mill building = new Mill(new BluePrint("Mill"), new Vector2(this.tileX.Value, this.tileY.Value)); building.indoors.Value = this.indoors.Value; building.daysOfConstructionLeft.Value = this.daysOfConstructionLeft.Value; building.tileX.Value = this.tileX.Value; diff --git a/MoreBuildings/Buildings/FishingShack/FishingShackBuilding.cs b/MoreBuildings/Buildings/FishingShack/FishingShackBuilding.cs index 3d5a520bb..096b8479e 100644 --- a/MoreBuildings/Buildings/FishingShack/FishingShackBuilding.cs +++ b/MoreBuildings/Buildings/FishingShack/FishingShackBuilding.cs @@ -23,7 +23,7 @@ protected override GameLocation getIndoors(string nameOfIndoorsWithoutUnique) public object getReplacement() { - Mill building = new Mill(new BluePrint("Mill"), new Vector2(this.tileX, this.tileY)); + Mill building = new Mill(new BluePrint("Mill"), new Vector2(this.tileX.Value, this.tileY.Value)); building.indoors.Value = this.indoors.Value; building.daysOfConstructionLeft.Value = this.daysOfConstructionLeft.Value; building.tileX.Value = this.tileX.Value; diff --git a/MoreBuildings/Buildings/MiniSpa/MiniSpaBuilding.cs b/MoreBuildings/Buildings/MiniSpa/MiniSpaBuilding.cs index 7aa7e3beb..035bafc5d 100644 --- a/MoreBuildings/Buildings/MiniSpa/MiniSpaBuilding.cs +++ b/MoreBuildings/Buildings/MiniSpa/MiniSpaBuilding.cs @@ -20,7 +20,7 @@ protected override GameLocation getIndoors(string nameOfIndoorsWithoutUnique) public object getReplacement() { - Mill building = new Mill(new BluePrint("Mill"), new Vector2(this.tileX, this.tileY)); + Mill building = new Mill(new BluePrint("Mill"), new Vector2(this.tileX.Value, this.tileY.Value)); building.indoors.Value = this.indoors.Value; building.daysOfConstructionLeft.Value = this.daysOfConstructionLeft.Value; building.tileX.Value = this.tileX.Value; diff --git a/MoreBuildings/Buildings/SpookyShed/SpookyShedBuilding.cs b/MoreBuildings/Buildings/SpookyShed/SpookyShedBuilding.cs index e7ce01cc6..fa2869df0 100644 --- a/MoreBuildings/Buildings/SpookyShed/SpookyShedBuilding.cs +++ b/MoreBuildings/Buildings/SpookyShed/SpookyShedBuilding.cs @@ -20,7 +20,7 @@ protected override GameLocation getIndoors(string nameOfIndoorsWithoutUnique) public object getReplacement() { - Mill building = new Mill(new BluePrint("Mill"), new Vector2(this.tileX, this.tileY)); + Mill building = new Mill(new BluePrint("Mill"), new Vector2(this.tileX.Value, this.tileY.Value)); building.indoors.Value = this.indoors.Value; building.daysOfConstructionLeft.Value = this.daysOfConstructionLeft.Value; building.tileX.Value = this.tileX.Value; diff --git a/MoreEnchantments/Patches/FishingRodPatcher.cs b/MoreEnchantments/Patches/FishingRodPatcher.cs index 1dbe6923c..fc87e2f88 100644 --- a/MoreEnchantments/Patches/FishingRodPatcher.cs +++ b/MoreEnchantments/Patches/FishingRodPatcher.cs @@ -62,7 +62,7 @@ private static bool Before_CalculateTimeUntilFishingBite(FishingRod __instance, if (Game1.currentLocation.isTileBuildingFishable((int)bobberTile.X, (int)bobberTile.Y) && Game1.currentLocation is BuildableGameLocation) { Building bldg = (Game1.currentLocation as BuildableGameLocation).getBuildingAt(bobberTile); - if (bldg is FishPond pond && pond.currentOccupants > 0) + if (bldg is FishPond pond && pond.currentOccupants.Value > 0) { __result = FishPond.FISHING_MILLISECONDS; return false; @@ -92,7 +92,7 @@ private static bool Before_CalculateTimeUntilFishingBite(FishingRod __instance, if (__instance.attachments[0] != null) { time *= 0.5f; - if ((int)__instance.attachments[0].parentSheetIndex == 774) + if (__instance.attachments[0].ParentSheetIndex == 774) { time *= 0.75f; } @@ -104,7 +104,7 @@ private static bool Before_CalculateTimeUntilFishingBite(FishingRod __instance, /// The method to call before . private static bool Before_Attach(FishingRod __instance, StardewValley.Object o, ref StardewValley.Object __result) { - if (o != null && o.Category == -21 && (int)__instance.upgradeLevel > 1) + if (o != null && o.Category == -21 && __instance.UpgradeLevel > 1) { StardewValley.Object tmp = __instance.attachments[0]; if (tmp != null && tmp.canStackWith(o)) @@ -120,7 +120,7 @@ private static bool Before_Attach(FishingRod __instance, StardewValley.Object o, __result = tmp; return false; } - if (o != null && o.Category == -22 && (int)__instance.upgradeLevel > 2) + if (o != null && o.Category == -22 && __instance.UpgradeLevel > 2) { // Rewrote this portion bool hasEnchant = __instance.hasEnchantmentOfType(); @@ -179,7 +179,7 @@ private static bool Before_Attach(FishingRod __instance, StardewValley.Object o, /// The method to call before . private static void After_DrawAttachments(FishingRod __instance, SpriteBatch b, int x, int y) { - if ((int)__instance.upgradeLevel > 2 && __instance.hasEnchantmentOfType()) + if (__instance.UpgradeLevel > 2 && __instance.hasEnchantmentOfType()) { if (__instance.attachments[2] == null) { diff --git a/MoreGrassStarters/CustomGrass.cs b/MoreGrassStarters/CustomGrass.cs index f0cdda493..5d9d24166 100644 --- a/MoreGrassStarters/CustomGrass.cs +++ b/MoreGrassStarters/CustomGrass.cs @@ -40,10 +40,10 @@ public void rebuild(Dictionary data, object replacement) public override void loadSprite() { base.loadSprite(); - if (this.grassType >= 5) + if (this.grassType.Value >= 5) { this.texture = new Lazy(() => GrassStarterItem.Tex2); - this.grassSourceOffset.Value = 20 * (this.grassType - 5); + this.grassSourceOffset.Value = 20 * (this.grassType.Value - 5); } } diff --git a/MoreGrassStarters/GrassStarterItem.cs b/MoreGrassStarters/GrassStarterItem.cs index 264d0fcd1..5fb07e2ab 100644 --- a/MoreGrassStarters/GrassStarterItem.cs +++ b/MoreGrassStarters/GrassStarterItem.cs @@ -91,13 +91,13 @@ public override void drawInMenu(SpriteBatch b, Vector2 pos, float scale, float t b.Draw(tex, pos + new Vector2(4, 0), new Rectangle(0, texOffset, 16, 20), Color.White, 0, Vector2.Zero, 4 * scale, SpriteEffects.None, layerDepth); if ((drawStackNumber == StackDrawType.Draw && this.maximumStackSize() > 1 && this.Stack > 1 || drawStackNumber == StackDrawType.Draw_OneInclusive) && scale > 0.3 && this.Stack != int.MaxValue) - Utility.drawTinyDigits(this.Stack, b, pos + new Vector2(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.stack, 3f * scale) + 3f * scale, (float)(Game1.tileSize - 18.0 * scale + 2.0)), 3f * scale, 1f, Color.White); + Utility.drawTinyDigits(this.Stack, b, pos + new Vector2(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scale) + 3f * scale, (float)(Game1.tileSize - 18.0 * scale + 2.0)), 3f * scale, 1f, Color.White); } // Custom Element Handler public object getReplacement() { - return new SObject(297, this.stack); + return new SObject(297, this.Stack); } public Dictionary getAdditionalSaveData() diff --git a/MultiFertilizer/Patches/HoeDirtPatcher.cs b/MultiFertilizer/Patches/HoeDirtPatcher.cs index 10bfae02f..722700c81 100644 --- a/MultiFertilizer/Patches/HoeDirtPatcher.cs +++ b/MultiFertilizer/Patches/HoeDirtPatcher.cs @@ -65,7 +65,7 @@ private static bool Before_Plant(HoeDirt __instance, int index, int tileX, int t { if (isFertilizer) { - if (__instance.crop != null && __instance.crop.currentPhase != 0) + if (__instance.crop != null && __instance.crop.currentPhase.Value != 0) return false; int level = 0; @@ -210,7 +210,7 @@ private static void After_DayUpdate(HoeDirt __instance, GameLocation environment /// The method to call before . private static void Before_SeasonUpdate(HoeDirt __instance, bool onLoad) { - if (!onLoad && (__instance.crop == null || (bool)__instance.crop.dead || !__instance.crop.seasonsToGrowIn.Contains(Game1.currentLocation.GetSeasonForLocation()))) + if (!onLoad && (__instance.crop == null || __instance.crop.dead.Value || !__instance.crop.seasonsToGrowIn.Contains(Game1.currentLocation.GetSeasonForLocation()))) { __instance.modData.Remove(Mod.KeyFert); __instance.modData.Remove(Mod.KeyRetain); diff --git a/MultiFertilizer/Patches/UtilityPatcher.cs b/MultiFertilizer/Patches/UtilityPatcher.cs index 7b28b9f9c..81d265691 100644 --- a/MultiFertilizer/Patches/UtilityPatcher.cs +++ b/MultiFertilizer/Patches/UtilityPatcher.cs @@ -108,7 +108,7 @@ private static bool TryToPlaceItemLogic(GameLocation location, Item item, int x, if (!location.terrainFeatures.TryGetValue(tileLocation, out TerrainFeature feature) || feature is not HoeDirt dirt) return true; - if ((int)dirt.fertilizer != 0) + if (dirt.fertilizer.Value != 0) { if (dirt.modData.ContainsKey(key)) { diff --git a/TheftOfTheWinterStar/Framework/Witch.cs b/TheftOfTheWinterStar/Framework/Witch.cs index 6e0530f37..fc5f67d4f 100644 --- a/TheftOfTheWinterStar/Framework/Witch.cs +++ b/TheftOfTheWinterStar/Framework/Witch.cs @@ -151,7 +151,7 @@ public override void behaviorAtGameTick(GameTime time) public override void drawAboveAllLayers(SpriteBatch b) { - b.Draw(Game1.mouseCursors, this.getLocalPosition(Game1.viewport), new Rectangle(Witch.CursorsPosX, Witch.CursorsPosY + (this.AnimTimer < 20 ? Witch.TexHeight : 0), Witch.TexWidth, Witch.TexHeight), Color.White, 0, Vector2.Zero, 4, this.FacingRight ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 1); + b.Draw(Game1.mouseCursors, this.getLocalPosition(Game1.viewport), new Rectangle(Witch.CursorsPosX, Witch.CursorsPosY + (this.AnimTimer < 20 ? Witch.TexHeight : 0), Witch.TexWidth, Witch.TexHeight), Color.White, 0, Vector2.Zero, 4, this.FacingRight.Value ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 1); if (++this.AnimTimer >= 40) this.AnimTimer = 0; } diff --git a/TheftOfTheWinterStar/Patches/HoeDirtPatcher.cs b/TheftOfTheWinterStar/Patches/HoeDirtPatcher.cs index 4730dda33..f436b4eec 100644 --- a/TheftOfTheWinterStar/Patches/HoeDirtPatcher.cs +++ b/TheftOfTheWinterStar/Patches/HoeDirtPatcher.cs @@ -57,7 +57,7 @@ private static bool Before_CanPlantThisSeedHere(HoeDirt __instance, int objectIn if (__instance.crop == null) { Crop crop = new Crop(objectIndex, tileX, tileY); - __result = !crop.raisedSeeds || !Utility.doesRectangleIntersectTile(Game1.player.GetBoundingBox(), tileX, tileY); + __result = !crop.raisedSeeds.Value || !Utility.doesRectangleIntersectTile(Game1.player.GetBoundingBox(), tileX, tileY); } else __result = false; @@ -102,15 +102,15 @@ private static bool Before_Plant(HoeDirt __instance, int index, int tileX, int t { return false; } - if (!who.currentLocation.isFarm && !who.currentLocation.IsGreenhouse && !who.currentLocation.CanPlantSeedsHere(index, tileX, tileY) && who.currentLocation.IsOutdoors) + if (!who.currentLocation.IsFarm && !who.currentLocation.IsGreenhouse && !who.currentLocation.CanPlantSeedsHere(index, tileX, tileY) && who.currentLocation.IsOutdoors) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:HoeDirt.cs.13919")); return false; } - if (foundDelimiter || !who.currentLocation.isOutdoors || who.currentLocation.IsGreenhouse || c.seasonsToGrowIn.Contains(location.GetSeasonForLocation()) || who.currentLocation.SeedsIgnoreSeasonsHere()) + if (foundDelimiter || !who.currentLocation.IsOutdoors || who.currentLocation.IsGreenhouse || c.seasonsToGrowIn.Contains(location.GetSeasonForLocation()) || who.currentLocation.SeedsIgnoreSeasonsHere()) { __instance.crop = c; - if ((bool)c.raisedSeeds) + if (c.raisedSeeds.Value) { location.playSound("stoneStep"); } diff --git a/ThrowableAxe/Mod.cs b/ThrowableAxe/Mod.cs index ffeae7f14..195d719d0 100644 --- a/ThrowableAxe/Mod.cs +++ b/ThrowableAxe/Mod.cs @@ -59,7 +59,7 @@ private void OnUpdateTicking(object sender, UpdateTickingEventArgs e) thrown.target.Value = Helper.Input.GetCursorPosition().AbsolutePixels; } */ - if (!this.Clicking || (this.Thrown.GetPosition() - this.Thrown.Target).Length() < 1) + if (!this.Clicking || (this.Thrown.GetPosition() - this.Thrown.Target.Value).Length() < 1) { var playerPos = Game1.player.getStandingPosition(); playerPos.X -= 16; diff --git a/ThrowableAxe/ThrownAxe.cs b/ThrowableAxe/ThrownAxe.cs index 6e90bf9bf..317454f31 100644 --- a/ThrowableAxe/ThrownAxe.cs +++ b/ThrowableAxe/ThrownAxe.cs @@ -11,7 +11,6 @@ namespace ThrowableAxe { public class ThrownAxe : Projectile { - private readonly GameLocation Loc; private readonly NetInt Tier = new(0); private readonly NetInt Damage = new(3); public readonly NetVector2 Target = new(); @@ -29,8 +28,7 @@ public ThrownAxe(Farmer thrower, int tier, int damage, Vector2 target, float spe this.position.X = thrower.getStandingX() - 16; this.position.Y = thrower.getStandingY() - 64; - this.Loc = thrower.currentLocation; - this.theOneWhoFiredMe.Set(this.Loc, thrower); + this.theOneWhoFiredMe.Set(thrower.currentLocation, thrower); this.damagesMonsters.Value = true; this.Tier.Value = tier; this.Damage.Value = damage; @@ -53,7 +51,7 @@ public override void behaviorOnCollisionWithMonster(NPC n, GameLocation location this.NpcsHit.Add(n); if (n is Monster) { - location.damageMonster(this.getBoundingBox(), this.Damage, this.Damage, false, (Farmer)this.theOneWhoFiredMe.Get(location)); + location.damageMonster(this.getBoundingBox(), this.Damage.Value, this.Damage.Value, false, (Farmer)this.theOneWhoFiredMe.Get(location)); } } @@ -91,8 +89,8 @@ public override void updatePosition(GameTime time) public override void draw(SpriteBatch b) { - int sheetShift = this.Tier * 7; - if (this.Tier > 2) + int sheetShift = this.Tier.Value * 7; + if (this.Tier.Value > 2) sheetShift += 21; var sourceRect = Game1.getSquareSourceRectForNonStandardTileSheet(Game1.toolSpriteSheet, 16, 16, 215 + sheetShift); //b.Draw(Game1.staminaRect, Game1.GlobalToLocal(Game1.viewport, getBoundingBox()), null, Color.Red, 0, Vector2.Zero, SpriteEffects.None, 0.99f);