diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs
index 094af3cb..207feb90 100644
--- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs
+++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs
@@ -2,6 +2,7 @@
using Microsoft.Xna.Framework.Graphics;
using PyTK.CustomElementHandler;
using Revitalize.Framework.Graphics.Animations;
+using Revitalize.Framework.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -31,6 +32,8 @@ namespace Revitalize.Framework.Objects
public bool ignoreBoundingBox;
+ public InventoryManager inventory;
+
public BasicItemInformation() : base()
{
name = "";
@@ -46,9 +49,10 @@ namespace Revitalize.Framework.Objects
this.animationManager = null;
this.drawPosition = Vector2.Zero;
this.drawColor = Color.White;
+ this.inventory = new InventoryManager();
}
- 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):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):base(id,data,texture,color,tileIndex,bigCraftable,type,craftingData)
{
this.name = name;
this.description = description;
@@ -88,6 +92,14 @@ namespace Revitalize.Framework.Objects
this.ignoreBoundingBox = ignoreBoundingBox;
recreateDataString();
+ if (Inventory == null)
+ {
+ this.inventory = new InventoryManager();
+ }
+ else
+ {
+ this.inventory = Inventory;
+ }
}
public void recreateDataString()
diff --git a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs
new file mode 100644
index 00000000..93fd67af
--- /dev/null
+++ b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs
@@ -0,0 +1,210 @@
+using StardewValley;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Revitalize.Framework.Utilities
+{
+ ///
+ /// Handles dealing with objects.
+ ///
+ public class InventoryManager
+ {
+ ///
+ /// How many items the inventory can hold.
+ ///
+ public int capacity;
+
+ ///
+ /// The hard uper limit in case of upgrading or resizing.
+ ///
+ private int maxCapacity;
+
+ ///
+ /// The hard uper limit for # of items to be held in case of upgrading or resizing.
+ ///
+ public int MaxCapacity
+ {
+ get
+ {
+ return maxCapacity;
+ }
+ }
+
+ ///
+ /// How many items are currently stored in the inventory.
+ ///
+ public int ItemCount
+ {
+ get
+ {
+ return this.items.Count;
+ }
+ }
+
+ ///
+ /// The actual contents of the inventory.
+ ///
+ public List- items;
+
+ ///
+ /// Checks if the inventory is full or not.
+ ///
+ public bool IsFull
+ {
+ get
+ {
+ return this.ItemCount >= this.capacity;
+ }
+ }
+
+ public InventoryManager()
+ {
+ this.capacity = 0;
+ setMaxLimit(0);
+ this.items = new List
- ();
+ }
+
+ ///
+ /// Constructor.
+ ///
+ ///
+ public InventoryManager(List
- items)
+ {
+ this.capacity = Int32.MaxValue;
+ this.setMaxLimit(Int32.MaxValue);
+ this.items = items;
+ }
+
+ ///
+ /// Constructor.
+ ///
+ ///
+ public InventoryManager(int capacity)
+ {
+ this.capacity = capacity;
+ this.maxCapacity = Int32.MaxValue;
+ this.items = new List
- ();
+ }
+
+ ///
+ /// Constructor.
+ ///
+ ///
+ ///
+ public InventoryManager(int capacity, int MaxCapacity)
+ {
+ this.capacity = capacity;
+ setMaxLimit(MaxCapacity);
+ this.items = new List
- ();
+ }
+
+ ///
+ /// Add the item to the inventory.
+ ///
+ ///
+ ///
+ public bool addItem(Item I)
+ {
+ if (IsFull)
+ {
+ return false;
+ }
+ else
+ {
+ foreach(Item self in this.items)
+ {
+ if (self.canStackWith(I))
+ {
+ self.addToStack(I.Stack);
+ return true;
+ }
+ }
+ this.items.Add(I);
+ return true;
+ }
+ }
+
+ ///
+ /// Gets a reference to the object IF it exists in the inventory.
+ ///
+ ///
+ ///
+ public Item getItem(Item I)
+ {
+ foreach(Item i in this.items)
+ {
+ if (I == i) return I;
+ }
+ return null;
+ }
+
+ ///
+ /// Get the item at the specific index.
+ ///
+ ///
+ ///
+ public Item getItemAtIndex(int Index)
+ {
+ return items[Index];
+ }
+
+ ///
+ /// Gets only one item from the stack.
+ ///
+ ///
+ ///
+ public Item getSingleItemFromStack(Item I)
+ {
+ if (I.Stack == 1)
+ {
+ return I;
+ }
+ else
+ {
+ I.Stack = I.Stack - 1;
+ return I.getOne();
+ }
+ }
+
+ ///
+ /// Empty the inventory.
+ ///
+ public void clear()
+ {
+ this.items.Clear();
+ }
+
+ ///
+ /// Empty the inventory.
+ ///
+ public void empty()
+ {
+ this.clear();
+ }
+
+ ///
+ /// Resize how many items can be held by this object.
+ ///
+ ///
+ public void resizeCapacity(int Amount)
+ {
+ if (this.capacity + Amount < this.maxCapacity)
+ {
+ this.capacity += Amount;
+ }
+ }
+
+ ///
+ /// Sets the upper limity of the capacity size for the inventory.
+ ///
+ ///
+ public void setMaxLimit(int amount)
+ {
+ this.maxCapacity = amount;
+ }
+
+ }
+}
diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs
index c8e6f9c4..78455f90 100644
--- a/GeneralMods/Revitalize/ModCore.cs
+++ b/GeneralMods/Revitalize/ModCore.cs
@@ -62,11 +62,11 @@ 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));
- 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));
- 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));
+ 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));
+ 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));
+ 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));
- MultiTiledObject bigObject= new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White,false));
+ MultiTiledObject bigObject= new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White,false,null));
bigObject.addComponent(new Vector2(0, 0), obj);
bigObject.addComponent(new Vector2(1, 0), obj2);
bigObject.addComponent(new Vector2(2, 0), obj3);
diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj
index 7c729339..018c0418 100644
--- a/GeneralMods/Revitalize/Revitalize.csproj
+++ b/GeneralMods/Revitalize/Revitalize.csproj
@@ -55,6 +55,7 @@
+