private static bool DrawPrefix(Bush __instance, float ___yDrawOffset, float ___alpha, float ___shakeRotation, SpriteBatch spriteBatch, Vector2 tileLocation) { if (__instance.modData.ContainsKey("AlternativeTextureName")) { var textureModel = AlternativeTextures.textureManager.GetSpecificTextureModel(__instance.modData["AlternativeTextureName"]); if (textureModel is null) { return(true); } var textureVariation = Int32.Parse(__instance.modData["AlternativeTextureVariation"]); if (textureVariation == -1 || AlternativeTextures.modConfig.IsTextureVariationDisabled(textureModel.GetId(), textureVariation)) { return(true); } var effectiveSize = 0; if ((bool)__instance.drawShadow) { if (effectiveSize > 0) { spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((tileLocation.X + ((effectiveSize == 1) ? 0.5f : 1f)) * 64f - 51f, tileLocation.Y * 64f - 16f + ___yDrawOffset)), Bush.shadowSourceRect, Color.White, 0f, Vector2.Zero, 4f, __instance.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 1E-06f); } else { spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2(tileLocation.X * 64f + 32f, tileLocation.Y * 64f + 64f - 4f + ___yDrawOffset)), Game1.shadowTexture.Bounds, Color.White * ___alpha, 0f, new Vector2(Game1.shadowTexture.Bounds.Center.X, Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, 1E-06f); } } var textureOffset = textureModel.GetTextureOffset(textureVariation); var sourceRect = new Rectangle(Math.Min(2, __instance.getAge() / 10) * 16 + __instance.tileSheetOffset.Value * 16, textureOffset, 16, 32); spriteBatch.Draw(textureModel.GetTexture(textureVariation), Game1.GlobalToLocal(Game1.viewport, new Vector2(tileLocation.X * 64f + (float)((effectiveSize + 1) * 64 / 2), (tileLocation.Y + 1f) * 64f - (float)((effectiveSize > 0 && (!__instance.townBush || effectiveSize != 1) && (int)__instance.size != 4) ? 64 : 0) + ___yDrawOffset)), sourceRect, Color.White * ___alpha, ___shakeRotation, new Vector2((effectiveSize + 1) * 16 / 2, 32f), 4f, __instance.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (float)(__instance.getBoundingBox(tileLocation).Center.Y + 48) / 10000f - tileLocation.X / 1000000f); return(false); } return(true); }
/// <summary>Get the data to display for this subject.</summary> /// <param name="metadata">Provides metadata that's not available from the game data directly.</param> public override IEnumerable <ICustomField> GetData(Metadata metadata) { // get basic info Bush bush = this.Target; bool isBerryBush = this.IsBerryBush(bush); bool isTeaBush = this.IsTeaBush(bush); SDate today = SDate.Now(); // next harvest if (isBerryBush || isTeaBush) { SDate nextHarvest = this.GetNextHarvestDate(bush); string nextHarvestStr = nextHarvest == today ? L10n.Generic.Now() : $"{this.Stringify(nextHarvest)} ({this.GetRelativeDateStr(nextHarvest)})"; string harvestSchedule = isTeaBush ? L10n.Bush.ScheduleTea() : L10n.Bush.ScheduleBerry(); yield return(new GenericField(this.GameHelper, L10n.Bush.NextHarvest(), $"{nextHarvestStr}{Environment.NewLine}{harvestSchedule}")); } // date planted + grown if (isTeaBush) { SDate datePlanted = this.GetDatePlanted(bush); SDate dateGrown = this.GetDateFullyGrown(bush); yield return(new GenericField(this.GameHelper, L10n.Bush.DatePlanted(), $"{this.Stringify(datePlanted)} ({this.GetRelativeDateStr(-bush.getAge())})")); if (dateGrown > today) { string grownOnDateText = L10n.Bush.GrowthSummary(date: this.Stringify(dateGrown)); yield return(new GenericField(this.GameHelper, L10n.Bush.Growth(), $"{grownOnDateText} ({this.GetRelativeDateStr(dateGrown)})")); } } }
private static bool checkAction_Prefix(GameLocation __instance, Location tileLocation, Farmer who, ref bool __result) { if (who?.CurrentItem == null || who.CurrentItem.Name != "Instant Growth Powder") { return(true); } if (__instance.isCropAtTile(tileLocation.X, tileLocation.Y)) { if (!(__instance.terrainFeatures[new Vector2(tileLocation.X, tileLocation.Y)] as HoeDirt).crop.fullyGrown.Value) { (__instance.terrainFeatures[new Vector2(tileLocation.X, tileLocation.Y)] as HoeDirt).crop.growCompletely(); } else if ((__instance.terrainFeatures[new Vector2(tileLocation.X, tileLocation.Y)] as HoeDirt).crop.regrowAfterHarvest.Value >= 0 && (__instance.terrainFeatures[new Vector2(tileLocation.X, tileLocation.Y)] as HoeDirt).crop.dayOfCurrentPhase.Value > 0) { (__instance.terrainFeatures[new Vector2(tileLocation.X, tileLocation.Y)] as HoeDirt).crop.dayOfCurrentPhase.Value = 0; } else { return(true); } who.reduceActiveItemByOne(); __instance.playSound("yoba"); __result = true; return(false); } Microsoft.Xna.Framework.Rectangle tileRect = new Microsoft.Xna.Framework.Rectangle(tileLocation.X * 64, tileLocation.Y * 64, 64, 64); foreach (NPC i in __instance.characters) { if (i != null && i is Child && i.GetBoundingBox().Intersects(tileRect) && (i.Age < 3)) { i.Age = 3; (i as Child).daysOld.Value = 55; i.speed = 4; i.reloadSprite(); who.reduceActiveItemByOne(); __instance.playSound("yoba"); __result = true; return(false); } } try { NetLongDictionary <FarmAnimal, NetRef <FarmAnimal> > dict = SHelper.Reflection.GetField <NetLongDictionary <FarmAnimal, NetRef <FarmAnimal> > >(__instance, "animals").GetValue(); foreach (KeyValuePair <long, FarmAnimal> i in dict.Pairs) { if (i.Value.GetCursorPetBoundingBox().Intersects(tileRect)) { i.Value.age.Value = i.Value.ageWhenMature.Value; i.Value.reloadData(); if (i.Value.type.Value.Contains("Sheep")) { i.Value.currentProduce.Value = i.Value.defaultProduceIndex.Value; } i.Value.daysSinceLastLay.Value = 99; who.reduceActiveItemByOne(); __instance.playSound("yoba"); __result = true; return(false); } } } catch { } foreach (KeyValuePair <Vector2, TerrainFeature> v in __instance.terrainFeatures.Pairs) { if (v.Value.getBoundingBox(v.Key).Intersects(tileRect) && v.Value is Tree && (v.Value as Tree).growthStage.Value < 5) { (__instance.terrainFeatures[v.Key] as Tree).growthStage.Value = 5; (__instance.terrainFeatures[v.Key] as Tree).fertilized.Value = true; (__instance.terrainFeatures[v.Key] as Tree).dayUpdate(Game1.currentLocation, v.Key); (__instance.terrainFeatures[v.Key] as Tree).fertilized.Value = false; who.reduceActiveItemByOne(); __instance.playSound("yoba"); __result = true; return(false); } if (v.Value.getBoundingBox(v.Key).Intersects(tileRect) && v.Value is FruitTree && (v.Value as FruitTree).growthStage.Value < 4) { FruitTree tree = v.Value as FruitTree; tree.daysUntilMature.Value = 0; tree.growthStage.Value = 4; __instance.terrainFeatures[v.Key] = tree; who.reduceActiveItemByOne(); __instance.playSound("yoba"); __result = true; return(false); } if (v.Value.getBoundingBox(v.Key).Intersects(tileRect) && v.Value is Bush && (v.Value as Bush).size.Value == 3 && (v.Value as Bush).getAge() < 20) { Bush bush = v.Value as Bush; bush.datePlanted.Value -= 20 - bush.getAge(); Game1.currentLocation.terrainFeatures[v.Key] = bush; Game1.currentLocation.terrainFeatures[v.Key].loadSprite(); who.reduceActiveItemByOne(); __instance.playSound("yoba"); __result = true; return(false); } } foreach (KeyValuePair <Vector2, Object> v in __instance.objects.Pairs) { if (v.Value.getBoundingBox(v.Key).Intersects(tileRect) && v.Value is IndoorPot && (v.Value as IndoorPot).hoeDirt.Value?.crop != null) { if (!(v.Value as IndoorPot).hoeDirt.Value.crop.fullyGrown.Value) { (v.Value as IndoorPot).hoeDirt.Value.crop.growCompletely(); } else if ((v.Value as IndoorPot).hoeDirt.Value.crop.regrowAfterHarvest.Value >= 0 && (v.Value as IndoorPot).hoeDirt.Value.crop.dayOfCurrentPhase.Value > 0) { (v.Value as IndoorPot).hoeDirt.Value.crop.dayOfCurrentPhase.Value = 0; } else { return(true); } who.reduceActiveItemByOne(); __instance.playSound("yoba"); __result = true; return(false); } if (v.Value.getBoundingBox(v.Key).Intersects(tileRect) && v.Value is IndoorPot && (v.Value as IndoorPot).bush.Value?.getAge() < 20) { (v.Value as IndoorPot).bush.Value.datePlanted.Value -= 20 - (v.Value as IndoorPot).bush.Value.getAge(); (v.Value as IndoorPot).bush.Value.loadSprite(); who.reduceActiveItemByOne(); __instance.playSound("yoba"); __result = true; return(false); } } return(true); }
private void GrowThis() { Monitor.Log($"Growing"); if (Game1.currentLocation.isCropAtTile((int)cursorLoc.X, (int)cursorLoc.Y) && !(Game1.currentLocation.terrainFeatures[new Vector2(cursorLoc.X, cursorLoc.Y)] as HoeDirt).crop.fullyGrown) { (Game1.currentLocation.terrainFeatures[new Vector2((int)cursorLoc.X, (int)cursorLoc.Y)] as HoeDirt).crop.growCompletely(); Monitor.Log($"Grew crop"); return; } Microsoft.Xna.Framework.Rectangle tileRect = new Microsoft.Xna.Framework.Rectangle((int)cursorLoc.X * 64, (int)cursorLoc.Y * 64, 64, 64); foreach (NPC i in Game1.currentLocation.characters) { if (i != null && i is Child && i.GetBoundingBox().Intersects(tileRect) && (i.Age < 3)) { i.Age = 3; Monitor.Log($"Grew child"); return; } } if (thing is FarmAnimal) { if (Game1.currentLocation is Farm) { if ((Game1.currentLocation as Farm).Animals.Pairs.FirstOrDefault(f => f.Value == thing).Value != null) { long id = (Game1.currentLocation as Farm).Animals.Pairs.FirstOrDefault(f => f.Value == thing).Key; FarmAnimal fa = (thing as FarmAnimal); if (fa.age < fa.ageWhenMature) { fa.age.Value = fa.ageWhenMature; fa.Sprite.LoadTexture("Animals\\" + fa.type.Value); if (fa.type.Value.Contains("Sheep")) { fa.currentProduce.Value = fa.defaultProduceIndex; } fa.daysSinceLastLay.Value = 99; (Game1.currentLocation as Farm).Animals[id] = fa; Monitor.Log($"Grew animal"); return; } } } if (Game1.currentLocation is AnimalHouse) { if ((Game1.currentLocation as AnimalHouse).Animals.Pairs.FirstOrDefault(f => f.Value == thing).Value != null) { long id = (Game1.currentLocation as AnimalHouse).Animals.Pairs.FirstOrDefault(f => f.Value == thing).Key; FarmAnimal fa = (thing as FarmAnimal); if (fa.age < fa.ageWhenMature) { fa.age.Value = fa.ageWhenMature; fa.Sprite.LoadTexture("Animals\\" + fa.type.Value); if (fa.type.Value.Contains("Sheep")) { fa.currentProduce.Value = fa.defaultProduceIndex; } fa.daysSinceLastLay.Value = 99; (Game1.currentLocation as AnimalHouse).Animals[id] = fa; Monitor.Log($"Grew animal"); return; } } } } foreach (KeyValuePair <Vector2, TerrainFeature> v in Game1.currentLocation.terrainFeatures.Pairs) { if (v.Value.getBoundingBox(v.Key).Intersects(tileRect) && v.Value is Tree && (v.Value as Tree).growthStage < 5) { (Game1.currentLocation.terrainFeatures[v.Key] as Tree).growthStage.Value = 5; (Game1.currentLocation.terrainFeatures[v.Key] as Tree).fertilized.Value = true; (Game1.currentLocation.terrainFeatures[v.Key] as Tree).dayUpdate(Game1.currentLocation, v.Key); (Game1.currentLocation.terrainFeatures[v.Key] as Tree).fertilized.Value = false; Monitor.Log($"Grew tree"); return; } if (v.Value.getBoundingBox(v.Key).Intersects(tileRect) && v.Value is FruitTree && (v.Value as FruitTree).growthStage < 4) { FruitTree tree = v.Value as FruitTree; tree.daysUntilMature.Value = 0; tree.growthStage.Value = 4; Game1.currentLocation.terrainFeatures[v.Key] = tree; Monitor.Log($"Grew fruit tree"); return; } if (v.Value.getBoundingBox(v.Key).Intersects(tileRect) && v.Value is Bush && (v.Value as Bush).size == 3 && (v.Value as Bush).getAge() < 20) { Bush bush = v.Value as Bush; bush.datePlanted.Value -= 20 - bush.getAge(); Game1.currentLocation.terrainFeatures[v.Key] = bush; Game1.currentLocation.terrainFeatures[v.Key].loadSprite(); Monitor.Log($"Grew tea bush tree"); return; } } foreach (KeyValuePair <Vector2, Object> v in Game1.currentLocation.objects.Pairs) { if (v.Value.getBoundingBox(v.Key).Intersects(tileRect) && v.Value is IndoorPot && (v.Value as IndoorPot).hoeDirt.Value?.crop != null && !(v.Value as IndoorPot).hoeDirt.Value.crop.fullyGrown) { (v.Value as IndoorPot).hoeDirt.Value.crop.growCompletely(); Monitor.Log($"Grew pot crop"); return; } if (v.Value.getBoundingBox(v.Key).Intersects(tileRect) && v.Value is IndoorPot && (v.Value as IndoorPot).bush.Value?.getAge() < 20) { (v.Value as IndoorPot).bush.Value.datePlanted.Value -= 20 - (v.Value as IndoorPot).bush.Value.getAge(); (v.Value as IndoorPot).bush.Value.loadSprite(); Monitor.Log($"Grew pot bush"); return; } } }