Got chairs to save as well!
This commit is contained in:
parent
e91313fe08
commit
d2173bb24b
|
@ -65,19 +65,49 @@ namespace Revitalize.Framework.Objects.Furniture
|
||||||
return new ChairMultiTiledObject(this.info, this.TileLocation, objs);
|
return new ChairMultiTiledObject(this.info, this.TileLocation, objs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
{
|
{
|
||||||
BasicItemInformation data = (BasicItemInformation)CustomObjectData.collection[additionalSaveData["id"]];
|
ChairMultiTiledObject obj = (ChairMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<ChairMultiTiledObject>(additionalSaveData["GUID"]);
|
||||||
|
if (obj == null)
|
||||||
Dictionary<Vector2, MultiTiledComponent> objs = new Dictionary<Vector2, MultiTiledComponent>();
|
|
||||||
foreach (var pair in this.objects)
|
|
||||||
{
|
{
|
||||||
objs.Add(pair.Key, (MultiTiledComponent)pair.Value);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ChairMultiTiledObject(data, (replacement as Chest).TileLocation, objs);
|
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());
|
||||||
|
ChairTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<ChairTileComponent>(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)
|
public override bool canBePlacedHere(GameLocation l, Vector2 tile)
|
||||||
{
|
{
|
||||||
return base.canBePlacedHere(l, tile);
|
return base.canBePlacedHere(l, tile);
|
||||||
|
|
|
@ -16,6 +16,8 @@ namespace Revitalize.Framework.Objects.Furniture
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ChairTileComponent:FurnitureTileComponent
|
public class ChairTileComponent:FurnitureTileComponent
|
||||||
{
|
{
|
||||||
|
public ChairInformation furnitureInfo;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the player can sit "on" this component.
|
/// Checks if the player can sit "on" this component.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -32,14 +34,14 @@ namespace Revitalize.Framework.Objects.Furniture
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChairTileComponent(BasicItemInformation Info,ChairInformation FurnitureInfo) : base(Info,FurnitureInfo)
|
public ChairTileComponent(BasicItemInformation Info,ChairInformation FurnitureInfo) : base(Info)
|
||||||
{
|
{
|
||||||
|
this.furnitureInfo = FurnitureInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChairTileComponent(BasicItemInformation Info,Vector2 TileLocation, ChairInformation FurnitureInfo) : base(Info, TileLocation,FurnitureInfo)
|
public ChairTileComponent(BasicItemInformation Info,Vector2 TileLocation, ChairInformation FurnitureInfo) : base(Info, TileLocation)
|
||||||
{
|
{
|
||||||
|
this.furnitureInfo = FurnitureInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,14 +91,44 @@ namespace Revitalize.Framework.Objects.Furniture
|
||||||
|
|
||||||
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
{
|
{
|
||||||
BasicItemInformation data = (BasicItemInformation)CustomObjectData.collection[additionalSaveData["id"]];
|
//instead of using this.offsetkey.x use get additional save data function and store offset key there
|
||||||
return new ChairTileComponent(data, (replacement as Chest).TileLocation,(ChairInformation)this.furnitureInfo)
|
|
||||||
|
Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
|
||||||
|
ChairTileComponent self = Revitalize.ModCore.Serializer.DeserializeGUID<ChairTileComponent>(additionalSaveData["GUID"]);
|
||||||
|
if (self == null)
|
||||||
{
|
{
|
||||||
containerObject = this.containerObject,
|
return null;
|
||||||
offsetKey = this.offsetKey
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
|
||||||
|
{
|
||||||
|
//Get new container
|
||||||
|
ChairMultiTiledObject obj = (ChairMultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<ChairMultiTiledObject>(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>
|
/// <summary>
|
||||||
///Used to manage graphics for chairs that need to deal with special "layering" for transparent chair backs. Otherwise the player would be hidden.
|
///Used to manage graphics for chairs that need to deal with special "layering" for transparent chair backs. Otherwise the player would be hidden.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -11,7 +11,6 @@ namespace Revitalize.Framework.Objects.Furniture
|
||||||
{
|
{
|
||||||
public class FurnitureTileComponent:MultiTiledComponent
|
public class FurnitureTileComponent:MultiTiledComponent
|
||||||
{
|
{
|
||||||
public FurnitureInformation furnitureInfo;
|
|
||||||
|
|
||||||
|
|
||||||
public FurnitureTileComponent():base()
|
public FurnitureTileComponent():base()
|
||||||
|
@ -19,14 +18,13 @@ namespace Revitalize.Framework.Objects.Furniture
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FurnitureTileComponent(BasicItemInformation itemInfo,FurnitureInformation furnitureInfo):base(itemInfo)
|
public FurnitureTileComponent(BasicItemInformation itemInfo):base(itemInfo)
|
||||||
{
|
{
|
||||||
this.furnitureInfo = furnitureInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FurnitureTileComponent(BasicItemInformation itemInfo,Vector2 TileLocation ,FurnitureInformation furnitureInfo) : base(itemInfo,TileLocation)
|
public FurnitureTileComponent(BasicItemInformation itemInfo,Vector2 TileLocation) : base(itemInfo,TileLocation)
|
||||||
{
|
{
|
||||||
this.furnitureInfo = furnitureInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,9 +208,6 @@ namespace Revitalize.Framework.Objects
|
||||||
|
|
||||||
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<MultiTiledObject>(additionalSaveData["GUID"]);
|
MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<MultiTiledObject>(additionalSaveData["GUID"]);
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -249,6 +249,7 @@ namespace Revitalize
|
||||||
oakChair.addComponent(new Vector2(0, 1), chairBottom);
|
oakChair.addComponent(new Vector2(0, 1), chairBottom);
|
||||||
|
|
||||||
customObjects.Add("Omegasis.BigTiledTest", bigObject);
|
customObjects.Add("Omegasis.BigTiledTest", bigObject);
|
||||||
|
customObjects.Add("Omegasis.Revitalize.Furniture.Chairs.OakChair",oakChair);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDirectories()
|
private void createDirectories()
|
||||||
|
@ -285,7 +286,8 @@ namespace Revitalize
|
||||||
{
|
{
|
||||||
throw new Exception("Can't run Revitalize in multiplayer due to lack of current support!");
|
throw new Exception("Can't run Revitalize in multiplayer due to lack of current support!");
|
||||||
}
|
}
|
||||||
Game1.player.addItemToInventory(customObjects["Omegasis.BigTiledTest"].getOne());
|
//Game1.player.addItemToInventory(customObjects["Omegasis.BigTiledTest"].getOne());
|
||||||
|
Game1.player.addItemToInventory(getObjectFromPool("Omegasis.Revitalize.Furniture.Chairs.OakChair"));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
StardewValley.Tools.Axe axe = new StardewValley.Tools.Axe();
|
StardewValley.Tools.Axe axe = new StardewValley.Tools.Axe();
|
||||||
|
@ -296,6 +298,17 @@ namespace Revitalize
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Item getObjectFromPool(string objName)
|
||||||
|
{
|
||||||
|
if (customObjects.ContainsKey(objName))
|
||||||
|
{
|
||||||
|
return customObjects[objName];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Object Key name not found: " + objName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void log(object message)
|
public static void log(object message)
|
||||||
|
|
Loading…
Reference in New Issue