From 4fd79dae21299f0f8f2b90cb8655cfbb1c199cfd Mon Sep 17 00:00:00 2001 From: Date: Tue, 22 Aug 2017 17:45:30 -0700 Subject: [PATCH] Started AdditionalCropsFramework. Addedin proof for modded crop seeds, seed bags, (crop objects? needs testing) and planter boxes. Still more to do. --- .../AdditionalCropsFramework.csproj | 82 + .../AdditionalCropsFramework/CoreObject.cs | 1551 +++++++++++++++++ .../Framework/TerrainDataNode.cs | 27 + .../Framework/Utilities.cs | 716 ++++++++ .../AdditionalCropsFramework/ModCore.cs | 59 + .../AdditionalCropsFramework/ModularCrop.cs | 489 ++++++ .../ModularCropObject.cs | 1413 +++++++++++++++ .../AdditionalCropsFramework/ModularSeeds.cs | 579 ++++++ .../AdditionalCropsFramework/PlanterBox.cs | 724 ++++++++ .../Properties/AssemblyInfo.cs | 36 + .../AdditionalCropsFramework/manifest.json | 14 + .../AdditionalCropsFramework/packages.config | 4 + GeneralMods/StardewMods.sln | 7 + .../Aesthetics/Draw/ThingsToDraw.cs | 4 +- 14 files changed, 5703 insertions(+), 2 deletions(-) create mode 100644 GeneralMods/AdditionalCropsFramework/AdditionalCropsFramework.csproj create mode 100644 GeneralMods/AdditionalCropsFramework/CoreObject.cs create mode 100644 GeneralMods/AdditionalCropsFramework/Framework/TerrainDataNode.cs create mode 100644 GeneralMods/AdditionalCropsFramework/Framework/Utilities.cs create mode 100644 GeneralMods/AdditionalCropsFramework/ModCore.cs create mode 100644 GeneralMods/AdditionalCropsFramework/ModularCrop.cs create mode 100644 GeneralMods/AdditionalCropsFramework/ModularCropObject.cs create mode 100644 GeneralMods/AdditionalCropsFramework/ModularSeeds.cs create mode 100644 GeneralMods/AdditionalCropsFramework/PlanterBox.cs create mode 100644 GeneralMods/AdditionalCropsFramework/Properties/AssemblyInfo.cs create mode 100644 GeneralMods/AdditionalCropsFramework/manifest.json create mode 100644 GeneralMods/AdditionalCropsFramework/packages.config diff --git a/GeneralMods/AdditionalCropsFramework/AdditionalCropsFramework.csproj b/GeneralMods/AdditionalCropsFramework/AdditionalCropsFramework.csproj new file mode 100644 index 00000000..0250fc69 --- /dev/null +++ b/GeneralMods/AdditionalCropsFramework/AdditionalCropsFramework.csproj @@ -0,0 +1,82 @@ + + + + + Debug + AnyCPU + {C5F88D48-EA20-40CD-91E2-C8725DC11795} + Library + Properties + AdditionalCropsFramework + AdditionalCropsFramework + v4.5 + 512 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/GeneralMods/AdditionalCropsFramework/CoreObject.cs b/GeneralMods/AdditionalCropsFramework/CoreObject.cs new file mode 100644 index 00000000..f03e7f6d --- /dev/null +++ b/GeneralMods/AdditionalCropsFramework/CoreObject.cs @@ -0,0 +1,1551 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI; +using StardewValley; +using StardewValley.Locations; +using StardewValley.Menus; +using StardewValley.Objects; +using System; +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace AdditionalCropsFramework +{ + /// + /// Extends StardewValley.Object. Might be broken and just mainly uses a ton of junk code. + /// + /// + + public class CoreObject : StardewValley.Object + { + public const int chair = 0; + + public const int bench = 1; + + public const int couch = 2; + + public const int armchair = 3; + + public const int dresser = 4; + + public const int longTable = 5; + + public const int painting = 6; + + public const int lamp = 7; + + public const int decor = 8; + + public const int other = 9; + + public const int bookcase = 10; + + public const int table = 11; + + public const int rug = 12; + + public const int window = 13; + + public new int price; + + public int Decoration_type; + + public int rotations; + + public int currentRotation; + + public int sourceIndexOffset; + + protected Vector2 drawPosition; + + public Rectangle sourceRect; + + public Rectangle defaultSourceRect; + + public Rectangle defaultBoundingBox; + + public string description; + + [XmlIgnore] + public Texture2D TextureSheet; + + public new bool flipped; + + [XmlIgnore] + public bool flaggedForPickUp; + + public bool lightGlowAdded; + + public string texturePath; + + public List inventory; + + public int inventoryMaxSize; + + public bool itemReadyForHarvest; + + public bool lightsOn; + + public GameLocation thisLocation; + + public Color lightColor; + + public string thisType; + + public bool removable; + + public string locationsName; + + public Color drawColor; + + public bool useXML; + + public override string Name + { + get + { + return this.name; + } + + } + + public virtual void InitializeBasics(int InvMaxSize, Vector2 tile) + { + this.inventory = new List(); + this.inventoryMaxSize = InvMaxSize; + this.tileLocation = tile; + lightsOn = false; + + lightColor = Color.Black; + thisType = this.GetType().ToString(); + } + + public CoreObject() + { + this.updateDrawPosition(); + } + + public CoreObject(bool f) + { + //does nothng + } + + public CoreObject(int which, Vector2 Tile, int InventoryMaxSize) + { + InitializeBasics(InventoryMaxSize, Tile); + if (TextureSheet == null) + { + TextureSheet = Game1.content.Load("TileSheets\\furniture"); + texturePath = "TileSheets\\furniture"; + } + Dictionary dictionary = Game1.content.Load>("Data\\Furniture"); + string[] array = dictionary[which].Split(new char[] + { + '/' + }); + this.name = array[0]; + + this.Decoration_type = this.getTypeNumberFromName(array[1]); + this.description = "Can be placed inside your house."; + this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 1, 1); + if (array[2].Equals("-1")) + { + this.sourceRect = this.getDefaultSourceRectForType(which, this.Decoration_type); + this.defaultSourceRect = this.sourceRect; + } + else + { + this.defaultSourceRect.Width = Convert.ToInt32(array[2].Split(new char[] + { + ' ' + })[0]); + this.defaultSourceRect.Height = Convert.ToInt32(array[2].Split(new char[] + { + ' ' + })[1]); + this.sourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16); + this.defaultSourceRect = this.sourceRect; + } + this.defaultBoundingBox = new Rectangle((int)this.tileLocation.X, (int)this.tileLocation.Y, 1, 1); + if (array[3].Equals("-1")) + { + this.boundingBox = this.getDefaultBoundingBoxForType(this.Decoration_type); + this.defaultBoundingBox = this.boundingBox; + } + else + { + this.defaultBoundingBox.Width = Convert.ToInt32(array[3].Split(new char[] + { + ' ' + })[0]); + this.defaultBoundingBox.Height = Convert.ToInt32(array[3].Split(new char[] + { + ' ' + })[1]); + this.boundingBox = new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize); + this.defaultBoundingBox = this.boundingBox; + } + this.updateDrawPosition(); + this.rotations = Convert.ToInt32(array[4]); + this.price = Convert.ToInt32(array[5]); + this.parentSheetIndex = which; + } + + public override string getDescription() + { + return this.description; + } + + public override bool performDropDownAction(StardewValley.Farmer who) + { + this.resetOnPlayerEntry((who == null) ? Game1.currentLocation : who.currentLocation); + return false; + } + + public override void hoverAction() + { + base.hoverAction(); + if (!Game1.player.isInventoryFull()) + { + Game1.mouseCursor = 2; + } + } + + public override bool checkForAction(StardewValley.Farmer who, bool justCheckingForActivity = false) + { + var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); + if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) + { + // Game1.showRedMessage("YOOO"); + //do some stuff when the right button is down + // rotate(); + if (this.heldObject != null) + { + // Game1.player.addItemByMenuIfNecessary(this.heldObject); + // this.heldObject = null; + } + else + { + // this.heldObject = Game1.player.ActiveObject; + // Game1.player.removeItemFromInventory(heldObject); + } + //this.minutesUntilReady = 30; + // Log.AsyncC("placed item!"); + } + else + { + //Game1.showRedMessage("CRY"); + } + + if (justCheckingForActivity) + { + return true; + } + return this.clicked(who); + } + + //DONT USE THIS BASE IT IS TERRIBLE + /* + public override bool clicked(StardewValley.Farmer who) + { + + // Game1.showRedMessage("THIS IS CLICKED!!!"); + Game1.haltAfterCheck = false; + + if (this.heldObject != null) + { + this.spillInventoryEverywhere(); + return false; + } + + if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is CoreObject))) + { + if (Game1.player.currentLocation is FarmHouse) + { + // Game1.showRedMessage("Why2?"); + // this.spillInventoryEverywhere(); + + if (this.heldObject != null) Util.addItemToInventoryElseDrop(this.heldObject.getOne()); + this.heldObject = new CoreObject(parentSheetIndex, Vector2.Zero, this.inventoryMaxSize); + // Util.addItemToInventoryElseDrop(this.heldObject.getOne()); + this.heldObject = null; + this.flaggedForPickUp = true; + thisLocation = null; + return true; + } + else + { + // return true; + + this.flaggedForPickUp = true; + if (this is TV) + { + // this.heldObject = new TV(parentSheetIndex, Vector2.Zero); + } + else + { + + // Util.addItemToInventoryElseDrop(this.heldObject); + + var obj = new CoreObject(parentSheetIndex, Vector2.Zero, this.inventoryMaxSize); + // Util.addItemToInventoryElseDrop(obj); + // this.spillInventoryEverywhere(); + if (this.heldObject != null) this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); + + this.heldObject = null; + Game1.playSound("coin"); + thisLocation = null; + return true; + } + + } + } + if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) + { + // Game1.showRedMessage("Why3?"); + // if(this.heldObject!=null) Game1.player.addItemByMenuIfNecessary((Item)this.heldObject); + // this.spillInventoryEverywhere(); + var obj = new CoreObject(parentSheetIndex, Vector2.Zero, this.inventoryMaxSize); + // Util.addItemToInventoryElseDrop(obj); + if (this.heldObject != null) this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); + this.heldObject = null; + Game1.playSound("coin"); + thisLocation = null; + return true; + } + + + + return false; + } + */ + + public virtual bool RightClicked(StardewValley.Farmer who) + { + // StardewModdingAPI.Log.AsyncC(lightColor); + // Game1.activeClickableMenu = new Revitalize.Menus.LightCustomizer(this); + + // Game1.showRedMessage("THIS IS CLICKED!!!"); + //var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); + /* + + Game1.haltAfterCheck = false; + if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null) + { + // Game1.showRedMessage("Why1?"); + return false; + } + if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is Light))) + { + if (Game1.player.currentLocation is FarmHouse) + { + // + Game1.player.addItemByMenuIfNecessary(this); + removeLights(this.thisLocation); + this.lightsOn = false; + Game1.playSound("coin"); + // this.flaggedForPickUp = true; + return true; + } + else + { + // return true; + // this.heldObject = new Light(parentSheetIndex, Vector2.Zero, this.lightColor, this.inventoryMaxSize); + Game1.player.addItemByMenuIfNecessary(this); + removeLights(this.thisLocation); + this.lightsOn = false; + Game1.playSound("coin"); + return true; + + } + } + if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) + { + // Game1.showRedMessage("Why3?"); + // if(this.heldObject!=null) Game1.player.addItemByMenuIfNecessary((Item)this.heldObject); + Util.addItemToInventoryElseDrop(this); + this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); + this.heldObject = null; + Game1.playSound("coin"); + removeLights(this.thisLocation); + this.lightsOn = false; + return true; + } + + */ + + return false; + } + + public override void DayUpdate(GameLocation location) + { + base.DayUpdate(location); + this.lightGlowAdded = false; + if (!Game1.isDarkOut() || (Game1.newDay && !Game1.isRaining)) + { + this.removeLights(location); + return; + } + this.addLights(location); + } + + public virtual void resetOnPlayerEntry(GameLocation environment) + { + this.removeLights(environment); + if (Game1.isDarkOut()) + { + this.addLights(environment); + } + } + + public override bool performObjectDropInAction(StardewValley.Object dropIn, bool probe, StardewValley.Farmer who) + { + // Log.AsyncG("HEY!"); + if ((this.Decoration_type == 11 || this.Decoration_type == 5) && this.heldObject == null && !dropIn.bigCraftable && (!(dropIn is CoreObject) || ((dropIn as CoreObject).getTilesWide() == 1 && (dropIn as CoreObject).getTilesHigh() == 1))) + { + this.heldObject = (StardewValley.Object)dropIn.getOne(); + this.heldObject.tileLocation = this.tileLocation; + this.heldObject.boundingBox.X = this.boundingBox.X; + this.heldObject.boundingBox.Y = this.boundingBox.Y; + // Log.AsyncO(getDefaultBoundingBoxForType((dropIn as CoreObject).Decoration_type)); + this.heldObject.performDropDownAction(who); + if (!probe) + { + Game1.playSound("woodyStep"); + // Log.AsyncC("HUH?"); + if (who != null) + { + who.reduceActiveItemByOne(); + } + } + return true; + } + return false; + } + + public virtual void addLights(GameLocation environment) + { + if (this.Decoration_type == 7) + { + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightSource == null) + { + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, lightColor, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + Game1.currentLightSources.Add(this.lightSource); + // Log.AsyncG("LIGHT SOURCE ADDED FFFFFFF"); + return; + } + } + else if (this.Decoration_type == 13) + { + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightGlowAdded) + { + environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); + this.lightGlowAdded = false; + } + } + else + { + + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightSource == null) + { + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, lightColor, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + Game1.currentLightSources.Add(this.lightSource); + return; + } + + } + } + + + public virtual void addLights(GameLocation environment, Color c) + { + if (this.Decoration_type == 7) + { + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightSource == null) + { + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, c, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + // this.lightSource.lightTexture = Game1.content.Load("LooseSprites\\Lighting\\BlueLight"); + Game1.currentLightSources.Add(this.lightSource); + // Log.AsyncG("LIGHT SOURCE ADDED FFFFFFF"); + return; + } + } + else if (this.Decoration_type == 13) + { + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightGlowAdded) + { + environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); + this.lightGlowAdded = false; + } + } + else + { + + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightSource == null) + { + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, c, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + Game1.currentLightSources.Add(this.lightSource); + return; + } + + } + } + + public void removeLights(GameLocation environment) + { + if (this.Decoration_type == 7) + { + if (this.sourceIndexOffset == 1) + { + this.sourceRect = this.defaultSourceRect; + } + this.sourceIndexOffset = 0; + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = null; + return; + } + if (this.Decoration_type == 13) + { + if (this.sourceIndexOffset == 1) + { + this.sourceRect = this.defaultSourceRect; + } + this.sourceIndexOffset = 0; + if (Game1.isRaining) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + this.sourceIndexOffset = 1; + return; + } + if (!this.lightGlowAdded && !environment.lightGlows.Contains(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize)))) + { + environment.lightGlows.Add(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); + } + this.lightGlowAdded = true; + } + + if (this.sourceIndexOffset == 1) + { + this.sourceRect = this.defaultSourceRect; + } + this.sourceIndexOffset = 0; + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = null; + return; + } + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + // Log.Info("minutes passed in"+minutes); + // Log.Info("minues remaining" + this.minutesUntilReady); + this.minutesUntilReady = (this.minutesUntilReady - minutes); + if (Game1.isDarkOut()) + { + // this.addLights(environment,this.lightColor); + this.addLights(environment); + } + else + { + this.removeLights(environment); + } + + if (minutesUntilReady == 0) + { + // Log.AsyncC(this.name + "Is ready!"); + // Log.AsyncC(Game1.player.getStandingPosition()); + // Vector2 v2 = new Vector2(this.tileLocation.X * Game1.tileSize, this.tileLocation.Y * Game1.tileSize); + //Game1.createItemDebris((Item)this.heldObject, v2, Game1.player.getDirection()); + // minutesUntilReady = 30; + } + + return false; + } + + public override void performRemoveAction(Vector2 tileLocation, GameLocation environment) + { + this.removeLights(environment); + if (this.Decoration_type == 13 && this.lightGlowAdded) + { + environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); + this.lightGlowAdded = false; + } + this.spillInventoryEverywhere(); + base.performRemoveAction(tileLocation, environment); + } + + public virtual void rotate() + { + if (this.rotations < 2) + { + return; + } + int num = (this.rotations == 4) ? 1 : 2; + this.currentRotation += num; + this.currentRotation %= 4; + this.flipped = false; + Point point = default(Point); + int num2 = this.Decoration_type; + switch (num2) + { + case 2: + point.Y = 1; + point.X = -1; + break; + case 3: + point.X = -1; + point.Y = 1; + break; + case 4: + break; + case 5: + point.Y = 0; + point.X = -1; + break; + default: + if (num2 == 12) + { + point.X = 0; + point.Y = 0; + } + break; + } + bool flag = this.Decoration_type == 5 || this.Decoration_type == 12 || this.parentSheetIndex == 724 || this.parentSheetIndex == 727; + bool flag2 = this.defaultBoundingBox.Width != this.defaultBoundingBox.Height; + if (flag && this.currentRotation == 2) + { + this.currentRotation = 1; + } + if (flag2) + { + int height = this.boundingBox.Height; + switch (this.currentRotation) + { + case 0: + case 2: + this.boundingBox.Height = this.defaultBoundingBox.Height; + this.boundingBox.Width = this.defaultBoundingBox.Width; + break; + case 1: + case 3: + this.boundingBox.Height = this.boundingBox.Width + point.X * Game1.tileSize; + this.boundingBox.Width = height + point.Y * Game1.tileSize; + break; + } + } + Point point2 = default(Point); + int num3 = this.Decoration_type; + if (num3 == 12) + { + point2.X = 1; + point2.Y = -1; + } + if (flag2) + { + switch (this.currentRotation) + { + case 0: + this.sourceRect = this.defaultSourceRect; + break; + case 1: + this.sourceRect = new Rectangle(this.defaultSourceRect.X + this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Height - 16 + point.Y * 16 + point2.X * 16, this.defaultSourceRect.Width + 16 + point.X * 16 + point2.Y * 16); + break; + case 2: + this.sourceRect = new Rectangle(this.defaultSourceRect.X + this.defaultSourceRect.Width + this.defaultSourceRect.Height - 16 + point.Y * 16 + point2.X * 16, this.defaultSourceRect.Y, this.defaultSourceRect.Width, this.defaultSourceRect.Height); + break; + case 3: + this.sourceRect = new Rectangle(this.defaultSourceRect.X + this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Height - 16 + point.Y * 16 + point2.X * 16, this.defaultSourceRect.Width + 16 + point.X * 16 + point2.Y * 16); + this.flipped = true; + break; + } + } + else + { + this.flipped = (this.currentRotation == 3); + if (this.rotations == 2) + { + this.sourceRect = new Rectangle(this.defaultSourceRect.X + ((this.currentRotation == 2) ? 1 : 0) * this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Width, this.defaultSourceRect.Height); + } + else + { + this.sourceRect = new Rectangle(this.defaultSourceRect.X + ((this.currentRotation == 3) ? 1 : this.currentRotation) * this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Width, this.defaultSourceRect.Height); + } + } + if (flag && this.currentRotation == 1) + { + this.currentRotation = 2; + } + this.updateDrawPosition(); + } + + public virtual bool isGroundFurniture() + { + return this.Decoration_type != 13 && this.Decoration_type != 6 && this.Decoration_type != 13; + } + + public override bool canBeGivenAsGift() + { + return false; + } + /* + public override bool canBePlacedHere(GameLocation l, Vector2 tile) + { + if ((l is FarmHouse)) + { + for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++) + { + for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++) + { + Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize; + vector.X += (float)(Game1.tileSize / 2); + vector.Y += (float)(Game1.tileSize / 2); + foreach (KeyValuePair something in l.objects) + { + StardewValley.Object obj = something.Value; + if ((obj.GetType()).ToString().Contains("CoreObject")) + { + CoreObject current = (CoreObject)obj; + if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1) + { + bool result = true; + return result; + } + if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y)) + { + bool result = false; + return result; + } + } + } + } + } + return Util.canBePlacedHere(this, l, tile); + } + else + { + // Game1.showRedMessage("NOT FARMHOUSE"); + for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++) + { + for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++) + { + Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize; + vector.X += (float)(Game1.tileSize / 2); + vector.Y += (float)(Game1.tileSize / 2); + /* + foreach (CoreObject current in (l as FarmHouse).CoreObject) + { + if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1) + { + bool result = true; + return result; + } + if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y)) + { + bool result = false; + return result; + } + } + + } + } + return Util.canBePlacedHere(this, l, tile); + } + } + */ + public virtual void updateDrawPosition() + { + this.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height))); + } + + public virtual int getTilesWide() + { + return this.boundingBox.Width / Game1.tileSize; + } + + public virtual int getTilesHigh() + { + return this.boundingBox.Height / Game1.tileSize; + } + /* + public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null) + { + // Log.AsyncC(x); + // Log.AsyncM(y); + + if (location is FarmHouse) + { + Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); + List walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); + this.tileLocation = new Vector2((float)point.X, (float)point.Y); + bool flag = false; + if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293) + { + int num = (this.parentSheetIndex == 1293) ? 3 : 0; + bool flag2 = false; + foreach (Rectangle current in walls) + { + if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num)) + { + flag2 = true; + break; + } + } + if (!flag2) + { + Game1.showRedMessage("Must be placed on wall"); + return false; + } + flag = true; + } + for (int i = point.X; i < point.X + this.getTilesWide(); i++) + { + for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++) + { + if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null) + { + Game1.showRedMessage("Furniture can't be placed here"); + return false; + } + if (!flag && Utility.pointInRectangles(walls, i, j)) + { + Game1.showRedMessage("Can't place on wall"); + return false; + } + if (location.getTileIndexAt(i, j, "Buildings") != -1) + { + return false; + } + } + } + this.boundingBox = new Rectangle(x, y, this.boundingBox.Width, this.boundingBox.Height); + foreach (KeyValuePair c in location.objects) + { + StardewValley.Object ehh = c.Value; + if (((ehh.GetType()).ToString()).Contains("CoreObject")) + { + CoreObject current2 = (CoreObject)ehh; + if (current2.Decoration_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox)) + { + current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); + bool result = true; + return result; + } + } + } + foreach (StardewValley.Farmer current3 in location.getStardewValley.Farmers()) + { + if (current3.GetBoundingBox().Intersects(this.boundingBox)) + { + Game1.showRedMessage("Can't place on top of a person."); + bool result = false; + return result; + } + } + this.updateDrawPosition(); + // Log.AsyncO(this.boundingBox); + // Log.AsyncO(x); + // Log.AsyncY(y); + for (int i = 0; i <= this.boundingBox.X / Game1.tileSize; i++) + { + base.placementAction(location, x + 1, y, who); + } + for (int i = 0; i <= this.boundingBox.Y / Game1.tileSize; i++) + { + base.placementAction(location, x, y + 1, who); + } + return true; + } + else + { + Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); + // List walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); + this.tileLocation = new Vector2((float)point.X, (float)point.Y); + bool flag = false; + if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293) + { + int num = (this.parentSheetIndex == 1293) ? 3 : 0; + bool flag2 = false; + /* + foreach (Rectangle current in walls) + { + if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num)) + { + flag2 = true; + break; + } + } + + if (!flag2) + { + Game1.showRedMessage("Must be placed on wall"); + return false; + } + flag = true; + } + for (int i = point.X; i < point.X + this.getTilesWide(); i++) + { + for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++) + { + if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null) + { + Game1.showRedMessage("Furniture can't be placed here"); + return false; + } + /* + if (!flag && Utility.pointInRectangles(walls, i, j)) + { + Game1.showRedMessage("Can't place on wall"); + return false; + } + + if (location.getTileIndexAt(i, j, "Buildings") != -1) + { + return false; + } + } + } + this.boundingBox = new Rectangle(x, y, this.boundingBox.Width, this.boundingBox.Height); + /* + foreach (Furniture current2 in (location as FarmHouse).furniture) + { + if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox)) + { + current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); + bool result = true; + return result; + } + } + + foreach (StardewValley.Farmer current3 in location.getStardewValley.Farmers()) + { + if (current3.GetBoundingBox().Intersects(this.boundingBox)) + { + Game1.showRedMessage("Can't place on top of a person."); + bool result = false; + return result; + } + } + this.updateDrawPosition(); + thisLocation = Game1.player.currentLocation; + return base.placementAction(location, x, y, who); + } + + } + */ + public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null) + { + + + if (location is FarmHouse) + { + Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); + List walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); + this.tileLocation = new Vector2((float)point.X, (float)point.Y); + bool flag = false; + if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293) + { + int num = (this.parentSheetIndex == 1293) ? 3 : 0; + bool flag2 = false; + foreach (Rectangle current in walls) + { + if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num)) + { + flag2 = true; + break; + } + } + if (!flag2) + { + Game1.showRedMessage("Must be placed on wall"); + return false; + } + flag = true; + } + for (int i = point.X; i < point.X + this.getTilesWide(); i++) + { + for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++) + { + if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null) + { + Game1.showRedMessage("Furniture can't be placed here"); + return false; + } + if (!flag && Utility.pointInRectangles(walls, i, j)) + { + Game1.showRedMessage("Can't place on wall"); + return false; + } + if (location.getTileIndexAt(i, j, "Buildings") != -1) + { + return false; + } + } + } + this.boundingBox = new Rectangle(x / Game1.tileSize, y / Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); + foreach (KeyValuePair c in location.objects) + { + StardewValley.Object ehh = c.Value; + if (((ehh.GetType()).ToString()).Contains("Spawner")) + { + CoreObject current2 = (CoreObject)ehh; + if (current2.Decoration_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox)) + { + current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); + bool result = true; + return result; + } + } + } + foreach (StardewValley.Farmer current3 in location.getFarmers()) + { + if (current3.GetBoundingBox().Intersects(this.boundingBox)) + { + Game1.showRedMessage("Can't place on top of a person."); + bool result = false; + return result; + } + } + this.updateDrawPosition(); + // Log.AsyncO(this.boundingBox); + // Log.AsyncO(x); + // Log.AsyncY(y); + for (int i = 0; i <= this.boundingBox.X / Game1.tileSize; i++) + { + base.placementAction(location, x + 1, y, who); + } + for (int i = 0; i <= this.boundingBox.Y / Game1.tileSize; i++) + { + base.placementAction(location, x, y + 1, who); + } + return true; + } + else + { + Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); + // List walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); + this.tileLocation = new Vector2((float)point.X, (float)point.Y); + bool flag = false; + if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293) + { + int num = (this.parentSheetIndex == 1293) ? 3 : 0; + bool flag2 = false; + /* + foreach (Rectangle current in walls) + { + if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num)) + { + flag2 = true; + break; + } + } + */ + if (!flag2) + { + Game1.showRedMessage("Must be placed on wall"); + return false; + } + flag = true; + } + for (int i = point.X; i < point.X + this.getTilesWide(); i++) + { + for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++) + { + if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null) + { + Game1.showRedMessage("Furniture can't be placed here"); + return false; + } + /* + if (!flag && Utility.pointInRectangles(walls, i, j)) + { + Game1.showRedMessage("Can't place on wall"); + return false; + } + */ + if (location.getTileIndexAt(i, j, "Buildings") != -1) + { + return false; + } + } + } + this.boundingBox = new Rectangle(x / Game1.tileSize, y / Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); + /* + foreach (Furniture current2 in (location as FarmHouse).furniture) + { + if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox)) + { + current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); + bool result = true; + return result; + } + } + */ + foreach (StardewValley.Farmer current3 in location.getFarmers()) + { + if (current3.GetBoundingBox().Intersects(this.boundingBox)) + { + Game1.showRedMessage("Can't place on top of a person."); + bool result = false; + return result; + } + } + this.updateDrawPosition(); + this.thisLocation = Game1.player.currentLocation; + return base.placementAction(location, x * Game1.tileSize, y * Game1.tileSize, who); + } + } + + public override bool isPlaceable() + { + return true; + } + + public override Rectangle getBoundingBox(Vector2 tileLocation) + { + return this.boundingBox; + } + + private Rectangle getDefaultSourceRectForType(int tileIndex, int type) + { + int num; + int num2; + switch (type) + { + case 0: + num = 1; + num2 = 2; + goto IL_94; + case 1: + num = 2; + num2 = 2; + goto IL_94; + case 2: + num = 3; + num2 = 2; + goto IL_94; + case 3: + num = 2; + num2 = 2; + goto IL_94; + case 4: + num = 2; + num2 = 2; + goto IL_94; + case 5: + num = 5; + num2 = 3; + goto IL_94; + case 6: + num = 2; + num2 = 2; + goto IL_94; + case 7: + num = 1; + num2 = 3; + goto IL_94; + case 8: + num = 1; + num2 = 2; + goto IL_94; + case 10: + num = 2; + num2 = 3; + goto IL_94; + case 11: + num = 2; + num2 = 3; + goto IL_94; + case 12: + num = 3; + num2 = 2; + goto IL_94; + case 13: + num = 1; + num2 = 2; + goto IL_94; + } + num = 1; + num2 = 2; + IL_94: + return new Rectangle(tileIndex * 16 % TextureSheet.Width, tileIndex * 16 / TextureSheet.Width * 16, num * 16, num2 * 16); + } + + private Rectangle getDefaultBoundingBoxForType(int type) + { + int num; + int num2; + switch (type) + { + case 0: + num = 1; + num2 = 1; + goto IL_94; + case 1: + num = 2; + num2 = 1; + goto IL_94; + case 2: + num = 3; + num2 = 1; + goto IL_94; + case 3: + num = 2; + num2 = 1; + goto IL_94; + case 4: + num = 2; + num2 = 1; + goto IL_94; + case 5: + num = 5; + num2 = 2; + goto IL_94; + case 6: + num = 2; + num2 = 2; + goto IL_94; + case 7: + num = 1; + num2 = 1; + goto IL_94; + case 8: + num = 1; + num2 = 1; + goto IL_94; + case 10: + num = 2; + num2 = 1; + goto IL_94; + case 11: + num = 2; + num2 = 2; + goto IL_94; + case 12: + num = 3; + num2 = 2; + goto IL_94; + case 13: + num = 1; + num2 = 2; + goto IL_94; + } + num = 1; + num2 = 1; + IL_94: + return new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, num * Game1.tileSize, num2 * Game1.tileSize); + } + + private int getTypeNumberFromName(string typeName) + { + string key; + switch (key = typeName.ToLower()) + { + case "chair": + return 0; + case "bench": + return 1; + case "couch": + return 2; + case "armchair": + return 3; + case "dresser": + return 4; + case "long table": + return 5; + case "painting": + return 6; + case "lamp": + return 7; + case "decor": + return 8; + case "bookcase": + return 10; + case "table": + return 11; + case "rug": + return 12; + case "window": + return 13; + } + return 9; + } + + public override int salePrice() + { + return this.price; + } + + public override int maximumStackSize() + { + return 1; + } + + public override int getStack() + { + return this.stack; + } + + public override int addToStack(int amount) + { + return 1; + } + + private float getScaleSize() + { + int num = this.sourceRect.Width / 16; + int num2 = this.sourceRect.Height / 16; + if (num >= 5) + { + return 0.75f; + } + if (num2 >= 3) + { + return 1f; + } + if (num <= 2) + { + return 2f; + } + if (num <= 4) + { + return 1f; + } + return 0.1f; + } + + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f) + { + if (f.ActiveObject.bigCraftable) + { + spriteBatch.Draw(Game1.bigCraftableSpriteSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(StardewValley.Object.getSourceRectForBigCraftable(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + return; + } + spriteBatch.Draw(Game1.objectSpriteSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + if (f.ActiveObject != null && f.ActiveObject.Name.Contains("=")) + { + spriteBatch.Draw(Game1.objectSpriteSheet, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + if (Math.Abs(Game1.starCropShimmerPause) <= 0.05f && Game1.random.NextDouble() < 0.97) + { + return; + } + Game1.starCropShimmerPause += 0.04f; + if (Game1.starCropShimmerPause >= 0.8f) + { + Game1.starCropShimmerPause = -0.8f; + } + } + //base.drawWhenHeld(spriteBatch, objectPosition, f); + } + + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber) + { + spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize), (float)(Game1.tileSize)), new Rectangle?(this.defaultSourceRect), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height)), 1f * this.getScaleSize() * scaleSize * .5f, SpriteEffects.None, layerDepth); + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + if (x == -1) + { + spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f)); + } + else + { + spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), (float)(y * Game1.tileSize - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height)))), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f)); + } + if (this.heldObject != null) + { + if (this.heldObject is CoreObject) + { + (this.heldObject as CoreObject).drawAtNonTileSpot(spriteBatch, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - (this.heldObject as CoreObject).sourceRect.Height * Game1.pixelZoom - Game1.tileSize / 4))), (float)(this.boundingBox.Bottom - 7) / 10000f, alpha); + return; + } + spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))) + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * 5 / 6)), new Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, (float)this.boundingBox.Bottom / 10000f); + spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))), new Rectangle?(Game1.currentLocation.getSourceRectForObject(this.heldObject.ParentSheetIndex)), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f); + } + } + + public virtual void drawAtNonTileSpot(SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1f) + { + spriteBatch.Draw(TextureSheet, location, new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth); + } + + public override Item getOne() + { + CoreObject CoreObject = new CoreObject(this.parentSheetIndex, this.tileLocation, this.inventoryMaxSize); + + CoreObject.drawPosition = this.drawPosition; + CoreObject.defaultBoundingBox = this.defaultBoundingBox; + CoreObject.boundingBox = this.boundingBox; + CoreObject.currentRotation = this.currentRotation - 1; + CoreObject.rotations = this.rotations; + //rotate(); + + return CoreObject; + } + + public virtual bool isInventoryFull() + { + // Log.AsyncC("Count" + inventory.Count); + // Log.AsyncC("size" + inventoryMaxSize); + if (inventory.Count >= inventoryMaxSize) + { + + return true; + } + else + { + return false; + } + + } + + public virtual bool addItemToInventory(Item I) + { + if (isInventoryFull() == false) + { + inventory.Add(I.getOne()); + return true; + } + else return false; + } + + public virtual void spillInventoryEverywhere() + { + Game1.activeClickableMenu = new StorageContainer(this.inventory, 3, 3); + this.itemReadyForHarvest = false; + /* + Log.AsyncC("DROPPING INVENTORY!"); + + Random random = new Random(inventory.Count); + int i = random.Next(); + i = i % 4; + Vector2 v2 = new Vector2(this.tileLocation.X * Game1.tileSize, this.tileLocation.Y * Game1.tileSize); + foreach (var I in inventory) + { + Log.AsyncY(I.Name); + Log.AsyncO(I.getStack()); + Log.AsyncM(I.Stack); + Log.AsyncC("Dropping an item!"); + Game1.createItemDebris(I, v2, i); + } + inventory.Clear(); + */ + } + + public virtual bool addItemToInventoryElseDrop(Item I) + { + + if (isInventoryFull() == false) + { + foreach (Item C in inventory) + { + if (C == null) continue; + if (I.canStackWith(C) == true) + { + C.addToStack(I.Stack); + return true; + } + else + { + inventory.Add(I.getOne()); + return true; + } + } + inventory.Add(I.getOne()); + return true; + } + else + { + Random random = new Random(inventory.Count); + int i = random.Next(); + i = i % 4; + Vector2 v2 = new Vector2(this.tileLocation.X * Game1.tileSize, this.tileLocation.Y * Game1.tileSize); + Game1.createItemDebris(I.getOne(), v2, i); + return false; + } + } + + public virtual void toggleLights() + { + + if (lightsOn == false) + { + + // Log.AsyncG("ADD LIGHTS"); + this.Decoration_type = 7; + this.type = "Lamp"; + + // this.lightSource.lightTexture = Game1.content.Load("LooseSprites\\Lighting\\Lantern"); + // this.lightSource.position = tileLocation; + + // this.addLights(thisLocation, lightColor); + this.addLights(thisLocation, lightColor); + lightsOn = true; + } + if (lightsOn == true) + { + this.removeLights(Game1.player.currentLocation); + lightsOn = false; + } + + } + + public virtual void resetTexture() + { + TextureSheet = Game1.content.Load(this.texturePath); + } + + public override string getCategoryName() + { + return "Core Mod Object"; + // return base.getCategoryName(); + } + + public override Color getCategoryColor() + { + return Color.Black; + } + + + } +} diff --git a/GeneralMods/AdditionalCropsFramework/Framework/TerrainDataNode.cs b/GeneralMods/AdditionalCropsFramework/Framework/TerrainDataNode.cs new file mode 100644 index 00000000..e12eb7da --- /dev/null +++ b/GeneralMods/AdditionalCropsFramework/Framework/TerrainDataNode.cs @@ -0,0 +1,27 @@ +using StardewValley; +using StardewValley.TerrainFeatures; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdditionalCropsFramework.Framework +{ + public class TerrainDataNode + { + public GameLocation location; + public int tileX; + public int tileY; + public HoeDirt terrainFeature; + + public TerrainDataNode(GameLocation loc, int Xtile, int Ytile, HoeDirt TerrainFeature) + { + location = loc; + tileX = Xtile; + tileY = Ytile; + terrainFeature = TerrainFeature; + } + + } +} diff --git a/GeneralMods/AdditionalCropsFramework/Framework/Utilities.cs b/GeneralMods/AdditionalCropsFramework/Framework/Utilities.cs new file mode 100644 index 00000000..4dd5e1d0 --- /dev/null +++ b/GeneralMods/AdditionalCropsFramework/Framework/Utilities.cs @@ -0,0 +1,716 @@ +using Microsoft.Xna.Framework; +using StardewModdingAPI; +using StardewValley; +using StardewValley.Locations; +using StardewValley.Objects; +using StardewValley.TerrainFeatures; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using xTile.Dimensions; + +namespace AdditionalCropsFramework.Framework +{ + class Utilities + { + public static List trackedTerrainFeatures= new List(); + public static List trackedObjectList = new List(); + public static List NonSolidThingsToDraw = new List(); + + + public static void createObjectDebris(Item I, int xTileOrigin, int yTileOrigin, int xTileTarget, int yTileTarget, int groundLevel = -1, int itemQuality = 0, float velocityMultiplyer = 1f, GameLocation location = null) + { + Debris debris = new Debris(I, new Vector2(xTileOrigin, yTileOrigin), new Vector2(xTileTarget, yTileTarget)) + { + itemQuality = itemQuality, + }; + + /* + Debris debris = new Debris(objectIndex, new Vector2((float)(xTile * Game1.tileSize + Game1.tileSize / 2), (float)(yTile * Game1.tileSize + Game1.tileSize / 2)), new Vector2((float)Game1.player.getStandingX(), (float)Game1.player.getStandingY())) + { + itemQuality = itemQuality + }; + */ + foreach (Chunk chunk in debris.Chunks) + { + double num1 = (double)chunk.xVelocity * (double)velocityMultiplyer; + chunk.xVelocity = (float)num1; + double num2 = (double)chunk.yVelocity * (double)velocityMultiplyer; + chunk.yVelocity = (float)num2; + } + if (groundLevel != -1) + debris.chunkFinalYLevel = groundLevel; + (location == null ? Game1.currentLocation : location).debris.Add(debris); + } + + /* + public static void plantModdedCropHere(ModularSeeds seeds) + { + /* + if (Lists.saplingNames.Contains(Game1.player.ActiveObject.name)) + { + bool f = plantSappling(); + if (f == true) return; + } + + //Log.AsyncC("HELLO"); + try + { + HoeDirt t; + TerrainFeature r; + bool plant = Game1.player.currentLocation.terrainFeatures.TryGetValue(Game1.currentCursorTile, out r); + t = (r as HoeDirt); + if (t is HoeDirt) + { + if ((t as HoeDirt).crop == null) + { + // Log.AsyncG("BOOP"); + (t as HoeDirt).crop = new ModularCrop(seeds.parentSheetIndex, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y, seeds.cropDataFilePath, seeds.cropTextureFilePath, seeds.cropObjectTextureFilePath, seeds.cropObjectDataFilePath); + //Game1.player.reduceActiveItemByOne(); + Game1.playSound("dirtyHit"); + trackedTerrainFeatures.Add(new TerrainDataNode(Game1.player.currentLocation, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y, t)); + } + } + }catch(Exception err) + { + Log.AsyncG("BUBBLES"); + } + } + */ + public static void plantRegularCropHere() + { + /* + Log.AsyncY(Game1.player.ActiveObject.name); + if (Lists.saplingNames.Contains(Game1.player.ActiveObject.name)) + { + Log.AsyncY("PLANT THE SAPLING"); + bool f = plantSappling(); + + if (f == true) return; + } + */ + HoeDirt t; + TerrainFeature r; + bool plant = Game1.player.currentLocation.terrainFeatures.TryGetValue(Game1.currentCursorTile, out r); + t = (r as HoeDirt); + if (t is HoeDirt) + { + if ((t as HoeDirt).crop == null) + { + (t as HoeDirt).crop = new Crop(Game1.player.ActiveObject.parentSheetIndex, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y); + Game1.player.reduceActiveItemByOne(); + Game1.playSound("dirtyHit"); + trackedTerrainFeatures.Add(new TerrainDataNode(Game1.player.currentLocation, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y,t)); + } + } + } + + + + public static bool placementAction(CoreObject cObj, GameLocation location, int x, int y, StardewValley.Farmer who = null, bool playSound = true) + { + Vector2 vector = new Vector2((float)(x / Game1.tileSize), (float)(y / Game1.tileSize)); + // cObj.health = 10; + if (who != null) + { + cObj.owner = who.uniqueMultiplayerID; + } + else + { + cObj.owner = Game1.player.uniqueMultiplayerID; + } + + if (!cObj.bigCraftable && !(cObj is Furniture)) + { + int num = cObj.ParentSheetIndex; + if (num <= 298) + { + if (num > 94) + { + bool result; + switch (num) + { + case 286: + { + using (List.Enumerator enumerator = Game1.currentLocation.temporarySprites.GetEnumerator()) + { + while (enumerator.MoveNext()) + { + if (enumerator.Current.position.Equals(vector * (float)Game1.tileSize)) + { + result = false; + return result; + } + } + } + int num2 = Game1.random.Next(); + Game1.playSound("thudStep"); + Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(cObj.parentSheetIndex, 100f, 1, 24, vector * (float)Game1.tileSize, true, false, Game1.currentLocation, who) + { + shakeIntensity = 0.5f, + shakeIntensityChange = 0.002f, + extraInfoForEndBehavior = num2, + endFunction = new TemporaryAnimatedSprite.endBehavior(Game1.currentLocation.removeTemporarySpritesWithID) + }); + Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 3f) * (float)Game1.pixelZoom, true, false, (float)(y + 7) / 10000f, 0f, Color.Yellow, (float)Game1.pixelZoom, 0f, 0f, 0f, false) + { + id = (float)num2 + }); + Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 3f) * (float)Game1.pixelZoom, true, true, (float)(y + 7) / 10000f, 0f, Color.Orange, (float)Game1.pixelZoom, 0f, 0f, 0f, false) + { + delayBeforeAnimationStart = 100, + id = (float)num2 + }); + Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 3f) * (float)Game1.pixelZoom, true, false, (float)(y + 7) / 10000f, 0f, Color.White, (float)Game1.pixelZoom * 0.75f, 0f, 0f, 0f, false) + { + delayBeforeAnimationStart = 200, + id = (float)num2 + }); + if (Game1.fuseSound != null && !Game1.fuseSound.IsPlaying) + { + Game1.fuseSound = Game1.soundBank.GetCue("fuse"); + Game1.fuseSound.Play(); + } + return true; + } + case 287: + { + using (List.Enumerator enumerator = Game1.currentLocation.temporarySprites.GetEnumerator()) + { + while (enumerator.MoveNext()) + { + if (enumerator.Current.position.Equals(vector * (float)Game1.tileSize)) + { + result = false; + return result; + } + } + } + int num2 = Game1.random.Next(); + Game1.playSound("thudStep"); + Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(cObj.parentSheetIndex, 100f, 1, 24, vector * (float)Game1.tileSize, true, false, Game1.currentLocation, who) + { + shakeIntensity = 0.5f, + shakeIntensityChange = 0.002f, + extraInfoForEndBehavior = num2, + endFunction = new TemporaryAnimatedSprite.endBehavior(Game1.currentLocation.removeTemporarySpritesWithID) + }); + Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize, true, false, (float)(y + 7) / 10000f, 0f, Color.Yellow, (float)Game1.pixelZoom, 0f, 0f, 0f, false) + { + id = (float)num2 + }); + Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize, true, false, (float)(y + 7) / 10000f, 0f, Color.Orange, (float)Game1.pixelZoom, 0f, 0f, 0f, false) + { + delayBeforeAnimationStart = 100, + id = (float)num2 + }); + Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize, true, false, (float)(y + 7) / 10000f, 0f, Color.White, (float)Game1.pixelZoom * 0.75f, 0f, 0f, 0f, false) + { + delayBeforeAnimationStart = 200, + id = (float)num2 + }); + if (Game1.fuseSound != null && !Game1.fuseSound.IsPlaying) + { + Game1.fuseSound = Game1.soundBank.GetCue("fuse"); + Game1.fuseSound.Play(); + } + return true; + } + case 288: + { + using (List.Enumerator enumerator = Game1.currentLocation.temporarySprites.GetEnumerator()) + { + while (enumerator.MoveNext()) + { + if (enumerator.Current.position.Equals(vector * (float)Game1.tileSize)) + { + result = false; + return result; + } + } + } + int num2 = Game1.random.Next(); + Game1.playSound("thudStep"); + Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(cObj.parentSheetIndex, 100f, 1, 24, vector * (float)Game1.tileSize, true, false, Game1.currentLocation, who) + { + shakeIntensity = 0.5f, + shakeIntensityChange = 0.002f, + extraInfoForEndBehavior = num2, + endFunction = new TemporaryAnimatedSprite.endBehavior(Game1.currentLocation.removeTemporarySpritesWithID) + }); + Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 0f) * (float)Game1.pixelZoom, true, false, (float)(y + 7) / 10000f, 0f, Color.Yellow, (float)Game1.pixelZoom, 0f, 0f, 0f, false) + { + id = (float)num2 + }); + Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 0f) * (float)Game1.pixelZoom, true, true, (float)(y + 7) / 10000f, 0f, Color.Orange, (float)Game1.pixelZoom, 0f, 0f, 0f, false) + { + delayBeforeAnimationStart = 100, + id = (float)num2 + }); + Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 0f) * (float)Game1.pixelZoom, true, false, (float)(y + 7) / 10000f, 0f, Color.White, (float)Game1.pixelZoom * 0.75f, 0f, 0f, 0f, false) + { + delayBeforeAnimationStart = 200, + id = (float)num2 + }); + if (Game1.fuseSound != null && !Game1.fuseSound.IsPlaying) + { + Game1.fuseSound = Game1.soundBank.GetCue("fuse"); + Game1.fuseSound.Play(); + } + return true; + } + default: + if (num != 297) + { + if (num != 298) + { + goto IL_FD7; + } + if (location.objects.ContainsKey(vector)) + { + return false; + } + location.objects.Add(vector, new Fence(vector, 5, false)); + Game1.playSound("axe"); + return true; + } + else + { + if (location.objects.ContainsKey(vector) || location.terrainFeatures.ContainsKey(vector)) + { + return false; + } + location.terrainFeatures.Add(vector, new Grass(1, 4)); + Game1.playSound("dirtyHit"); + return true; + } + break; + } + return result; + } + if (num != 93) + { + if (num == 94) + { + if (location.objects.ContainsKey(vector)) + { + return false; + } + new Torch(vector, 1, 94).placementAction(location, x, y, who); + return true; + } + } + else + { + if (location.objects.ContainsKey(vector)) + { + return false; + } + Utility.removeLightSource((int)(cObj.tileLocation.X * 2000f + cObj.tileLocation.Y)); + Utility.removeLightSource((int)Game1.player.uniqueMultiplayerID); + new Torch(vector, 1).placementAction(location, x, y, (who == null) ? Game1.player : who); + return true; + } + } + else if (num <= 401) + { + switch (num) + { + case 309: + case 310: + case 311: + { + bool flag = location.terrainFeatures.ContainsKey(vector) && location.terrainFeatures[vector] is HoeDirt && (location.terrainFeatures[vector] as HoeDirt).crop == null; + if (!flag && (location.objects.ContainsKey(vector) || location.terrainFeatures.ContainsKey(vector) || (!(location is Farm) && !location.name.Contains("Greenhouse")))) + { + Game1.showRedMessage("Invalid Position"); + return false; + } + string text = location.doesTileHaveProperty(x, y, "NoSpawn", "Back"); + if ((text == null || (!text.Equals("Tree") && !text.Equals("All"))) && (flag || (location.isTileLocationOpen(new Location(x * Game1.tileSize, y * Game1.tileSize)) && !location.isTileOccupied(new Vector2((float)x, (float)y), "") && location.doesTileHaveProperty(x, y, "Water", "Back") == null))) + { + int which = 1; + num = cObj.parentSheetIndex; + if (num != 310) + { + if (num == 311) + { + which = 3; + } + } + else + { + which = 2; + } + location.terrainFeatures.Remove(vector); + location.terrainFeatures.Add(vector, new Tree(which, 0)); + Game1.playSound("dirtyHit"); + return true; + } + break; + } + default: + switch (num) + { + case 322: + if (location.objects.ContainsKey(vector)) + { + return false; + } + location.objects.Add(vector, new Fence(vector, 1, false)); + Game1.playSound("axe"); + return true; + case 323: + if (location.objects.ContainsKey(vector)) + { + return false; + } + location.objects.Add(vector, new Fence(vector, 2, false)); + Game1.playSound("stoneStep"); + return true; + case 324: + if (location.objects.ContainsKey(vector)) + { + return false; + } + location.objects.Add(vector, new Fence(vector, 3, false)); + Game1.playSound("hammer"); + return true; + case 325: + if (location.objects.ContainsKey(vector)) + { + return false; + } + location.objects.Add(vector, new Fence(vector, 4, true)); + Game1.playSound("axe"); + return true; + case 326: + case 327: + case 330: + case 332: + break; + case 328: + if (location.terrainFeatures.ContainsKey(vector)) + { + return false; + } + location.terrainFeatures.Add(vector, new Flooring(0)); + Game1.playSound("axchop"); + return true; + case 329: + if (location.terrainFeatures.ContainsKey(vector)) + { + return false; + } + location.terrainFeatures.Add(vector, new Flooring(1)); + Game1.playSound("thudStep"); + return true; + case 331: + if (location.terrainFeatures.ContainsKey(vector)) + { + return false; + } + location.terrainFeatures.Add(vector, new Flooring(2)); + Game1.playSound("axchop"); + return true; + case 333: + if (location.terrainFeatures.ContainsKey(vector)) + { + return false; + } + location.terrainFeatures.Add(vector, new Flooring(3)); + Game1.playSound("thudStep"); + return true; + default: + if (num == 401) + { + if (location.terrainFeatures.ContainsKey(vector)) + { + return false; + } + location.terrainFeatures.Add(vector, new Flooring(4)); + Game1.playSound("thudStep"); + return true; + } + break; + } + break; + } + } + else + { + switch (num) + { + case 405: + if (location.terrainFeatures.ContainsKey(vector)) + { + return false; + } + location.terrainFeatures.Add(vector, new Flooring(6)); + Game1.playSound("woodyStep"); + return true; + case 406: + case 408: + case 410: + break; + case 407: + if (location.terrainFeatures.ContainsKey(vector)) + { + return false; + } + location.terrainFeatures.Add(vector, new Flooring(5)); + Game1.playSound("dirtyHit"); + return true; + case 409: + if (location.terrainFeatures.ContainsKey(vector)) + { + return false; + } + location.terrainFeatures.Add(vector, new Flooring(7)); + Game1.playSound("stoneStep"); + return true; + case 411: + if (location.terrainFeatures.ContainsKey(vector)) + { + return false; + } + location.terrainFeatures.Add(vector, new Flooring(8)); + Game1.playSound("stoneStep"); + return true; + default: + if (num != 415) + { + if (num == 710) + { + if (location.objects.ContainsKey(vector) || location.doesTileHaveProperty((int)vector.X, (int)vector.Y, "Water", "Back") == null) + { + return false; + } + new CrabPot(vector, 1).placementAction(location, x, y, who); + return true; + } + } + else + { + if (location.terrainFeatures.ContainsKey(vector)) + { + return false; + } + location.terrainFeatures.Add(vector, new Flooring(9)); + Game1.playSound("stoneStep"); + return true; + } + break; + } + } + } + else + { + int num = cObj.ParentSheetIndex; + if (num <= 130) + { + if (num == 71) + { + if (location is MineShaft) + { + if ((location as MineShaft).mineLevel != 120 && (location as MineShaft).recursiveTryToCreateLadderDown(vector, "hoeHit", 16)) + { + return true; + } + Game1.showRedMessage("Unsuitable Location"); + } + return false; + } + if (num == 130) + { + if (location.objects.ContainsKey(vector) || Game1.currentLocation is MineShaft) + { + Game1.showRedMessage("Unsuitable Location"); + return false; + } + location.objects.Add(vector, new Chest(true) + { + shakeTimer = 50 + }); + Game1.playSound("axe"); + return true; + } + } + else + { + switch (num) + { + case 143: + case 144: + case 145: + case 146: + case 147: + case 148: + case 149: + case 150: + case 151: + if (location.objects.ContainsKey(vector)) + { + return false; + } + new Torch(vector, cObj.parentSheetIndex, true) + { + shakeTimer = 25 + }.placementAction(location, x, y, who); + return true; + default: + if (num == 163) + { + location.objects.Add(vector, new Cask(vector)); + Game1.playSound("hammer"); + } + break; + } + } + } + IL_FD7: + if (cObj.name.Equals("Tapper")) + { + if (location.terrainFeatures.ContainsKey(vector) && location.terrainFeatures[vector] is Tree && (location.terrainFeatures[vector] as Tree).growthStage >= 5 && !(location.terrainFeatures[vector] as Tree).stump && !location.objects.ContainsKey(vector)) + { + cObj.tileLocation = vector; + location.objects.Add(vector, cObj); + int treeType = (location.terrainFeatures[vector] as Tree).treeType; + (location.terrainFeatures[vector] as Tree).tapped = true; + switch (treeType) + { + case 1: + cObj.heldObject = new StardewValley.Object(725, 1, false, -1, 0); + cObj.minutesUntilReady = 13000 - Game1.timeOfDay; + break; + case 2: + cObj.heldObject = new StardewValley.Object(724, 1, false, -1, 0); + cObj.minutesUntilReady = 16000 - Game1.timeOfDay; + break; + case 3: + cObj.heldObject = new StardewValley.Object(726, 1, false, -1, 0); + cObj.minutesUntilReady = 10000 - Game1.timeOfDay; + break; + case 7: + cObj.heldObject = new StardewValley.Object(420, 1, false, -1, 0); + cObj.minutesUntilReady = 3000 - Game1.timeOfDay; + if (!Game1.currentSeason.Equals("fall")) + { + cObj.heldObject = new StardewValley.Object(404, 1, false, -1, 0); + cObj.minutesUntilReady = 6000 - Game1.timeOfDay; + } + break; + } + Game1.playSound("axe"); + return true; + } + return false; + } + else if (cObj.name.Contains("Sapling")) + { + Vector2 key = default(Vector2); + for (int i = x / Game1.tileSize - 2; i <= x / Game1.tileSize + 2; i++) + { + for (int j = y / Game1.tileSize - 2; j <= y / Game1.tileSize + 2; j++) + { + key.X = (float)i; + key.Y = (float)j; + if (location.terrainFeatures.ContainsKey(key) && (location.terrainFeatures[key] is Tree || location.terrainFeatures[key] is FruitTree)) + { + Game1.showRedMessage("Too close to another tree"); + return false; + } + } + } + if (location.terrainFeatures.ContainsKey(vector)) + { + if (!(location.terrainFeatures[vector] is HoeDirt) || (location.terrainFeatures[vector] as HoeDirt).crop != null) + { + return false; + } + location.terrainFeatures.Remove(vector); + } + if (location is Farm && (location.doesTileHaveProperty((int)vector.X, (int)vector.Y, "Diggable", "Back") != null || location.doesTileHavePropertyNoNull((int)vector.X, (int)vector.Y, "Type", "Back").Equals("Grass"))) + { + Game1.playSound("dirtyHit"); + DelayedAction.playSoundAfterDelay("coin", 100); + location.terrainFeatures.Add(vector, new FruitTree(cObj.parentSheetIndex)); + return true; + } + Game1.showRedMessage("Can't be planted here."); + return false; + } + else + { + + //Game1.showRedMessage("STEP 1"); + + if (cObj.category == -74) + { + return true; + } + if (!cObj.performDropDownAction(who)) + { + CoreObject @object = (CoreObject)cObj.getOne(); + @object.shakeTimer = 50; + @object.tileLocation = vector; + @object.performDropDownAction(who); + if (location.objects.ContainsKey(vector)) + { + if (location.objects[vector].ParentSheetIndex != cObj.parentSheetIndex) + { + Game1.createItemDebris(location.objects[vector], vector * (float)Game1.tileSize, Game1.random.Next(4)); + location.objects[vector] = @object; + } + } + + else + { + // Game1.showRedMessage("STEP 2"); + Log.Info(vector); + + Vector2 newVec = new Vector2(vector.X, vector.Y); + // cObj.boundingBox.Inflate(32, 32); + location.objects.Add(newVec, cObj); + } + @object.initializeLightSource(vector); + } + if (playSound == true) Game1.playSound("woodyStep"); + else + { + Log.AsyncG("restoring item from file"); + } + //Log.AsyncM("Placed and object"); + cObj.locationsName = location.name; + trackedObjectList.Add(cObj); + return true; + + } + } + + + + public static bool addItemToInventoryAndCleanTrackedList(CoreObject I) + { + if (Game1.player.isInventoryFull() == false) + { + Game1.player.addItemToInventoryBool(I, false); + trackedObjectList.Remove(I); + return true; + } + else + { + Random random = new Random(129); + int i = random.Next(); + i = i % 4; + Vector2 v2 = new Vector2(Game1.player.getTileX() * Game1.tileSize, Game1.player.getTileY() * Game1.tileSize); + Game1.createItemDebris(I, v2, i); + return false; + } + } + + + } +} diff --git a/GeneralMods/AdditionalCropsFramework/ModCore.cs b/GeneralMods/AdditionalCropsFramework/ModCore.cs new file mode 100644 index 00000000..9ef5bc08 --- /dev/null +++ b/GeneralMods/AdditionalCropsFramework/ModCore.cs @@ -0,0 +1,59 @@ +using AdditionalCropsFramework.Framework; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Input; +using StardewModdingAPI; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdditionalCropsFramework +{ + + /* + Todo: + Reuse Seedbag code from revitalize in this mod. (Done!) + + Make a way to interact with the modded seedbags (look at revitalize's code again) (Done! Fixed with planter boxes) + ! Serialize and deserialize the modded crop objects and planter boxes and seed bags that exist in the game. Maybe have a list to keep track of all of them or just iterate through everything in the world? + + Make it so I can plant the modded crops. (DONE! Fixed in planterboxes) + ! Make sure crops grow overnight. + ! Add way for crops to be watered and to ensure that there is a graphical update when the crop is being watered. + ! Add way to harvest crop from planterbox without removing planterbox. + ! Fix invisible planterbox so that it does get removed when planting seeds on tillable soil and keep that soil as HoeDirt instead of reverting to normal. This can also be used to just make the dirt look wet. + * * */ + public class ModCore : Mod + { + public static IModHelper ModHelper; + + public static readonly List SpringWildCrops = new List(); + public static readonly List SummerWildCrops = new List(); + public static readonly List FallWildCrops = new List(); + public static readonly List WinterWildCrops = new List(); + + + public override void Entry(IModHelper helper) + { + ModHelper = helper; + + StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed; + + } + + + + + private void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e) + { + if (e.KeyPressed == Keys.U) + { + List shopInventory = new List(); + shopInventory.Add((Item)new ModularSeeds(1, "SeedsGraphics", "SeedsData", "CropsGraphics", "CropsData","CropsObjectTexture","CropsObjectData")); + shopInventory.Add((Item)new PlanterBox(0, Vector2.Zero)); + shopInventory.Add((Item)new PlanterBox(1, Vector2.Zero, "PlanterBox.png", "PlanterBox")); + Game1.activeClickableMenu = new StardewValley.Menus.ShopMenu(shopInventory); + } + } + + } + } diff --git a/GeneralMods/AdditionalCropsFramework/ModularCrop.cs b/GeneralMods/AdditionalCropsFramework/ModularCrop.cs new file mode 100644 index 00000000..6caf62f5 --- /dev/null +++ b/GeneralMods/AdditionalCropsFramework/ModularCrop.cs @@ -0,0 +1,489 @@ +using AdditionalCropsFramework; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI; +using StardewValley.Characters; +using StardewValley.Objects; +using StardewValley.TerrainFeatures; +using System; +using System.Collections.Generic; + +namespace StardewValley +{ + public class ModularCrop : StardewValley.Crop + { + public List phaseDays = new List(); + public int phaseToShow = -1; + public List seasonsToGrowIn = new List(); + public const int mixedSeedIndex = 770; + public const int seedPhase = 0; + public const int grabHarvest = 0; + public const int sickleHarvest = 1; + public const int rowOfWildSeeds = 23; + public const int finalPhaseLength = 99999; + public const int forageCrop_springOnion = 1; + public int rowInSpriteSheet; + public int currentPhase; + public int harvestMethod; + public int indexOfHarvest; + public int regrowAfterHarvest; + public int dayOfCurrentPhase; + public int minHarvest; + public int maxHarvest; + public int maxHarvestIncreasePerFarmingLevel; + public int daysOfUnclutteredGrowth; + public int whichForageCrop; + public Color tintColor; + public bool flip; + public bool fullyGrown; + public bool raisedSeeds; + public bool programColored; + public bool dead; + public bool forageCrop; + public double chanceForExtraCrops; + + + public int experienceGainWhenHarvesting; + + public Texture2D spriteSheet; + public string spriteSheetName; + public string dataFileName; + + public string cropObjectTexture; + public string cropObjectData; + + public ModularCrop() + { + } + + public ModularCrop(bool forageCrop, int which, int tileX, int tileY) + { + this.forageCrop = forageCrop; + this.whichForageCrop = which; + this.fullyGrown = true; + this.currentPhase = 5; + } + + public ModularCrop(int seedIndex, int tileX, int tileY, string DataFileName, string cropTextureSheet,string AssociatedObjectTextureSheet,string AssociatedObjectDataFile) + { + this.forageCrop = false; + this.dataFileName = DataFileName; + this.spriteSheet = ModCore.ModHelper.Content.Load(cropTextureSheet); + this.spriteSheetName = cropTextureSheet; + this.experienceGainWhenHarvesting = 0; + this.fullyGrown = false; + cropObjectTexture = AssociatedObjectTextureSheet; + cropObjectData = AssociatedObjectDataFile; + + Dictionary dictionary = ModCore.ModHelper.Content.Load>(dataFileName); //Game1.content.Load>("Data\\Crops"); + + if (seedIndex == 770) + { + seedIndex = ModularCrop.getRandomLowGradeCropForThisSeason(Game1.currentSeason); + if (seedIndex == 473) + --seedIndex; + } + if (dictionary.ContainsKey(seedIndex)) + { + string[] strArray1 = dictionary[seedIndex].Split('/'); + string str1 = strArray1[0]; + char[] chArray1 = new char[1] { ' ' }; + foreach (string str2 in str1.Split(chArray1)) + this.phaseDays.Add(Convert.ToInt32(str2)); + this.phaseDays.Add(99999); + string str3 = strArray1[1]; + char[] chArray2 = new char[1] { ' ' }; + foreach (string str2 in str3.Split(chArray2)) + this.seasonsToGrowIn.Add(str2); + this.rowInSpriteSheet = Convert.ToInt32(strArray1[2]); + this.indexOfHarvest = Convert.ToInt32(strArray1[3]); + this.regrowAfterHarvest = Convert.ToInt32(strArray1[4]); + this.harvestMethod = Convert.ToInt32(strArray1[5]); + string[] strArray2 = strArray1[6].Split(' '); + if (strArray2.Length != 0 && strArray2[0].Equals("true")) + { + this.minHarvest = Convert.ToInt32(strArray2[1]); + this.maxHarvest = Convert.ToInt32(strArray2[2]); + this.maxHarvestIncreasePerFarmingLevel = Convert.ToInt32(strArray2[3]); + this.chanceForExtraCrops = Convert.ToDouble(strArray2[4]); + } + this.raisedSeeds = Convert.ToBoolean(strArray1[7]); + string[] strArray3 = strArray1[8].Split(' '); + if (strArray3.Length != 0 && strArray3[0].Equals("true")) + { + List colorList = new List(); + int index = 1; + while (index < strArray3.Length) + { + colorList.Add(new Color((int)Convert.ToByte(strArray3[index]), (int)Convert.ToByte(strArray3[index + 1]), (int)Convert.ToByte(strArray3[index + 2]))); + index += 3; + } + Random random = new Random(tileX * 1000 + tileY + Game1.dayOfMonth); + this.tintColor = colorList[random.Next(colorList.Count)]; + this.programColored = true; + } + this.flip = Game1.random.NextDouble() < 0.5; + } + if (this.rowInSpriteSheet != 23) + return; + this.whichForageCrop = seedIndex; + } + + public static int getRandomLowGradeCropForThisSeason(string season) + { + if (season.Equals("winter")) + season = Game1.random.NextDouble() < 0.33 ? "spring" : (Game1.random.NextDouble() < 0.5 ? "summer" : "fall"); + if (season == "spring") + return Game1.random.Next(472, 476); + if (!(season == "summer")) + { + if (season == "fall") + return Game1.random.Next(487, 491); + } + else + { + switch (Game1.random.Next(4)) + { + case 0: + return 487; + case 1: + return 483; + case 2: + return 482; + case 3: + return 484; + } + } + return -1; + } + + public void growCompletely() + { + this.currentPhase = this.phaseDays.Count - 1; + this.dayOfCurrentPhase = 0; + if (this.regrowAfterHarvest == -1) + return; + this.fullyGrown = true; + } + + public bool harvest(int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester = null) + { + + if (this.dead) + return junimoHarvester != null; + if (this.forageCrop) + { + ModularCropObject @object = (ModularCropObject)null; + int howMuch = 3; + if (this.whichForageCrop == 1) + //@object = new ModularCropObject(399, 1, false, -1, 0); + if (Game1.player.professions.Contains(16)) + @object.quality = 4; + else if (Game1.random.NextDouble() < (double)Game1.player.ForagingLevel / 30.0) + @object.quality = 2; + else if (Game1.random.NextDouble() < (double)Game1.player.ForagingLevel / 15.0) + @object.quality = 1; + Game1.stats.ItemsForaged += (uint)@object.Stack; + if (junimoHarvester != null) + { + junimoHarvester.tryToAddItemToHut((Item)@object); + return true; + } + if (Game1.player.addItemToInventoryBool((Item)@object, false)) + { + Vector2 vector2 = new Vector2((float)xTile, (float)yTile); + Game1.player.animateOnce(279 + Game1.player.facingDirection); + Game1.player.canMove = false; + Game1.playSound("harvest"); + DelayedAction.playSoundAfterDelay("coin", 260); + if (this.regrowAfterHarvest == -1) + { + Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(17, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 125f, 0, -1, -1f, -1, 0)); + Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(14, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0)); + } + Game1.player.gainExperience(2, howMuch); + return true; + } + Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588")); + } + else if (this.currentPhase >= this.phaseDays.Count - 1 && (!this.fullyGrown || this.dayOfCurrentPhase <= 0)) + { + int num1 = 1; + int num2 = 0; + int num3 = 0; + if (this.indexOfHarvest == 0) + return true; + Random random = new Random(xTile * 7 + yTile * 11 + (int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame); + switch (soil.fertilizer) + { + case 368: + num3 = 1; + break; + case 369: + num3 = 2; + break; + } + double num4 = 0.2 * ((double)Game1.player.FarmingLevel / 10.0) + 0.2 * (double)num3 * (((double)Game1.player.FarmingLevel + 2.0) / 12.0) + 0.01; + double num5 = Math.Min(0.75, num4 * 2.0); + if (random.NextDouble() < num4) + num2 = 2; + else if (random.NextDouble() < num5) + num2 = 1; + if (this.minHarvest > 1 || this.maxHarvest > 1) + num1 = random.Next(this.minHarvest, Math.Min(this.minHarvest + 1, this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel)); + if (this.chanceForExtraCrops > 0.0) + { + while (random.NextDouble() < Math.Min(0.9, this.chanceForExtraCrops)) + ++num1; + } + if (this.harvestMethod == 1) + { + if (junimoHarvester == null) + DelayedAction.playSoundAfterDelay("daggerswipe", 150); + if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) + Game1.playSound("harvest"); + if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) + DelayedAction.playSoundAfterDelay("coin", 260); + for (int index = 0; index < num1; ++index) + { + if (junimoHarvester != null) + junimoHarvester.tryToAddItemToHut((Item)new ModularCropObject(this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData)); + else + AdditionalCropsFramework.Framework.Utilities.createObjectDebris((Item)new ModularCropObject(this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData), xTile, yTile, xTile, yTile, -1, this.getQualityOfCrop(), 1); + + //Game1.createObjectDebris(this.indexOfHarvest, xTile, yTile, -1, num2, 1f, (GameLocation)null); + } + if (this.regrowAfterHarvest == -1) + return true; + this.dayOfCurrentPhase = this.regrowAfterHarvest; + this.fullyGrown = true; + } + else + { + if (junimoHarvester == null) + { + Farmer player = Game1.player; + ModularCropObject @object= new ModularCropObject(this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData); + int num7 = 0; + if (!player.addItemToInventoryBool((Item)@object, num7 != 0)) + { + Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588")); + goto label_86; + } + } + Vector2 vector2 = new Vector2((float)xTile, (float)yTile); + if (junimoHarvester == null) + { + Game1.player.animateOnce(279 + Game1.player.facingDirection); + Game1.player.canMove = false; + } + else + { + JunimoHarvester junimoHarvester1 = junimoHarvester; + ModularCropObject @object = new ModularCropObject(this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData); + junimoHarvester1.tryToAddItemToHut((Item)@object); + } + if (random.NextDouble() < (double)Game1.player.LuckLevel / 1500.0 + Game1.dailyLuck / 1200.0 + 9.99999974737875E-05) + { + num1 *= 2; + if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) + Game1.playSound("dwoop"); + } + else if (this.harvestMethod == 0) + { + if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) + Game1.playSound("harvest"); + if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) + DelayedAction.playSoundAfterDelay("coin", 260); + if (this.regrowAfterHarvest == -1 && (junimoHarvester == null || junimoHarvester.currentLocation.Equals((object)Game1.currentLocation))) + { + Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(17, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 125f, 0, -1, -1f, -1, 0)); + Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(14, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0)); + } + } + if (this.indexOfHarvest == 421) + { + this.indexOfHarvest = 431; + num1 = random.Next(1, 4); + } + for (int index = 0; index < num1 - 1; ++index) + { + if (junimoHarvester == null) + AdditionalCropsFramework.Framework.Utilities.createObjectDebris((Item)new ModularCropObject(this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData), xTile, yTile, xTile, yTile, -1, this.getQualityOfCrop(), 1); + else + junimoHarvester.tryToAddItemToHut((Item)new ModularCropObject(this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData)); + } + float num8 = (float)(16.0 * Math.Log(0.018 * (double)Convert.ToInt32(this.experienceGainWhenHarvesting + 1.0), Math.E)); + if (junimoHarvester == null) + Game1.player.gainExperience(0, (int)Math.Round((double)num8)); + if (this.regrowAfterHarvest == -1) + return true; + this.dayOfCurrentPhase = this.regrowAfterHarvest; + this.fullyGrown = true; + } + } + label_86: + return false; + } + + /// + /// Not yet implemented. Contact the mod author if this is something you want! + /// + /// + /// + public new ModularCropObject getRandomWildCropForSeason(string season) + { + ModularCropObject newThing=null; + + if (season == "spring" || season=="Spring") + { + Random r = new Random((Game1.timeOfDay + Game1.dayOfMonth + Game1.player.money) / Game1.player.maxStamina); + int cropListIndex = r.Next(0,ModCore.SpringWildCrops.Count-1); + newThing = ModCore.SpringWildCrops[cropListIndex]; + } + if (season == "summer" || season=="Summer") + { + Random r = new Random((Game1.timeOfDay + Game1.dayOfMonth + Game1.player.money) / Game1.player.maxStamina); + int cropListIndex = r.Next(0, ModCore.SummerWildCrops.Count - 1); + newThing = ModCore.SummerWildCrops[cropListIndex]; + } + + if (season == "fall" || season=="Fall") + { + Random r = new Random((Game1.timeOfDay + Game1.dayOfMonth + Game1.player.money) / Game1.player.maxStamina); + int cropListIndex = r.Next(0, ModCore.FallWildCrops.Count - 1); + newThing = ModCore.FallWildCrops[cropListIndex]; + } + + if (season == "winter" || season=="Winter") + { + Random r = new Random((Game1.timeOfDay + Game1.dayOfMonth + Game1.player.money) / Game1.player.maxStamina); + int cropListIndex = r.Next(0, ModCore.WinterWildCrops.Count - 1); + newThing = ModCore.WinterWildCrops[cropListIndex]; + } + return newThing; + } + + private Rectangle getSourceRect(int number) + { + if (this.dead) + return new Rectangle(192 + number % 4 * 16, 384, 16, 32); + return new Rectangle(Math.Min(240, (this.fullyGrown ? (this.dayOfCurrentPhase <= 0 ? 6 : 7) : (this.phaseToShow != -1 ? this.phaseToShow : this.currentPhase) + ((this.phaseToShow != -1 ? this.phaseToShow : this.currentPhase) != 0 || number % 2 != 0 ? 0 : -1) + 1) * 16 + (this.rowInSpriteSheet % 2 != 0 ? 128 : 0)), this.rowInSpriteSheet / 2 * 16 * 2, 16, 32); + } + + public void newDay(int state, int fertilizer, int xTile, int yTile, GameLocation environment) + { + if (!environment.name.Equals("Greenhouse") && (this.dead || !this.seasonsToGrowIn.Contains(Game1.currentSeason))) + { + this.dead = true; + } + else + { + if (state == 1) + { + this.dayOfCurrentPhase = this.fullyGrown ? this.dayOfCurrentPhase - 1 : Math.Min(this.dayOfCurrentPhase + 1, this.phaseDays.Count > 0 ? this.phaseDays[Math.Min(this.phaseDays.Count - 1, this.currentPhase)] : 0); + if (this.dayOfCurrentPhase >= (this.phaseDays.Count > 0 ? this.phaseDays[Math.Min(this.phaseDays.Count - 1, this.currentPhase)] : 0) && this.currentPhase < this.phaseDays.Count - 1) + { + this.currentPhase = this.currentPhase + 1; + this.dayOfCurrentPhase = 0; + } + while (this.currentPhase < this.phaseDays.Count - 1 && this.phaseDays.Count > 0 && this.phaseDays[this.currentPhase] <= 0) + this.currentPhase = this.currentPhase + 1; + if (this.rowInSpriteSheet == 23 && this.phaseToShow == -1 && this.currentPhase > 0) + this.phaseToShow = Game1.random.Next(1, 7); + if (environment is Farm && this.currentPhase == this.phaseDays.Count - 1 && (this.indexOfHarvest == 276 || this.indexOfHarvest == 190 || this.indexOfHarvest == 254) && new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed + xTile * 2000 + yTile).NextDouble() < 0.01) + { + for (int index1 = xTile - 1; index1 <= xTile + 1; ++index1) + { + for (int index2 = yTile - 1; index2 <= yTile + 1; ++index2) + { + Vector2 key = new Vector2((float)index1, (float)index2); + if (!environment.terrainFeatures.ContainsKey(key) || !(environment.terrainFeatures[key] is HoeDirt) || ((environment.terrainFeatures[key] as HoeDirt).crop == null || (environment.terrainFeatures[key] as HoeDirt).crop.indexOfHarvest != this.indexOfHarvest)) + return; + } + } + for (int index1 = xTile - 1; index1 <= xTile + 1; ++index1) + { + for (int index2 = yTile - 1; index2 <= yTile + 1; ++index2) + { + Vector2 index3 = new Vector2((float)index1, (float)index2); + (environment.terrainFeatures[index3] as HoeDirt).crop = (ModularCrop)null; + } + } + (environment as Farm).resourceClumps.Add((ResourceClump)new GiantCrop(this.indexOfHarvest, new Vector2((float)(xTile - 1), (float)(yTile - 1)))); + } + } + if (this.fullyGrown && this.dayOfCurrentPhase > 0 || (this.currentPhase < this.phaseDays.Count - 1 || this.rowInSpriteSheet != 23)) + return; + Vector2 index = new Vector2((float)xTile, (float)yTile); + environment.objects.Remove(index); + string season = Game1.currentSeason; + switch (this.whichForageCrop) + { + case 495: + season = "spring"; + break; + case 496: + season = "summer"; + break; + case 497: + season = "fall"; + break; + case 498: + season = "winter"; + break; + } + ModularCropObject @object = this.getRandomWildCropForSeason(season); + @object.isSpawnedObject = true; + @object.canBeGrabbed = true; + environment.objects.Add(index, this.getRandomWildCropForSeason(season)); + + + if (environment.terrainFeatures[index] == null || !(environment.terrainFeatures[index] is HoeDirt)) + return; + (environment.terrainFeatures[index] as HoeDirt).crop = (ModularCrop)null; + } + } + + public bool isWildSeedCrop() + { + return this.rowInSpriteSheet == 23; + } + + public new void draw(SpriteBatch b, Vector2 tileLocation, Color toTint, float rotation) + { + if (this.forageCrop) + { + b.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + Log.AsyncC((float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0 / (this.currentPhase != 0 || this.raisedSeeds ? 1.0 : 2.0))); + } + else + { + b.Draw(this.spriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (this.raisedSeeds || this.currentPhase >= this.phaseDays.Count - 1 ? 0.0 : ((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (this.raisedSeeds || this.currentPhase >= this.phaseDays.Count - 1 ? 0.0 : ((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(this.getSourceRect((int)tileLocation.X * 7 + (int)tileLocation.Y * 11)), toTint, rotation, new Vector2(8f, 24f), (float)Game1.pixelZoom, this.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (this.raisedSeeds || this.currentPhase >= this.phaseDays.Count - 1 ? 0.0 : ((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0 / (this.currentPhase != 0 || this.raisedSeeds ? 1.0 : 2.0))); + + Log.AsyncG((float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0 / (this.currentPhase != 0 || this.raisedSeeds ? 1.0 : 2.0))); + + if (this.tintColor.Equals(Color.White) || this.currentPhase != this.phaseDays.Count - 1 || this.dead) + return; + b.Draw(this.spriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (this.raisedSeeds || this.currentPhase >= this.phaseDays.Count - 1 ? 0.0 : ((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (this.raisedSeeds || this.currentPhase >= this.phaseDays.Count - 1 ? 0.0 : ((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((this.fullyGrown ? (this.dayOfCurrentPhase <= 0 ? 6 : 7) : this.currentPhase + 1 + 1) * 16 + (this.rowInSpriteSheet % 2 != 0 ? 128 : 0), this.rowInSpriteSheet / 2 * 16 * 2, 16, 32)), this.tintColor, rotation, new Vector2(8f, 24f), (float)Game1.pixelZoom, this.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0 / (this.currentPhase != 0 || this.raisedSeeds ? 1.0 : 2.0))); + } + + } + + public new void drawInMenu(SpriteBatch b, Vector2 screenPosition, Color toTint, float rotation, float scale, float layerDepth) + { + b.Draw(this.spriteSheet, screenPosition, new Rectangle?(this.getSourceRect(0)), toTint, rotation, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize + Game1.tileSize / 2)), scale, this.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth); + } + + public int getQualityOfCrop() + { + return 0; + } + + public int getAmountForHarvest() + { + return 1; + } + + } +} diff --git a/GeneralMods/AdditionalCropsFramework/ModularCropObject.cs b/GeneralMods/AdditionalCropsFramework/ModularCropObject.cs new file mode 100644 index 00000000..4a69b6e2 --- /dev/null +++ b/GeneralMods/AdditionalCropsFramework/ModularCropObject.cs @@ -0,0 +1,1413 @@ + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI; +using StardewValley; +using StardewValley.Locations; +using StardewValley.Menus; +using StardewValley.Objects; +using System; +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace AdditionalCropsFramework +{ + /// + /// Revitalize ModularCropObject Class. This is a core class and should only be extended upon. + /// + /// + public class ModularCropObject : StardewValley.Object + { + + public new int price; + + public int Decoration_type; + + public int rotations; + + public int currentRotation; + + public int sourceIndexOffset; + + protected Vector2 drawPosition; + + public Rectangle sourceRect; + + public Rectangle defaultSourceRect; + + public Rectangle defaultBoundingBox; + + public string description; + + [XmlIgnore] + public Texture2D TextureSheet; + public string dataFileName; + + public new bool flipped; + + [XmlIgnore] + public bool flaggedForPickUp; + + public bool lightGlowAdded; + + public string texturePath; + + public bool itemReadyForHarvest; + + public string thisType; + + public bool removable; + + public string locationsName; + + public Color drawColor; + + public bool useXML; + + public string cropType; + + public override string Name + { + get + { + return this.name; + } + + } + + public ModularCropObject() + { + this.updateDrawPosition(); + } + + public ModularCropObject(bool f) + { + //does nothng + } + + public ModularCropObject(int which, int initalStack, string ObjectTextureSheetName, string DataFileName) + { + this.stack = initalStack; + TextureSheet = ModCore.ModHelper.Content.Load(ObjectTextureSheetName); //Game1.content.Load("TileSheets\\furniture"); + texturePath = ObjectTextureSheetName; + this.dataFileName = DataFileName; + this.canBeSetDown = false; + + Dictionary dictionary = Game1.content.Load>(DataFileName); + string[] array = dictionary[which].Split(new char[] + { + '/' + }); + this.name = array[0]; + + this.Decoration_type = this.getTypeNumberFromName(array[1]); + this.description = "Can be placed inside your house."; + this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 1, 1); + if (array[2].Equals("-1")) + { + this.sourceRect = this.getDefaultSourceRectForType(which, this.Decoration_type); + this.defaultSourceRect = this.sourceRect; + } + else + { + this.defaultSourceRect.Width = Convert.ToInt32(array[2].Split(new char[] + { + ' ' + })[0]); + this.defaultSourceRect.Height = Convert.ToInt32(array[2].Split(new char[] + { + ' ' + })[1]); + this.sourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16); + this.defaultSourceRect = this.sourceRect; + } + this.defaultBoundingBox = new Rectangle((int)this.tileLocation.X, (int)this.tileLocation.Y, 1, 1); + if (array[3].Equals("-1")) + { + this.boundingBox = this.getDefaultBoundingBoxForType(this.Decoration_type); + this.defaultBoundingBox = this.boundingBox; + } + else + { + this.defaultBoundingBox.Width = Convert.ToInt32(array[3].Split(new char[] + { + ' ' + })[0]); + this.defaultBoundingBox.Height = Convert.ToInt32(array[3].Split(new char[] + { + ' ' + })[1]); + this.boundingBox = new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize); + this.defaultBoundingBox = this.boundingBox; + } + this.updateDrawPosition(); + this.rotations = Convert.ToInt32(array[4]); + this.price = Convert.ToInt32(array[5]); + this.parentSheetIndex = which; + } + + public override string getDescription() + { + return this.description; + } + + /* + public override bool performDropDownAction(StardewValley.Farmer who) + { + this.resetOnPlayerEntry((who == null) ? Game1.currentLocation : who.currentLocation); + return false; + } + */ + public override void hoverAction() + { + base.hoverAction(); + if (!Game1.player.isInventoryFull()) + { + Game1.mouseCursor = 2; + } + } + + /* + public override bool checkForAction(StardewValley.Farmer who, bool justCheckingForActivity = false) + { + /* + var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); + if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) + { + // Game1.showRedMessage("YOOO"); + //do some stuff when the right button is down + // rotate(); + if (this.heldObject != null) + { + // Game1.player.addItemByMenuIfNecessary(this.heldObject); + // this.heldObject = null; + } + else + { + // this.heldObject = Game1.player.ActiveObject; + // Game1.player.removeItemFromInventory(heldObject); + } + //this.minutesUntilReady = 30; + // Log.AsyncC("placed item!"); + } + else + { + //Game1.showRedMessage("CRY"); + } + + if (justCheckingForActivity) + { + return true; + } + return this.clicked(who); + + } + */ + //DONT USE THIS BASE IT IS TERRIBLE + /* + public override bool clicked(StardewValley.Farmer who) + { + + // Game1.showRedMessage("THIS IS CLICKED!!!"); + Game1.haltAfterCheck = false; + + if (this.heldObject != null) + { + this.spillInventoryEverywhere(); + return false; + } + + if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is ModularCropObject))) + { + if (Game1.player.currentLocation is FarmHouse) + { + // Game1.showRedMessage("Why2?"); + // this.spillInventoryEverywhere(); + + // if (this.heldObject != null) Util.addItemToInventoryElseDrop(this.heldObject.getOne()); + this.heldObject = new ModularCropObject(parentSheetIndex, Vector2.Zero, this.inventoryMaxSize); + // Util.addItemToInventoryElseDrop(this.heldObject.getOne()); + this.heldObject = null; + this.flaggedForPickUp = true; + thisLocation = null; + return true; + } + else + { + // return true; + + this.flaggedForPickUp = true; + if (this is TV) + { + // this.heldObject = new TV(parentSheetIndex, Vector2.Zero); + } + else + { + + // Util.addItemToInventoryElseDrop(this.heldObject); + + var obj = new ModularCropObject(parentSheetIndex, Vector2.Zero, this.inventoryMaxSize); + Util.addItemToInventoryElseDrop(obj); + // this.spillInventoryEverywhere(); + if (this.heldObject != null) this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); + + this.heldObject = null; + Game1.playSound("coin"); + thisLocation = null; + return true; + } + + } + } + if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) + { + // Game1.showRedMessage("Why3?"); + // if(this.heldObject!=null) Game1.player.addItemByMenuIfNecessary((Item)this.heldObject); + // this.spillInventoryEverywhere(); + var obj = new ModularCropObject(parentSheetIndex, Vector2.Zero, this.inventoryMaxSize); + Util.addItemToInventoryElseDrop(obj); + if (this.heldObject != null) this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); + this.heldObject = null; + Game1.playSound("coin"); + thisLocation = null; + return true; + } + + + + return false; + } + */ + /* + public virtual bool RightClicked(StardewValley.Farmer who) + { + // StardewModdingAPI.Log.AsyncC(lightColor); + // Game1.activeClickableMenu = new Revitalize.Menus.LightCustomizer(this); + + // Game1.showRedMessage("THIS IS CLICKED!!!"); + //var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); + /* + + Game1.haltAfterCheck = false; + if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null) + { + // Game1.showRedMessage("Why1?"); + return false; + } + if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is Light))) + { + if (Game1.player.currentLocation is FarmHouse) + { + // + Game1.player.addItemByMenuIfNecessary(this); + removeLights(this.thisLocation); + this.lightsOn = false; + Game1.playSound("coin"); + // this.flaggedForPickUp = true; + return true; + } + else + { + // return true; + // this.heldObject = new Light(parentSheetIndex, Vector2.Zero, this.lightColor, this.inventoryMaxSize); + Game1.player.addItemByMenuIfNecessary(this); + removeLights(this.thisLocation); + this.lightsOn = false; + Game1.playSound("coin"); + return true; + + } + } + if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) + { + // Game1.showRedMessage("Why3?"); + // if(this.heldObject!=null) Game1.player.addItemByMenuIfNecessary((Item)this.heldObject); + Util.addItemToInventoryElseDrop(this); + this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); + this.heldObject = null; + Game1.playSound("coin"); + removeLights(this.thisLocation); + this.lightsOn = false; + return true; + } + + + + return false; + } + */ + + /* + public override void DayUpdate(GameLocation location) + { + base.DayUpdate(location); + this.lightGlowAdded = false; + if (!Game1.isDarkOut() || (Game1.newDay && !Game1.isRaining)) + { + this.removeLights(location); + return; + } + this.addLights(location); + } + */ + + /* + public virtual void resetOnPlayerEntry(GameLocation environment) + { + this.removeLights(environment); + if (Game1.isDarkOut()) + { + this.addLights(environment); + } + } + + public override bool performObjectDropInAction(StardewValley.Object dropIn, bool probe, StardewValley.Farmer who) + { + // Log.AsyncG("HEY!"); + if ((this.Decoration_type == 11 || this.Decoration_type == 5) && this.heldObject == null && !dropIn.bigCraftable && (!(dropIn is ModularCropObject) || ((dropIn as ModularCropObject).getTilesWide() == 1 && (dropIn as ModularCropObject).getTilesHigh() == 1))) + { + this.heldObject = (StardewValley.Object)dropIn.getOne(); + this.heldObject.tileLocation = this.tileLocation; + this.heldObject.boundingBox.X = this.boundingBox.X; + this.heldObject.boundingBox.Y = this.boundingBox.Y; + // Log.AsyncO(getDefaultBoundingBoxForType((dropIn as ModularCropObject).Decoration_type)); + this.heldObject.performDropDownAction(who); + if (!probe) + { + Game1.playSound("woodyStep"); + // Log.AsyncC("HUH?"); + if (who != null) + { + who.reduceActiveItemByOne(); + } + } + return true; + } + return false; + } + + public virtual void addLights(GameLocation environment) + { + if (this.Decoration_type == 7) + { + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightSource == null) + { + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, lightColor, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + Game1.currentLightSources.Add(this.lightSource); + // Log.AsyncG("LIGHT SOURCE ADDED FFFFFFF"); + return; + } + } + else if (this.Decoration_type == 13) + { + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightGlowAdded) + { + environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); + this.lightGlowAdded = false; + } + } + else + { + + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightSource == null) + { + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, lightColor, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + Game1.currentLightSources.Add(this.lightSource); + return; + } + + } + } + + + public virtual void addLights(GameLocation environment, Color c) + { + if (this.Decoration_type == 7) + { + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightSource == null) + { + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, c, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + // this.lightSource.lightTexture = Game1.content.Load("LooseSprites\\Lighting\\BlueLight"); + Game1.currentLightSources.Add(this.lightSource); + // Log.AsyncG("LIGHT SOURCE ADDED FFFFFFF"); + return; + } + } + else if (this.Decoration_type == 13) + { + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightGlowAdded) + { + environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); + this.lightGlowAdded = false; + } + } + else + { + + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightSource == null) + { + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, c, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + Game1.currentLightSources.Add(this.lightSource); + return; + } + + } + } + + public void removeLights(GameLocation environment) + { + if (this.Decoration_type == 7) + { + if (this.sourceIndexOffset == 1) + { + this.sourceRect = this.defaultSourceRect; + } + this.sourceIndexOffset = 0; + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = null; + return; + } + if (this.Decoration_type == 13) + { + if (this.sourceIndexOffset == 1) + { + this.sourceRect = this.defaultSourceRect; + } + this.sourceIndexOffset = 0; + if (Game1.isRaining) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + this.sourceIndexOffset = 1; + return; + } + if (!this.lightGlowAdded && !environment.lightGlows.Contains(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize)))) + { + environment.lightGlows.Add(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); + } + this.lightGlowAdded = true; + } + + if (this.sourceIndexOffset == 1) + { + this.sourceRect = this.defaultSourceRect; + } + this.sourceIndexOffset = 0; + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = null; + return; + } + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + // Log.Info("minutes passed in"+minutes); + // Log.Info("minues remaining" + this.minutesUntilReady); + this.minutesUntilReady = (this.minutesUntilReady - minutes); + if (Game1.isDarkOut()) + { + // this.addLights(environment,this.lightColor); + this.addLights(environment); + } + else + { + this.removeLights(environment); + } + + if (minutesUntilReady == 0) + { + // Log.AsyncC(this.name + "Is ready!"); + // Log.AsyncC(Game1.player.getStandingPosition()); + // Vector2 v2 = new Vector2(this.tileLocation.X * Game1.tileSize, this.tileLocation.Y * Game1.tileSize); + //Game1.createItemDebris((Item)this.heldObject, v2, Game1.player.getDirection()); + // minutesUntilReady = 30; + } + + return false; + } + + public override void performRemoveAction(Vector2 tileLocation, GameLocation environment) + { + this.removeLights(environment); + if (this.Decoration_type == 13 && this.lightGlowAdded) + { + environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); + this.lightGlowAdded = false; + } + this.spillInventoryEverywhere(); + base.performRemoveAction(tileLocation, environment); + } + + public virtual void rotate() + { + if (this.rotations < 2) + { + return; + } + int num = (this.rotations == 4) ? 1 : 2; + this.currentRotation += num; + this.currentRotation %= 4; + this.flipped = false; + Point point = default(Point); + int num2 = this.Decoration_type; + switch (num2) + { + case 2: + point.Y = 1; + point.X = -1; + break; + case 3: + point.X = -1; + point.Y = 1; + break; + case 4: + break; + case 5: + point.Y = 0; + point.X = -1; + break; + default: + if (num2 == 12) + { + point.X = 0; + point.Y = 0; + } + break; + } + bool flag = this.Decoration_type == 5 || this.Decoration_type == 12 || this.parentSheetIndex == 724 || this.parentSheetIndex == 727; + bool flag2 = this.defaultBoundingBox.Width != this.defaultBoundingBox.Height; + if (flag && this.currentRotation == 2) + { + this.currentRotation = 1; + } + if (flag2) + { + int height = this.boundingBox.Height; + switch (this.currentRotation) + { + case 0: + case 2: + this.boundingBox.Height = this.defaultBoundingBox.Height; + this.boundingBox.Width = this.defaultBoundingBox.Width; + break; + case 1: + case 3: + this.boundingBox.Height = this.boundingBox.Width + point.X * Game1.tileSize; + this.boundingBox.Width = height + point.Y * Game1.tileSize; + break; + } + } + Point point2 = default(Point); + int num3 = this.Decoration_type; + if (num3 == 12) + { + point2.X = 1; + point2.Y = -1; + } + if (flag2) + { + switch (this.currentRotation) + { + case 0: + this.sourceRect = this.defaultSourceRect; + break; + case 1: + this.sourceRect = new Rectangle(this.defaultSourceRect.X + this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Height - 16 + point.Y * 16 + point2.X * 16, this.defaultSourceRect.Width + 16 + point.X * 16 + point2.Y * 16); + break; + case 2: + this.sourceRect = new Rectangle(this.defaultSourceRect.X + this.defaultSourceRect.Width + this.defaultSourceRect.Height - 16 + point.Y * 16 + point2.X * 16, this.defaultSourceRect.Y, this.defaultSourceRect.Width, this.defaultSourceRect.Height); + break; + case 3: + this.sourceRect = new Rectangle(this.defaultSourceRect.X + this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Height - 16 + point.Y * 16 + point2.X * 16, this.defaultSourceRect.Width + 16 + point.X * 16 + point2.Y * 16); + this.flipped = true; + break; + } + } + else + { + this.flipped = (this.currentRotation == 3); + if (this.rotations == 2) + { + this.sourceRect = new Rectangle(this.defaultSourceRect.X + ((this.currentRotation == 2) ? 1 : 0) * this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Width, this.defaultSourceRect.Height); + } + else + { + this.sourceRect = new Rectangle(this.defaultSourceRect.X + ((this.currentRotation == 3) ? 1 : this.currentRotation) * this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Width, this.defaultSourceRect.Height); + } + } + if (flag && this.currentRotation == 1) + { + this.currentRotation = 2; + } + this.updateDrawPosition(); + } + + public virtual bool isGroundFurniture() + { + return this.Decoration_type != 13 && this.Decoration_type != 6 && this.Decoration_type != 13; + } + */ + public override bool canBeGivenAsGift() + { + return true; + } + + public override bool canBePlacedHere(GameLocation l, Vector2 tile) + { + return false; + if ((l is FarmHouse)) + { + for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++) + { + for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++) + { + Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize; + vector.X += (float)(Game1.tileSize / 2); + vector.Y += (float)(Game1.tileSize / 2); + foreach (KeyValuePair something in l.objects) + { + StardewValley.Object obj = something.Value; + if ((obj.GetType()).ToString().Contains("ModularCropObject")) + { + ModularCropObject current = (ModularCropObject)obj; + if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1) + { + bool result = true; + return result; + } + if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y)) + { + bool result = false; + return result; + } + } + } + } + } + //return Util.canBePlacedHere(this, l, tile); + } + else + { + // Game1.showRedMessage("NOT FARMHOUSE"); + for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++) + { + for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++) + { + Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize; + vector.X += (float)(Game1.tileSize / 2); + vector.Y += (float)(Game1.tileSize / 2); + /* + foreach (ModularCropObject current in (l as FarmHouse).ModularCropObject) + { + if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1) + { + bool result = true; + return result; + } + if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y)) + { + bool result = false; + return result; + } + } + */ + } + } + // return Util.canBePlacedHere(this, l, tile); + } + + } + + public virtual void updateDrawPosition() + { + this.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height))); + } + + public virtual int getTilesWide() + { + return this.boundingBox.Width / Game1.tileSize; + } + + public virtual int getTilesHigh() + { + return this.boundingBox.Height / Game1.tileSize; + } + /* + public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null) + { + // Log.AsyncC(x); + // Log.AsyncM(y); + + if (location is FarmHouse) + { + Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); + List walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); + this.tileLocation = new Vector2((float)point.X, (float)point.Y); + bool flag = false; + if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293) + { + int num = (this.parentSheetIndex == 1293) ? 3 : 0; + bool flag2 = false; + foreach (Rectangle current in walls) + { + if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num)) + { + flag2 = true; + break; + } + } + if (!flag2) + { + Game1.showRedMessage("Must be placed on wall"); + return false; + } + flag = true; + } + for (int i = point.X; i < point.X + this.getTilesWide(); i++) + { + for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++) + { + if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null) + { + Game1.showRedMessage("Furniture can't be placed here"); + return false; + } + if (!flag && Utility.pointInRectangles(walls, i, j)) + { + Game1.showRedMessage("Can't place on wall"); + return false; + } + if (location.getTileIndexAt(i, j, "Buildings") != -1) + { + return false; + } + } + } + this.boundingBox = new Rectangle(x, y, this.boundingBox.Width, this.boundingBox.Height); + foreach (KeyValuePair c in location.objects) + { + StardewValley.Object ehh = c.Value; + if (((ehh.GetType()).ToString()).Contains("ModularCropObject")) + { + ModularCropObject current2 = (ModularCropObject)ehh; + if (current2.Decoration_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox)) + { + current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); + bool result = true; + return result; + } + } + } + foreach (StardewValley.Farmer current3 in location.getStardewValley.Farmers()) + { + if (current3.GetBoundingBox().Intersects(this.boundingBox)) + { + Game1.showRedMessage("Can't place on top of a person."); + bool result = false; + return result; + } + } + this.updateDrawPosition(); + // Log.AsyncO(this.boundingBox); + // Log.AsyncO(x); + // Log.AsyncY(y); + for (int i = 0; i <= this.boundingBox.X / Game1.tileSize; i++) + { + base.placementAction(location, x + 1, y, who); + } + for (int i = 0; i <= this.boundingBox.Y / Game1.tileSize; i++) + { + base.placementAction(location, x, y + 1, who); + } + return true; + } + else + { + Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); + // List walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); + this.tileLocation = new Vector2((float)point.X, (float)point.Y); + bool flag = false; + if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293) + { + int num = (this.parentSheetIndex == 1293) ? 3 : 0; + bool flag2 = false; + /* + foreach (Rectangle current in walls) + { + if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num)) + { + flag2 = true; + break; + } + } + + if (!flag2) + { + Game1.showRedMessage("Must be placed on wall"); + return false; + } + flag = true; + } + for (int i = point.X; i < point.X + this.getTilesWide(); i++) + { + for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++) + { + if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null) + { + Game1.showRedMessage("Furniture can't be placed here"); + return false; + } + /* + if (!flag && Utility.pointInRectangles(walls, i, j)) + { + Game1.showRedMessage("Can't place on wall"); + return false; + } + + if (location.getTileIndexAt(i, j, "Buildings") != -1) + { + return false; + } + } + } + this.boundingBox = new Rectangle(x, y, this.boundingBox.Width, this.boundingBox.Height); + /* + foreach (Furniture current2 in (location as FarmHouse).furniture) + { + if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox)) + { + current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); + bool result = true; + return result; + } + } + + foreach (StardewValley.Farmer current3 in location.getStardewValley.Farmers()) + { + if (current3.GetBoundingBox().Intersects(this.boundingBox)) + { + Game1.showRedMessage("Can't place on top of a person."); + bool result = false; + return result; + } + } + this.updateDrawPosition(); + thisLocation = Game1.player.currentLocation; + return base.placementAction(location, x, y, who); + } + + } + */ + public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null) + { + return false; + if (base.placementAction(location, x, y, who) == true) + { + // Lists.trackedObjectList.Add(this); + } + + + if (location is FarmHouse) + { + Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); + List walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); + this.tileLocation = new Vector2((float)point.X, (float)point.Y); + bool flag = false; + if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293) + { + int num = (this.parentSheetIndex == 1293) ? 3 : 0; + bool flag2 = false; + foreach (Rectangle current in walls) + { + if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num)) + { + flag2 = true; + break; + } + } + if (!flag2) + { + Game1.showRedMessage("Must be placed on wall"); + return false; + } + flag = true; + } + for (int i = point.X; i < point.X + this.getTilesWide(); i++) + { + for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++) + { + if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null) + { + Game1.showRedMessage("Furniture can't be placed here"); + return false; + } + if (!flag && Utility.pointInRectangles(walls, i, j)) + { + Game1.showRedMessage("Can't place on wall"); + return false; + } + if (location.getTileIndexAt(i, j, "Buildings") != -1) + { + return false; + } + } + } + this.boundingBox = new Rectangle(x / Game1.tileSize, y / Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); + foreach (KeyValuePair c in location.objects) + { + StardewValley.Object ehh = c.Value; + if (((ehh.GetType()).ToString()).Contains("Spawner")) + { + ModularCropObject current2 = (ModularCropObject)ehh; + if (current2.Decoration_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox)) + { + current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); + bool result = true; + return result; + } + } + } + foreach (StardewValley.Farmer current3 in location.getFarmers()) + { + if (current3.GetBoundingBox().Intersects(this.boundingBox)) + { + Game1.showRedMessage("Can't place on top of a person."); + bool result = false; + return result; + } + } + this.updateDrawPosition(); + // Log.AsyncO(this.boundingBox); + // Log.AsyncO(x); + // Log.AsyncY(y); + for (int i = 0; i <= this.boundingBox.X / Game1.tileSize; i++) + { + base.placementAction(location, x + 1, y, who); + } + for (int i = 0; i <= this.boundingBox.Y / Game1.tileSize; i++) + { + base.placementAction(location, x, y + 1, who); + } + return true; + } + else + { + Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); + // List walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); + this.tileLocation = new Vector2((float)point.X, (float)point.Y); + bool flag = false; + if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293) + { + int num = (this.parentSheetIndex == 1293) ? 3 : 0; + bool flag2 = false; + /* + foreach (Rectangle current in walls) + { + if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num)) + { + flag2 = true; + break; + } + } + */ + if (!flag2) + { + Game1.showRedMessage("Must be placed on wall"); + return false; + } + flag = true; + } + for (int i = point.X; i < point.X + this.getTilesWide(); i++) + { + for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++) + { + if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null) + { + Game1.showRedMessage("Furniture can't be placed here"); + return false; + } + /* + if (!flag && Utility.pointInRectangles(walls, i, j)) + { + Game1.showRedMessage("Can't place on wall"); + return false; + } + */ + if (location.getTileIndexAt(i, j, "Buildings") != -1) + { + return false; + } + } + } + this.boundingBox = new Rectangle(x / Game1.tileSize, y / Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); + /* + foreach (Furniture current2 in (location as FarmHouse).furniture) + { + if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox)) + { + current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); + bool result = true; + return result; + } + } + */ + foreach (StardewValley.Farmer current3 in location.getFarmers()) + { + if (current3.GetBoundingBox().Intersects(this.boundingBox)) + { + Game1.showRedMessage("Can't place on top of a person."); + bool result = false; + return result; + } + } + this.updateDrawPosition(); + return base.placementAction(location, x * Game1.tileSize, y * Game1.tileSize, who); + } + } + + public override bool isPlaceable() + { + return true; + } + + public override Rectangle getBoundingBox(Vector2 tileLocation) + { + return this.boundingBox; + } + + private Rectangle getDefaultSourceRectForType(int tileIndex, int type) + { + int num; + int num2; + switch (type) + { + case 0: + num = 1; + num2 = 2; + goto IL_94; + case 1: + num = 2; + num2 = 2; + goto IL_94; + case 2: + num = 3; + num2 = 2; + goto IL_94; + case 3: + num = 2; + num2 = 2; + goto IL_94; + case 4: + num = 2; + num2 = 2; + goto IL_94; + case 5: + num = 5; + num2 = 3; + goto IL_94; + case 6: + num = 2; + num2 = 2; + goto IL_94; + case 7: + num = 1; + num2 = 3; + goto IL_94; + case 8: + num = 1; + num2 = 2; + goto IL_94; + case 10: + num = 2; + num2 = 3; + goto IL_94; + case 11: + num = 2; + num2 = 3; + goto IL_94; + case 12: + num = 3; + num2 = 2; + goto IL_94; + case 13: + num = 1; + num2 = 2; + goto IL_94; + } + num = 1; + num2 = 2; + IL_94: + return new Rectangle(tileIndex * 16 % TextureSheet.Width, tileIndex * 16 / TextureSheet.Width * 16, num * 16, num2 * 16); + } + + private Rectangle getDefaultBoundingBoxForType(int type) + { + int num; + int num2; + switch (type) + { + case 0: + num = 1; + num2 = 1; + goto IL_94; + case 1: + num = 2; + num2 = 1; + goto IL_94; + case 2: + num = 3; + num2 = 1; + goto IL_94; + case 3: + num = 2; + num2 = 1; + goto IL_94; + case 4: + num = 2; + num2 = 1; + goto IL_94; + case 5: + num = 5; + num2 = 2; + goto IL_94; + case 6: + num = 2; + num2 = 2; + goto IL_94; + case 7: + num = 1; + num2 = 1; + goto IL_94; + case 8: + num = 1; + num2 = 1; + goto IL_94; + case 10: + num = 2; + num2 = 1; + goto IL_94; + case 11: + num = 2; + num2 = 2; + goto IL_94; + case 12: + num = 3; + num2 = 2; + goto IL_94; + case 13: + num = 1; + num2 = 2; + goto IL_94; + } + num = 1; + num2 = 1; + IL_94: + return new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, num * Game1.tileSize, num2 * Game1.tileSize); + } + + private int getTypeNumberFromName(string typeName) + { + string key; + switch (key = typeName.ToLower()) + { + case "chair": + return 0; + case "bench": + return 1; + case "couch": + return 2; + case "armchair": + return 3; + case "dresser": + return 4; + case "long table": + return 5; + case "painting": + return 6; + case "lamp": + return 7; + case "decor": + return 8; + case "bookcase": + return 10; + case "table": + return 11; + case "rug": + return 12; + case "window": + return 13; + } + return 9; + } + + public override int salePrice() + { + return this.price; + } + + public override int maximumStackSize() + { + return 1; + } + + public override int getStack() + { + return this.stack; + } + + public override int addToStack(int amount) + { + return 1; + } + + private float getScaleSize() + { + int num = this.sourceRect.Width / 16; + int num2 = this.sourceRect.Height / 16; + if (num >= 5) + { + return 0.75f; + } + if (num2 >= 3) + { + return 1f; + } + if (num <= 2) + { + return 2f; + } + if (num <= 4) + { + return 1f; + } + return 0.1f; + } + + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f) + { + if (f.ActiveObject.bigCraftable) + { + spriteBatch.Draw(Game1.bigCraftableSpriteSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(StardewValley.Object.getSourceRectForBigCraftable(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + return; + } + spriteBatch.Draw(Game1.objectSpriteSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + if (f.ActiveObject != null && f.ActiveObject.Name.Contains("=")) + { + spriteBatch.Draw(Game1.objectSpriteSheet, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + if (Math.Abs(Game1.starCropShimmerPause) <= 0.05f && Game1.random.NextDouble() < 0.97) + { + return; + } + Game1.starCropShimmerPause += 0.04f; + if (Game1.starCropShimmerPause >= 0.8f) + { + Game1.starCropShimmerPause = -0.8f; + } + } + //base.drawWhenHeld(spriteBatch, objectPosition, f); + } + + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber) + { + spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize), (float)(Game1.tileSize)), new Rectangle?(this.defaultSourceRect), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height)), 1f * this.getScaleSize() * scaleSize * .5f, SpriteEffects.None, layerDepth); + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + if (x == -1) + { + spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f)); + } + else + { + spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), (float)(y * Game1.tileSize - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height)))), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f)); + } + if (this.heldObject != null) + { + if (this.heldObject is ModularCropObject) + { + (this.heldObject as ModularCropObject).drawAtNonTileSpot(spriteBatch, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - (this.heldObject as ModularCropObject).sourceRect.Height * Game1.pixelZoom - Game1.tileSize / 4))), (float)(this.boundingBox.Bottom - 7) / 10000f, alpha); + return; + } + spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))) + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * 5 / 6)), new Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, (float)this.boundingBox.Bottom / 10000f); + spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))), new Rectangle?(Game1.currentLocation.getSourceRectForObject(this.heldObject.ParentSheetIndex)), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f); + } + } + + public virtual void drawAtNonTileSpot(SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1f) + { + spriteBatch.Draw(TextureSheet, location, new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth); + } + + public override Item getOne() + { + ModularCropObject ModularCropObject = new ModularCropObject(this.parentSheetIndex,this.stack,this.texturePath,this.dataFileName); + + ModularCropObject.drawPosition = this.drawPosition; + ModularCropObject.defaultBoundingBox = this.defaultBoundingBox; + ModularCropObject.boundingBox = this.boundingBox; + ModularCropObject.currentRotation = this.currentRotation - 1; + ModularCropObject.rotations = this.rotations; + //rotate(); + + return ModularCropObject; + } + + public virtual void resetTexture() + { + TextureSheet = Game1.content.Load(this.texturePath); + } + + public override string getCategoryName() + { + if (this.cropType != "") return this.cropType; + return "ModdedCrop"; + } + + public override Color getCategoryColor() + { + return Color.DarkBlue; + } + + + } +} diff --git a/GeneralMods/AdditionalCropsFramework/ModularSeeds.cs b/GeneralMods/AdditionalCropsFramework/ModularSeeds.cs new file mode 100644 index 00000000..0f4e20ab --- /dev/null +++ b/GeneralMods/AdditionalCropsFramework/ModularSeeds.cs @@ -0,0 +1,579 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +using StardewModdingAPI; +using StardewValley; +using StardewValley.Locations; +using StardewValley.Menus; +using System; +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace AdditionalCropsFramework +{ + ///Make xtra crops data sheet + ///edit crops png, crops xnb, and objectInformation.XNB and springObjects.png. + + + /// + /// Stardew ExtraSeeds Class. VERY Broken. Only extend from this class. + /// + /// + public class ModularSeeds : CoreObject + { + + public new Texture2D TextureSheet; + public string dataFilePath; + + public string cropDataFilePath; + public string cropTextureFilePath; + + public string cropObjectDataFilePath; + public string cropObjectTextureFilePath; + + public override string Name + { + get + { + return this.name; + } + } + + public ModularSeeds() + { + this.updateDrawPosition(); + } + + public ModularSeeds(int which, string ObjectSpriteSheet, string ObjectDataFile, string AssociatedCropTextureFile, string AssociatedCropDataFile, string AssociatedCropObjectTexture,string AssociatedCropObjectDataFile) + { + if (TextureSheet == null) + { + TextureSheet = ModCore.ModHelper.Content.Load(ObjectSpriteSheet); //Game1.content.Load("Revitalize\\CropsNSeeds\\Graphics\\seeds"); + texturePath = ObjectSpriteSheet; + } + Dictionary dictionary = ModCore.ModHelper.Content.Load>(ObjectDataFile);//Game1.content.Load>("Revitalize\\CropsNSeeds\\Data\\seeds"); + dataFilePath = ObjectDataFile; + cropDataFilePath = AssociatedCropDataFile; + cropTextureFilePath = AssociatedCropTextureFile; + + cropObjectDataFilePath = AssociatedCropObjectDataFile; + cropObjectTextureFilePath = AssociatedCropObjectTexture; + + Log.AsyncC(cropDataFilePath); + Log.AsyncG(cropTextureFilePath); + + + //Log.AsyncC(which); + string[] array = dictionary[which].Split(new char[] + { + '/' + }); + this.name = array[0]; + + try + { + this.description = array[6]; + this.description += "\nGrown in "; + ModularCrop c = parseCropInfo(which); + int trackCount = 0; + foreach (var v in c.seasonsToGrowIn) + { + if (c.seasonsToGrowIn.Count > 1) + { + trackCount++; + if (trackCount != c.seasonsToGrowIn.Count) description += v + ", "; + else description += "and " + v; + } + else description += v; + } + this.description += ".\n"; + this.description += "Takes "; + int totalDaysToGrow = 0; + foreach (var v in c.phaseDays) + { + totalDaysToGrow += v; + } + totalDaysToGrow -= 99999; + this.description += Convert.ToString(totalDaysToGrow) + " days to mature.\n"; + + try + { + this.description += array[7]; + } + catch (Exception e) + { + + } + } + catch (Exception e) + { + this.description = "Some seeds! Maybe you should plant them."; + } + this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 1, 1); + if (array[2].Equals("-1")) + { + } + else + { + this.defaultSourceRect.Width = Convert.ToInt32(array[2].Split(new char[] + { + ' ' + })[0]); + this.defaultSourceRect.Height = Convert.ToInt32(array[2].Split(new char[] + { + ' ' + })[1]); + this.sourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16); + this.defaultSourceRect = this.sourceRect; + } + this.defaultBoundingBox = new Rectangle((int)this.tileLocation.X, (int)this.tileLocation.Y, 1, 1); + if (array[3].Equals("-1")) + { + } + else + { + this.defaultBoundingBox.Width = Convert.ToInt32(array[3].Split(new char[] + { + ' ' + })[0]); + this.defaultBoundingBox.Height = Convert.ToInt32(array[3].Split(new char[] + { + ' ' + })[1]); + this.boundingBox = new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize); + this.defaultBoundingBox = this.boundingBox; + } + this.updateDrawPosition(); + this.rotations = Convert.ToInt32(array[4]); + this.price = Convert.ToInt32(array[5]); + this.parentSheetIndex = which; + + } + + public override string getDescription() + { + return this.description; + } + + public override bool performDropDownAction(StardewValley.Farmer who) + { + this.resetOnPlayerEntry((who == null) ? Game1.currentLocation : who.currentLocation); + return false; + } + + public override void hoverAction() + { + base.hoverAction(); + if (!Game1.player.isInventoryFull()) + { + Game1.mouseCursor = 2; + } + } + + + + public override bool checkForAction(StardewValley.Farmer who, bool justCheckingForActivity = false) + { + var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); + if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) + { + return this.RightClicked(who); + + // Game1.showRedMessage("YOOO"); + //do some stuff when the right button is down + // rotate(); + if (this.heldObject != null) + { + // Game1.player.addItemByMenuIfNecessary(this.heldObject); + // this.heldObject = null; + } + else + { + // this.heldObject = Game1.player.ActiveObject; + // Game1.player.removeItemFromInventory(heldObject); + } + //this.minutesUntilReady = 30; + } + else + { + //Game1.showRedMessage("CRY"); + } + + if (justCheckingForActivity) + { + return true; + } + return this.clicked(who); + } + + //DONT USE THIS BASE IT IS TERRIBLE + public override bool clicked(StardewValley.Farmer who) + { + /* + // Game1.showRedMessage("THIS IS CLICKED!!!"); + //var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); + + + if (removable == false) return false; + + + Game1.haltAfterCheck = false; + if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null) + { + // Game1.showRedMessage("Why1?"); + return false; + } + if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is ExtraSeeds))) + { + if (Game1.player.currentLocation is FarmHouse) + { + // + Util.addItemToInventoryAndCleanTrackedList(this); + removeLights(this.thisLocation); + this.lightsOn = false; + Game1.playSound("coin"); + // this.flaggedForPickUp = true; + thisLocation = null; + return true; + } + else + { + // return true; + // this.heldObject = new ExtraSeeds(parentSheetIndex, Vector2.Zero, this.lightColor, this.inventoryMaxSize); + Util.addItemToInventoryAndCleanTrackedList(this); + removeLights(this.thisLocation); + this.lightsOn = false; + Game1.playSound("coin"); + thisLocation = null; + return true; + + } + } + if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) + { + // Game1.showRedMessage("Why3?"); + // if(this.heldObject!=null) Game1.player.addItemByMenuIfNecessary((Item)this.heldObject); + Util.addItemToInventoryAndCleanTrackedList(this); + this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); + this.heldObject = null; + Game1.playSound("coin"); + removeLights(this.thisLocation); + this.lightsOn = false; + thisLocation = null; + return true; + } + + */ + + return false; + } + + public virtual bool RightClicked(StardewValley.Farmer who) + { + + + // Game1.showRedMessage("THIS IS CLICKED!!!"); + //var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); + /* + + Game1.haltAfterCheck = false; + if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null) + { + // Game1.showRedMessage("Why1?"); + return false; + } + if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is ExtraSeeds))) + { + if (Game1.player.currentLocation is FarmHouse) + { + // + Game1.player.addItemByMenuIfNecessary(this); + removeLights(this.thisLocation); + this.lightsOn = false; + Game1.playSound("coin"); + // this.flaggedForPickUp = true; + return true; + } + else + { + // return true; + // this.heldObject = new ExtraSeeds(parentSheetIndex, Vector2.Zero, this.lightColor, this.inventoryMaxSize); + Game1.player.addItemByMenuIfNecessary(this); + removeLights(this.thisLocation); + this.lightsOn = false; + Game1.playSound("coin"); + return true; + + } + } + if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) + { + // Game1.showRedMessage("Why3?"); + // if(this.heldObject!=null) Game1.player.addItemByMenuIfNecessary((Item)this.heldObject); + Util.addItemToInventoryElseDrop(this); + this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); + this.heldObject = null; + Game1.playSound("coin"); + removeLights(this.thisLocation); + this.lightsOn = false; + return true; + } + + */ + + return false; + } + + public override void DayUpdate(GameLocation location) + { + base.DayUpdate(location); + this.lightGlowAdded = false; + if (!Game1.isDarkOut() || (Game1.newDay && !Game1.isRaining)) + { + this.removeLights(location); + return; + } + // this.addLights(thisLocation, lightColor); + this.addLights(thisLocation, lightColor); + } + + public override bool performObjectDropInAction(StardewValley.Object dropIn, bool probe, StardewValley.Farmer who) + { + return false; + } + + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + return false; + } + + public override void performRemoveAction(Vector2 tileLocation, GameLocation environment) + { + + } + + public override bool canBeGivenAsGift() + { + return false; + } + + public override bool canBePlacedHere(GameLocation l, Vector2 tile) + { + return false; + } + + public virtual void updateDrawPosition() + { + this.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height))); + } + + public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) + { + + } + + + public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null) + { + return true; + } + + public override bool isPlaceable() + { + return false; + } + + public override int salePrice() + { + return this.price; + } + + public override int getStack() + { + return this.stack; + } + + public override int addToStack(int amount) + { + return 1; + } + + private float getScaleSize() + { + int num = this.sourceRect.Width / 16; + int num2 = this.sourceRect.Height / 16; + if (num >= 5) + { + return 0.75f; + } + if (num2 >= 3) + { + return 1f; + } + if (num <= 2) + { + return 2f; + } + if (num <= 4) + { + return 1f; + } + return 0.1f; + } + + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f) + { + + spriteBatch.Draw(this.TextureSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + if (f.ActiveObject != null && f.ActiveObject.Name.Contains("=")) + { + spriteBatch.Draw(Game1.objectSpriteSheet, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + if (Math.Abs(Game1.starCropShimmerPause) <= 0.05f && Game1.random.NextDouble() < 0.97) + { + return; + } + Game1.starCropShimmerPause += 0.04f; + if (Game1.starCropShimmerPause >= 0.8f) + { + Game1.starCropShimmerPause = -0.8f; + } + } + } + + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber) + { + //spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(this.defaultSourceRect), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * this.getScaleSize() * scaleSize, SpriteEffects.None, layerDepth); + spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(this.defaultSourceRect), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * this.getScaleSize() * scaleSize * 1.5f, SpriteEffects.None, layerDepth); + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + if (x == -1) + { + spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f)); + } + else + { + spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), (float)(y * Game1.tileSize - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height)))), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f)); + } + if (this.heldObject != null) + { + if (this.heldObject is ModularSeeds) + { + (this.heldObject as ModularSeeds).drawAtNonTileSpot(spriteBatch, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - (this.heldObject as ModularSeeds).sourceRect.Height * Game1.pixelZoom - Game1.tileSize / 4))), (float)(this.boundingBox.Bottom - 7) / 10000f, alpha); + return; + } + spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))) + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * 5 / 6)), new Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, (float)this.boundingBox.Bottom / 10000f); + spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))), new Rectangle?(Game1.currentLocation.getSourceRectForObject(this.heldObject.ParentSheetIndex)), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f); + } + } + + public override void drawAtNonTileSpot(SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1f) + { + spriteBatch.Draw(TextureSheet, location, new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth); + } + + public override Item getOne() + { + ModularSeeds ExtraSeeds = new ModularSeeds(this.parentSheetIndex, this.texturePath, this.dataFilePath,this.cropTextureFilePath,this.cropDataFilePath,this.cropObjectTextureFilePath,this.cropObjectDataFilePath); + /* + drawPosition = this.drawPosition; + defaultBoundingBox = this.defaultBoundingBox; + boundingBox = this.boundingBox; + currentRotation = this.currentRotation - 1; + rotations = this.rotations; + rotate(); + */ + return ExtraSeeds; + } + + public override string getCategoryName() + { + return "Modular Seeds"; + // return base.getCategoryName(); + } + + public override Color getCategoryColor() + { + return Color.Turquoise; + } + + + public override int maximumStackSize() + { + return base.maximumStackSize(); + } + + public ModularCrop parseCropInfo(int seedIndex) + { + ModularCrop c = new ModularCrop(); + Log.AsyncC(this.cropDataFilePath); + Dictionary dictionary = ModCore.ModHelper.Content.Load>(this.cropDataFilePath); //Game1.content.Load>("Data\\Crops"); + + if (dictionary.ContainsKey(seedIndex)) + { + string[] array = dictionary[seedIndex].Split(new char[] + { + '/' + }); + string[] array2 = array[0].Split(new char[] + { + ' ' + }); + for (int i = 0; i < array2.Length; i++) + { + c.phaseDays.Add(Convert.ToInt32(array2[i])); + } + c.phaseDays.Add(99999); + string[] array3 = array[1].Split(new char[] + { + ' ' + }); + for (int j = 0; j < array3.Length; j++) + { + c.seasonsToGrowIn.Add(array3[j]); + } + c.rowInSpriteSheet = Convert.ToInt32(array[2]); + c.indexOfHarvest = Convert.ToInt32(array[3]); + c.regrowAfterHarvest = Convert.ToInt32(array[4]); + c.harvestMethod = Convert.ToInt32(array[5]); + string[] array4 = array[6].Split(new char[] + { + ' ' + }); + if (array4.Length != 0 && array4[0].Equals("true")) + { + c.minHarvest = Convert.ToInt32(array4[1]); + c.maxHarvest = Convert.ToInt32(array4[2]); + c.maxHarvestIncreasePerFarmingLevel = Convert.ToInt32(array4[3]); + c.chanceForExtraCrops = Convert.ToDouble(array4[4]); + } + c.raisedSeeds = Convert.ToBoolean(array[7]); + string[] array5 = array[8].Split(new char[] + { + ' ' + }); + if (array5.Length != 0 && array5[0].Equals("true")) + { + List list = new List(); + for (int k = 1; k < array5.Length; k += 3) + { + list.Add(new Color((int)Convert.ToByte(array5[k]), (int)Convert.ToByte(array5[k + 1]), (int)Convert.ToByte(array5[k + 2]))); + } + Random random = new Random(seedIndex * 1000 + Game1.timeOfDay + Game1.dayOfMonth); + c.tintColor = list[random.Next(list.Count)]; + c.programColored = true; + } + c.flip = (Game1.random.NextDouble() < 0.5); + } + if (c.rowInSpriteSheet == 23) + { + c.whichForageCrop = seedIndex; + } + + return c; + } + + } +} diff --git a/GeneralMods/AdditionalCropsFramework/PlanterBox.cs b/GeneralMods/AdditionalCropsFramework/PlanterBox.cs new file mode 100644 index 00000000..ced7da70 --- /dev/null +++ b/GeneralMods/AdditionalCropsFramework/PlanterBox.cs @@ -0,0 +1,724 @@ +using AdditionalCropsFramework.Framework; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +using StardewModdingAPI; +using StardewValley; +using StardewValley.Locations; +using StardewValley.Menus; +using StardewValley.Objects; +using System; +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace AdditionalCropsFramework +{ + /// + /// Original Stardew Furniture Class but rewritten to be placed anywhere. + /// + public class PlanterBox : CoreObject + { + + + public new int price; + + public int Decoration_type; + + public int rotations; + + public int currentRotation; + + private int sourceIndexOffset; + + public Vector2 drawPosition; + + public Rectangle sourceRect; + + public Rectangle defaultSourceRect; + + public Rectangle defaultBoundingBox; + + public string description; + + public Texture2D TextureSheet; + + public new bool flipped; + + [XmlIgnore] + public bool flaggedForPickUp; + + private bool lightGlowAdded; + + public string texturePath; + public string dataPath; + + public bool IsSolid; + + public Crop crop; + public ModularCrop modularCrop; + public bool isWatered; + + public override string Name + { + get + { + return this.name; + } + } + + public PlanterBox() + { + this.updateDrawPosition(); + } + + public PlanterBox(bool f) + { + //does nothng + } + + public PlanterBox(int which, Vector2 tile, bool isRemovable = true, int price = 0, bool isSolid = false) + { + removable = isRemovable; + // this.thisType = GetType(); + this.tileLocation = tile; + this.InitializeBasics(0, tile); + if (TextureSheet == null) + { + TextureSheet = ModCore.ModHelper.Content.Load("PlanterBox.png"); //Game1.content.Load("TileSheets\\furniture"); + texturePath = "PlanterBoxGraphic"; + } + dataPath = ""; + + this.name = "Planter Box"; + this.description = "A planter box that can be used to grow many different crops in many different locations."; + this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 1, 1); + + this.defaultSourceRect.Width = 1; + this.defaultSourceRect.Height = 1; + this.sourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16); + this.defaultSourceRect = this.sourceRect; + + + this.defaultBoundingBox = new Rectangle((int)this.tileLocation.X, (int)this.tileLocation.Y, 1, 1); + + this.defaultBoundingBox.Width = 1; + this.defaultBoundingBox.Height = 1; + IsSolid = isSolid; + if (isSolid == true) + { + this.boundingBox = new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize); + } + else + { + this.boundingBox = new Rectangle(int.MinValue, (int)this.tileLocation.Y * Game1.tileSize, 0, 0); //Throw the bounding box away as far as possible. + } + this.defaultBoundingBox = this.boundingBox; + this.updateDrawPosition(); + this.price = price; + this.parentSheetIndex = which; + } + + + public PlanterBox(int which, Vector2 tile, string ObjectTexture, bool isRemovable = true, int price = 0, bool isSolid = false) + { + removable = isRemovable; + // this.thisType = GetType(); + this.tileLocation = tile; + this.InitializeBasics(0, tile); + if (TextureSheet == null) + { + TextureSheet = ModCore.ModHelper.Content.Load(ObjectTexture); //Game1.content.Load("TileSheets\\furniture"); + texturePath = ObjectTexture; + } + + + this.name = "Planter Box"; + this.description = "A planter box that can be used to grow many different crops in many different locations."; + this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 1, 1); + + this.defaultSourceRect.Width = 1; + this.defaultSourceRect.Height = 1; + this.sourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16); + this.defaultSourceRect = this.sourceRect; + + + this.defaultBoundingBox = new Rectangle((int)this.tileLocation.X, (int)this.tileLocation.Y, 1, 1); + + this.defaultBoundingBox.Width = 1; + this.defaultBoundingBox.Height = 1; + IsSolid = isSolid; + if (isSolid == true) + { + this.boundingBox = new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize); + } + else + { + this.boundingBox = new Rectangle(int.MinValue, (int)this.tileLocation.Y * Game1.tileSize, 0, 0); //Throw the bounding box away as far as possible. + } + this.defaultBoundingBox = this.boundingBox; + this.updateDrawPosition(); + this.price = price; + this.parentSheetIndex = which; + } + + + public PlanterBox(int which, Vector2 tile, string ObjectTexture, string DataPath, bool isRemovable = true, bool isSolid = false) + { + removable = isRemovable; + // this.thisType = GetType(); + this.tileLocation = tile; + this.InitializeBasics(0, tile); + TextureSheet = ModCore.ModHelper.Content.Load(ObjectTexture); //Game1.content.Load("TileSheets\\furniture"); + texturePath = ObjectTexture; + Dictionary dictionary = ModCore.ModHelper.Content.Load>(DataPath); + dataPath = DataPath; + string s=""; + dictionary.TryGetValue(which,out s); + string[] array = s.Split('/'); + this.name = array[0]; + this.description = array[1]; + this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 1, 1); + + this.defaultSourceRect.Width = 1; + this.defaultSourceRect.Height = 1; + this.sourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16); + this.defaultSourceRect = this.sourceRect; + + + this.defaultBoundingBox = new Rectangle((int)this.tileLocation.X, (int)this.tileLocation.Y, 1, 1); + + this.defaultBoundingBox.Width = 1; + this.defaultBoundingBox.Height = 1; + IsSolid = isSolid; + if (isSolid == true) + { + this.boundingBox = new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize); + } + else + { + this.boundingBox = new Rectangle(int.MinValue, (int)this.tileLocation.Y * Game1.tileSize, 0, 0); //Throw the bounding box away as far as possible. + } + this.defaultBoundingBox = this.boundingBox; + this.updateDrawPosition(); + this.price =Convert.ToInt32(array[2]); + this.parentSheetIndex = which; + } + + + public override string getDescription() + { + return this.description; + } + + public override bool performDropDownAction(StardewValley.Farmer who) + { + this.resetOnPlayerEntry((who == null) ? Game1.currentLocation : who.currentLocation); + return false; + } + + public override void hoverAction() + { + base.hoverAction(); + if (!Game1.player.isInventoryFull()) + { + Game1.mouseCursor = 2; + } + } + + public override bool checkForAction(StardewValley.Farmer who, bool justCheckingForActivity = false) + { + var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); + if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) + { + // Game1.showRedMessage("YOOO"); + //do some stuff when the right button is down + // rotate(); + if (Game1.player.ActiveObject == null) return false; + if (Game1.player.ActiveObject is ModularSeeds || Game1.player.ActiveObject.getCategoryName() == "Modular Seeds") + { + this.plantModdedCrop((Game1.player.ActiveObject as ModularSeeds)); + Log.AsyncO("Modded seeds"); + } + if (Game1.player.ActiveObject.getCategoryName() == "Seeds" || Game1.player.ActiveObject.getCategoryName() == "seeds") + { + this.plantRegularCrop(); + Log.AsyncY("regular seeds"); + } + + if(Game1.player.getToolFromName(Game1.player.CurrentItem.Name) is StardewValley.Tools.WateringCan) + { + //Do a thing. + } + + + Game1.playSound("coin"); + return true; + } + else + { + //Game1.showRedMessage("CRY"); + } + + if (justCheckingForActivity) + { + return true; + } + if (this.parentSheetIndex == 1402) + { + Game1.activeClickableMenu = new Billboard(false); + } + return this.clicked(who); //check for left clicked action. + } + + public void plantModdedCrop(ModularSeeds seeds) + { + this.modularCrop = new ModularCrop(seeds.parentSheetIndex, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y, seeds.cropDataFilePath, seeds.cropTextureFilePath, seeds.cropObjectTextureFilePath, seeds.cropObjectDataFilePath); + // Game1.player.reduceActiveItemByOne(); + Game1.playSound("dirtyHit"); + } + + public void plantRegularCrop() + { + this.crop = new Crop(Game1.player.ActiveObject.parentSheetIndex, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y); + // Game1.player.reduceActiveItemByOne(); + Game1.playSound("dirtyHit"); + } + + + public override bool clicked(StardewValley.Farmer who) + { + + if (removable == false) return false; + // Game1.showRedMessage("THIS IS CLICKED!!!"); + Game1.haltAfterCheck = false; + if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null) + { + // Game1.showRedMessage("Why1?"); + return false; + } + if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is PlanterBox))) + { + if (Game1.player.currentLocation is FarmHouse) + { + // Game1.showRedMessage("Why2?"); + // this.heldObject = new PlanterBox(parentSheetIndex, Vector2.Zero); + Utilities.addItemToInventoryAndCleanTrackedList(this); + this.flaggedForPickUp = true; + this.thisLocation = null; + return true; + } + else + { + // return true; + + this.flaggedForPickUp = true; + if (this is TV) + { + this.heldObject = new TV(parentSheetIndex, Vector2.Zero); + } + else + { + // this.heldObject = new PlanterBox(parentSheetIndex, Vector2.Zero); + Utilities.addItemToInventoryAndCleanTrackedList(this); + // this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); + // this.heldObject = null; + Game1.playSound("coin"); + this.thisLocation = null; + return true; + } + + } + } + if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) + { + // Game1.showRedMessage("Why3?"); + this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); + this.heldObject = null; + Utilities.addItemToInventoryAndCleanTrackedList(this); + Game1.playSound("coin"); + this.thisLocation = null; + return true; + } + + + + return false; + } + + public override void DayUpdate(GameLocation location) + { + base.DayUpdate(location); + this.lightGlowAdded = false; + if (!Game1.isDarkOut() || (Game1.newDay && !Game1.isRaining)) + { + this.removeLights(location); + return; + } + this.addLights(location); + } + + public void resetOnPlayerEntry(GameLocation environment) + { + this.removeLights(environment); + if (Game1.isDarkOut()) + { + this.addLights(environment); + } + } + + public override bool performObjectDropInAction(StardewValley.Object dropIn, bool probe, StardewValley.Farmer who) + { + if ((this.Decoration_type == 11 || this.Decoration_type == 5) && this.heldObject == null && !dropIn.bigCraftable && (!(dropIn is PlanterBox) || ((dropIn as PlanterBox).getTilesWide() == 1 && (dropIn as PlanterBox).getTilesHigh() == 1))) + { + this.heldObject = (StardewValley.Object)dropIn.getOne(); + this.heldObject.tileLocation = this.tileLocation; + this.heldObject.boundingBox.X = this.boundingBox.X; + this.heldObject.boundingBox.Y = this.boundingBox.Y; + // Log.AsyncO(getDefaultBoundingBoxForType((dropIn as PlanterBox).Decoration_type)); + this.heldObject.performDropDownAction(who); + if (!probe) + { + Game1.playSound("woodyStep"); + // Log.AsyncC("HUH?"); + if (who != null) + { + who.reduceActiveItemByOne(); + } + } + return true; + } + return false; + } + + private void addLights(GameLocation environment) + { + // this.lightSource.lightTexture = Game1.content.Load("LooseSprites\\Lighting\\lantern"); + + if (this.Decoration_type == 7) + { + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightSource == null) + { + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, Color.Black, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + Game1.currentLightSources.Add(this.lightSource); + return; + } + } + else if (this.Decoration_type == 13) + { + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightGlowAdded) + { + environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); + this.lightGlowAdded = false; + } + } + } + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + if (Game1.isDarkOut()) + { + this.addLights(environment); + } + else + { + this.removeLights(environment); + } + return false; + } + + public override void performRemoveAction(Vector2 tileLocation, GameLocation environment) + { + this.removeLights(environment); + if (this.Decoration_type == 13 && this.lightGlowAdded) + { + environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); + this.lightGlowAdded = false; + } + base.performRemoveAction(tileLocation, environment); + } + public bool isGroundFurniture() + { + return this.Decoration_type != 13 && this.Decoration_type != 6 && this.Decoration_type != 13; + } + + public override bool canBeGivenAsGift() + { + return false; + } + + public override bool canBePlacedHere(GameLocation l, Vector2 tile) + { + if ((l is FarmHouse)) + { + for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++) + { + for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++) + { + Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize; + vector.X += (float)(Game1.tileSize / 2); + vector.Y += (float)(Game1.tileSize / 2); + foreach (KeyValuePair something in l.objects) + { + StardewValley.Object obj = something.Value; + if ((obj.GetType()).ToString().Contains("PlanterBox")) + { + PlanterBox current = (PlanterBox)obj; + if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1) + { + bool result = true; + return result; + } + if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y)) + { + bool result = false; + return result; + } + } + } + } + } + return base.canBePlacedHere(l, tile); + } + else + { + // Game1.showRedMessage("NOT FARMHOUSE"); + for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++) + { + for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++) + { + Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize; + vector.X += (float)(Game1.tileSize / 2); + vector.Y += (float)(Game1.tileSize / 2); + /* + foreach (PlanterBox current in (l as FarmHouse).PlanterBox) + { + if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1) + { + bool result = true; + return result; + } + if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y)) + { + bool result = false; + return result; + } + } + */ + } + } + return base.canBePlacedHere(l, tile); + } + } + + public void updateDrawPosition() + { + this.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height))); + } + + public int getTilesWide() + { + return this.boundingBox.Width / Game1.tileSize; + } + + public int getTilesHigh() + { + return this.boundingBox.Height / Game1.tileSize; + } + + public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null) + { + + Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); + + + this.tileLocation = new Vector2((float)point.X, (float)point.Y); + bool flag = false; + + if (this.IsSolid) + { + this.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); + } + else + { + this.boundingBox = new Rectangle(int.MinValue, y / Game1.tileSize * Game1.tileSize, 0, 0); + } + /* + foreach (Furniture current2 in (location as DecoratableLocation).furniture) + { + if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox)) + { + current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); + bool result = true; + return result; + } + } + */ + using (List.Enumerator enumerator3 = location.getFarmers().GetEnumerator()) + { + while (enumerator3.MoveNext()) + { + if (enumerator3.Current.GetBoundingBox().Intersects(this.boundingBox)) + { + Game1.showRedMessage("Can't place on top of a person."); + bool result = false; + return result; + } + } + } + this.updateDrawPosition(); + + bool f=Utilities.placementAction(this, location, x, y, who); + this.thisLocation = Game1.player.currentLocation; + return f; + // Game1.showRedMessage("Can only be placed in House"); + // return false; + } + + public override bool isPlaceable() + { + return true; + } + + public override Rectangle getBoundingBox(Vector2 tileLocation) + { + return this.boundingBox; + } + + public override int salePrice() + { + return this.price; + } + + public override int maximumStackSize() + { + return 1; + } + + public override int getStack() + { + return this.stack; + } + + public override int addToStack(int amount) + { + return 1; + } + + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f) + { + if (f.ActiveObject.bigCraftable) + { + spriteBatch.Draw(this.TextureSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(StardewValley.Object.getSourceRectForBigCraftable(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + return; + } + spriteBatch.Draw(this.TextureSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + if (f.ActiveObject != null && f.ActiveObject.Name.Contains("=")) + { + spriteBatch.Draw(this.TextureSheet, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + if (Math.Abs(Game1.starCropShimmerPause) <= 0.05f && Game1.random.NextDouble() < 0.97) + { + return; + } + Game1.starCropShimmerPause += 0.04f; + if (Game1.starCropShimmerPause >= 0.8f) + { + Game1.starCropShimmerPause = -0.8f; + } + } + //base.drawWhenHeld(spriteBatch, objectPosition, f); + } + + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber) + { + spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(this.defaultSourceRect), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * (3) * scaleSize, SpriteEffects.None, layerDepth); + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + if (x == -1) + { + spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f)); + } + else + { + spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y*Game1.tileSize)), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + } + if (this.heldObject != null) + { + if (this.heldObject is PlanterBox) + { + (this.heldObject as PlanterBox).drawAtNonTileSpot(spriteBatch, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - (this.heldObject as PlanterBox).sourceRect.Height * Game1.pixelZoom - Game1.tileSize / 4))), (float)(this.boundingBox.Bottom - 7) / 10000f, alpha); + return; + } + spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))) + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * 5 / 6)), new Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, (float)this.boundingBox.Bottom / 10000f); + spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))), new Rectangle?(Game1.currentLocation.getSourceRectForObject(this.heldObject.ParentSheetIndex)), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f); + } + this.drawCrops(Game1.spriteBatch, (int)this.tileLocation.X, (int)this.tileLocation.Y); + + } + public void drawCrops(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + if (this.thisLocation != null) + { + if (this.modularCrop != null) + { + this.modularCrop.draw(Game1.spriteBatch, this.tileLocation, Color.White, 0); + Log.AsyncM("draw a modular crop now"); + } + Log.AsyncC("wait WTF"); + + if (this.crop != null) + { + this.crop.draw(Game1.spriteBatch, this.tileLocation, Color.White, 0); + Log.AsyncG("COWS GO MOO"); + } + } + else Log.AsyncM("I DONT UNDERSTAND"); + } + + public void drawAtNonTileSpot(SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1f) + { + spriteBatch.Draw(TextureSheet, location, new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth); + } + + public override Item getOne() + { + + if (this.dataPath == "") return new PlanterBox(this.parentSheetIndex, this.tileLocation); + else return new PlanterBox(this.parentSheetIndex, this.tileLocation,this.texturePath,this.dataPath); + + /* + drawPosition = this.drawPosition; + defaultBoundingBox = this.defaultBoundingBox; + boundingBox = this.boundingBox; + currentRotation = this.currentRotation - 1; + rotations = this.rotations; + rotate(); + */ + } + + public override string getCategoryName() + { + return "Planter Box"; + // return base.getCategoryName(); + } + + public override Color getCategoryColor() + { + return Color.Purple; + } + } +} \ No newline at end of file diff --git a/GeneralMods/AdditionalCropsFramework/Properties/AssemblyInfo.cs b/GeneralMods/AdditionalCropsFramework/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..8d1c7d08 --- /dev/null +++ b/GeneralMods/AdditionalCropsFramework/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("AdditionalCropsFramework")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AdditionalCropsFramework")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c5f88d48-ea20-40cd-91e2-c8725dc11795")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/AdditionalCropsFramework/manifest.json b/GeneralMods/AdditionalCropsFramework/manifest.json new file mode 100644 index 00000000..98e99a23 --- /dev/null +++ b/GeneralMods/AdditionalCropsFramework/manifest.json @@ -0,0 +1,14 @@ +{ + "Name": "AdditionalCropsFramework", + "Author": "Alpha_Omegasis", + "Version": { + "MajorVersion": 1, + "MinorVersion": 0, + "PatchVersion": 0, + "Build": null + }, + "MinimumApiVersion": "1.15", + "Description": "Allows additional crops to be added to their own .xnb files without having to override crop.xnb!", + "UniqueID": "Omegasis.AdditionalCropsFramework", + "EntryDll": "AdditionalCropsFramework.dll" +} diff --git a/GeneralMods/AdditionalCropsFramework/packages.config b/GeneralMods/AdditionalCropsFramework/packages.config new file mode 100644 index 00000000..5a0c3d1f --- /dev/null +++ b/GeneralMods/AdditionalCropsFramework/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/GeneralMods/StardewMods.sln b/GeneralMods/StardewMods.sln index df30bd96..11491706 100644 --- a/GeneralMods/StardewMods.sln +++ b/GeneralMods/StardewMods.sln @@ -41,11 +41,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "~metadata", "~metadata", "{ ProjectSection(SolutionItems) = preProject deploy.targets = deploy.targets GlobalAssemblyInfo.cs = GlobalAssemblyInfo.cs + AdditionalCropsFramework\ModularCropObject.cs = AdditionalCropsFramework\ModularCropObject.cs ..\README.md = ..\README.md EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleSoundManager", "SimpleSoundManager\SimpleSoundManager.csproj", "{7B1E9A54-ED9E-47AA-BBAA-98A6E7CB527A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdditionalCropsFramework", "AdditionalCropsFramework\AdditionalCropsFramework.csproj", "{C5F88D48-EA20-40CD-91E2-C8725DC11795}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -124,6 +127,10 @@ Global {7B1E9A54-ED9E-47AA-BBAA-98A6E7CB527A}.Debug|Any CPU.Build.0 = Debug|Any CPU {7B1E9A54-ED9E-47AA-BBAA-98A6E7CB527A}.Release|Any CPU.ActiveCfg = Release|Any CPU {7B1E9A54-ED9E-47AA-BBAA-98A6E7CB527A}.Release|Any CPU.Build.0 = Release|Any CPU + {C5F88D48-EA20-40CD-91E2-C8725DC11795}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5F88D48-EA20-40CD-91E2-C8725DC11795}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5F88D48-EA20-40CD-91E2-C8725DC11795}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5F88D48-EA20-40CD-91E2-C8725DC11795}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Revitalize/Revitalize/Revitalize/Aesthetics/Draw/ThingsToDraw.cs b/Revitalize/Revitalize/Revitalize/Aesthetics/Draw/ThingsToDraw.cs index b6475503..02a90440 100644 --- a/Revitalize/Revitalize/Revitalize/Aesthetics/Draw/ThingsToDraw.cs +++ b/Revitalize/Revitalize/Revitalize/Aesthetics/Draw/ThingsToDraw.cs @@ -42,9 +42,9 @@ namespace Revitalize.Draw { //Log.Async(i); //i++; - if (v is ModularDecoration && v.thisLocation==Game1.player.currentLocation) + if (v is Decoration && v.thisLocation==Game1.player.currentLocation) { - if (v.boundingBox.Height == 0 && v.boundingBox.Width == 0) (v as ModularDecoration).drawInfront(b, (int)v.tileLocation.X, (int)v.tileLocation.Y); + if (v.boundingBox.Height == 0 && v.boundingBox.Width == 0) (v as Decoration).drawInfront(b, (int)v.tileLocation.X, (int)v.tileLocation.Y); } } b.End();