Started object manager.
This commit is contained in:
parent
76aa7f7894
commit
c1509c9371
|
@ -65,10 +65,10 @@ namespace Revitalize.Framework.Factories.Objects
|
||||||
|
|
||||||
FactoryInfo lO = new FactoryInfo(lamp);
|
FactoryInfo lO = new FactoryInfo(lamp);
|
||||||
|
|
||||||
ModCore.Serializer.SerializeContentFile("OakLamp_0_-2", lT, LampsFolder);
|
ModCore.Serializer.SerializeContentFile("OakLamp_0_-2", lT,Path.Combine(LampsFolder,"OakLamp"));
|
||||||
ModCore.Serializer.SerializeContentFile("OakLamp_0_-1", lM, LampsFolder);
|
ModCore.Serializer.SerializeContentFile("OakLamp_0_-1", lM, Path.Combine(LampsFolder, "OakLamp"));
|
||||||
ModCore.Serializer.SerializeContentFile("OakLamp_0_0", lB, LampsFolder);
|
ModCore.Serializer.SerializeContentFile("OakLamp_0_0", lB, Path.Combine(LampsFolder, "OakLamp"));
|
||||||
ModCore.Serializer.SerializeContentFile("OakLamp", lO, LampsFolder);
|
ModCore.Serializer.SerializeContentFile("OakLamp", lO, Path.Combine(LampsFolder, "OakLamp"));
|
||||||
|
|
||||||
//ModCore.customObjects.Add(lamp.info.id, lamp);
|
//ModCore.customObjects.Add(lamp.info.id, lamp);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,11 @@ namespace Revitalize.Framework.Factories.Objects
|
||||||
private static void DeserializeLamps()
|
private static void DeserializeLamps()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", LampsFolder))) Directory.CreateDirectory(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", LampsFolder));
|
if (!Directory.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", LampsFolder))) Directory.CreateDirectory(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", LampsFolder));
|
||||||
string[] files = Directory.GetFiles(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", LampsFolder));
|
string[] directories = Directory.GetDirectories(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", LampsFolder));
|
||||||
|
|
||||||
|
foreach(string directory in directories)
|
||||||
|
{
|
||||||
|
string[] files = Directory.GetFiles(directory);
|
||||||
|
|
||||||
Dictionary<string, LampMultiTiledObject> objs = new Dictionary<string, LampMultiTiledObject>();
|
Dictionary<string, LampMultiTiledObject> objs = new Dictionary<string, LampMultiTiledObject>();
|
||||||
|
|
||||||
|
@ -109,12 +113,12 @@ namespace Revitalize.Framework.Factories.Objects
|
||||||
lampPiece.lights.lights.Clear();
|
lampPiece.lights.lights.Clear();
|
||||||
foreach (KeyValuePair<Vector2, FakeLightSource> light in info.info.lightManager.fakeLights)
|
foreach (KeyValuePair<Vector2, FakeLightSource> light in info.info.lightManager.fakeLights)
|
||||||
{
|
{
|
||||||
lampPiece.lights.addLight(new Vector2(Game1.tileSize), new LightSource(light.Value.id, new Vector2(0, 0), light.Value.radius,light.Value.color.Invert()), lampPiece);
|
lampPiece.lights.addLight(new Vector2(Game1.tileSize), new LightSource(light.Value.id, new Vector2(0, 0), light.Value.radius, light.Value.color.Invert()), lampPiece);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
objs[name].addComponent(offset,lampPiece );
|
objs[name].addComponent(offset, lampPiece);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (var v in objs)
|
foreach (var v in objs)
|
||||||
|
@ -124,6 +128,9 @@ namespace Revitalize.Framework.Factories.Objects
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static void SerializeChairs()
|
private static void SerializeChairs()
|
||||||
|
@ -219,14 +226,18 @@ namespace Revitalize.Framework.Factories.Objects
|
||||||
ChairFactoryInfo obj = new ChairFactoryInfo(oakChair);
|
ChairFactoryInfo obj = new ChairFactoryInfo(oakChair);
|
||||||
|
|
||||||
|
|
||||||
ModCore.Serializer.SerializeContentFile("OakChair_0_-1", top, ChairFolder);
|
ModCore.Serializer.SerializeContentFile("OakChair_0_-1", top, Path.Combine(ChairFolder, "OakChair"));
|
||||||
ModCore.Serializer.SerializeContentFile("OakChair_0_0", bottom, ChairFolder);
|
ModCore.Serializer.SerializeContentFile("OakChair_0_0", bottom, Path.Combine(ChairFolder, "OakChair"));
|
||||||
ModCore.Serializer.SerializeContentFile("OakChair", obj, ChairFolder);
|
ModCore.Serializer.SerializeContentFile("OakChair", obj, Path.Combine(ChairFolder, "OakChair"));
|
||||||
}
|
}
|
||||||
private static void DeserializeChairs()
|
private static void DeserializeChairs()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", ChairFolder))) Directory.CreateDirectory(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", ChairFolder));
|
if (!Directory.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", ChairFolder))) Directory.CreateDirectory(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", ChairFolder));
|
||||||
string[] files = Directory.GetFiles(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", ChairFolder));
|
string[] directories = Directory.GetDirectories(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", ChairFolder));
|
||||||
|
|
||||||
|
foreach (string directory in directories)
|
||||||
|
{
|
||||||
|
string[] files = Directory.GetFiles(directory);
|
||||||
|
|
||||||
Dictionary<string, ChairMultiTiledObject> chairObjects = new Dictionary<string, ChairMultiTiledObject>();
|
Dictionary<string, ChairMultiTiledObject> chairObjects = new Dictionary<string, ChairMultiTiledObject>();
|
||||||
|
|
||||||
|
@ -258,6 +269,7 @@ namespace Revitalize.Framework.Factories.Objects
|
||||||
ModCore.customObjects.Add(v.Value.info.id, v.Value);
|
ModCore.customObjects.Add(v.Value.info.id, v.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void SerializeTableFiles()
|
private static void SerializeTableFiles()
|
||||||
{
|
{
|
||||||
|
@ -280,21 +292,26 @@ namespace Revitalize.Framework.Factories.Objects
|
||||||
TableFactoryInfo table = new TableFactoryInfo(obj);
|
TableFactoryInfo table = new TableFactoryInfo(obj);
|
||||||
|
|
||||||
|
|
||||||
ModCore.Serializer.SerializeContentFile("OakTable_0_0", uL, TablesFolder);
|
ModCore.Serializer.SerializeContentFile("OakTable_0_0", uL, Path.Combine(TablesFolder, "OakTable"));
|
||||||
ModCore.Serializer.SerializeContentFile("OakTable_1_0", uR, TablesFolder);
|
ModCore.Serializer.SerializeContentFile("OakTable_1_0", uR, Path.Combine(TablesFolder, "OakTable"));
|
||||||
ModCore.Serializer.SerializeContentFile("OakTable_0_1", cL, TablesFolder);
|
ModCore.Serializer.SerializeContentFile("OakTable_0_1", cL, Path.Combine(TablesFolder, "OakTable"));
|
||||||
ModCore.Serializer.SerializeContentFile("OakTable_1_1", cR, TablesFolder);
|
ModCore.Serializer.SerializeContentFile("OakTable_1_1", cR, Path.Combine(TablesFolder, "OakTable"));
|
||||||
ModCore.Serializer.SerializeContentFile("OakTable_0_2", bL, TablesFolder);
|
ModCore.Serializer.SerializeContentFile("OakTable_0_2", bL, Path.Combine(TablesFolder, "OakTable"));
|
||||||
ModCore.Serializer.SerializeContentFile("OakTable_1_2", bR, TablesFolder);
|
ModCore.Serializer.SerializeContentFile("OakTable_1_2", bR, Path.Combine(TablesFolder, "OakTable"));
|
||||||
|
|
||||||
ModCore.Serializer.SerializeContentFile("OakTable", table, TablesFolder);
|
ModCore.Serializer.SerializeContentFile("OakTable", table, Path.Combine(TablesFolder, "OakTable"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DeserializeTableFiles()
|
private static void DeserializeTableFiles()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", TablesFolder))) Directory.CreateDirectory(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", TablesFolder));
|
if (!Directory.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", TablesFolder))) Directory.CreateDirectory(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", TablesFolder));
|
||||||
string[] files = Directory.GetFiles(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", TablesFolder));
|
|
||||||
|
string[] directories = Directory.GetDirectories(Path.Combine(ModCore.ModHelper.DirectoryPath, "Content", TablesFolder));
|
||||||
|
foreach (string directory in directories)
|
||||||
|
{
|
||||||
|
|
||||||
|
string[] files = Directory.GetFiles(directory);
|
||||||
|
|
||||||
Dictionary<string, TableMultiTiledObject> chairObjects = new Dictionary<string, TableMultiTiledObject>();
|
Dictionary<string, TableMultiTiledObject> chairObjects = new Dictionary<string, TableMultiTiledObject>();
|
||||||
|
|
||||||
|
@ -326,6 +343,7 @@ namespace Revitalize.Framework.Factories.Objects
|
||||||
ModCore.customObjects.Add(v.Value.info.id, v.Value);
|
ModCore.customObjects.Add(v.Value.info.id, v.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static ChairMultiTiledObject GetChair(string name)
|
public static ChairMultiTiledObject GetChair(string name)
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Xna.Framework;
|
|
||||||
using PyTK.CustomElementHandler;
|
|
||||||
using StardewValley;
|
|
||||||
using StardewValley.Objects;
|
|
||||||
|
|
||||||
namespace Revitalize.Framework.Objects
|
|
||||||
{
|
|
||||||
public class GarbageTest:CustomObject
|
|
||||||
{
|
|
||||||
public GarbageTest()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public GarbageTest(BasicItemInformation info) : base(info)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public GarbageTest(BasicItemInformation info,Vector2 TileLocation) : base(info,TileLocation)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Item getOne()
|
|
||||||
{
|
|
||||||
return new GarbageTest(this.info);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
|
||||||
{
|
|
||||||
CustomObjectData data = CustomObjectData.collection[additionalSaveData["id"]];
|
|
||||||
return new GarbageTest((BasicItemInformation)data, (replacement as Chest).TileLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Revitalize.Framework.Objects.Furniture;
|
||||||
|
using StardewModdingAPI;
|
||||||
|
using StardewValley;
|
||||||
|
|
||||||
|
namespace Revitalize.Framework.Objects
|
||||||
|
{
|
||||||
|
public class ObjectManager
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// All of the object managers id'd by a mod's or content pack's unique id.
|
||||||
|
/// </summary>
|
||||||
|
public static Dictionary<string, ObjectManager> ObjectPools;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of this object manager.
|
||||||
|
/// </summary>
|
||||||
|
public string name;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// All of the chairs held by this object pool.
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, ChairMultiTiledObject> chairs;
|
||||||
|
/// <summary>
|
||||||
|
/// All of the tables held by this object pool.
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, TableMultiTiledObject> tables;
|
||||||
|
/// <summary>
|
||||||
|
/// All of the lamps held by this object pool.
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, LampMultiTiledObject> lamps;
|
||||||
|
/// <summary>
|
||||||
|
/// All of the rugs held by this object pool.
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, RugMultiTiledObject> rugs;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor.
|
||||||
|
/// </summary>
|
||||||
|
public ObjectManager()
|
||||||
|
{
|
||||||
|
this.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="manifest"></param>
|
||||||
|
public ObjectManager(IManifest manifest)
|
||||||
|
{
|
||||||
|
this.name = manifest.UniqueID;
|
||||||
|
this.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize all objects used to manage this class.
|
||||||
|
/// </summary>
|
||||||
|
private void initialize()
|
||||||
|
{
|
||||||
|
this.chairs = new Dictionary<string, ChairMultiTiledObject>();
|
||||||
|
this.tables = new Dictionary<string, TableMultiTiledObject>();
|
||||||
|
this.lamps = new Dictionary<string, LampMultiTiledObject>();
|
||||||
|
this.rugs = new Dictionary<string, RugMultiTiledObject>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a random object from the dictionary passed in.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dictionary"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Item getRandomObject(Dictionary<string,CustomObject> dictionary)
|
||||||
|
{
|
||||||
|
if (dictionary.Count == 0) return null;
|
||||||
|
List<CustomObject> objs = new List<CustomObject>();
|
||||||
|
foreach(KeyValuePair<string,CustomObject> pair in dictionary)
|
||||||
|
{
|
||||||
|
objs.Add(pair.Value);
|
||||||
|
}
|
||||||
|
int rand = Game1.random.Next(0,objs.Count);
|
||||||
|
return objs[rand].getOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an object from the dictionary that is passed in.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="objectName"></param>
|
||||||
|
/// <param name="dictionary"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Item getObject(string objectName, Dictionary<string,CustomObject> dictionary)
|
||||||
|
{
|
||||||
|
if (dictionary.ContainsKey(objectName))
|
||||||
|
{
|
||||||
|
return dictionary[objectName].getOne();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Object pool doesn't contain said object.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new object manager to the master pool of managers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Manifest"></param>
|
||||||
|
public static void AddObjectManager(IManifest Manifest)
|
||||||
|
{
|
||||||
|
if (ObjectPools == null) ObjectPools = new Dictionary<string, ObjectManager>();
|
||||||
|
ObjectPools.Add(Manifest.UniqueID, new ObjectManager(Manifest));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,9 +27,8 @@ namespace Revitalize
|
||||||
// -load content MUST be enabled for the table to be placed?????? WTF
|
// -load content MUST be enabled for the table to be placed?????? WTF
|
||||||
// TODO:
|
// TODO:
|
||||||
//
|
//
|
||||||
// -Add in object pool class to handle the multitudes of objects I'll be making.
|
// -Add in object pool class to handle the multitudes of objects I'll be making. (WIP)
|
||||||
// -Make this mod able to load content packs for easier future modding
|
// -Make this mod able to load content packs for easier future modding
|
||||||
// -Make deserialize/serialize look through sub directories instead of just one directory.
|
|
||||||
//
|
//
|
||||||
// -Multiple Lights On Object
|
// -Multiple Lights On Object
|
||||||
// -Illumination Colors
|
// -Illumination Colors
|
||||||
|
@ -57,6 +56,8 @@ namespace Revitalize
|
||||||
// -Tin/Bronze/Alluminum/Silver?Platinum/Etc
|
// -Tin/Bronze/Alluminum/Silver?Platinum/Etc
|
||||||
// -Crafting Menu
|
// -Crafting Menu
|
||||||
// -Item Grab Menu (Extendable)
|
// -Item Grab Menu (Extendable)
|
||||||
|
// -Yes/No Dialogue Box
|
||||||
|
// -Multi Choice dialogue box
|
||||||
// -Gift Boxes
|
// -Gift Boxes
|
||||||
// Magic!
|
// Magic!
|
||||||
// -Alchemy Bags
|
// -Alchemy Bags
|
||||||
|
@ -68,7 +69,7 @@ namespace Revitalize
|
||||||
// -Connected chests much like Project EE2 from MC
|
// -Connected chests much like Project EE2 from MC
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
// -Food?
|
||||||
// -Bigger chests
|
// -Bigger chests
|
||||||
//
|
//
|
||||||
// Festivals
|
// Festivals
|
||||||
|
@ -119,6 +120,9 @@ namespace Revitalize
|
||||||
|
|
||||||
public static Dictionary<string, MultiTiledObject>ObjectGroups;
|
public static Dictionary<string, MultiTiledObject>ObjectGroups;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static PlayerInfo playerInfo;
|
public static PlayerInfo playerInfo;
|
||||||
|
|
||||||
public static Serializer Serializer;
|
public static Serializer Serializer;
|
||||||
|
@ -211,8 +215,10 @@ namespace Revitalize
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.Combine(this.Helper.DirectoryPath, "Content"));
|
Directory.CreateDirectory(Path.Combine(this.Helper.DirectoryPath, "Content"));
|
||||||
Directory.CreateDirectory(Path.Combine(this.Helper.DirectoryPath,"Content" ,"Graphics"));
|
Directory.CreateDirectory(Path.Combine(this.Helper.DirectoryPath,"Content" ,"Graphics"));
|
||||||
Directory.CreateDirectory(Path.Combine(this.Helper.DirectoryPath, "Content", "Graphics","Furniture"));
|
//Directory.CreateDirectory(Path.Combine(this.Helper.DirectoryPath, "Content", "Graphics","Furniture"));
|
||||||
Directory.CreateDirectory(Path.Combine(this.Helper.DirectoryPath, "Content", "Graphics", "Furniture","Chairs"));
|
Directory.CreateDirectory(Path.Combine(this.Helper.DirectoryPath, "Content", "Graphics", "Furniture","Chairs"));
|
||||||
|
Directory.CreateDirectory(Path.Combine(this.Helper.DirectoryPath, "Content", "Graphics", "Furniture", "Lamps"));
|
||||||
|
Directory.CreateDirectory(Path.Combine(this.Helper.DirectoryPath, "Content", "Graphics", "Furniture", "Tables"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initailizeComponents()
|
private void initailizeComponents()
|
||||||
|
|
Loading…
Reference in New Issue