Got container objects to sync across the net which is good.
This commit is contained in:
parent
2f07190926
commit
e0d61f19cc
|
@ -121,15 +121,21 @@ namespace Revitalize.Framework.Objects
|
|||
{
|
||||
get
|
||||
{
|
||||
//ModCore.log("Location Name is: " + this.info.locationName);
|
||||
if (this._location == null)
|
||||
{
|
||||
this._location = Game1.getLocationFromName(this.info.locationName);
|
||||
return this._location;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Game1.getLocationFromName(this.info.locationName);
|
||||
}
|
||||
return this._location;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
this._location = value;
|
||||
if (this._location == null) this.info.locationName = "";
|
||||
else
|
||||
|
@ -168,10 +174,12 @@ namespace Revitalize.Framework.Objects
|
|||
this.guid = Guid.Parse(guidString);
|
||||
if (ModCore.CustomObjects.ContainsKey(this.guid))
|
||||
{
|
||||
//ModCore.log("Update item with guid: " + this.guid);
|
||||
ModCore.CustomObjects[this.guid] = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
//ModCore.log("Add in new guid: " + this.guid);
|
||||
ModCore.CustomObjects.Add(this.guid,this);
|
||||
}
|
||||
|
||||
|
@ -179,7 +187,7 @@ namespace Revitalize.Framework.Objects
|
|||
{
|
||||
if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid)
|
||||
{
|
||||
ModCore.CustomObjects.Remove(oldGuid);
|
||||
//ModCore.CustomObjects.Remove(oldGuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ namespace Revitalize.Framework.Objects.Extras
|
|||
}
|
||||
}
|
||||
|
||||
public override void pickUp()
|
||||
public override void pickUp(Farmer who)
|
||||
{
|
||||
|
||||
bool canPickUp = this.removeAndAddToPlayersInventory();
|
||||
|
@ -163,7 +163,7 @@ namespace Revitalize.Framework.Objects.Extras
|
|||
{
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
{
|
||||
(pair.Value as ArcadeCabinetTile).removeFromLocation((pair.Value as ArcadeCabinetTile).location, pair.Key);
|
||||
(pair.Value as ArcadeCabinetTile).removeFromLocation(who.currentLocation, pair.Key);
|
||||
}
|
||||
this.location = null;
|
||||
}
|
||||
|
|
|
@ -143,6 +143,7 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
|
||||
public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location)
|
||||
{
|
||||
this.updateInfo();
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
{
|
||||
if (!this.isPlaceable())
|
||||
|
|
|
@ -155,7 +155,7 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
}
|
||||
}
|
||||
|
||||
public override void pickUp()
|
||||
public override void pickUp(Farmer Who)
|
||||
{
|
||||
|
||||
bool canPickUp = this.removeAndAddToPlayersInventory();
|
||||
|
@ -163,7 +163,7 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
{
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
{
|
||||
(pair.Value as LampTileComponent).removeFromLocation((pair.Value as LampTileComponent).location, pair.Key);
|
||||
(pair.Value as LampTileComponent).removeFromLocation(Who.currentLocation, pair.Key);
|
||||
}
|
||||
this.location = null;
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
}
|
||||
}
|
||||
|
||||
public override void pickUp()
|
||||
public override void pickUp(Farmer who)
|
||||
{
|
||||
|
||||
bool canPickUp = this.removeAndAddToPlayersInventory();
|
||||
|
@ -161,7 +161,7 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
{
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
{
|
||||
(pair.Value as StorageFurnitureTile).removeFromLocation((pair.Value as StorageFurnitureTile).location, pair.Key);
|
||||
(pair.Value as StorageFurnitureTile).removeFromLocation(who.currentLocation, pair.Key);
|
||||
}
|
||||
this.location = null;
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
}
|
||||
}
|
||||
|
||||
public override void pickUp()
|
||||
public override void pickUp(Farmer who)
|
||||
{
|
||||
|
||||
bool canPickUp = this.removeAndAddToPlayersInventory();
|
||||
|
@ -164,7 +164,7 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
{
|
||||
(pair.Value as TableTileComponent).clearHeldObject();
|
||||
(pair.Value as TableTileComponent).removeFromLocation((pair.Value as TableTileComponent).location, pair.Key);
|
||||
(pair.Value as TableTileComponent).removeFromLocation(who.currentLocation, pair.Key);
|
||||
}
|
||||
this.location = null;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,11 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
this.Price = Info.price;
|
||||
}
|
||||
|
||||
public override void updateWhenCurrentLocation(GameTime time, GameLocation environment)
|
||||
{
|
||||
base.updateWhenCurrentLocation(time, environment);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Forcefully clears the held object without much fuss.
|
||||
/// </summary>
|
||||
|
@ -112,8 +117,12 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
|
||||
{
|
||||
this.updateInfo();
|
||||
return base.placementAction(location, x, y, who);
|
||||
}
|
||||
public override bool performObjectDropInAction(Item dropInItem, bool probe, Farmer who)
|
||||
{
|
||||
return false; //this.pickUpItem()==PickUpState.DoNothing;
|
||||
|
@ -235,7 +244,10 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
public override Dictionary<string, string> getAdditionalSaveData()
|
||||
{
|
||||
Dictionary<string, string> saveData = base.getAdditionalSaveData();
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
|
||||
if (this.containerObject.childrenGuids.ContainsKey(this.offsetKey))
|
||||
{
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
|
||||
}
|
||||
this.containerObject.getAdditionalSaveData();
|
||||
return saveData;
|
||||
|
||||
|
@ -251,7 +263,7 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
y *= -1;
|
||||
}
|
||||
*/
|
||||
|
||||
this.updateInfo();
|
||||
if (this.info == null)
|
||||
{
|
||||
Revitalize.ModCore.log("info is null");
|
||||
|
@ -302,5 +314,22 @@ namespace Revitalize.Framework.Objects.Furniture
|
|||
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1)
|
||||
{
|
||||
this.updateInfo();
|
||||
base.draw(spriteBatch, xNonTile, yNonTile, layerDepth, alpha);
|
||||
}
|
||||
|
||||
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow)
|
||||
{
|
||||
this.updateInfo();
|
||||
base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, c, drawShadow);
|
||||
}
|
||||
|
||||
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f)
|
||||
{
|
||||
this.updateInfo();
|
||||
base.drawWhenHeld(spriteBatch, objectPosition, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Text;
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using PyTK.CustomElementHandler;
|
||||
using Revitalize.Framework.Utilities;
|
||||
using StardewValley;
|
||||
using StardewValley.Objects;
|
||||
|
||||
|
@ -12,6 +13,76 @@ namespace Revitalize.Framework.Objects
|
|||
{
|
||||
public class MultiTiledComponent : CustomObject,ISaveElement
|
||||
{
|
||||
|
||||
public override string ItemInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
string info = Revitalize.ModCore.Serializer.ToJSONString(this.info);
|
||||
string guidStr = this.guid.ToString();
|
||||
string offsetKey = this.offsetKey != null ? ModCore.Serializer.ToJSONString(this.offsetKey) : "";
|
||||
string container=this.containerObject!=null? this.containerObject.guid.ToString():"";
|
||||
return info+ "<" +guidStr+"<"+offsetKey+"<"+container;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return;
|
||||
string[] data = value.Split('<');
|
||||
string infoString = data[0];
|
||||
string guidString = data[1];
|
||||
string offsetVec = data[2];
|
||||
string containerObject = data[3];
|
||||
this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation));
|
||||
|
||||
if (string.IsNullOrEmpty(offsetVec)) return;
|
||||
if (string.IsNullOrEmpty(containerObject)) return;
|
||||
this.offsetKey = ModCore.Serializer.DeserializeFromJSONString<Vector2>(offsetVec);
|
||||
Guid oldGuid = this.guid;
|
||||
this.guid = Guid.Parse(guidString);
|
||||
if (ModCore.CustomObjects.ContainsKey(this.guid))
|
||||
{
|
||||
//ModCore.log("Update item with guid: " + this.guid);
|
||||
ModCore.CustomObjects[this.guid] = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
//ModCore.log("Add in new guid: " + this.guid);
|
||||
ModCore.CustomObjects.Add(this.guid, this);
|
||||
}
|
||||
|
||||
if (this.containerObject == null)
|
||||
{
|
||||
//ModCore.log(containerObject);
|
||||
Guid containerGuid = Guid.Parse(containerObject);
|
||||
if (ModCore.CustomObjects.ContainsKey(containerGuid))
|
||||
{
|
||||
this.containerObject = (MultiTiledObject)ModCore.CustomObjects[containerGuid];
|
||||
this.containerObject.removeComponent(this.offsetKey);
|
||||
this.containerObject.addComponent(this.offsetKey, this);
|
||||
//ModCore.log("Set container object from existing object!");
|
||||
}
|
||||
else
|
||||
{
|
||||
//ModCore.log("Container hasn't been synced???");
|
||||
MultiplayerUtilities.RequestGuidObject(containerGuid);
|
||||
MultiplayerUtilities.RequestGuidObject_Tile(this.guid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.containerObject.updateInfo();
|
||||
}
|
||||
|
||||
if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid))
|
||||
{
|
||||
if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid)
|
||||
{
|
||||
//ModCore.CustomObjects.Remove(oldGuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MultiTiledObject containerObject;
|
||||
|
||||
public Vector2 offsetKey;
|
||||
|
@ -29,6 +100,10 @@ namespace Revitalize.Framework.Objects
|
|||
this.containerObject = obj;
|
||||
}
|
||||
|
||||
public override void updateWhenCurrentLocation(GameTime time, GameLocation environment)
|
||||
{
|
||||
base.updateWhenCurrentLocation(time, environment);
|
||||
}
|
||||
public override bool isPassable()
|
||||
{
|
||||
return this.info.ignoreBoundingBox || Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject;
|
||||
|
@ -43,7 +118,7 @@ namespace Revitalize.Framework.Objects
|
|||
public override bool clicked(Farmer who)
|
||||
{
|
||||
//ModCore.log("Clicked a multiTiledComponent!");
|
||||
this.containerObject.pickUp();
|
||||
this.containerObject.pickUp(who);
|
||||
return true;
|
||||
//return base.clicked(who);
|
||||
}
|
||||
|
@ -82,6 +157,7 @@ namespace Revitalize.Framework.Objects
|
|||
/// <summary>Places an object down.</summary>
|
||||
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
|
||||
{
|
||||
this.updateInfo();
|
||||
this.updateDrawPosition(x, y);
|
||||
this.location = location;
|
||||
|
||||
|
@ -110,6 +186,7 @@ namespace Revitalize.Framework.Objects
|
|||
|
||||
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow)
|
||||
{
|
||||
this.updateInfo();
|
||||
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);
|
||||
if (drawStackNumber && this.Quality > 0)
|
||||
|
@ -188,7 +265,12 @@ namespace Revitalize.Framework.Objects
|
|||
|
||||
saveData.Add("ParentGUID", this.containerObject.guid.ToString());
|
||||
saveData.Add("GUID", this.guid.ToString());
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(),this);
|
||||
|
||||
|
||||
if (this.containerObject.childrenGuids.ContainsKey(this.offsetKey))
|
||||
{
|
||||
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
|
||||
}
|
||||
this.containerObject.getAdditionalSaveData();
|
||||
return saveData;
|
||||
|
||||
|
@ -210,6 +292,7 @@ namespace Revitalize.Framework.Objects
|
|||
/// <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)
|
||||
{
|
||||
this.updateInfo();
|
||||
if (this.info.ignoreBoundingBox == true)
|
||||
{
|
||||
x *= -1;
|
||||
|
@ -265,7 +348,23 @@ namespace Revitalize.Framework.Objects
|
|||
|
||||
}
|
||||
|
||||
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f)
|
||||
{
|
||||
base.drawWhenHeld(spriteBatch, objectPosition, f);
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1)
|
||||
{
|
||||
base.draw(spriteBatch, xNonTile, yNonTile, layerDepth, alpha);
|
||||
}
|
||||
|
||||
public override void updateInfo()
|
||||
{
|
||||
if (this.containerObject != null)
|
||||
{
|
||||
this.containerObject.updateInfo();
|
||||
}
|
||||
base.updateInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,44 @@ namespace Revitalize.Framework.Objects
|
|||
{
|
||||
public class MultiTiledObject : CustomObject
|
||||
{
|
||||
[JsonIgnore]
|
||||
public override string ItemInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
string infoStr = Revitalize.ModCore.Serializer.ToJSONString(this.info);
|
||||
string guidStr = this.guid.ToString();
|
||||
return infoStr+ "<" + guidStr;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return;
|
||||
string[] data = value.Split('<');
|
||||
string infoString = data[0];
|
||||
string guidString = data[1];
|
||||
|
||||
this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation));
|
||||
Guid oldGuid = this.guid;
|
||||
this.guid = Guid.Parse(guidString);
|
||||
if (ModCore.CustomObjects.ContainsKey(this.guid))
|
||||
{
|
||||
ModCore.CustomObjects[this.guid] = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
ModCore.CustomObjects.Add(this.guid, this);
|
||||
}
|
||||
|
||||
if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid))
|
||||
{
|
||||
if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid)
|
||||
{
|
||||
//ModCore.CustomObjects.Remove(oldGuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public Dictionary<Vector2, StardewValley.Object> objects;
|
||||
|
||||
|
@ -104,6 +142,7 @@ namespace Revitalize.Framework.Objects
|
|||
|
||||
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1)
|
||||
{
|
||||
this.updateInfo();
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
{
|
||||
(pair.Value as MultiTiledComponent).draw(spriteBatch, x + ((int)pair.Key.X), y + ((int)pair.Key.Y), alpha);
|
||||
|
@ -112,6 +151,7 @@ namespace Revitalize.Framework.Objects
|
|||
|
||||
public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1)
|
||||
{
|
||||
this.updateInfo();
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
{
|
||||
pair.Value.draw(spriteBatch, xNonTile + (int)pair.Key.X * Game1.tileSize, yNonTile + (int)pair.Key.Y * Game1.tileSize, layerDepth, alpha);
|
||||
|
@ -122,6 +162,7 @@ namespace Revitalize.Framework.Objects
|
|||
|
||||
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow)
|
||||
{
|
||||
this.updateInfo();
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
pair.Value.drawInMenu(spriteBatch, location + (pair.Key * 16), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow);
|
||||
//base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, c, drawShadow);
|
||||
|
@ -129,6 +170,7 @@ namespace Revitalize.Framework.Objects
|
|||
|
||||
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f)
|
||||
{
|
||||
this.updateInfo();
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
pair.Value.drawWhenHeld(spriteBatch, objectPosition + (pair.Key * Game1.tileSize), f);
|
||||
//base.drawWhenHeld(spriteBatch, objectPosition, f);
|
||||
|
@ -137,6 +179,7 @@ namespace Revitalize.Framework.Objects
|
|||
|
||||
public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location)
|
||||
{
|
||||
this.updateInfo();
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
{
|
||||
if (!this.isPlaceable())
|
||||
|
@ -172,7 +215,7 @@ namespace Revitalize.Framework.Objects
|
|||
|
||||
|
||||
|
||||
public virtual void pickUp()
|
||||
public virtual void pickUp(Farmer who)
|
||||
{
|
||||
bool canPickUp = this.removeAndAddToPlayersInventory();
|
||||
if (canPickUp)
|
||||
|
@ -187,7 +230,7 @@ namespace Revitalize.Framework.Objects
|
|||
ModCore.log("Got a light???");
|
||||
}
|
||||
}
|
||||
(pair.Value as MultiTiledComponent).removeFromLocation((pair.Value as MultiTiledComponent).location, pair.Key);
|
||||
(pair.Value as MultiTiledComponent).removeFromLocation(who.currentLocation, pair.Key);
|
||||
|
||||
}
|
||||
this.location = null;
|
||||
|
@ -209,6 +252,7 @@ namespace Revitalize.Framework.Objects
|
|||
|
||||
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
|
||||
{
|
||||
this.updateInfo();
|
||||
foreach (KeyValuePair<Vector2, StardewValley.Object> pair in this.objects)
|
||||
{
|
||||
/*
|
||||
|
@ -242,7 +286,7 @@ namespace Revitalize.Framework.Objects
|
|||
{
|
||||
bool cleanUp = this.clicked(who);
|
||||
if (cleanUp)
|
||||
this.pickUp();
|
||||
this.pickUp(who);
|
||||
return cleanUp;
|
||||
}
|
||||
|
||||
|
@ -372,5 +416,29 @@ namespace Revitalize.Framework.Objects
|
|||
return 1;
|
||||
}
|
||||
|
||||
public override void updateInfo()
|
||||
{
|
||||
if (this.info == null)
|
||||
{
|
||||
this.ItemInfo = this.text;
|
||||
ModCore.log("Updated item info for container!");
|
||||
return;
|
||||
}
|
||||
|
||||
this.ItemInfo = this.text;
|
||||
this.text = this.ItemInfo;
|
||||
|
||||
if (this.objects == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*
|
||||
foreach(CustomObject c in this.objects.Values)
|
||||
{
|
||||
c.updateInfo();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ namespace Revitalize.Framework.Objects.Resources.OreVeins
|
|||
}
|
||||
}
|
||||
|
||||
public override void pickUp()
|
||||
public override void pickUp(Farmer who)
|
||||
{
|
||||
return; //Don't pick up ore veins!
|
||||
bool canPickUp = this.removeAndAddToPlayersInventory();
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Revitalize.Framework.Objects;
|
||||
using StardewValley;
|
||||
|
||||
namespace Revitalize.Framework.Utilities
|
||||
{
|
||||
public static class MultiplayerUtilities
|
||||
{
|
||||
public static string RequestGUIDMessage = "Revitalize.RequestGUIDObject";
|
||||
public static string RequestGUIDMessage_Tile = "Revitalize.RequestGUIDObject_Tile";
|
||||
public static string ReceieveGUIDMessage = "Revitalize.ReceieveGUIDObject";
|
||||
public static string ReceieveGUIDMessage_Tile = "Revitalize.ReceieveGUIDObject_Tile";
|
||||
public static void GetModMessage(object o, StardewModdingAPI.Events.ModMessageReceivedEventArgs e)
|
||||
{
|
||||
ModCore.log("Get a mod message: "+e.Type);
|
||||
if (e.Type.Equals(RequestGUIDMessage))
|
||||
{
|
||||
ModCore.log("Send GUID Request");
|
||||
Guid request = Guid.Parse(e.ReadAs<string>());
|
||||
SendGuidObject(request);
|
||||
}
|
||||
|
||||
if (e.Type.Equals(ReceieveGUIDMessage))
|
||||
{
|
||||
ModCore.log("Receieve GUID Request");
|
||||
string objStr = e.ReadAs <string>();
|
||||
var v=ModCore.Serializer.DeserializeFromJSONString<Item>(objStr);
|
||||
if (ModCore.CustomObjects.ContainsKey((v as CustomObject).guid) == false)
|
||||
{
|
||||
ModCore.CustomObjects.Add((v as CustomObject).guid, (v as CustomObject));
|
||||
}
|
||||
else
|
||||
{
|
||||
ModCore.CustomObjects[(v as CustomObject).guid] = (v as CustomObject);
|
||||
}
|
||||
}
|
||||
|
||||
if(e.Type.Equals(RequestGUIDMessage_Tile))
|
||||
{
|
||||
ModCore.log("Send GUID Request FOR TILE");
|
||||
Guid request = Guid.Parse(e.ReadAs<string>());
|
||||
SendGuidObject_Tile(request);
|
||||
}
|
||||
if(e.Type.Equals(ReceieveGUIDMessage_Tile))
|
||||
{
|
||||
ModCore.log("Receieve GUID Request FOR TILE");
|
||||
string objStr = e.ReadAs<string>();
|
||||
var v = ModCore.Serializer.DeserializeFromJSONString<Item>(objStr);
|
||||
if (ModCore.CustomObjects.ContainsKey((v as CustomObject).guid) == false)
|
||||
{
|
||||
ModCore.CustomObjects.Add((v as CustomObject).guid, (v as CustomObject));
|
||||
}
|
||||
else
|
||||
{
|
||||
ModCore.CustomObjects[(v as CustomObject).guid] = (v as CustomObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SendGuidObject(Guid request)
|
||||
{
|
||||
if (ModCore.CustomObjects.ContainsKey(request))
|
||||
{
|
||||
ModCore.log("Send guid request!");
|
||||
ModCore.ModHelper.Multiplayer.SendMessage<string>(ModCore.Serializer.ToJSONString(ModCore.CustomObjects[request]), ReceieveGUIDMessage, new string[] { Revitalize.ModCore.Manifest.UniqueID.ToString() });
|
||||
}
|
||||
else
|
||||
{
|
||||
ModCore.log("This mod doesn't have the guid object");
|
||||
}
|
||||
}
|
||||
|
||||
public static void SendGuidObject_Tile(Guid request)
|
||||
{
|
||||
if (ModCore.CustomObjects.ContainsKey(request))
|
||||
{
|
||||
ModCore.log("Send guid tile request!");
|
||||
ModCore.ModHelper.Multiplayer.SendMessage<string>(ModCore.Serializer.ToJSONString( (ModCore.CustomObjects[request] as MultiTiledComponent).containerObject), ReceieveGUIDMessage_Tile , new string[] { Revitalize.ModCore.Manifest.UniqueID.ToString() });
|
||||
}
|
||||
else
|
||||
{
|
||||
ModCore.log("This mod doesn't have the guid tile");
|
||||
}
|
||||
}
|
||||
|
||||
public static void RequestGuidObject(Guid request)
|
||||
{
|
||||
ModCore.ModHelper.Multiplayer.SendMessage<string>(request.ToString(),RequestGUIDMessage, new string[] { ModCore.Manifest.UniqueID.ToString() });
|
||||
}
|
||||
|
||||
public static void RequestGuidObject_Tile(Guid request)
|
||||
{
|
||||
ModCore.ModHelper.Multiplayer.SendMessage<string>(request.ToString(), RequestGUIDMessage_Tile, new string[] { ModCore.Manifest.UniqueID.ToString() });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
|
|||
{
|
||||
new Framework.Utilities.Serialization.Converters.RectangleConverter(),
|
||||
new Framework.Utilities.Serialization.Converters.Texture2DConverter(),
|
||||
//new NetFieldConverter()
|
||||
},
|
||||
Formatting = Formatting.Indented,
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
|
@ -35,7 +36,7 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
|
|||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
string convertedString = JsonConvert.SerializeObject((Item)value, this.settings);
|
||||
DefaultContractResolver resolver = serializer.ContractResolver as DefaultContractResolver;
|
||||
DefaultContractResolver resolver = serializer.ContractResolver as ContractResolvers.NetFieldContract;
|
||||
writer.WriteStartObject();
|
||||
writer.WritePropertyName("Type");
|
||||
serializer.Serialize(writer, value.GetType().FullName.ToString());
|
||||
|
|
|
@ -231,6 +231,7 @@ namespace Revitalize
|
|||
ModHelper.Events.Display.RenderedWorld += ObjectInteractionHacks.Render_RenderCustomObjectsHeldInMachines;
|
||||
//ModHelper.Events.Display.Rendered += MenuHacks.EndOfDay_OnMenuChanged;
|
||||
//ModHelper.Events.GameLoop.Saved += MenuHacks.EndOfDay_CleanupForNewDay;
|
||||
ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.GetModMessage;
|
||||
CustomObjects = new Dictionary<Guid, CustomObject>();
|
||||
|
||||
//Adds in recipes to the mod.
|
||||
|
@ -398,7 +399,7 @@ namespace Revitalize
|
|||
// Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest"));
|
||||
//Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair"));
|
||||
//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"));
|
||||
//Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp"));
|
||||
|
||||
//Game1.player.addItemToInventory(ObjectManager.getObject("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble",ObjectManager.miscellaneous));
|
||||
|
|
|
@ -146,6 +146,7 @@
|
|||
<Compile Include="Framework\Utilities\IntRange.cs" />
|
||||
<Compile Include="Framework\Utilities\InventoryManager.cs" />
|
||||
<Compile Include="Framework\Utilities\LocationUtilities.cs" />
|
||||
<Compile Include="Framework\Utilities\MultiplayerUtilities.cs" />
|
||||
<Compile Include="Framework\Utilities\ObjectUtilities.cs" />
|
||||
<Compile Include="Framework\Utilities\PyTKHelper.cs" />
|
||||
<Compile Include="Framework\Utilities\RotationUtilities.cs" />
|
||||
|
|
Loading…
Reference in New Issue