Added in storage furniture!
This commit is contained in:
parent
d6fa1672db
commit
1a6ee664b7
Binary file not shown.
After Width: | Height: | Size: 491 B |
|
@ -27,12 +27,14 @@ namespace Revitalize.Framework.Factories.Objects
|
||||||
public static string ChairFolder = Path.Combine("Data", "Furniture", "Chairs");
|
public static string ChairFolder = Path.Combine("Data", "Furniture", "Chairs");
|
||||||
public static string TablesFolder = Path.Combine("Data", "Furniture", "Tables");
|
public static string TablesFolder = Path.Combine("Data", "Furniture", "Tables");
|
||||||
public static string LampsFolder = Path.Combine("Data", "Furniture", "Lamps");
|
public static string LampsFolder = Path.Combine("Data", "Furniture", "Lamps");
|
||||||
|
public static string StorageFolder = Path.Combine("Data", "Furniture", "Storage");
|
||||||
|
|
||||||
public static void LoadFurnitureFiles()
|
public static void LoadFurnitureFiles()
|
||||||
{
|
{
|
||||||
LoadChairFiles();
|
LoadChairFiles();
|
||||||
LoadTableFiles();
|
LoadTableFiles();
|
||||||
LoadLampFiles();
|
LoadLampFiles();
|
||||||
|
LoadFurnitureStorageFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void LoadChairFiles()
|
private static void LoadChairFiles()
|
||||||
|
@ -52,6 +54,13 @@ namespace Revitalize.Framework.Factories.Objects
|
||||||
SerializeLamps();
|
SerializeLamps();
|
||||||
DeserializeLamps();
|
DeserializeLamps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void LoadFurnitureStorageFiles()
|
||||||
|
{
|
||||||
|
SerializeFurnitureStorageFiles();
|
||||||
|
DeserializeFurnitureStorageFiles();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serialize a lamp to a .json file for easier creation of like objects.
|
/// Serialize a lamp to a .json file for easier creation of like objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -364,6 +373,83 @@ namespace Revitalize.Framework.Factories.Objects
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void SerializeFurnitureStorageFiles()
|
||||||
|
{
|
||||||
|
StorageFurnitureTile upperLeft = new StorageFurnitureTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Storage.OakCabinet", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Cabinet", "Omegasis.Revitalize.Furniture.Storage.OakCabinet", "A beautiful oak cabinet to place objects inside of.", "Storage", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new Animation(0, 0, 16, 16)), Color.White, false, null, null));
|
||||||
|
StorageFurnitureTile upperRight = new StorageFurnitureTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Storage.OakCabinet", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Cabinet", "Omegasis.Revitalize.Furniture.Storage.OakCabinet", "A beautiful oak cabinet to place objects inside of.", "Storage", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new Animation(16, 0, 16, 16)), Color.White, false, null, null));
|
||||||
|
StorageFurnitureTile bottomLeft = new StorageFurnitureTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Storage.OakCabinet", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Cabinet", "Omegasis.Revitalize.Furniture.Storage.OakCabinet", "A beautiful oak cabinet to place objects inside of.", "Storage", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new Animation(0, 16, 16, 16)), Color.White, false, null, null));
|
||||||
|
StorageFurnitureTile bottomRight = new StorageFurnitureTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Storage.OakCabinet", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Cabinet", "Omegasis.Revitalize.Furniture.Storage.OakCabinet", "A beautiful oak cabinet to place objects inside of.", "Storage", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new Animation(16, 16, 16, 16)), Color.White, false, null, null));
|
||||||
|
|
||||||
|
|
||||||
|
StorageFurnitureOBJ obj = new StorageFurnitureOBJ(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Storage.OakCabinet", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Cabinet", "Omegasis.Revitalize.Furniture.Storage.OakCabinet", "A beautiful oak cabinet to place objects inside of.", "Storage", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Cabinet"), new Animation(16, 16, 16, 16)), Color.White, false, new InventoryManager(9), null));
|
||||||
|
|
||||||
|
FactoryInfo uL = new FactoryInfo(upperLeft);
|
||||||
|
FactoryInfo uR = new FactoryInfo(upperRight);
|
||||||
|
FactoryInfo bL = new FactoryInfo(bottomLeft);
|
||||||
|
FactoryInfo bR = new FactoryInfo(bottomRight);
|
||||||
|
FactoryInfo cabinet = new FactoryInfo(obj);
|
||||||
|
//TableMultiTiledObject obj = new TableMultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Tables.OakTable", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), typeof(TableMultiTiledObject), Color.White), new BasicItemInformation("Oak Table", "Omegasis.Revitalize.Furniture.Tables.OakTable", "A simple oak table to place things on.", "Tables", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), new AnimationManager(), Color.White, false, null, null));
|
||||||
|
|
||||||
|
//TableFactoryInfo uL = new TableFactoryInfo(upperLeft);
|
||||||
|
//TableFactoryInfo uR = new TableFactoryInfo(upperRight);
|
||||||
|
//TableFactoryInfo cL = new TableFactoryInfo(centerLeft);
|
||||||
|
//TableFactoryInfo cR = new TableFactoryInfo(centerRight);
|
||||||
|
//TableFactoryInfo bR = new TableFactoryInfo(bottomRight);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ModCore.Serializer.SerializeContentFile("OakCabinet_0_0", uL, Path.Combine(StorageFolder, "OakCabinet"));
|
||||||
|
ModCore.Serializer.SerializeContentFile("OakCabinet_1_0", uR, Path.Combine(StorageFolder, "OakCabinet"));
|
||||||
|
ModCore.Serializer.SerializeContentFile("OakCabinet_0_1", bL, Path.Combine(StorageFolder, "OakCabinet"));
|
||||||
|
ModCore.Serializer.SerializeContentFile("OakCabinet_1_1", bR, Path.Combine(StorageFolder, "OakCabinet"));
|
||||||
|
ModCore.Serializer.SerializeContentFile("OakCabinet", cabinet, Path.Combine(StorageFolder, "OakCabinet"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DeserializeFurnitureStorageFiles()
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", StorageFolder))) Directory.CreateDirectory(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", StorageFolder));
|
||||||
|
|
||||||
|
string[] directories = Directory.GetDirectories(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", StorageFolder));
|
||||||
|
foreach (string directory in directories)
|
||||||
|
{
|
||||||
|
|
||||||
|
string[] files = Directory.GetFiles(directory);
|
||||||
|
|
||||||
|
Dictionary<string, StorageFurnitureOBJ> chairObjects = new Dictionary<string, StorageFurnitureOBJ>();
|
||||||
|
|
||||||
|
//Deserialize container.
|
||||||
|
foreach (string file in files)
|
||||||
|
{
|
||||||
|
if ((Path.GetFileName(file)).Contains("_") == true) continue;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FactoryInfo factoryInfo = ModCore.Serializer.DeserializeContentFile<FactoryInfo>(file);
|
||||||
|
chairObjects.Add(Path.GetFileNameWithoutExtension(file), new StorageFurnitureOBJ(factoryInfo.PyTkData, factoryInfo.info));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Deseralize components
|
||||||
|
foreach (string file in files)
|
||||||
|
{
|
||||||
|
if ((Path.GetFileName(file)).Contains("_") == false) continue;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
string[] splits = Path.GetFileNameWithoutExtension(file).Split('_');
|
||||||
|
string name = splits[0];
|
||||||
|
Vector2 offset = new Vector2(Convert.ToInt32(splits[1]), Convert.ToInt32(splits[2]));
|
||||||
|
FactoryInfo info = ModCore.Serializer.DeserializeContentFile<FactoryInfo>(file);
|
||||||
|
chairObjects[name].addComponent(offset, new StorageFurnitureTile(info.PyTkData, info.info));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var v in chairObjects)
|
||||||
|
{
|
||||||
|
ModCore.customObjects.Add(v.Value.info.id, v.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static ChairMultiTiledObject GetChair(string name)
|
public static ChairMultiTiledObject GetChair(string name)
|
||||||
{
|
{
|
||||||
return (ChairMultiTiledObject)ModCore.GetObjectFromPool(name);
|
return (ChairMultiTiledObject)ModCore.GetObjectFromPool(name);
|
||||||
|
|
|
@ -140,8 +140,6 @@ namespace Revitalize.Framework.Objects.Extras
|
||||||
}
|
}
|
||||||
this.location = null;
|
this.location = null;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Game1.showRedMessage("NOOOOOOOO");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,146 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using PyTK.CustomElementHandler;
|
||||||
|
using StardewValley;
|
||||||
|
|
||||||
|
namespace Revitalize.Framework.Objects.Furniture
|
||||||
|
{
|
||||||
|
public class StorageFurnitureOBJ:MultiTiledObject
|
||||||
|
{
|
||||||
|
public StorageFurnitureOBJ() : base()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorageFurnitureOBJ(CustomObjectData PyTKData, BasicItemInformation Info) : base(PyTKData, Info)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorageFurnitureOBJ(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TilePosition) : base(PyTKData, Info, TilePosition)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorageFurnitureOBJ(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TilePosition, Dictionary<Vector2, MultiTiledComponent> Objects) : base(PyTKData, Info, TilePosition, Objects)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void rotate()
|
||||||
|
{
|
||||||
|
base.rotate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Item getOne()
|
||||||
|
{
|
||||||
|
Dictionary<Vector2, MultiTiledComponent> objs = new Dictionary<Vector2, MultiTiledComponent>();
|
||||||
|
foreach (var pair in this.objects)
|
||||||
|
{
|
||||||
|
objs.Add(pair.Key, (MultiTiledComponent)pair.Value.getOne());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return new StorageFurnitureOBJ(this.data, this.info, this.TileLocation, objs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
{
|
||||||
|
StorageFurnitureOBJ obj = (StorageFurnitureOBJ)Revitalize.ModCore.Serializer.DeserializeGUID<StorageFurnitureOBJ>(additionalSaveData["GUID"]);
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<Vector2, Guid> guids = new Dictionary<Vector2, Guid>();
|
||||||
|
|
||||||
|
foreach (KeyValuePair<Vector2, Guid> pair in obj.childrenGuids)
|
||||||
|
{
|
||||||
|
guids.Add(pair.Key, pair.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (KeyValuePair<Vector2, Guid> pair in guids)
|
||||||
|
{
|
||||||
|
obj.childrenGuids.Remove(pair.Key);
|
||||||
|
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
|
||||||
|
StorageFurnitureTile component = Revitalize.ModCore.Serializer.DeserializeGUID<StorageFurnitureTile>(pair.Value.ToString());
|
||||||
|
component.InitNetFields();
|
||||||
|
|
||||||
|
obj.addComponent(pair.Key, component);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
obj.InitNetFields();
|
||||||
|
|
||||||
|
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
|
||||||
|
{
|
||||||
|
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["GUID"], obj);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool canBePlacedHere(GameLocation l, Vector2 tile)
|
||||||
|
{
|
||||||
|
return base.canBePlacedHere(l, tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||||
|
{
|
||||||
|
if (!this.isPlaceable())
|
||||||
|
return;
|
||||||
|
int x = Game1.getOldMouseX() + Game1.viewport.X + (int)((pair.Value as MultiTiledComponent).offsetKey.X * Game1.tileSize);
|
||||||
|
int y = Game1.getOldMouseY() + Game1.viewport.Y + (int)((pair.Value as MultiTiledComponent).offsetKey.Y * Game1.tileSize);
|
||||||
|
if ((double)Game1.mouseCursorTransparency == 0.0)
|
||||||
|
{
|
||||||
|
x = ((int)Game1.player.GetGrabTile().X + (int)((pair.Value as MultiTiledComponent).offsetKey.X)) * 64;
|
||||||
|
y = ((int)Game1.player.GetGrabTile().Y + (int)((pair.Value as MultiTiledComponent).offsetKey.Y)) * 64;
|
||||||
|
}
|
||||||
|
if (Game1.player.GetGrabTile().Equals(Game1.player.getTileLocation()) && (double)Game1.mouseCursorTransparency == 0.0)
|
||||||
|
{
|
||||||
|
Vector2 translatedVector2 = Utility.getTranslatedVector2(Game1.player.GetGrabTile(), Game1.player.FacingDirection, 1f);
|
||||||
|
translatedVector2 += (pair.Value as MultiTiledComponent).offsetKey;
|
||||||
|
x = (int)translatedVector2.X * 64;
|
||||||
|
y = (int)translatedVector2.Y * 64;
|
||||||
|
}
|
||||||
|
bool flag = (pair.Value as MultiTiledComponent).canBePlacedHere(location, new Vector2(x / Game1.tileSize, y / Game1.tileSize));
|
||||||
|
spriteBatch.Draw(Game1.mouseCursors, new Vector2((float)(x / 64 * 64 - Game1.viewport.X), (float)(y / 64 * 64 - Game1.viewport.Y)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(flag ? 194 : 210, 388, 16, 16)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.01f);
|
||||||
|
|
||||||
|
|
||||||
|
(pair.Value as MultiTiledComponent).draw(spriteBatch, x / Game1.tileSize, y / Game1.tileSize, 0.5f);
|
||||||
|
//break;
|
||||||
|
//this.draw(spriteBatch, x / 64, y / 64, 0.5f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void pickUp()
|
||||||
|
{
|
||||||
|
|
||||||
|
bool canPickUp = this.removeAndAddToPlayersInventory();
|
||||||
|
if (canPickUp)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||||
|
{
|
||||||
|
(pair.Value as StorageFurnitureTile).removeFromLocation((pair.Value as StorageFurnitureTile).location, pair.Key);
|
||||||
|
}
|
||||||
|
this.location = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,206 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
using PyTK.CustomElementHandler;
|
||||||
|
using Revitalize.Framework.Utilities.Serialization;
|
||||||
|
using StardewValley;
|
||||||
|
|
||||||
|
namespace Revitalize.Framework.Objects.Furniture
|
||||||
|
{
|
||||||
|
public class StorageFurnitureTile:FurnitureTileComponent
|
||||||
|
{
|
||||||
|
|
||||||
|
public StorageFurnitureTile() : base()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorageFurnitureTile(CustomObjectData PyTKData, BasicItemInformation Info) : base(PyTKData, Info)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorageFurnitureTile(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TileLocation) : base(PyTKData, Info, TileLocation)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool performObjectDropInAction(Item dropInItem, bool probe, Farmer who)
|
||||||
|
{
|
||||||
|
return false; //this.pickUpItem()==PickUpState.DoNothing;
|
||||||
|
//return base.performObjectDropInAction(dropInItem, probe, who);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool performDropDownAction(Farmer who)
|
||||||
|
{
|
||||||
|
return base.performDropDownAction(who);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Checks for any sort of interaction IF and only IF there is a held object on this tile.
|
||||||
|
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false)
|
||||||
|
{
|
||||||
|
MouseState mState = Mouse.GetState();
|
||||||
|
KeyboardState keyboardState = Game1.GetKeyboardState();
|
||||||
|
|
||||||
|
if (mState.RightButton == ButtonState.Pressed && (!keyboardState.IsKeyDown(Keys.LeftShift) || !keyboardState.IsKeyDown(Keys.RightShift)))
|
||||||
|
{
|
||||||
|
return this.rightClicked(who);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift)))
|
||||||
|
return this.shiftRightClicked(who);
|
||||||
|
|
||||||
|
|
||||||
|
//return base.checkForAction(who, justCheckingForActivity);
|
||||||
|
|
||||||
|
if (justCheckingForActivity)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//return this.clicked(who);
|
||||||
|
//return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool performToolAction(Tool t, GameLocation location)
|
||||||
|
{
|
||||||
|
return base.performToolAction(t, location);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool performUseAction(GameLocation location)
|
||||||
|
{
|
||||||
|
return base.performUseAction(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets called when there is no actively held item on the tile.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="who"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override bool clicked(Farmer who)
|
||||||
|
{
|
||||||
|
if (this.containerObject.info.inventory.ItemCount > 0) return false;
|
||||||
|
return base.clicked(who);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool rightClicked(Farmer who)
|
||||||
|
{
|
||||||
|
if (Game1.menuUp || Game1.currentMinigame != null) return false;
|
||||||
|
if (this.containerObject.info.inventory != null && Game1.activeClickableMenu==null)
|
||||||
|
{
|
||||||
|
Game1.activeClickableMenu = new Revitalize.Framework.Menus.InventoryTransferMenu(100, 100, 500, 500, this.containerObject.info.inventory.items, this.containerObject.info.inventory.capacity);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool shiftRightClicked(Farmer who)
|
||||||
|
{
|
||||||
|
return base.shiftRightClicked(who);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override Item getOne()
|
||||||
|
{
|
||||||
|
StorageFurnitureTile component = new StorageFurnitureTile(this.data, this.info);
|
||||||
|
component.containerObject = this.containerObject;
|
||||||
|
component.offsetKey = this.offsetKey;
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
{
|
||||||
|
//instead of using this.offsetkey.x use get additional save data function and store offset key there
|
||||||
|
|
||||||
|
Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
|
||||||
|
StorageFurnitureTile self = Revitalize.ModCore.Serializer.DeserializeGUID<StorageFurnitureTile>(additionalSaveData["GUID"]);
|
||||||
|
if (self == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
|
||||||
|
{
|
||||||
|
//Get new container
|
||||||
|
StorageFurnitureOBJ obj = (StorageFurnitureOBJ)Revitalize.ModCore.Serializer.DeserializeGUID<StorageFurnitureOBJ>(additionalSaveData["ParentGUID"]);
|
||||||
|
self.containerObject = obj;
|
||||||
|
obj.addComponent(offsetKey, self);
|
||||||
|
//Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
|
||||||
|
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
|
||||||
|
Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
|
||||||
|
//Revitalize.ModCore.log("READD AN OBJECT!!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ICustomObject)self;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<string, string> getAdditionalSaveData()
|
||||||
|
{
|
||||||
|
Dictionary<string, string> saveData = base.getAdditionalSaveData();
|
||||||
|
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
|
||||||
|
|
||||||
|
return saveData;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>What happens when the object is drawn at a tile location.</summary>
|
||||||
|
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (this.info == null)
|
||||||
|
{
|
||||||
|
Revitalize.ModCore.log("info is null");
|
||||||
|
if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC");
|
||||||
|
}
|
||||||
|
if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
|
||||||
|
if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
|
||||||
|
|
||||||
|
//The actual planter box being drawn.
|
||||||
|
if (this.animationManager == null)
|
||||||
|
{
|
||||||
|
if (this.animationManager.getExtendedTexture() == null)
|
||||||
|
ModCore.ModMonitor.Log("Tex Extended is null???");
|
||||||
|
|
||||||
|
spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(y * Game1.tileSize) / 10000f));
|
||||||
|
// Log.AsyncG("ANIMATION IS NULL?!?!?!?!");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Log.AsyncC("Animation Manager is working!");
|
||||||
|
float addedDepth = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up)
|
||||||
|
{
|
||||||
|
addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y));
|
||||||
|
if (this.info.ignoreBoundingBox) addedDepth += 1.5f;
|
||||||
|
}
|
||||||
|
else if (this.info.ignoreBoundingBox)
|
||||||
|
{
|
||||||
|
addedDepth += 1.0f;
|
||||||
|
}
|
||||||
|
this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)((y + addedDepth) * Game1.tileSize) / 10000f) + .00001f);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.animationManager.tickAnimation();
|
||||||
|
// Log.AsyncC("Tick animation");
|
||||||
|
}
|
||||||
|
catch (Exception err)
|
||||||
|
{
|
||||||
|
ModCore.ModMonitor.Log(err.ToString());
|
||||||
|
}
|
||||||
|
if (this.heldObject.Value != null) SpriteBatchUtilities.Draw(spriteBatch, this, this.heldObject.Value, alpha, addedDepth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
|
||||||
namespace Revitalize.Framework.Utilities
|
namespace Revitalize.Framework.Utilities
|
||||||
|
@ -19,7 +20,7 @@ namespace Revitalize.Framework.Utilities
|
||||||
public List<Item> items;
|
public List<Item> items;
|
||||||
|
|
||||||
/// <summary>Checks if the inventory is full or not.</summary>
|
/// <summary>Checks if the inventory is full or not.</summary>
|
||||||
public bool IsFull => this.ItemCount >= this.capacity;
|
public bool IsFull => this.ItemCount >= this.capacity && this.items.Where(i=>i==null).Count()==0;
|
||||||
|
|
||||||
/// <summary>Checks to see if this core object actually has a valid inventory.</summary>
|
/// <summary>Checks to see if this core object actually has a valid inventory.</summary>
|
||||||
public bool HasInventory => this.capacity > 0;
|
public bool HasInventory => this.capacity > 0;
|
||||||
|
|
|
@ -78,12 +78,14 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
|
||||||
|
|
||||||
type = asm.GetType(t);
|
type = asm.GetType(t);
|
||||||
|
|
||||||
|
//Check if the type exists in the SDV assembly. If not then try to load it from revitalize.
|
||||||
if (type == null)
|
if (type == null)
|
||||||
{
|
{
|
||||||
asm = typeof(Revitalize.ModCore).Assembly;
|
asm = typeof(Revitalize.ModCore).Assembly;
|
||||||
type = asm.GetType(t);
|
type = asm.GetType(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If the type doesn't exist from revitalize look through ALL loded assemblies and try to load it.
|
||||||
if (type == null)
|
if (type == null)
|
||||||
{
|
{
|
||||||
foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
|
@ -96,7 +98,7 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
|
||||||
|
|
||||||
if (type == null)
|
if (type == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Unsupported type found when Deserializing Unsure what to do so we can;t deserialize this thing!: " + t);
|
throw new Exception("Unsupported type found when Deserializing Unsure what to do so we can't deserialize this thing!: " + t);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Cache the newly found type.
|
//Cache the newly found type.
|
||||||
|
|
|
@ -331,6 +331,7 @@ namespace Revitalize
|
||||||
Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Lamps.OakLamp"));
|
Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Lamps.OakLamp"));
|
||||||
|
|
||||||
Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble"));
|
Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble"));
|
||||||
|
Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Storage.OakCabinet"));
|
||||||
/*
|
/*
|
||||||
StardewValley.Tools.Axe axe = new StardewValley.Tools.Axe();
|
StardewValley.Tools.Axe axe = new StardewValley.Tools.Axe();
|
||||||
Serializer.Serialize(Path.Combine(this.Helper.DirectoryPath, "AXE.json"), axe);
|
Serializer.Serialize(Path.Combine(this.Helper.DirectoryPath, "AXE.json"), axe);
|
||||||
|
|
|
@ -115,6 +115,8 @@
|
||||||
<Compile Include="Framework\Objects\Furniture\LampTileComponent.cs" />
|
<Compile Include="Framework\Objects\Furniture\LampTileComponent.cs" />
|
||||||
<Compile Include="Framework\Objects\Furniture\RugMultiTiledObject.cs" />
|
<Compile Include="Framework\Objects\Furniture\RugMultiTiledObject.cs" />
|
||||||
<Compile Include="Framework\Objects\Furniture\RugTileComponent.cs" />
|
<Compile Include="Framework\Objects\Furniture\RugTileComponent.cs" />
|
||||||
|
<Compile Include="Framework\Objects\Furniture\StorageFurnitureOBJ.cs" />
|
||||||
|
<Compile Include="Framework\Objects\Furniture\StorageFurnitureTile.cs" />
|
||||||
<Compile Include="Framework\Objects\Furniture\TableMultiTiledObject.cs" />
|
<Compile Include="Framework\Objects\Furniture\TableMultiTiledObject.cs" />
|
||||||
<Compile Include="Framework\Objects\Furniture\TableTileComponent.cs" />
|
<Compile Include="Framework\Objects\Furniture\TableTileComponent.cs" />
|
||||||
<Compile Include="Framework\Objects\InformationFiles\Furniture\ArcadeCabinetInformation.cs" />
|
<Compile Include="Framework\Objects\InformationFiles\Furniture\ArcadeCabinetInformation.cs" />
|
||||||
|
@ -166,6 +168,9 @@
|
||||||
<Content Include="Content\Graphics\Furniture\Lamps\Oak Lamp.png">
|
<Content Include="Content\Graphics\Furniture\Lamps\Oak Lamp.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Content\Graphics\Furniture\Storage\Oak Cabinet.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Content\Graphics\Furniture\Tables\Oak Table.png">
|
<Content Include="Content\Graphics\Furniture\Tables\Oak Table.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
Loading…
Reference in New Issue