From c329613f09ee4788b494cec69debe87735b931cf Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Wed, 9 Jan 2019 18:05:03 -0800 Subject: [PATCH] The experiment failed. It looks like I won't be able to do perfect object placement unless I figure something else out. --- .../Framework/Objects/BasicItemInformation.cs | 2 +- .../Framework/Objects/CustomObject.cs | 1 + .../Objects/Furniture/CustomFurniture.cs | 32 +++++++++++ .../Framework/Utilities/BoundingBoxInfo.cs | 53 +++++++++++++++++++ GeneralMods/Revitalize/ModCore.cs | 18 +++++-- GeneralMods/Revitalize/Revitalize.csproj | 2 + 6 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Objects/Furniture/CustomFurniture.cs create mode 100644 GeneralMods/Revitalize/Framework/Utilities/BoundingBoxInfo.cs diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index eee605af..840e1337 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -56,7 +56,7 @@ namespace Revitalize.Framework.Objects this.facingDirection = Enums.Direction.Down; } - public BasicItemInformation(string name, string description, string categoryName, Color categoryColor, int edibility, int fragility, bool isLamp, int price, Vector2 TileLocation, bool canBeSetOutdoors, bool canBeSetIndoors, string id, string data, Texture2D texture, Color color, int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights) : base(id, data, texture, color, tileIndex, bigCraftable, type, craftingData) + public BasicItemInformation(string name, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, Vector2 TileLocation, bool canBeSetOutdoors, bool canBeSetIndoors, string id, string data, Texture2D texture, Color color, int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights) : base(id, data, texture, color, tileIndex, bigCraftable, type, craftingData) { this.name = name; this.description = description; diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 57793303..dcfed18e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -75,6 +75,7 @@ namespace Revitalize.Framework.Objects public override Rectangle getBoundingBox(Vector2 tileLocation) { + //Revitalize.ModCore.log(System.Environment.StackTrace); return this.info.ignoreBoundingBox ? new Rectangle(int.MinValue, int.MinValue, 0, 0) : base.getBoundingBox(tileLocation); diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/CustomFurniture.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/CustomFurniture.cs new file mode 100644 index 00000000..7ef18e8b --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/CustomFurniture.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Revitalize.Framework.Objects.InformationFiles.Furniture; + +namespace Revitalize.Framework.Objects.Furniture +{ + public class CustomFurniture:CustomObject + { + public FurnitureInformation furnitureInfo; + + + public CustomFurniture() : base() + { + + } + + public CustomFurniture(BasicItemInformation itemInfo, FurnitureInformation furnitureInfo) : base(itemInfo) + { + this.furnitureInfo = furnitureInfo; + } + + public CustomFurniture(BasicItemInformation itemInfo, Vector2 TileLocation, FurnitureInformation furnitureInfo) : base(itemInfo, TileLocation) + { + this.furnitureInfo = furnitureInfo; + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Utilities/BoundingBoxInfo.cs b/GeneralMods/Revitalize/Framework/Utilities/BoundingBoxInfo.cs new file mode 100644 index 00000000..baed3795 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Utilities/BoundingBoxInfo.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Revitalize.Framework.Objects; +using StardewValley; + +namespace Revitalize.Framework.Utilities +{ + /// + /// Deals with calculating bounding boxes on objects. + /// + public class BoundingBoxInfo + { + /// + /// The number of tiles in size for this bounding box; + /// + public Rectangle tileSize; + /// + /// The pixel offset for this bounding box dimensions. + /// + public Rectangle pixelOffsets; + + public BoundingBoxInfo() + { + + } + + /// + /// Constructor + /// + /// How big in tiles this bounding box is. + public BoundingBoxInfo(Rectangle TileSize) + { + this.tileSize = TileSize; + this.pixelOffsets = new Rectangle(0, 0, 0, 0); + } + + /// + /// Constructor. + /// + /// How big in tiles this bounding box is. + /// The offset in size and position in pixels. + public BoundingBoxInfo(Rectangle TileSize,Rectangle PixelOffsets) + { + this.tileSize = TileSize; + this.pixelOffsets = PixelOffsets; + } + + } +} diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 72e2ed43..1e91c4bf 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -3,6 +3,7 @@ using System.IO; using Microsoft.Xna.Framework; using PyTK.Extensions; using PyTK.Types; +using Revitalize.Framework; using Revitalize.Framework.Crafting; using Revitalize.Framework.Environment; using Revitalize.Framework.Graphics; @@ -144,6 +145,7 @@ namespace Revitalize private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { + MultiTiledComponent obj = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest", "YAY FUN!", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 0, 16, 16))), Color.Red, true, null, null)); MultiTiledComponent obj2 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest2", "SomeFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 16, 16, 16))), Color.Red, false, null, null)); MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red, false, null, null)); @@ -159,7 +161,7 @@ namespace Revitalize Recipe pie = new Recipe(new Dictionary() { [bigObject] = 1 - }, new KeyValuePair(new Furniture(3, Vector2.Zero), 1),new StatCost(100,50,0,0)); + }, new KeyValuePair(new Furniture(3, Vector2.Zero), 1), new StatCost(100, 50, 0, 0)); @@ -204,7 +206,7 @@ namespace Revitalize new Animation(new Rectangle(48,0,16,16)) } } - }, "Default_" + (int)Framework.Enums.Direction.Down), Color.White, true, new Framework.Utilities.InventoryManager(), new LightManager()),new Framework.Objects.InformationFiles.Furniture.ChairInformation(false)); + }, "Default_" + (int)Framework.Enums.Direction.Down), Color.White, true, new Framework.Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.ChairInformation(false)); Framework.Objects.Furniture.ChairTileComponent chairBottom = new Framework.Objects.Furniture.ChairTileComponent(new BasicItemInformation("Oak Chair", "A basic wooden chair", "Chairs", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Basic.OakChair", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Framework.Graphics.TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, false, typeof(Framework.Objects.Furniture.ChairTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 16, 16, 16)), new Dictionary>() { @@ -248,10 +250,10 @@ namespace Revitalize new Animation(new Rectangle(48,16,16,16)) } } - }, "Default_"+(int)Framework.Enums.Direction.Down), Color.White, false, new Framework.Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.ChairInformation(true)); + }, "Default_" + (int)Framework.Enums.Direction.Down), Color.White, false, new Framework.Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.ChairInformation(true)); - Framework.Objects.Furniture.ChairMultiTiledObject oakChair = new Framework.Objects.Furniture.ChairMultiTiledObject(new BasicItemInformation("Oak Chair","A wood chair you can place anywhere.","Chair",Color.White,-300,0,true,100,Vector2.Zero,true,true,"Omegasis.Revitalize.Furniture.OakChair", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048",TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture,Color.White,0,true,typeof(Revitalize.Framework.Objects.Furniture.ChairMultiTiledObject),null,new AnimationManager(),Color.White,false,new Framework.Utilities.InventoryManager(), new LightManager())); + Framework.Objects.Furniture.ChairMultiTiledObject oakChair = new Framework.Objects.Furniture.ChairMultiTiledObject(new BasicItemInformation("Oak Chair", "A wood chair you can place anywhere.", "Chair", Color.White, -300, 0, true, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.OakChair", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(Revitalize.Framework.Objects.Furniture.ChairMultiTiledObject), null, new AnimationManager(), Color.White, false, new Framework.Utilities.InventoryManager(), new LightManager())); oakChair.addComponent(new Vector2(0, 0), chairTop); oakChair.addComponent(new Vector2(0, 1), chairBottom); @@ -264,11 +266,19 @@ namespace Revitalize { //pie.craft(); } + } + + public static void log(object message) { ModMonitor.Log(message.ToString()); } + + public static string generatePlaceholderString() + { + return "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048"; + } } } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 04a97ab0..b080366e 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -61,6 +61,7 @@ + @@ -69,6 +70,7 @@ +