URevert "Fixed vanilla machines not rendering CustomObject(s) when finished producing."

This reverts commit f3f4f4da27.
This commit is contained in:
JoshuaNavarro 2019-08-26 16:34:03 -07:00
parent 36528407ba
commit 50b77b44e2
30 changed files with 291 additions and 711 deletions

View File

@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Revitalize.Framework.Crafting; using Revitalize.Framework.Crafting;
using Revitalize.Framework.Objects;
using Revitalize.Framework.Utilities; using Revitalize.Framework.Utilities;
using StardewValley; using StardewValley;
using SObject = StardewValley.Object; using SObject = StardewValley.Object;
@ -17,6 +18,8 @@ namespace Revitalize.Framework.Hacks
/// Returns the object underneath the mouse's position. /// Returns the object underneath the mouse's position.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
///
public static Dictionary<GameLocation, List<SObject>> TrackedMachines = new Dictionary<GameLocation, List<SObject>>();
public static SObject GetItemAtMouseTile() public static SObject GetItemAtMouseTile()
{ {
if (Game1.player == null) return null; if (Game1.player == null) return null;
@ -58,9 +61,55 @@ namespace Revitalize.Framework.Hacks
*/ */
(Game1.player.currentLocation).TemporarySprites.Add(new TemporaryAnimatedSprite(30, obj.TileLocation * 64f + new Vector2(0.0f, -16f), Color.White, 4, false, 50f, 10, 64, (float)(((double)obj.TileLocation.Y + 1.0) * 64.0 / 10000.0 + 9.99999974737875E-05), -1, 0)); (Game1.player.currentLocation).TemporarySprites.Add(new TemporaryAnimatedSprite(30, obj.TileLocation * 64f + new Vector2(0.0f, -16f), Color.White, 4, false, 50f, 10, 64, (float)(((double)obj.TileLocation.Y + 1.0) * 64.0 / 10000.0 + 9.99999974737875E-05), -1, 0));
obj.addWorkingAnimation(Game1.player.currentLocation); obj.addWorkingAnimation(Game1.player.currentLocation);
if (TrackedMachines.ContainsKey(Game1.player.currentLocation))
{
TrackedMachines[Game1.player.currentLocation].Add(obj);
}
else
{
TrackedMachines.Add(Game1.player.currentLocation, new List<SObject>()
{
obj
});
}
} }
} }
} }
public static void Render_RenderCustomObjectsHeldInMachines(object sender, StardewModdingAPI.Events.RenderedWorldEventArgs e)
{
if (TrackedMachines.ContainsKey(Game1.player.currentLocation))
{
List<SObject> removalList = new List<SObject>();
foreach(SObject obj in TrackedMachines[Game1.player.currentLocation])
{
if (obj.heldObject.Value == null)
{
removalList.Add(obj);
}
else
{
if(obj.heldObject.Value is CustomObject)
{
if (obj.MinutesUntilReady == 0)
{
float num = (float)(4.0 * Math.Round(Math.Sin(DateTime.UtcNow.TimeOfDay.TotalMilliseconds / 250.0), 2));
Vector2 pos = new Vector2(obj.TileLocation.X * Game1.tileSize, (obj.TileLocation.Y-1) * Game1.tileSize - 32+num);
obj.heldObject.Value.draw(e.SpriteBatch, (int)pos.X, (int)pos.Y, 0.25f, 1f);
}
}
}
}
foreach(SObject obj in removalList)
{
TrackedMachines[Game1.player.currentLocation].Remove(obj);
}
}
else
{
}
}
} }
} }

View File

@ -18,11 +18,11 @@ namespace Revitalize.Framework.Hacks
/// </summary> /// </summary>
public static void AddOreToClintsShop() public static void AddOreToClintsShop()
{ {
//PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Tin",1),100), "Clint"); PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Tin",1),100), "Clint");
//PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Bauxite", 1), 150), "Clint"); PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Bauxite", 1), 150), "Clint");
//PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Lead", 1), 200), "Clint"); PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Lead", 1), 200), "Clint");
//PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Silver", 1), 250), "Clint"); PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Silver", 1), 250), "Clint");
//PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Titanium", 1), 300), "Clint"); PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Titanium", 1), 300), "Clint");
} }
} }
} }

View File

@ -41,8 +41,6 @@ namespace Revitalize.Framework.Objects
public int shakeTimer; public int shakeTimer;
public bool bigCraftable;
public BasicItemInformation() public BasicItemInformation()
{ {
this.name = ""; this.name = "";
@ -66,7 +64,7 @@ namespace Revitalize.Framework.Objects
} }
public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors,bool BigCraftable,Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights) public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights)
{ {
this.name = name; this.name = name;
this.id = id; this.id = id;
@ -95,7 +93,6 @@ namespace Revitalize.Framework.Objects
this.lightManager = Lights ?? new LightManager(); this.lightManager = Lights ?? new LightManager();
this.facingDirection = Enums.Direction.Down; this.facingDirection = Enums.Direction.Down;
this.shakeTimer = 0; this.shakeTimer = 0;
this.bigCraftable = BigCraftable;
} }
@ -114,7 +111,7 @@ namespace Revitalize.Framework.Objects
/// <returns></returns> /// <returns></returns>
public BasicItemInformation Copy() public BasicItemInformation Copy()
{ {
return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors,this.bigCraftable ,this.animationManager.getTexture(), this.animationManager, this.drawColor, this.ignoreBoundingBox, this.inventory.Copy(), this.lightManager.Copy()); return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.drawColor, this.ignoreBoundingBox, this.inventory.Copy(), this.lightManager.Copy());
} }
} }

View File

@ -8,9 +8,6 @@ using PyTK.CustomElementHandler;
using StardustCore.Animations; using StardustCore.Animations;
using StardewValley; using StardewValley;
using StardewValley.Objects; using StardewValley.Objects;
using Netcode;
using StardewModdingAPI;
using Revitalize.Framework.Utilities;
namespace Revitalize.Framework.Objects namespace Revitalize.Framework.Objects
{ {
@ -20,7 +17,7 @@ namespace Revitalize.Framework.Objects
// -Inventories // -Inventories
/// <summary>A custom object template.</summary> /// <summary>A custom object template.</summary>
public class CustomObject : StardewValley.Object,ISaveElement public class CustomObject : PySObject
{ {
public string id public string id
{ {
@ -86,12 +83,12 @@ namespace Revitalize.Framework.Objects
public CustomObject() public CustomObject()
{ {
this.guid = Guid.NewGuid(); this.guid = Guid.NewGuid();
//this.InitNetFields(); this.InitNetFields();
} }
/// <summary>Construct an instance.</summary> /// <summary>Construct an instance.</summary>
public CustomObject(BasicItemInformation info, int Stack = 1) public CustomObject(CustomObjectData PyTKData, BasicItemInformation info, int Stack = 1)
: base() : base(PyTKData, Vector2.Zero)
{ {
this.info = info; this.info = info;
this.initializeBasics(); this.initializeBasics();
@ -101,8 +98,8 @@ namespace Revitalize.Framework.Objects
} }
/// <summary>Construct an instance.</summary> /// <summary>Construct an instance.</summary>
public CustomObject(BasicItemInformation info, Vector2 TileLocation, int Stack = 1) public CustomObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, int Stack = 1)
: base() : base(PyTKData, TileLocation)
{ {
this.info = info; this.info = info;
this.initializeBasics(); this.initializeBasics();
@ -118,21 +115,17 @@ namespace Revitalize.Framework.Objects
this.Edibility = this.info.edibility; this.Edibility = this.info.edibility;
this.Category = -9; //For crafting. this.Category = -9; //For crafting.
this.displayName = this.info.name; this.displayName = this.info.name;
this.setOutdoors.Value = this.info.canBeSetOutdoors; this.setOutdoors.Value = true;
this.setIndoors.Value = this.info.canBeSetIndoors; this.setIndoors.Value = true;
this.isLamp.Value = false; this.isLamp.Value = false;
this.Fragility = 0; this.Fragility = 0;
this.updateDrawPosition(0, 0); this.updateDrawPosition(0, 0);
this.bigCraftable.Value = this.info.bigCraftable; this.bigCraftable.Value = false;
this.Price = this.info.price;
ModCore.CustomObjects.Add(this.guid, this);
this.NetFields.AddField(new NetGuid(this.guid));
//this.initNetFields(); //this.initNetFields();
//this.InitNetFields(); this.InitNetFields();
//if (this.info.ignoreBoundingBox) //if (this.info.ignoreBoundingBox)
// this.boundingBox.Value = new Rectangle(int.MinValue, int.MinValue, 0, 0); // this.boundingBox.Value = new Rectangle(int.MinValue, int.MinValue, 0, 0);
} }
@ -141,7 +134,7 @@ namespace Revitalize.Framework.Objects
public override bool isPassable() public override bool isPassable()
{ {
return this.info.ignoreBoundingBox; //|| Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this; return this.info.ignoreBoundingBox || Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this;
} }
public override Rectangle getBoundingBox(Vector2 tileLocation) public override Rectangle getBoundingBox(Vector2 tileLocation)
@ -155,6 +148,8 @@ namespace Revitalize.Framework.Objects
/// <summary>Checks for interaction with the object.</summary> /// <summary>Checks for interaction with the object.</summary>
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) public override bool checkForAction(Farmer who, bool justCheckingForActivity = false)
{ {
MouseState mState = Mouse.GetState(); MouseState mState = Mouse.GetState();
KeyboardState keyboardState = Game1.GetKeyboardState(); KeyboardState keyboardState = Game1.GetKeyboardState();
@ -175,33 +170,18 @@ namespace Revitalize.Framework.Objects
return this.clicked(who); return this.clicked(who);
} }
/*
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement) public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
{ {
CustomObjectData data = CustomObjectData.collection[additionalSaveData["id"]]; CustomObjectData data = CustomObjectData.collection[additionalSaveData["id"]];
BasicItemInformation info = Revitalize.ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]); BasicItemInformation info = Revitalize.ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
return new CustomObject(data, info); return new CustomObject(data, info, (replacement as Chest).TileLocation);
} }
*/
/*
public override Dictionary<string, string> getAdditionalSaveData() public override Dictionary<string, string> getAdditionalSaveData()
{ {
Dictionary<string, string> serializedInfo = new Dictionary<string, string>(); Dictionary<string, string> serializedInfo = new Dictionary<string, string>();
serializedInfo.Add("id", this.ItemInfo);
serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info));
return serializedInfo; return serializedInfo;
} }
*/
/*
public override void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
{
string id = additionalSaveData["id"];
this.ItemInfo = id;
this.info = Revitalize.ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
base.rebuild(additionalSaveData, replacement);
ModCore.log("Rebuilt custom object.");
}
*/
/// <summary>What happens when the player right clicks the object.</summary> /// <summary>What happens when the player right clicks the object.</summary>
public virtual bool rightClicked(Farmer who) public virtual bool rightClicked(Farmer who)
@ -346,19 +326,12 @@ namespace Revitalize.Framework.Objects
/// <summary>Gets a clone of the game object.</summary> /// <summary>Gets a clone of the game object.</summary>
public override Item getOne() public override Item getOne()
{ {
return new CustomObject(this.info); return new CustomObject(this.data, this.info);
} }
/// <summary>What happens when the object is drawn at a tile location.</summary> /// <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) public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
{ {
if (this.info == null)
{
ModCore.log("Info is null:");
ModCore.log("Need request for guid: " + this.guid);
MultiplayerUtilities.SendRequestForSpecificGUID(this.guid);
return;
}
if (x <= -1) if (x <= -1)
{ {
spriteBatch.Draw(this.info.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.info.drawPosition), 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)(this.TileLocation.Y * Game1.tileSize) / 10000f)); spriteBatch.Draw(this.info.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.info.drawPosition), 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)(this.TileLocation.Y * Game1.tileSize) / 10000f));
@ -380,6 +353,7 @@ namespace Revitalize.Framework.Objects
//Log.AsyncC("Animation Manager is working!"); //Log.AsyncC("Animation Manager is working!");
int addedDepth = 0; int addedDepth = 0;
if (this.info.ignoreBoundingBox) addedDepth++; if (this.info.ignoreBoundingBox) addedDepth++;
if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this) addedDepth++;
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)((this.TileLocation.Y + addedDepth) * Game1.tileSize) / 10000f)); 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)((this.TileLocation.Y + addedDepth) * Game1.tileSize) / 10000f));
try try
{ {
@ -399,14 +373,25 @@ namespace Revitalize.Framework.Objects
/// <summary>Draw the game object at a non-tile spot. Aka like debris.</summary> /// <summary>Draw the game object at a non-tile spot. Aka like debris.</summary>
public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1f) public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1f)
{ {
/*
if(this.info == null) if (Game1.eventUp && Game1.CurrentEvent.isTileWalkedOn(xNonTile / 64, yNonTile / 64))
{
ModCore.log("Info is null:");
ModCore.log("Need request for guid: " + this.guid);
MultiplayerUtilities.SendRequestForSpecificGUID(this.guid);
return; return;
} if ((int)(this.ParentSheetIndex) != 590 && (int)(this.Fragility) != 2)
spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile + 32), (float)(yNonTile + 51 + 4))), new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0.0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, layerDepth - 1E-06f);
SpriteBatch spriteBatch1 = spriteBatch;
Texture2D objectSpriteSheet = Game1.objectSpriteSheet;
Vector2 local = Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile + 32 + (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0)), (float)(yNonTile + 32 + (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0))));
Microsoft.Xna.Framework.Rectangle? sourceRectangle = new Microsoft.Xna.Framework.Rectangle?(GameLocation.getSourceRectForObject(this.ParentSheetIndex));
Color color = Color.White * alpha;
double num1 = 0.0;
Vector2 origin = new Vector2(8f, 8f);
Vector2 scale = this.scale;
double num2 = (double)this.scale.Y > 1.0 ? (double)this.getScale().Y : 4.0;
int num3 = (bool)(this.flipped) ? 1 : 0;
double num4 = (double)layerDepth;
spriteBatch1.Draw(this.displayTexture, local, this.animationManager.defaultDrawFrame.sourceRectangle, this.info.drawColor * alpha, (float)num1, origin, (float)4f, (SpriteEffects)num3, (float)num4);
*/
//The actual planter box being drawn. //The actual planter box being drawn.
if (this.animationManager == null) if (this.animationManager == null)
{ {
@ -422,6 +407,7 @@ namespace Revitalize.Framework.Objects
//Log.AsyncC("Animation Manager is working!"); //Log.AsyncC("Animation Manager is working!");
int addedDepth = 0; int addedDepth = 0;
if (this.info.ignoreBoundingBox) addedDepth++; if (this.info.ignoreBoundingBox) addedDepth++;
if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this) addedDepth++;
this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile), yNonTile)), 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, layerDepth)); this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile), yNonTile)), 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, layerDepth));
try try
{ {
@ -441,13 +427,6 @@ namespace Revitalize.Framework.Objects
/// <summary>What happens when the object is drawn in a menu.</summary> /// <summary>What happens when the object is drawn in a menu.</summary>
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow)
{ {
if (this.info == null)
{
ModCore.log("Info is null:");
ModCore.log("Need request for guid: " + this.guid);
MultiplayerUtilities.SendRequestForSpecificGUID(this.guid);
return;
}
if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1) if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1)
Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White); Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White);
if (drawStackNumber && this.Quality > 0) if (drawStackNumber && this.Quality > 0)
@ -461,37 +440,7 @@ namespace Revitalize.Framework.Objects
/// <summary>What happens when the object is drawn when held by a player.</summary> /// <summary>What happens when the object is drawn when held by a player.</summary>
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f) public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f)
{ {
if (this.info == null)
{
ModCore.log("Info is null:");
ModCore.log("Need request for guid: " + this.guid);
MultiplayerUtilities.SendRequestForSpecificGUID(this.guid);
if (ModCore.CustomObjects.ContainsKey(this.guid))
{
if (ModCore.CustomObjects[this.guid].info != null)
{
this.info = ModCore.CustomObjects[this.guid].info;
}
}
else
{
foreach(var v in ModCore.CustomObjects)
{
if (v.Value == this)
{
this.info = v.Value.info;
}
}
}
return;
}
else
{
ModCore.log("Drawing custom object: " + this.guid);
}
if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
if (f.ActiveObject.bigCraftable.Value) if (f.ActiveObject.bigCraftable.Value)
@ -521,36 +470,38 @@ namespace Revitalize.Framework.Objects
{ {
//Do nothing because this shouldn't be placeable anywhere. //Do nothing because this shouldn't be placeable anywhere.
} }
/*
public virtual bool InitNetFields() public void InitNetFields()
{ {
if (Game1.IsMultiplayer == false) if (Game1.IsMultiplayer == false && (Game1.IsClient == false || Game1.IsClient == false)) return;
{ this.initNetFields();
//ModCore.log("Not multiplayer!");
return false;
}
if (MultiplayerUtilities.HasLoadedIn == false)
{
return false;
}
ModCore.log("Initialize net fields!");
//this.initNetFields();
this.syncObject = new PySync(this); this.syncObject = new PySync(this);
///this.NetFields.AddField(this.syncObject); this.NetFields.AddField(this.syncObject);
//this.netItemInfo = new Netcode.NetString(this.ItemInfo); this.netItemInfo = new Netcode.NetString(this.ItemInfo);
//this.NetFields.AddField(this.netItemInfo); this.NetFields.AddField(this.netItemInfo);
//this.netInfo = new NetBasicItemInformation(this.info);
//this.NetFields.AddField(this.netInfo);
return true;
} }
*/
/// <summary>
/// Gets all of the data necessary for syncing.
/// </summary>
/// <returns></returns>
public override Dictionary<string, string> getSyncData()
{
Dictionary<string, string> syncData = base.getSyncData();
syncData.Add("BasicItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info));
return syncData;
}
/// <summary> /// <summary>
/// Syncs all of the info to all players. /// Syncs all of the info to all players.
/// </summary> /// </summary>
/// <param name="syncData"></param> /// <param name="syncData"></param>
public override void sync(Dictionary<string, string> syncData)
{
//Revitalize.ModCore.log("SYNC OBJECT DATA!");
base.sync(syncData);
this.info = Revitalize.ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(syncData["BasicItemInfo"]);
}
public virtual void replaceAfterLoad() public virtual void replaceAfterLoad()
@ -563,7 +514,6 @@ namespace Revitalize.Framework.Objects
//ModCore.log("Do I ingnore BB? " + this.info.ignoreBoundingBox); //ModCore.log("Do I ingnore BB? " + this.info.ignoreBoundingBox);
//ModCore.log("This is my BB: " + this.boundingBox.Value); //ModCore.log("This is my BB: " + this.boundingBox.Value);
//this.InitNetFields();
} }
} }
@ -573,26 +523,5 @@ namespace Revitalize.Framework.Objects
//Load in a file that has all object names referenced here or something. //Load in a file that has all object names referenced here or something.
return this.info.name; return this.info.name;
} }
public object getReplacement()
{
return new StardewValley.Object(this.TileLocation, 14, false);
}
public Dictionary<string, string> getAdditionalSaveData()
{
Dictionary<string, string> saveData = new Dictionary<string, string>();
saveData.Add("Greeting", "Hello");
saveData.Add("ItemInfo", ModCore.Serializer.ToJSONString(this.info));
return saveData;
}
public void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
{
this.DisplayName = additionalSaveData["Greeting"];
this.info =ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
this.initializeBasics();
ModCore.log("Rebuilt custom object and it's info from save!");
}
} }
} }

View File

@ -71,12 +71,13 @@ namespace Revitalize.Framework.Objects.Extras
obj.childrenGuids.Remove(pair.Key); obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString()); //Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
ArcadeCabinetTile component = Revitalize.ModCore.Serializer.DeserializeGUID<ArcadeCabinetTile>(pair.Value.ToString()); ArcadeCabinetTile component = Revitalize.ModCore.Serializer.DeserializeGUID<ArcadeCabinetTile>(pair.Value.ToString());
component.InitNetFields();
obj.addComponent(pair.Key, component); obj.addComponent(pair.Key, component);
} }
obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"])) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{ {
@ -104,11 +105,13 @@ namespace Revitalize.Framework.Objects.Extras
{ {
this.childrenGuids.Remove(pair.Key); this.childrenGuids.Remove(pair.Key);
ArcadeCabinetTile component = Revitalize.ModCore.Serializer.DeserializeGUID<ArcadeCabinetTile>(pair.Value.ToString()); ArcadeCabinetTile component = Revitalize.ModCore.Serializer.DeserializeGUID<ArcadeCabinetTile>(pair.Value.ToString());
component.InitNetFields();
this.removeComponent(pair.Key); this.removeComponent(pair.Key);
this.addComponent(pair.Key, component); this.addComponent(pair.Key, component);
} }
this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString())) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{ {

View File

@ -86,13 +86,13 @@ namespace Revitalize.Framework.Objects.Furniture
obj.childrenGuids.Remove(pair.Key); obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString()); //Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
ChairTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<ChairTileComponent>(pair.Value.ToString()); ChairTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<ChairTileComponent>(pair.Value.ToString());
///component.InitNetFields(); component.InitNetFields();
obj.addComponent(pair.Key, component); obj.addComponent(pair.Key, component);
} }
//obj.InitNetFields(); obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"])) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{ {
@ -118,13 +118,13 @@ namespace Revitalize.Framework.Objects.Furniture
{ {
this.childrenGuids.Remove(pair.Key); this.childrenGuids.Remove(pair.Key);
ChairTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<ChairTileComponent>(pair.Value.ToString()); ChairTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<ChairTileComponent>(pair.Value.ToString());
//component.InitNetFields(); component.InitNetFields();
this.removeComponent(pair.Key); this.removeComponent(pair.Key);
this.addComponent(pair.Key, component); this.addComponent(pair.Key, component);
} }
//this.InitNetFields(); this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString())) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{ {

View File

@ -87,13 +87,13 @@ namespace Revitalize.Framework.Objects.Furniture
obj.childrenGuids.Remove(pair.Key); obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString()); //Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
ChairTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<ChairTileComponent>(pair.Value.ToString()); ChairTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<ChairTileComponent>(pair.Value.ToString());
//component.InitNetFields(); component.InitNetFields();
obj.addComponent(pair.Key, component); obj.addComponent(pair.Key, component);
} }
//obj.InitNetFields(); obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"])) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{ {
@ -121,13 +121,13 @@ namespace Revitalize.Framework.Objects.Furniture
{ {
this.childrenGuids.Remove(pair.Key); this.childrenGuids.Remove(pair.Key);
ChairTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<ChairTileComponent>(pair.Value.ToString()); ChairTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<ChairTileComponent>(pair.Value.ToString());
//component.InitNetFields(); component.InitNetFields();
this.removeComponent(pair.Key); this.removeComponent(pair.Key);
this.addComponent(pair.Key, component); this.addComponent(pair.Key, component);
} }
//this.InitNetFields(); this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString())) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{ {

View File

@ -163,7 +163,7 @@ namespace Revitalize.Framework.Objects.Furniture
y *= -1; y *= -1;
} }
*/ */
this.updateInfoIfNull();
if (this.info == null) if (this.info == null)
{ {
Revitalize.ModCore.log("info is null"); Revitalize.ModCore.log("info is null");
@ -215,7 +215,6 @@ namespace Revitalize.Framework.Objects.Furniture
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f)
{ {
this.updateInfoIfNull();
if (objectPosition.X < 0) objectPosition.X *= -1; if (objectPosition.X < 0) objectPosition.X *= -1;
if (objectPosition.Y < 0) objectPosition.Y *= -1; if (objectPosition.Y < 0) objectPosition.Y *= -1;
base.drawWhenHeld(spriteBatch, objectPosition, f); base.drawWhenHeld(spriteBatch, objectPosition, f);

View File

@ -71,13 +71,13 @@ namespace Revitalize.Framework.Objects.Furniture
obj.childrenGuids.Remove(pair.Key); obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString()); //Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
LampTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<LampTileComponent>(pair.Value.ToString()); LampTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<LampTileComponent>(pair.Value.ToString());
//component.InitNetFields(); component.InitNetFields();
obj.addComponent(pair.Key, component); obj.addComponent(pair.Key, component);
} }
//obj.InitNetFields(); obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"])) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{ {
@ -105,13 +105,13 @@ namespace Revitalize.Framework.Objects.Furniture
{ {
this.childrenGuids.Remove(pair.Key); this.childrenGuids.Remove(pair.Key);
LampTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<LampTileComponent>(pair.Value.ToString()); LampTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<LampTileComponent>(pair.Value.ToString());
//component.InitNetFields(); component.InitNetFields();
this.removeComponent(pair.Key); this.removeComponent(pair.Key);
this.addComponent(pair.Key, component); this.addComponent(pair.Key, component);
} }
//this.InitNetFields(); this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString())) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{ {

View File

@ -73,13 +73,13 @@ namespace Revitalize.Framework.Objects.Furniture
obj.childrenGuids.Remove(pair.Key); obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString()); //Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
RugTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<RugTileComponent>(pair.Value.ToString()); RugTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<RugTileComponent>(pair.Value.ToString());
//component.InitNetFields(); component.InitNetFields();
obj.addComponent(pair.Key, component); obj.addComponent(pair.Key, component);
} }
//obj.InitNetFields(); obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"])) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{ {
@ -107,13 +107,13 @@ namespace Revitalize.Framework.Objects.Furniture
{ {
this.childrenGuids.Remove(pair.Key); this.childrenGuids.Remove(pair.Key);
RugTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<RugTileComponent>(pair.Value.ToString()); RugTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<RugTileComponent>(pair.Value.ToString());
//component.InitNetFields(); component.InitNetFields();
this.removeComponent(pair.Key); this.removeComponent(pair.Key);
this.addComponent(pair.Key, component); this.addComponent(pair.Key, component);
} }
//this.InitNetFields(); this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString())) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{ {

View File

@ -71,13 +71,13 @@ namespace Revitalize.Framework.Objects.Furniture
obj.childrenGuids.Remove(pair.Key); obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString()); //Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
StorageFurnitureTile component = Revitalize.ModCore.Serializer.DeserializeGUID<StorageFurnitureTile>(pair.Value.ToString()); StorageFurnitureTile component = Revitalize.ModCore.Serializer.DeserializeGUID<StorageFurnitureTile>(pair.Value.ToString());
//component.InitNetFields(); component.InitNetFields();
obj.addComponent(pair.Key, component); obj.addComponent(pair.Key, component);
} }
//obj.InitNetFields(); obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"])) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{ {
@ -105,13 +105,13 @@ namespace Revitalize.Framework.Objects.Furniture
{ {
this.childrenGuids.Remove(pair.Key); this.childrenGuids.Remove(pair.Key);
StorageFurnitureTile component = Revitalize.ModCore.Serializer.DeserializeGUID<StorageFurnitureTile>(pair.Value.ToString()); StorageFurnitureTile component = Revitalize.ModCore.Serializer.DeserializeGUID<StorageFurnitureTile>(pair.Value.ToString());
//component.InitNetFields(); component.InitNetFields();
this.removeComponent(pair.Key); this.removeComponent(pair.Key);
this.addComponent(pair.Key, component); this.addComponent(pair.Key, component);
} }
//this.InitNetFields(); this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString())) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{ {

View File

@ -72,13 +72,13 @@ namespace Revitalize.Framework.Objects.Furniture
obj.childrenGuids.Remove(pair.Key); obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString()); //Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
TableTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<TableTileComponent>(pair.Value.ToString()); TableTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<TableTileComponent>(pair.Value.ToString());
//component.InitNetFields(); component.InitNetFields();
obj.addComponent(pair.Key, component); obj.addComponent(pair.Key, component);
} }
//obj.InitNetFields(); obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"])) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{ {
@ -106,13 +106,13 @@ namespace Revitalize.Framework.Objects.Furniture
{ {
this.childrenGuids.Remove(pair.Key); this.childrenGuids.Remove(pair.Key);
TableTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<TableTileComponent>(pair.Value.ToString()); TableTileComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<TableTileComponent>(pair.Value.ToString());
//component.InitNetFields(); component.InitNetFields();
this.removeComponent(pair.Key); this.removeComponent(pair.Key);
this.addComponent(pair.Key, component); this.addComponent(pair.Key, component);
} }
//this.InitNetFields(); this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString())) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{ {

View File

@ -255,23 +255,9 @@ namespace Revitalize.Framework.Objects.Furniture
if (this.info == null) if (this.info == null)
{ {
Revitalize.ModCore.log("info is null"); Revitalize.ModCore.log("info is null");
this.info = this.netInfo.Value;
if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC");
} }
if (this.animationManager == null) if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
{
Revitalize.ModCore.log("Animation Manager Null");
if (this.info == null)
{
ModCore.log("And info is still null!");
return;
}
else
{
this.info.animationManager = this.netInfo.Value.animationManager;
return;
}
}
if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
//The actual planter box being drawn. //The actual planter box being drawn.

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Revitalize.Framework.Objects.InformationFiles
{
public class ObjectGUIDInfo
{
public enum ObjectType
{
Solid,
Display
}
public ObjectGUIDInfo()
{
}
}
}

View File

@ -1,48 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PyTK.CustomElementHandler;
using StardewValley;
using StardewValley.Objects;
namespace Revitalize.Framework.Objects.Items
{
internal class MyTool : Tool, ISaveElement
{
public string something;
public object getReplacement()
{
return new Chest(true);
}
public Dictionary<string, string> getAdditionalSaveData()
{
Dictionary<string, string> saveData = new Dictionary<string, string>();
saveData.Add("something", "myValue");
return saveData;
}
public void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
{
this.something = additionalSaveData["something"];
ModCore.log("What is my something: " + this.something);
}
protected override string loadDisplayName()
{
return "Pytk tool";
}
protected override string loadDescription()
{
return "My description";
}
public override Item getOne()
{
return new MyTool();
}
}
}

View File

@ -177,19 +177,16 @@ namespace Revitalize.Framework.Objects.Items.Resources
/// <summary>What happens when the object is drawn at a tile location.</summary> /// <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) public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
{ {
this.updateInfoIfNull();
if (this.info.ignoreBoundingBox == true) if (this.info.ignoreBoundingBox == true)
{ {
x *= -1; x *= -1;
y *= -1; y *= -1;
} }
if (this.info == null) if (this.info == null)
{ {
Revitalize.ModCore.log("info is null"); Revitalize.ModCore.log("info is null");
if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC");
return;
} }
if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
@ -226,7 +223,6 @@ namespace Revitalize.Framework.Objects.Items.Resources
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow)
{ {
this.updateInfoIfNull();
if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1) if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1)
Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White); Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White);
if (drawStackNumber && this.Quality > 0) if (drawStackNumber && this.Quality > 0)

View File

@ -4,12 +4,9 @@ using System.IO;
using System.Text; using System.Text;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Netcode;
using Newtonsoft.Json; using Newtonsoft.Json;
using PyTK.CustomElementHandler; using PyTK.CustomElementHandler;
using Revitalize.Framework.Networking.Fields;
using StardewValley; using StardewValley;
using StardewValley.Network;
using StardewValley.Objects; using StardewValley.Objects;
namespace Revitalize.Framework.Objects namespace Revitalize.Framework.Objects
@ -294,11 +291,13 @@ namespace Revitalize.Framework.Objects
{ {
obj.childrenGuids.Remove(pair.Key); obj.childrenGuids.Remove(pair.Key);
MultiTiledComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<MultiTiledComponent>(pair.Value.ToString()); MultiTiledComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<MultiTiledComponent>(pair.Value.ToString());
component.InitNetFields();
obj.removeComponent(pair.Key); obj.removeComponent(pair.Key);
obj.addComponent(pair.Key, component); obj.addComponent(pair.Key, component);
} }
obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"])) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{ {
@ -329,11 +328,13 @@ namespace Revitalize.Framework.Objects
{ {
this.childrenGuids.Remove(pair.Key); this.childrenGuids.Remove(pair.Key);
MultiTiledComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<MultiTiledComponent>(pair.Value.ToString()); MultiTiledComponent component = Revitalize.ModCore.Serializer.DeserializeGUID<MultiTiledComponent>(pair.Value.ToString());
component.InitNetFields();
this.removeComponent(pair.Key); this.removeComponent(pair.Key);
this.addComponent(pair.Key, component); this.addComponent(pair.Key, component);
} }
this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString())) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{ {
@ -371,6 +372,5 @@ namespace Revitalize.Framework.Objects
return 1; return 1;
} }
} }
} }

View File

@ -83,13 +83,13 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins
obj.childrenGuids.Remove(pair.Key); obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString()); //Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
OreVeinTile component = Revitalize.ModCore.Serializer.DeserializeGUID<OreVeinTile>(pair.Value.ToString()); OreVeinTile component = Revitalize.ModCore.Serializer.DeserializeGUID<OreVeinTile>(pair.Value.ToString());
//component.InitNetFields(); component.InitNetFields();
obj.addComponent(pair.Key, component); obj.addComponent(pair.Key, component);
} }
//obj.InitNetFields(); obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"])) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{ {
@ -117,13 +117,13 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins
{ {
this.childrenGuids.Remove(pair.Key); this.childrenGuids.Remove(pair.Key);
OreVeinTile component = Revitalize.ModCore.Serializer.DeserializeGUID<OreVeinTile>(pair.Value.ToString()); OreVeinTile component = Revitalize.ModCore.Serializer.DeserializeGUID<OreVeinTile>(pair.Value.ToString());
//component.InitNetFields(); component.InitNetFields();
this.removeComponent(pair.Key); this.removeComponent(pair.Key);
this.addComponent(pair.Key, component); this.addComponent(pair.Key, component);
} }
//this.InitNetFields(); this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString())) if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{ {

View File

@ -4,18 +4,18 @@ namespace Revitalize.Framework.Player
{ {
public class PlayerInfo public class PlayerInfo
{ {
//public SittingInfo sittingInfo; public SittingInfo sittingInfo;
public MagicManager magicManager; public MagicManager magicManager;
public PlayerInfo() public PlayerInfo()
{ {
//this.sittingInfo = new SittingInfo(); this.sittingInfo = new SittingInfo();
this.magicManager = new MagicManager(); this.magicManager = new MagicManager();
} }
public void update() public void update()
{ {
//this.sittingInfo.update(); this.sittingInfo.update();
} }
} }
} }

View File

@ -93,7 +93,7 @@ namespace Revitalize.Framework.Utilities
//ModCore.log("Dimensions of map is: " + dimensions); //ModCore.log("Dimensions of map is: " + dimensions);
return dimensions; return dimensions;
} }
/*
/// <summary> /// <summary>
/// Gets all open positions for this location for this object. /// Gets all open positions for this location for this object.
/// </summary> /// </summary>
@ -117,7 +117,7 @@ namespace Revitalize.Framework.Utilities
} }
return openTiles; return openTiles;
} }
*/
/// <summary> /// <summary>
/// Checks to see if the farm for the game is the hilltop farm. /// Checks to see if the farm for the game is the hilltop farm.
/// </summary> /// </summary>

View File

@ -1,212 +0,0 @@
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
{
public class MultiplayerUtilities
{
public static Dictionary<GameLocation, Dictionary<Vector2, List<Item>>> ItemsToRestore = new Dictionary<GameLocation, Dictionary<Vector2, List<Item>>>();
public static Dictionary<long, List<Item>> PlayerItemsToRestore = new Dictionary<long, List<Item>>();
public static int onlineFarmers;
public static bool needToRestore;
public static bool HasLoadedIn;
public static bool ShouldRestoreObjects
{
get
{
return HasLoadedIn && Game1.player.isMoving() && needToRestore == true;
}
}
public static void OnPlayerConnect(object sender, StardewModdingAPI.Events.PeerContextReceivedEventArgs e)
{
if (Game1.IsServer)
{
needToRestore = true;
foreach (Farmer f in Game1.getAllFarmers())
{
if (PlayerItemsToRestore.ContainsKey(f.UniqueMultiplayerID))
{
//Do nothing.
}
else
{
PlayerItemsToRestore.Add(f.UniqueMultiplayerID, new List<Item>());
}
foreach (Item I in f.Items)
{
if (I == null) continue;
if (I is CustomObject)
{
//(I as CustomObject).InitNetFields();
PlayerItemsToRestore[f.UniqueMultiplayerID].Add(I);
}
}
foreach (Item I in PlayerItemsToRestore[f.UniqueMultiplayerID])
{
f.removeItemFromInventory(I);
}
}
ModCore.log("Clear items because someone showed up.");
}
}
public static void OnPlayerDisconnect(object sender, StardewModdingAPI.Events.PeerDisconnectedEventArgs e)
{
if (Game1.IsServer)
{
foreach (Farmer f in Game1.getAllFarmers())
{
if (PlayerItemsToRestore.ContainsKey(f.UniqueMultiplayerID))
{
//Do nothing.
}
else
{
PlayerItemsToRestore.Add(f.UniqueMultiplayerID, new List<Item>());
}
foreach (Item I in f.Items)
{
if (I == null) continue;
if (I is CustomObject)
{
//(I as CustomObject).InitNetFields();
PlayerItemsToRestore[f.UniqueMultiplayerID].Add(I);
/*
if (I is MultiTiledObject)
{
foreach (CustomObject c in (I as MultiTiledObject).objects.Values)
{
//c.InitNetFields();
}
}
*/
}
}
foreach (Item I in PlayerItemsToRestore[f.UniqueMultiplayerID])
{
f.removeItemFromInventory(I);
}
}
ModCore.log("Clear items because someone disconnected.");
}
}
public static void GameLoop_OneSecondUpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
{
if (ShouldRestoreObjects)
{
ModCore.ModHelper.Multiplayer.SendMessage("Revitalize.RestoreModObjectsAfterConnect", "Revitalize.RestoreModObjectsAfterConnect", new string[] { ModCore.Manifest.UniqueID });
needToRestore = false;
}
}
public static void ModMessageReceived(object sender, StardewModdingAPI.Events.ModMessageReceivedEventArgs e)
{
if (e.Type == "Revitalize.RestoreModObjectsAfterConnect")
{
RestoreModObjects();
needToRestore = false;
}
if(e.Type == "Revitalize.RequestCustomObjects")
{
SendCustomObjects();
}
if(e.Type== "Revitalize.SendCustomObjects")
{
Dictionary<Guid, CustomObject> additionalObjects =ModCore.Serializer.Deserialize<Dictionary<Guid,CustomObject>>(e.ReadAs<string>());
foreach(KeyValuePair<Guid,CustomObject> pair in additionalObjects)
{
if (ModCore.CustomObjects.ContainsKey(pair.Key))
{
ModCore.CustomObjects[pair.Key] = pair.Value;
}
else
{
ModCore.CustomObjects.Add(pair.Key, pair.Value);
}
}
}
if(e.Type== "Revitalize.RequestCustomObjectGUID")
{
Guid requested = Guid.Parse(e.ReadAs<string>());
//if specific guid exists send that.
if (ModCore.CustomObjects.ContainsKey(requested))
{
if (ModCore.CustomObjects[requested].info != null)
{
KeyValuePair<Guid, CustomObject> pair = new KeyValuePair<Guid, CustomObject>(requested, ModCore.CustomObjects[requested]);
SendCustomObject(pair);
}
}
else
{
//If it doesn't exist send the whole dictionary.
SendCustomObjects();
}
}
if(e.Type== "Revitalize.SendCustomObjectGUID")
{
KeyValuePair<Guid,CustomObject> requested = ModCore.Serializer.DeserializeFromJSONString<KeyValuePair<Guid,CustomObject>>(e.ReadAs<string>());
if (ModCore.CustomObjects.ContainsKey(requested.Key))
{
ModCore.CustomObjects[requested.Key] = requested.Value;
}
else
{
ModCore.CustomObjects.Add(requested.Key, requested.Value);
}
}
}
public static void RestoreModObjects()
{
foreach (KeyValuePair<long, List<Item>> items in PlayerItemsToRestore)
{
Farmer f = Game1.getFarmer(items.Key);
foreach (Item I in items.Value)
{
f.addItemToInventoryBool(I, false);
}
items.Value.Clear();
}
ModCore.log("Restore mod objects!");
needToRestore = false;
}
public static void SendCustomObjects()
{
ModCore.ModHelper.Multiplayer.SendMessage("Revitalize.SendCustomObjects", ModCore.Serializer.ToJSONString(ModCore.CustomObjects), new string[] { ModCore.Manifest.UniqueID });
}
public static void SendRequestForCustomObjects()
{
ModCore.ModHelper.Multiplayer.SendMessage("Revitalize.RequestCustomObjects", "Revitalize.RequestCustomObjects", new string[] { ModCore.Manifest.UniqueID });
}
public static void SendRequestForSpecificGUID(Guid guid)
{
ModCore.ModHelper.Multiplayer.SendMessage("Revitalize.RequestCustomObjectGUID", guid.ToString(), new string[] { ModCore.Manifest.UniqueID });
}
public static void SendCustomObject(KeyValuePair<Guid,CustomObject> Pair)
{
string s = ModCore.Serializer.ToJSONString(Pair);
ModCore.ModHelper.Multiplayer.SendMessage("Revitalize.SendCustomObjectGUID", s , new string[] { ModCore.Manifest.UniqueID });
}
}
}

View File

@ -1,168 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Netcode;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using Revitalize.Framework.Utilities.Serialization.ContractResolvers;
namespace Revitalize.Framework.Utilities.Serialization.Converters
{
public class INetSerializableConverter : Newtonsoft.Json.JsonConverter
{
public static Dictionary<string, Type> AllTypes = new Dictionary<string, Type>();
JsonSerializerSettings settings;
public INetSerializableConverter()
{
this.settings = new JsonSerializerSettings()
{
Converters = new List<JsonConverter>()
{
new Framework.Utilities.Serialization.Converters.RectangleConverter(),
new Framework.Utilities.Serialization.Converters.Texture2DConverter(),
},
ContractResolver = new NetFieldContract(),
Formatting = Formatting.Indented,
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
NullValueHandling = NullValueHandling.Include
};
this.settings.Converters.Add(this);
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
string convertedString = JsonConvert.SerializeObject((INetSerializable)value, this.settings);
DefaultContractResolver resolver = serializer.ContractResolver as DefaultContractResolver;
writer.WriteStartObject();
writer.WritePropertyName("Type");
serializer.Serialize(writer, value.GetType().FullName.ToString());
writer.WritePropertyName("Item");
serializer.Serialize(writer, convertedString);
writer.WriteEndObject();
}
/// <summary>
/// Reads the JSON representation of the object.
/// </summary>
/// <param name="reader">The <see cref="JsonReader"/> to read from.</param>
/// <param name="objectType">Type of the object.</param>
/// <param name="existingValue">The existing value of object being read.</param>
/// <param name="serializer">The calling serializer.</param>
/// <returns>The object value.</returns>
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null)
{
return null;
}
JObject jo = null;
try
{
jo = JObject.Load(reader);
}
catch(Exception err)
{
if (reader.Value == null) return null;
JArray arr= JArray.Parse(reader.Value.ToString());
jo=JObject.Parse(arr[0].ToString());
}
string t = jo["Type"].Value<string>();
//See if the type has already been cached and if so return it for deserialization.
if (AllTypes.ContainsKey(t))
{
return JsonConvert.DeserializeObject(jo["Item"].ToString(), AllTypes[t], this.settings);
}
Assembly asm = typeof(StardewValley.Object).Assembly;
Type type = null;
type = asm.GetType(t);
if (type == null)
{
asm = typeof(Revitalize.ModCore).Assembly;
type = asm.GetType(t);
}
if (type == null)
{
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
asm = assembly;
type = asm.GetType(t);
if (t != null) break;
}
}
if (type == null)
{
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.
AllTypes.Add(t, type);
return JsonConvert.DeserializeObject(jo["Item"].ToString(), type, this.settings);
/*
if (t== typeof(StardewValley.Tools.Axe).FullName.ToString())
{
Revitalize.ModCore.log("DESERIALIZE AXE!!!");
//return jo["Item"].Value<StardewValley.Tools.Axe>();
return JsonConvert.DeserializeObject<StardewValley.Tools.Axe>(jo["Item"].ToString(),this.settings);
}
else if (t == typeof(Revitalize.Framework.Objects.MultiTiledObject).FullName.ToString())
{
Revitalize.ModCore.log("DESERIALIZE Multi Tile Object!!!");
return JsonConvert.DeserializeObject<Revitalize.Framework.Objects.MultiTiledObject>(jo["Item"].ToString(), this.settings);
// return jo["Item"].Value<Revitalize.Framework.Objects.MultiTiledObject>();
}
else if (t == typeof(Revitalize.Framework.Objects.MultiTiledComponent).FullName.ToString())
{
Revitalize.ModCore.log("DESERIALIZE Multi Tile Component!!!");
return JsonConvert.DeserializeObject<Revitalize.Framework.Objects.MultiTiledComponent>(jo["Item"].ToString(), this.settings);
// return jo["Item"].Value<Revitalize.Framework.Objects.MultiTiledObject>();
}
else
{
throw new NotImplementedException("CANT DESERIALIZE: " + t.ToString());
}
*/
}
public override bool CanWrite => true;
public override bool CanRead => true;
public override bool CanConvert(Type objectType)
{
return this.IsSameOrSubclass(typeof(INetSerializable), objectType);
}
/// <summary>
/// https://stackoverflow.com/questions/2742276/how-do-i-check-if-a-type-is-a-subtype-or-the-type-of-an-object
/// </summary>
/// <param name="potentialBase"></param>
/// <param name="potentialDescendant"></param>
/// <returns></returns>
public bool IsSameOrSubclass(Type potentialBase, Type potentialDescendant)
{
return potentialDescendant.IsSubclassOf(potentialBase)
|| potentialDescendant == potentialBase;
}
}
}

View File

@ -7,7 +7,6 @@ using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using Revitalize.Framework.Utilities.Serialization.ContractResolvers;
using StardewValley; using StardewValley;
namespace Revitalize.Framework.Utilities.Serialization.Converters namespace Revitalize.Framework.Utilities.Serialization.Converters
@ -25,21 +24,18 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
{ {
new Framework.Utilities.Serialization.Converters.RectangleConverter(), new Framework.Utilities.Serialization.Converters.RectangleConverter(),
new Framework.Utilities.Serialization.Converters.Texture2DConverter(), new Framework.Utilities.Serialization.Converters.Texture2DConverter(),
new INetSerializableConverter()
}, },
ContractResolver = new NetFieldContract(),
Formatting = Formatting.Indented, Formatting = Formatting.Indented,
ReferenceLoopHandling = ReferenceLoopHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
NullValueHandling = NullValueHandling.Include NullValueHandling = NullValueHandling.Include
}; };
//this.settings.Converters.Add(this);
} }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{ {
string convertedString = JsonConvert.SerializeObject((Item)value, this.settings); string convertedString = JsonConvert.SerializeObject((Item)value, this.settings);
DefaultContractResolver resolver = serializer.ContractResolver as DefaultContractResolver;
writer.WriteStartObject(); writer.WriteStartObject();
writer.WritePropertyName("Type"); writer.WritePropertyName("Type");
serializer.Serialize(writer, value.GetType().FullName.ToString()); serializer.Serialize(writer, value.GetType().FullName.ToString());
@ -66,18 +62,7 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
return null; return null;
} }
JObject jo = null; JObject jo = JObject.Load(reader);
try
{
jo = JObject.Load(reader);
}
catch (Exception err)
{
if (reader.Value == null) return null;
JArray arr = JArray.Parse(reader.Value.ToString());
jo = JObject.Parse(arr[0].ToString());
}
string t = jo["Type"].Value<string>(); string t = jo["Type"].Value<string>();

View File

@ -4,12 +4,10 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Netcode;
using Newtonsoft.Json; using Newtonsoft.Json;
using Revitalize.Framework.Objects; using Revitalize.Framework.Objects;
//using Revitalize.Framework.Objects.Furniture; using Revitalize.Framework.Objects.Furniture;
using Revitalize.Framework.Utilities.Serialization.ContractResolvers; using Revitalize.Framework.Utilities.Serialization.ContractResolvers;
using Revitalize.Framework.Utilities.Serialization.Converters;
using StardewValley; using StardewValley;
using StardewValley.Objects; using StardewValley.Objects;
@ -20,8 +18,6 @@ namespace Revitalize.Framework.Utilities
/// </summary> /// </summary>
public class Serializer public class Serializer
{ {
/// <summary> /// <summary>
/// The actual json serializer. /// The actual json serializer.
/// </summary> /// </summary>
@ -52,12 +48,11 @@ namespace Revitalize.Framework.Utilities
this.serializer.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; this.serializer.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
this.serializer.NullValueHandling = NullValueHandling.Include; this.serializer.NullValueHandling = NullValueHandling.Include;
//this.serializer.ContractResolver = new NetFieldContract(); this.serializer.ContractResolver = new NetFieldContract();
this.addConverter(new Framework.Utilities.Serialization.Converters.RectangleConverter()); this.addConverter(new Framework.Utilities.Serialization.Converters.RectangleConverter());
this.addConverter(new Framework.Utilities.Serialization.Converters.Texture2DConverter()); this.addConverter(new Framework.Utilities.Serialization.Converters.Texture2DConverter());
this.addConverter(new Framework.Utilities.Serialization.Converters.ItemCoverter()); this.addConverter(new Framework.Utilities.Serialization.Converters.ItemCoverter());
this.addConverter(new Serialization.Converters.INetSerializableConverter());
//this.addConverter(new Framework.Utilities.Serialization.Converters.CustomObjectDataConverter()); //this.addConverter(new Framework.Utilities.Serialization.Converters.CustomObjectDataConverter());
//this.addConverter(new Framework.Utilities.Serialization.Converters.NetFieldConverter()); //this.addConverter(new Framework.Utilities.Serialization.Converters.NetFieldConverter());
//this.addConverter(new Framework.Utilities.Serialization.Converters.Vector2Converter()); //this.addConverter(new Framework.Utilities.Serialization.Converters.Vector2Converter());
@ -72,7 +67,7 @@ namespace Revitalize.Framework.Utilities
this.settings.Formatting = Formatting.Indented; this.settings.Formatting = Formatting.Indented;
this.settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; this.settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
this.settings.NullValueHandling = NullValueHandling.Include; this.settings.NullValueHandling = NullValueHandling.Include;
//this.settings.ContractResolver = new NetFieldContract(); this.settings.ContractResolver = new NetFieldContract();
} }
/// <summary> /// <summary>
@ -135,10 +130,9 @@ namespace Revitalize.Framework.Utilities
{ {
this.deleteAllUnusedFiles(); this.deleteAllUnusedFiles();
//this.removeNullObjects(); //this.removeNullObjects();
//this.restoreModObjects(); this.restoreModObjects();
} }
/*
/// <summary> /// <summary>
/// Restore mod objects to inventories and world after load. /// Restore mod objects to inventories and world after load.
/// </summary> /// </summary>
@ -253,7 +247,7 @@ namespace Revitalize.Framework.Utilities
Game1.player.addItemToInventory(I); Game1.player.addItemToInventory(I);
} }
} }
*/
/// <summary> /// <summary>
/// Gets an Item recreated from PYTK's chest replacement objects. /// Gets an Item recreated from PYTK's chest replacement objects.
@ -269,7 +263,10 @@ namespace Revitalize.Framework.Utilities
string type = jsonString.Split('|')[2]; string type = jsonString.Split('|')[2];
Item I = (Item)ModCore.Serializer.DeserializeGUID(guidName, Type.GetType(type)); Item I = (Item)ModCore.Serializer.DeserializeGUID(guidName, Type.GetType(type));
//(I as CustomObject).InitNetFields(); if (I is MultiTiledObject)
{
(I as MultiTiledObject).recreate();
}
return I; return I;
} }

View File

@ -5,12 +5,12 @@ using Microsoft.Xna.Framework;
using PyTK.Extensions; using PyTK.Extensions;
using PyTK.Types; using PyTK.Types;
using Revitalize.Framework; using Revitalize.Framework;
//using Revitalize.Framework.Crafting; using Revitalize.Framework.Crafting;
using Revitalize.Framework.Environment; using Revitalize.Framework.Environment;
//using Revitalize.Framework.Factories.Objects; using Revitalize.Framework.Factories.Objects;
using Revitalize.Framework.Illuminate; using Revitalize.Framework.Illuminate;
using Revitalize.Framework.Objects; using Revitalize.Framework.Objects;
//using Revitalize.Framework.Objects.Furniture; using Revitalize.Framework.Objects.Furniture;
using Revitalize.Framework.Player; using Revitalize.Framework.Player;
using Revitalize.Framework.Utilities; using Revitalize.Framework.Utilities;
using StardewModdingAPI; using StardewModdingAPI;
@ -19,12 +19,10 @@ using StardewValley.Objects;
using StardustCore.UIUtilities; using StardustCore.UIUtilities;
using StardustCore.Animations; using StardustCore.Animations;
using StardewValley.Menus; using StardewValley.Menus;
//using Revitalize.Framework.Objects.Extras; using Revitalize.Framework.Objects.Extras;
using Revitalize.Framework.Minigame.SeasideScrambleMinigame; using Revitalize.Framework.Minigame.SeasideScrambleMinigame;
//using Revitalize.Framework.Objects.Items.Resources; using Revitalize.Framework.Objects.Items.Resources;
using Revitalize.Framework.Hacks; using Revitalize.Framework.Hacks;
using Netcode;
//using Revitalize.Framework.Objects.Items;
namespace Revitalize namespace Revitalize
{ {
@ -184,23 +182,22 @@ namespace Revitalize
/// <summary> /// <summary>
/// Keeps track of custom objects. /// Keeps track of custom objects.
/// </summary> /// </summary>
//public static ObjectManager ObjectManager; public static ObjectManager ObjectManager;
/// <summary> /// <summary>
/// Keeps track of all of the extra object groups. /// Keeps track of all of the extra object groups.
/// </summary> /// </summary>
//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;
//public static Dictionary<GameLocation, MultiTiledObject> ObjectsToDraw; public static Dictionary<GameLocation, MultiTiledObject> ObjectsToDraw;
//public static VanillaRecipeBook VanillaRecipeBook; public static VanillaRecipeBook VanillaRecipeBook;
public static Dictionary<Guid, CustomObject> CustomObjects; public static Dictionary<Guid, CustomObject> CustomObjects;
public override void Entry(IModHelper helper) public override void Entry(IModHelper helper)
{ {
ModHelper = helper; ModHelper = helper;
@ -209,7 +206,6 @@ namespace Revitalize
this.createDirectories(); this.createDirectories();
this.initailizeComponents(); this.initailizeComponents();
CustomObjects = new Dictionary<Guid, CustomObject>();
Serializer = new Serializer(); Serializer = new Serializer();
playerInfo = new PlayerInfo(); playerInfo = new PlayerInfo();
@ -217,10 +213,10 @@ namespace Revitalize
this.loadInTextures(); this.loadInTextures();
//Loads in objects to be use by the mod. //Loads in objects to be use by the mod.
//ObjectGroups = new Dictionary<string, MultiTiledObject>(); ObjectGroups = new Dictionary<string, MultiTiledObject>();
//ObjectManager = new ObjectManager(Manifest); ObjectManager = new ObjectManager(Manifest);
//ObjectManager.loadInItems(); ObjectManager.loadInItems();
//ObjectsToDraw = new Dictionary<GameLocation, MultiTiledObject>(); ObjectsToDraw = new Dictionary<GameLocation, MultiTiledObject>();
//Adds in event handling for the mod. //Adds in event handling for the mod.
ModHelper.Events.GameLoop.SaveLoaded += this.GameLoop_SaveLoaded; ModHelper.Events.GameLoop.SaveLoaded += this.GameLoop_SaveLoaded;
@ -228,20 +224,19 @@ namespace Revitalize
ModHelper.Events.GameLoop.UpdateTicked += this.GameLoop_UpdateTicked; ModHelper.Events.GameLoop.UpdateTicked += this.GameLoop_UpdateTicked;
ModHelper.Events.GameLoop.ReturnedToTitle += this.GameLoop_ReturnedToTitle; ModHelper.Events.GameLoop.ReturnedToTitle += this.GameLoop_ReturnedToTitle;
ModHelper.Events.Input.ButtonPressed += this.Input_ButtonPressed; ModHelper.Events.Input.ButtonPressed += this.Input_ButtonPressed;
//ModHelper.Events.Player.Warped += ObjectManager.resources.OnPlayerLocationChanged; ModHelper.Events.Player.Warped += ObjectManager.resources.OnPlayerLocationChanged;
//ModHelper.Events.GameLoop.DayStarted += ObjectManager.resources.DailyResourceSpawn; ModHelper.Events.GameLoop.DayStarted += ObjectManager.resources.DailyResourceSpawn;
//ModHelper.Events.Input.ButtonPressed += ObjectInteractionHacks.Input_CheckForObjectInteraction; ModHelper.Events.Input.ButtonPressed += ObjectInteractionHacks.Input_CheckForObjectInteraction;
ModHelper.Events.GameLoop.DayEnding += Serializer.DayEnding_CleanUpFilesForDeletion; ModHelper.Events.GameLoop.DayEnding += Serializer.DayEnding_CleanUpFilesForDeletion;
ModHelper.Events.Display.RenderedWorld += ObjectInteractionHacks.Render_RenderCustomObjectsHeldInMachines;
//ModHelper.Events.Display.Rendered += MenuHacks.EndOfDay_OnMenuChanged; //ModHelper.Events.Display.Rendered += MenuHacks.EndOfDay_OnMenuChanged;
//ModHelper.Events.GameLoop.Saved += MenuHacks.EndOfDay_CleanupForNewDay; //ModHelper.Events.GameLoop.Saved += MenuHacks.EndOfDay_CleanupForNewDay;
//ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.ModMessageReceived; CustomObjects = new Dictionary<Guid, CustomObject>();
//MultiplayerUtilities.onlineFarmers = 1;
//Adds in recipes to the mod. //Adds in recipes to the mod.
//VanillaRecipeBook = new VanillaRecipeBook(); VanillaRecipeBook = new VanillaRecipeBook();
} }
/// <summary> /// <summary>
/// Loads in textures to be used by the mod. /// Loads in textures to be used by the mod.
/// </summary> /// </summary>
@ -280,17 +275,17 @@ namespace Revitalize
private void GameLoop_ReturnedToTitle(object sender, StardewModdingAPI.Events.ReturnedToTitleEventArgs e) private void GameLoop_ReturnedToTitle(object sender, StardewModdingAPI.Events.ReturnedToTitleEventArgs e)
{ {
Serializer.returnToTitle(); Serializer.returnToTitle();
//ObjectManager = new ObjectManager(Manifest); ObjectManager = new ObjectManager(Manifest);
} }
/// <summary> /// <summary>
/// Must be enabled for the tabled to be placed???? /// Must be enabled for the tabled to be placed????
/// </summary> /// </summary>
private void loadContent() private void loadContent()
{ {
/*
//MultiTiledComponent obj = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledComponent), Color.White), new BasicItemInformation("CoreObjectTest", "Omegasis.TEST1", "YAY FUN!", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 300, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White, false, null, null)); MultiTiledComponent obj = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledComponent), Color.White), new BasicItemInformation("CoreObjectTest", "Omegasis.TEST1", "YAY FUN!", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 300, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White, false, null, null));
//MultiTiledComponent obj2 = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledComponent), Color.White), new BasicItemInformation("CoreObjectTest2", "Omegasis.TEST2", "Some fun!", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 300, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 16, 16, 16))), Color.White, false, null, null)); MultiTiledComponent obj2 = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledComponent), Color.White), new BasicItemInformation("CoreObjectTest2", "Omegasis.TEST2", "Some fun!", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 300, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 16, 16, 16))), Color.White, false, null, null));
//MultiTiledComponent obj3 = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledComponent), Color.White), new BasicItemInformation("CoreObjectTest3", "Omegasis.TEST3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 100, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red, false, null, null)); MultiTiledComponent obj3 = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledComponent), Color.White), new BasicItemInformation("CoreObjectTest3", "Omegasis.TEST3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 100, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red, false, null, null));
obj3.info.lightManager.addLight(new Vector2(Game1.tileSize), new LightSource(4, new Vector2(0, 0), 2.5f, Color.Orange.Invert()), obj3); obj3.info.lightManager.addLight(new Vector2(Game1.tileSize), new LightSource(4, new Vector2(0, 0), 2.5f, Color.Orange.Invert()), obj3);
@ -351,7 +346,6 @@ namespace Revitalize
ObjectManager.miscellaneous.Add("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", sscCabinet); ObjectManager.miscellaneous.Add("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", sscCabinet);
//ModCore.log("Added in SSC!"); //ModCore.log("Added in SSC!");
*/
} }
private void createDirectories() private void createDirectories()
@ -387,26 +381,20 @@ namespace Revitalize
private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e)
{ {
MultiplayerUtilities.HasLoadedIn = true;
this.loadContent(); this.loadContent();
/*
if (Game1.IsServer || Game1.IsMultiplayer || Game1.IsClient) if (Game1.IsServer || Game1.IsMultiplayer || Game1.IsClient)
{ {
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!");
} }
*/
Serializer.afterLoad(); Serializer.afterLoad();
ShopHacks.AddOreToClintsShop(); ShopHacks.AddOreToClintsShop();
MultiplayerUtilities.needToRestore = true;
// Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest")); // Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest"));
//Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair")); Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair"));
//Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest")); //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest"));
//Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable")); Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable"));
MultiplayerUtilities.onlineFarmers = Game1.getOnlineFarmers().Count;
//Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp")); //Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp"));
//Game1.player.addItemToInventory(ObjectManager.getObject("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble",ObjectManager.miscellaneous)); //Game1.player.addItemToInventory(ObjectManager.getObject("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble",ObjectManager.miscellaneous));
@ -419,16 +407,14 @@ namespace Revitalize
*/ */
//Game1.player.addItemToInventory(ObjectManager.resources.ores["Test"].getOne()); //Game1.player.addItemToInventory(ObjectManager.resources.ores["Test"].getOne());
//Game1.player.addItemToInventory(ObjectManager.GetItem("TinIngot"));
//Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin", 19)); Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin", 19));
//Ore tin = ObjectManager.resources.getOre("Tin", 19); //Ore tin = ObjectManager.resources.getOre("Tin", 19);
//Game1.player.addItemToInventory(new MyTool());
//ModCore.log("Tin sells for: " + tin.sellToStorePrice()); //ModCore.log("Tin sells for: " + tin.sellToStorePrice());
//ObjectManager.resources.spawnOreVein("Omegasis.Revitalize.Resources.Ore.Test", new Vector2(8, 7)); //ObjectManager.resources.spawnOreVein("Omegasis.Revitalize.Resources.Ore.Test", new Vector2(8, 7));
CustomObject tinIngot = new CustomObject(new BasicItemInformation("Tin Ingot", "Omegasis.Revitalize.Items.Resources.Ore.TinIngot", "A tin ingot that can be used for crafting purposes.", "Metal", Color.Silver, -300, 0, false, 75, false, false,false,TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TinIngot"), new AnimationManager(), Color.White, true, null, null), 1);
Game1.player.addItemToInventory(tinIngot);
} }
/* /*

View File

@ -31,7 +31,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json"> <PackageReference Include="Newtonsoft.Json">
<Version>12.0.2</Version> <Version>12.0.1</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="2.2.0" /> <PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="2.2.0" />
</ItemGroup> </ItemGroup>
@ -52,10 +52,22 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Framework\Crafting\Recipe.cs" />
<Compile Include="Framework\Crafting\RecipeBook.cs" />
<Compile Include="Framework\Crafting\StatCost.cs" />
<Compile Include="Framework\Crafting\VanillaRecipeBook.cs" />
<Compile Include="Framework\Crafting\VanillaRecipe.cs" />
<Compile Include="Framework\Enums\Enums.cs" /> <Compile Include="Framework\Enums\Enums.cs" />
<Compile Include="Framework\Environment\DarkerNight.cs" /> <Compile Include="Framework\Environment\DarkerNight.cs" />
<Compile Include="Framework\Environment\DarkerNightConfig.cs" /> <Compile Include="Framework\Environment\DarkerNightConfig.cs" />
<Compile Include="Framework\Factories\Objects\Extras\ArcadeFactoryInfo.cs" />
<Compile Include="Framework\Factories\Objects\Furniture\FurnitureFactory.cs" />
<Compile Include="Framework\Factories\Objects\Furniture\ChairFactoryInfo.cs" />
<Compile Include="Framework\Factories\Objects\FactoryInfo.cs" />
<Compile Include="Framework\Factories\Objects\Furniture\TableFactoryInfo.cs" />
<Compile Include="Framework\Factories\Objects\Resources\OreFactoryInfo.cs" />
<Compile Include="Framework\Hacks\MenuHacks.cs" /> <Compile Include="Framework\Hacks\MenuHacks.cs" />
<Compile Include="Framework\Hacks\ObjectInteractionHacks.cs" />
<Compile Include="Framework\Hacks\ShopHacks.cs" /> <Compile Include="Framework\Hacks\ShopHacks.cs" />
<Compile Include="Framework\Illuminate\ColorExtensions.cs" /> <Compile Include="Framework\Illuminate\ColorExtensions.cs" />
<Compile Include="Framework\Illuminate\FakeLightSource.cs" /> <Compile Include="Framework\Illuminate\FakeLightSource.cs" />
@ -97,21 +109,48 @@
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCStatusEffects\StatusEffect.cs" /> <Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCStatusEffects\StatusEffect.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCStatusEffects\StatusEffectManager.cs" /> <Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCStatusEffects\StatusEffectManager.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCTextureUtilities.cs" /> <Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCTextureUtilities.cs" />
<Compile Include="Framework\Objects\Extras\ArcadeCabinetOBJ.cs" />
<Compile Include="Framework\Objects\Extras\ArcadeCabinetTile.cs" />
<Compile Include="Framework\Objects\BasicItemInformation.cs" /> <Compile Include="Framework\Objects\BasicItemInformation.cs" />
<Compile Include="Framework\Objects\CustomObject.cs" /> <Compile Include="Framework\Objects\CustomObject.cs" />
<Compile Include="Framework\Objects\Furniture\Bench.cs" />
<Compile Include="Framework\Objects\Furniture\ChairMultiTiledObject.cs" />
<Compile Include="Framework\Objects\Furniture\ChairTileComponent.cs" />
<Compile Include="Framework\Objects\Furniture\FurnitureTileComponent.cs" />
<Compile Include="Framework\Objects\Furniture\LampMultiTiledObject.cs" />
<Compile Include="Framework\Objects\Furniture\LampTileComponent.cs" />
<Compile Include="Framework\Objects\Furniture\RugMultiTiledObject.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\TableTileComponent.cs" />
<Compile Include="Framework\Objects\InformationFiles\Furniture\ArcadeCabinetInformation.cs" />
<Compile Include="Framework\Objects\InformationFiles\Furniture\ChairInformation.cs" />
<Compile Include="Framework\Objects\InformationFiles\Furniture\FurnitureInformation.cs" />
<Compile Include="Framework\Objects\InformationFiles\Furniture\TableInformation.cs" />
<Compile Include="Framework\Objects\InformationFiles\ObjectGUIDInfo.cs" />
<Compile Include="Framework\Objects\InformationFiles\ResourceInformaton.cs" />
<Compile Include="Framework\Objects\Items\Resources\Ore.cs" />
<Compile Include="Framework\Objects\MultiTiledComponent.cs" />
<Compile Include="Framework\Objects\MultiTiledObject.cs" />
<Compile Include="Framework\Objects\ObjectManager.cs" />
<Compile Include="Framework\Objects\InformationFiles\OreResourceInformation.cs" />
<Compile Include="Framework\Objects\ResourceManager.cs" />
<Compile Include="Framework\Objects\Resources\OreVeins\OreVeinObj.cs" />
<Compile Include="Framework\Objects\Resources\OreVeins\OreVeinTile.cs" />
<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\PlayerInfo.cs" /> <Compile Include="Framework\Player\PlayerInfo.cs" />
<Compile Include="Framework\Utilities\BoundingBoxInfo.cs" /> <Compile Include="Framework\Utilities\BoundingBoxInfo.cs" />
<Compile Include="Framework\Utilities\IntRange.cs" /> <Compile Include="Framework\Utilities\IntRange.cs" />
<Compile Include="Framework\Utilities\InventoryManager.cs" /> <Compile Include="Framework\Utilities\InventoryManager.cs" />
<Compile Include="Framework\Utilities\LocationUtilities.cs" /> <Compile Include="Framework\Utilities\LocationUtilities.cs" />
<Compile Include="Framework\Utilities\MultiplayerUtilities.cs" />
<Compile Include="Framework\Utilities\ObjectUtilities.cs" /> <Compile Include="Framework\Utilities\ObjectUtilities.cs" />
<Compile Include="Framework\Utilities\PyTKHelper.cs" /> <Compile Include="Framework\Utilities\PyTKHelper.cs" />
<Compile Include="Framework\Utilities\RotationUtilities.cs" /> <Compile Include="Framework\Utilities\RotationUtilities.cs" />
<Compile Include="Framework\Utilities\Serialization\ContractResolvers\NetFieldContract.cs" /> <Compile Include="Framework\Utilities\Serialization\ContractResolvers\NetFieldContract.cs" />
<Compile Include="Framework\Utilities\Serialization\Converters\CustomObjectDataConverter.cs" /> <Compile Include="Framework\Utilities\Serialization\Converters\CustomObjectDataConverter.cs" />
<Compile Include="Framework\Utilities\Serialization\Converters\INetSerializableConverter.cs" />
<Compile Include="Framework\Utilities\Serialization\Converters\ItemCoverter.cs" /> <Compile Include="Framework\Utilities\Serialization\Converters\ItemCoverter.cs" />
<Compile Include="Framework\Utilities\Serialization\Converters\NetFieldConverter.cs" /> <Compile Include="Framework\Utilities\Serialization\Converters\NetFieldConverter.cs" />
<Compile Include="Framework\Utilities\Serialization\Converters\RectangleConverter.cs" /> <Compile Include="Framework\Utilities\Serialization\Converters\RectangleConverter.cs" />
@ -335,7 +374,7 @@
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Framework\Factories\Objects\" /> <Folder Include="Framework\Objects\InformationFiles\Extras\" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -8,11 +8,6 @@
"MinimumApiVersion": "2.10.1", "MinimumApiVersion": "2.10.1",
"UpdateKeys": [], "UpdateKeys": [],
"Dependencies": [ "Dependencies": [
{ { "UniqueID": "Omegasis.StardustCore" }
"UniqueID": "Omegasis.StardustCore"
},
{
"UniqueID": "Platonymous.Toolkit"
}
] ]
} }

View File

@ -91,6 +91,7 @@ namespace Vocalization.Framework.Menus
this.drawOnlyDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, new Color(255, 255, 255, 255), 0.4f); this.drawOnlyDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, new Color(255, 255, 255, 255), 0.4f);
this.sliderButton.draw(b, Color.White, Vector2.Zero, 0.5f); this.sliderButton.draw(b, Color.White, Vector2.Zero, 0.5f);
this.languages.draw(b, Color.White, Vector2.Zero, 0.5f); this.languages.draw(b, Color.White, Vector2.Zero, 0.5f);
this.drawMouse(b);
} }
/// <summary>Save the menu information upon menu being closed.</summary> /// <summary>Save the menu information upon menu being closed.</summary>

View File

@ -7,6 +7,16 @@ namespace Vocalization
public class ModConfig public class ModConfig
{ {
/// <summary>The volume at which the sound for voices is played at.</summary>
public decimal voiceVolume = 1;
/// <summary>
/// Should the mod automatically mute the game's npc dialogue typing sound?
/// </summary>
public bool muteDialogueTyping = true;
public string menuHotkey = "Y";
/// <summary>Handles all of the translation information and parsing.</summary> /// <summary>Handles all of the translation information and parsing.</summary>
public TranslationInfo translationInfo = new TranslationInfo(); public TranslationInfo translationInfo = new TranslationInfo();
@ -16,8 +26,6 @@ namespace Vocalization
/// <summary>The current mode for the mod.</summary> /// <summary>The current mode for the mod.</summary>
public string currentMode = "Full"; public string currentMode = "Full";
/// <summary>The volume at which the sound for voices is played at.</summary>
public decimal voiceVolume = 1;
/// <summary>Validates</summary> /// <summary>Validates</summary>
public void verifyValidMode() public void verifyValidMode()

View File

@ -220,6 +220,7 @@ namespace Vocalization
helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded; helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked; helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
helper.Events.Display.MenuChanged += this.MenuEvents_MenuChanged; helper.Events.Display.MenuChanged += this.MenuEvents_MenuChanged;
helper.Events.Input.ButtonPressed += this.Input_ButtonPressed;
ModMonitor = this.Monitor; ModMonitor = this.Monitor;
ModHelper = this.Helper; ModHelper = this.Helper;
Manifest = this.ModManifest; Manifest = this.ModManifest;
@ -239,6 +240,20 @@ namespace Vocalization
config.verifyValidMode(); //Make sure the current mode is valid. config.verifyValidMode(); //Make sure the current mode is valid.
soundManager.volume = (float)config.voiceVolume; //Set the volume for voices. soundManager.volume = (float)config.voiceVolume; //Set the volume for voices.
//Game1.waveBank = new Microsoft.Xna.Framework.Audio.WaveBank(Game1.audioEngine, Path.Combine(this.Helper.DirectoryPath, "WavBanks", "Wave Bank (Code 3).xwb"));
if (config.muteDialogueTyping)
{
Game1.options.dialogueTyping = false;
}
}
private void Input_ButtonPressed(object sender, ButtonPressedEventArgs e)
{
if(e.Button.ToString()== config.menuHotkey)
{
Game1.activeClickableMenu = new VocalizationMenu(100, 64, 600, 300, true);
}
} }
/// <summary>Raised after a game menu is opened, closed, or replaced.</summary> /// <summary>Raised after a game menu is opened, closed, or replaced.</summary>