The experiment failed. It looks like I won't be able to do perfect object placement unless I figure something else out.

This commit is contained in:
Joshua Navarro 2019-01-09 18:05:03 -08:00
parent 198a908c01
commit c329613f09
6 changed files with 103 additions and 5 deletions

View File

@ -56,7 +56,7 @@ namespace Revitalize.Framework.Objects
this.facingDirection = Enums.Direction.Down; 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.name = name;
this.description = description; this.description = description;

View File

@ -75,6 +75,7 @@ namespace Revitalize.Framework.Objects
public override Rectangle getBoundingBox(Vector2 tileLocation) public override Rectangle getBoundingBox(Vector2 tileLocation)
{ {
//Revitalize.ModCore.log(System.Environment.StackTrace);
return this.info.ignoreBoundingBox return this.info.ignoreBoundingBox
? new Rectangle(int.MinValue, int.MinValue, 0, 0) ? new Rectangle(int.MinValue, int.MinValue, 0, 0)
: base.getBoundingBox(tileLocation); : base.getBoundingBox(tileLocation);

View File

@ -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;
}
}
}

View File

@ -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
{
/// <summary>
/// Deals with calculating bounding boxes on objects.
/// </summary>
public class BoundingBoxInfo
{
/// <summary>
/// The number of tiles in size for this bounding box;
/// </summary>
public Rectangle tileSize;
/// <summary>
/// The pixel offset for this bounding box dimensions.
/// </summary>
public Rectangle pixelOffsets;
public BoundingBoxInfo()
{
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="TileSize">How big in tiles this bounding box is.</param>
public BoundingBoxInfo(Rectangle TileSize)
{
this.tileSize = TileSize;
this.pixelOffsets = new Rectangle(0, 0, 0, 0);
}
/// <summary>
/// Constructor.
/// </summary>
/// <param name="TileSize">How big in tiles this bounding box is.</param>
/// <param name="PixelOffsets">The offset in size and position in pixels.</param>
public BoundingBoxInfo(Rectangle TileSize,Rectangle PixelOffsets)
{
this.tileSize = TileSize;
this.pixelOffsets = PixelOffsets;
}
}
}

View File

@ -3,6 +3,7 @@ using System.IO;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using PyTK.Extensions; using PyTK.Extensions;
using PyTK.Types; using PyTK.Types;
using Revitalize.Framework;
using Revitalize.Framework.Crafting; using Revitalize.Framework.Crafting;
using Revitalize.Framework.Environment; using Revitalize.Framework.Environment;
using Revitalize.Framework.Graphics; using Revitalize.Framework.Graphics;
@ -144,6 +145,7 @@ namespace Revitalize
private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) 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 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 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)); 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<Item, int>() Recipe pie = new Recipe(new Dictionary<Item, int>()
{ {
[bigObject] = 1 [bigObject] = 1
}, new KeyValuePair<Item, int>(new Furniture(3, Vector2.Zero), 1),new StatCost(100,50,0,0)); }, new KeyValuePair<Item, int>(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)) 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<string, List<Animation>>() { 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<string, List<Animation>>() {
@ -248,10 +250,10 @@ namespace Revitalize
new Animation(new Rectangle(48,16,16,16)) 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, 0), chairTop);
oakChair.addComponent(new Vector2(0, 1), chairBottom); oakChair.addComponent(new Vector2(0, 1), chairBottom);
@ -264,11 +266,19 @@ namespace Revitalize
{ {
//pie.craft(); //pie.craft();
} }
} }
public static void log(object message) public static void log(object message)
{ {
ModMonitor.Log(message.ToString()); ModMonitor.Log(message.ToString());
} }
public static string generatePlaceholderString()
{
return "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048";
}
} }
} }

View File

@ -61,6 +61,7 @@
<Compile Include="Framework\Objects\CustomObject.cs" /> <Compile Include="Framework\Objects\CustomObject.cs" />
<Compile Include="Framework\Objects\Furniture\ChairMultiTiledObject.cs" /> <Compile Include="Framework\Objects\Furniture\ChairMultiTiledObject.cs" />
<Compile Include="Framework\Objects\Furniture\ChairTileComponent.cs" /> <Compile Include="Framework\Objects\Furniture\ChairTileComponent.cs" />
<Compile Include="Framework\Objects\Furniture\CustomFurniture.cs" />
<Compile Include="Framework\Objects\Furniture\FurnitureTileComponent.cs" /> <Compile Include="Framework\Objects\Furniture\FurnitureTileComponent.cs" />
<Compile Include="Framework\Objects\InformationFiles\Furniture\ChairInformation.cs" /> <Compile Include="Framework\Objects\InformationFiles\Furniture\ChairInformation.cs" />
<Compile Include="Framework\Objects\InformationFiles\Furniture\FurnitureInformation.cs" /> <Compile Include="Framework\Objects\InformationFiles\Furniture\FurnitureInformation.cs" />
@ -69,6 +70,7 @@
<Compile Include="Framework\Player\Managers\MagicManager.cs" /> <Compile Include="Framework\Player\Managers\MagicManager.cs" />
<Compile Include="Framework\Player\Managers\SittingInfo.cs" /> <Compile Include="Framework\Player\Managers\SittingInfo.cs" />
<Compile Include="Framework\Player\PlayerInfo.cs" /> <Compile Include="Framework\Player\PlayerInfo.cs" />
<Compile Include="Framework\Utilities\BoundingBoxInfo.cs" />
<Compile Include="Framework\Utilities\InventoryManager.cs" /> <Compile Include="Framework\Utilities\InventoryManager.cs" />
<Compile Include="ModCore.cs" /> <Compile Include="ModCore.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />