2018-12-30 18:00:05 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using Microsoft.Xna.Framework;
|
2018-12-21 05:34:08 +08:00
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2018-12-21 05:54:00 +08:00
|
|
|
using Microsoft.Xna.Framework.Input;
|
2019-01-10 18:31:23 +08:00
|
|
|
using Newtonsoft.Json;
|
2018-12-21 05:34:08 +08:00
|
|
|
using PyTK.CustomElementHandler;
|
2019-07-18 01:18:51 +08:00
|
|
|
using StardustCore.Animations;
|
2018-12-21 05:34:08 +08:00
|
|
|
using StardewValley;
|
|
|
|
using StardewValley.Objects;
|
|
|
|
|
|
|
|
namespace Revitalize.Framework.Objects
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
// TODO:
|
|
|
|
// -Multiple Lights
|
|
|
|
// -Events when walking over?
|
|
|
|
// -Inventories
|
|
|
|
|
|
|
|
/// <summary>A custom object template.</summary>
|
2019-08-27 07:34:03 +08:00
|
|
|
public class CustomObject : PySObject
|
2018-12-21 05:34:08 +08:00
|
|
|
{
|
2019-08-27 12:14:37 +08:00
|
|
|
|
2019-08-27 12:46:36 +08:00
|
|
|
public virtual string text
|
2019-08-27 12:14:37 +08:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
|
|
|
|
return split[1]; //This is custom data. If the net name has a much larger name split the value and return the result.
|
|
|
|
else
|
|
|
|
return ""; //Otherwise return nothing.
|
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (this.netName == null) return;
|
|
|
|
if (this.netName.Value == null) return;
|
|
|
|
{
|
|
|
|
this.netName.Value = this.netName.Value.Split('>')[0] + ">" + value; //When setting the custom dataappend it to the end of the name.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string Name
|
|
|
|
{
|
|
|
|
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (this.info != null)
|
|
|
|
{
|
|
|
|
return this.netName.Value.Split('>')[0];
|
|
|
|
//return this.info.name;
|
|
|
|
}
|
|
|
|
if (this.netName == null)
|
|
|
|
{
|
|
|
|
return this.name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return this.netName.Value.Split('>')[0]; //Return the value before the name because that is the true value.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (this.netName == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (this.netName.Value == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
|
|
|
|
{
|
|
|
|
this.netName.Value = value + ">" + split[1]; //When setting the name if appended data is added on set the new value and add that appended data back.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.netName.Value = value; //Otherwise just set the net name.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override string DisplayName
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (this.info != null)
|
|
|
|
{
|
|
|
|
return this.info.name;
|
|
|
|
}
|
|
|
|
return this.netName.Value.Split('>')[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
2019-08-27 14:32:30 +08:00
|
|
|
if (this.netName == null) return;
|
|
|
|
if (this.netName.Value == null) return;
|
|
|
|
|
2019-08-27 12:14:37 +08:00
|
|
|
if (this.netName.Value.Split('>') is string[] split && split.Length > 1)
|
|
|
|
this.netName.Value = value + ">" + split[1];
|
|
|
|
else
|
|
|
|
this.netName.Value = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-16 03:42:48 +08:00
|
|
|
public string id
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2019-08-28 10:27:34 +08:00
|
|
|
|
|
|
|
if (this.info == null)
|
|
|
|
{
|
|
|
|
ModCore.log("Info was null when getting data.");
|
|
|
|
this.updateInfo();
|
|
|
|
}
|
|
|
|
|
2019-05-16 03:42:48 +08:00
|
|
|
return this.info.id;
|
|
|
|
}
|
|
|
|
}
|
2019-01-10 18:31:23 +08:00
|
|
|
|
|
|
|
|
2018-12-21 05:34:08 +08:00
|
|
|
public BasicItemInformation info;
|
2019-08-22 10:06:17 +08:00
|
|
|
private GameLocation _location;
|
|
|
|
[JsonIgnore]
|
|
|
|
public GameLocation location
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2019-08-28 06:10:56 +08:00
|
|
|
//ModCore.log("Location Name is: " + this.info.locationName);
|
2019-08-22 10:06:17 +08:00
|
|
|
if (this._location == null)
|
|
|
|
{
|
|
|
|
this._location = Game1.getLocationFromName(this.info.locationName);
|
|
|
|
return this._location;
|
|
|
|
}
|
2019-08-28 06:10:56 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return Game1.getLocationFromName(this.info.locationName);
|
|
|
|
}
|
2019-08-22 10:06:17 +08:00
|
|
|
return this._location;
|
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
2019-08-28 06:10:56 +08:00
|
|
|
|
2019-08-22 10:06:17 +08:00
|
|
|
this._location = value;
|
|
|
|
if (this._location == null) this.info.locationName = "";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.info.locationName = this._location.Name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-23 16:53:43 +08:00
|
|
|
|
2019-01-11 04:44:10 +08:00
|
|
|
|
|
|
|
public Guid guid;
|
2019-08-23 11:04:49 +08:00
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>The animation manager.</summary>
|
|
|
|
public AnimationManager animationManager => this.info.animationManager;
|
2018-12-22 07:28:52 +08:00
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>The display texture for this object.</summary>
|
2019-01-10 18:31:23 +08:00
|
|
|
[JsonIgnore]
|
2018-12-30 18:00:05 +08:00
|
|
|
public Texture2D displayTexture => this.animationManager.getTexture();
|
2018-12-21 05:34:08 +08:00
|
|
|
|
2019-08-27 14:32:30 +08:00
|
|
|
[JsonIgnore]
|
|
|
|
public virtual string ItemInfo
|
2019-01-21 15:34:11 +08:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2019-08-27 14:32:30 +08:00
|
|
|
return Revitalize.ModCore.Serializer.ToJSONString(this.info)+"<"+this.guid;
|
2019-01-21 15:34:11 +08:00
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
2019-08-27 12:46:36 +08:00
|
|
|
if (string.IsNullOrEmpty(value)) return;
|
2019-08-27 14:32:30 +08:00
|
|
|
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))
|
|
|
|
{
|
2019-08-28 06:10:56 +08:00
|
|
|
//ModCore.log("Update item with guid: " + this.guid);
|
2019-08-27 14:32:30 +08:00
|
|
|
ModCore.CustomObjects[this.guid] = this;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-28 06:10:56 +08:00
|
|
|
//ModCore.log("Add in new guid: " + this.guid);
|
2019-08-27 14:32:30 +08:00
|
|
|
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)
|
|
|
|
{
|
2019-08-28 06:10:56 +08:00
|
|
|
//ModCore.CustomObjects.Remove(oldGuid);
|
2019-08-27 14:32:30 +08:00
|
|
|
}
|
|
|
|
}
|
2019-01-21 15:34:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Empty constructor.</summary>
|
2019-08-23 11:04:49 +08:00
|
|
|
public CustomObject()
|
|
|
|
{
|
2019-01-11 04:44:10 +08:00
|
|
|
this.guid = Guid.NewGuid();
|
2019-08-27 07:34:03 +08:00
|
|
|
this.InitNetFields();
|
2019-01-11 04:44:10 +08:00
|
|
|
}
|
2018-12-21 05:34:08 +08:00
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Construct an instance.</summary>
|
2019-08-27 07:34:03 +08:00
|
|
|
public CustomObject(CustomObjectData PyTKData, BasicItemInformation info, int Stack = 1)
|
|
|
|
: base(PyTKData, Vector2.Zero)
|
2018-12-21 05:34:08 +08:00
|
|
|
{
|
|
|
|
this.info = info;
|
2019-01-11 04:44:10 +08:00
|
|
|
this.guid = Guid.NewGuid();
|
2019-08-27 14:32:30 +08:00
|
|
|
this.initializeBasics();
|
|
|
|
|
2019-08-23 10:09:58 +08:00
|
|
|
this.Stack = Stack;
|
2019-05-18 00:43:50 +08:00
|
|
|
|
2018-12-21 05:34:08 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Construct an instance.</summary>
|
2019-08-27 07:34:03 +08:00
|
|
|
public CustomObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, int Stack = 1)
|
|
|
|
: base(PyTKData, TileLocation)
|
2018-12-21 05:34:08 +08:00
|
|
|
{
|
|
|
|
this.info = info;
|
2019-01-11 04:44:10 +08:00
|
|
|
this.guid = Guid.NewGuid();
|
2019-08-27 14:32:30 +08:00
|
|
|
this.initializeBasics();
|
|
|
|
|
2019-08-23 10:09:58 +08:00
|
|
|
this.Stack = Stack;
|
2018-12-21 05:34:08 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Sets some basic information up.</summary>
|
2018-12-21 05:34:08 +08:00
|
|
|
public virtual void initializeBasics()
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
this.name = this.info.name;
|
|
|
|
this.displayName = this.getDisplayNameFromStringsFile(this.id);
|
|
|
|
this.Edibility = this.info.edibility;
|
2018-12-21 05:34:08 +08:00
|
|
|
this.Category = -9; //For crafting.
|
2018-12-30 18:00:05 +08:00
|
|
|
this.displayName = this.info.name;
|
2019-08-27 07:34:03 +08:00
|
|
|
this.setOutdoors.Value = true;
|
|
|
|
this.setIndoors.Value = true;
|
2018-12-21 05:34:08 +08:00
|
|
|
this.isLamp.Value = false;
|
2019-07-16 17:09:42 +08:00
|
|
|
this.Fragility = 0;
|
2018-12-22 07:28:52 +08:00
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
this.updateDrawPosition(0, 0);
|
2018-12-22 07:28:52 +08:00
|
|
|
|
2019-08-27 07:34:03 +08:00
|
|
|
this.bigCraftable.Value = false;
|
2018-12-25 02:58:20 +08:00
|
|
|
|
2019-01-21 15:34:11 +08:00
|
|
|
//this.initNetFields();
|
2019-08-27 07:34:03 +08:00
|
|
|
this.InitNetFields();
|
2019-08-27 12:14:37 +08:00
|
|
|
this.updateInfo();
|
2019-08-27 12:46:36 +08:00
|
|
|
this.Price = this.info.price;
|
2018-12-30 18:00:05 +08:00
|
|
|
//if (this.info.ignoreBoundingBox)
|
|
|
|
// this.boundingBox.Value = new Rectangle(int.MinValue, int.MinValue, 0, 0);
|
2018-12-29 14:23:16 +08:00
|
|
|
}
|
|
|
|
|
2019-01-21 15:34:11 +08:00
|
|
|
|
|
|
|
|
2018-12-29 14:23:16 +08:00
|
|
|
public override bool isPassable()
|
|
|
|
{
|
2019-08-27 07:34:03 +08:00
|
|
|
return this.info.ignoreBoundingBox || Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this;
|
2018-12-25 02:58:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public override Rectangle getBoundingBox(Vector2 tileLocation)
|
|
|
|
{
|
2019-01-10 10:05:03 +08:00
|
|
|
//Revitalize.ModCore.log(System.Environment.StackTrace);
|
2018-12-30 18:00:05 +08:00
|
|
|
return this.info.ignoreBoundingBox
|
|
|
|
? new Rectangle(int.MinValue, int.MinValue, 0, 0)
|
|
|
|
: base.getBoundingBox(tileLocation);
|
2018-12-21 05:34:08 +08:00
|
|
|
}
|
|
|
|
|
2019-08-27 12:14:37 +08:00
|
|
|
public override int sellToStorePrice()
|
|
|
|
{
|
|
|
|
return this.Price;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override int salePrice()
|
|
|
|
{
|
|
|
|
return this.Price * 2;
|
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Checks for interaction with the object.</summary>
|
2018-12-21 05:34:08 +08:00
|
|
|
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false)
|
|
|
|
{
|
2019-08-27 07:34:03 +08:00
|
|
|
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
MouseState mState = Mouse.GetState();
|
|
|
|
KeyboardState keyboardState = Game1.GetKeyboardState();
|
2018-12-21 05:54:00 +08:00
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || !keyboardState.IsKeyDown(Keys.RightShift)))
|
2018-12-21 05:54:00 +08:00
|
|
|
{
|
2019-08-23 04:43:11 +08:00
|
|
|
//ModCore.log("Right clicked!");
|
2018-12-30 18:00:05 +08:00
|
|
|
return this.rightClicked(who);
|
2018-12-21 05:54:00 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift)))
|
|
|
|
return this.shiftRightClicked(who);
|
|
|
|
|
2019-05-16 13:27:38 +08:00
|
|
|
return base.checkForAction(who, justCheckingForActivity);
|
|
|
|
|
2018-12-21 05:34:08 +08:00
|
|
|
if (justCheckingForActivity)
|
|
|
|
return true;
|
2018-12-30 18:00:05 +08:00
|
|
|
ModCore.log("Left clicked!");
|
2018-12-21 05:54:00 +08:00
|
|
|
return this.clicked(who);
|
2018-12-21 05:34:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>What happens when the player right clicks the object.</summary>
|
2018-12-21 05:54:00 +08:00
|
|
|
public virtual bool rightClicked(Farmer who)
|
|
|
|
{
|
|
|
|
// Game1.showRedMessage("YOOO");
|
|
|
|
//do some stuff when the right button is down
|
|
|
|
// rotate();
|
|
|
|
if (this.heldObject.Value != null)
|
|
|
|
{
|
|
|
|
// Game1.player.addItemByMenuIfNecessary(this.heldObject);
|
|
|
|
// this.heldObject = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// this.heldObject = Game1.player.ActiveObject;
|
|
|
|
// Game1.player.removeItemFromInventory(heldObject);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>What happens when the player shift-right clicks this object.</summary>
|
2018-12-21 05:54:00 +08:00
|
|
|
public virtual bool shiftRightClicked(Farmer who)
|
|
|
|
{
|
2019-08-23 04:43:11 +08:00
|
|
|
//ModCore.log("Shift right clicked!");
|
2018-12-21 05:54:00 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>What happens when the player left clicks the object.</summary>
|
2018-12-21 05:54:00 +08:00
|
|
|
public override bool clicked(Farmer who)
|
|
|
|
{
|
2019-08-23 04:43:11 +08:00
|
|
|
//ModCore.log("Clicky click!");
|
2018-12-22 08:00:44 +08:00
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
return this.removeAndAddToPlayersInventory();
|
2018-12-22 08:00:44 +08:00
|
|
|
//return base.clicked(who);
|
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>What happens when a player uses a tool on this object.</summary>
|
2018-12-22 08:00:44 +08:00
|
|
|
public override bool performToolAction(Tool t, GameLocation location)
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
if (t.GetType() == typeof(StardewValley.Tools.Axe) || t.GetType() == typeof(StardewValley.Tools.Pickaxe))
|
2018-12-22 08:00:44 +08:00
|
|
|
{
|
|
|
|
Game1.createItemDebris(this, Game1.player.getStandingPosition(), Game1.player.getDirection());
|
2018-12-23 16:53:43 +08:00
|
|
|
this.location = null;
|
2018-12-25 02:58:20 +08:00
|
|
|
this.updateDrawPosition(0, 0);
|
2018-12-22 08:00:44 +08:00
|
|
|
Game1.player.currentLocation.removeObject(this.TileLocation, false);
|
2018-12-25 02:58:20 +08:00
|
|
|
this.updateDrawPosition(0, 0);
|
2018-12-22 08:00:44 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
//return base.performToolAction(t, location);
|
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Remove the object from the world and add it to the player's inventory if possible.</summary>
|
2018-12-22 08:00:44 +08:00
|
|
|
public virtual bool removeAndAddToPlayersInventory()
|
|
|
|
{
|
|
|
|
if (Game1.player.isInventoryFull())
|
|
|
|
{
|
|
|
|
Game1.showRedMessage("Inventory full.");
|
|
|
|
return false;
|
|
|
|
}
|
2018-12-23 16:53:43 +08:00
|
|
|
this.location = null;
|
2018-12-22 08:00:44 +08:00
|
|
|
Game1.player.currentLocation.removeObject(this.TileLocation, false);
|
|
|
|
Game1.player.addItemToInventory(this);
|
2018-12-25 02:58:20 +08:00
|
|
|
this.updateDrawPosition(0, 0);
|
2018-12-22 08:00:44 +08:00
|
|
|
return true;
|
2018-12-21 05:54:00 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Gets the category color for the object.</summary>
|
2018-12-21 05:34:08 +08:00
|
|
|
public override Color getCategoryColor()
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
return this.info.categoryColor;
|
2018-12-21 05:34:08 +08:00
|
|
|
//return data.categoryColor;
|
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Gets the category name for the object.</summary>
|
2018-12-21 05:34:08 +08:00
|
|
|
public override string getCategoryName()
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
return this.info.categoryName;
|
2018-12-21 05:34:08 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Gets the description for the object.</summary>
|
2018-12-21 05:34:08 +08:00
|
|
|
public override string getDescription()
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
string text = this.info.description;
|
2018-12-21 05:34:08 +08:00
|
|
|
SpriteFont smallFont = Game1.smallFont;
|
|
|
|
int width = Game1.tileSize * 4 + Game1.tileSize / 4;
|
|
|
|
return Game1.parseText(text, smallFont, width);
|
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Places an object down.</summary>
|
2018-12-22 07:28:52 +08:00
|
|
|
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
|
|
|
|
{
|
2019-08-23 11:04:49 +08:00
|
|
|
if (this.info.canBeSetIndoors == false && location.IsOutdoors == false) return false;
|
|
|
|
if (this.info.canBeSetOutdoors == false && location.IsOutdoors) return false;
|
2018-12-30 18:00:05 +08:00
|
|
|
this.updateDrawPosition(x, y);
|
2018-12-23 16:53:43 +08:00
|
|
|
this.location = location;
|
2018-12-22 07:28:52 +08:00
|
|
|
return base.placementAction(location, x, y, who);
|
|
|
|
}
|
|
|
|
|
2019-01-21 15:34:11 +08:00
|
|
|
public override bool canBePlacedHere(GameLocation l, Vector2 tile)
|
|
|
|
{
|
2019-08-23 11:04:49 +08:00
|
|
|
if (this.info.ignoreBoundingBox && l.isObjectAtTile((int)tile.X, (int)tile.Y) == false) return true;
|
2019-01-21 15:34:11 +08:00
|
|
|
return base.canBePlacedHere(l, tile);
|
|
|
|
}
|
|
|
|
|
2019-01-09 14:15:58 +08:00
|
|
|
public virtual void rotate()
|
|
|
|
{
|
|
|
|
if (this.info.facingDirection == Enums.Direction.Down) this.info.facingDirection = Enums.Direction.Right;
|
|
|
|
else if (this.info.facingDirection == Enums.Direction.Right) this.info.facingDirection = Enums.Direction.Up;
|
|
|
|
else if (this.info.facingDirection == Enums.Direction.Up) this.info.facingDirection = Enums.Direction.Left;
|
|
|
|
else if (this.info.facingDirection == Enums.Direction.Left) this.info.facingDirection = Enums.Direction.Down;
|
|
|
|
|
2019-05-14 01:59:26 +08:00
|
|
|
if (this.info.animationManager.animations.ContainsKey(this.generateRotationalAnimationKey()))
|
2019-01-09 14:15:58 +08:00
|
|
|
{
|
2019-05-14 01:59:26 +08:00
|
|
|
this.info.animationManager.setAnimation(this.generateRotationalAnimationKey());
|
2019-01-09 14:15:58 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Revitalize.ModCore.log("Animation does not exist...." + generateRotationalAnimationKey());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string generateRotationalAnimationKey()
|
2019-08-23 11:04:49 +08:00
|
|
|
{
|
|
|
|
return (this.info.animationManager.currentAnimationName.Split('_')[0]) + "_" + (int)this.info.facingDirection;
|
2019-01-09 14:15:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public string generateDefaultRotationalAnimationKey()
|
|
|
|
{
|
|
|
|
return ("Default" + "_" + (int)this.info.facingDirection);
|
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Updates a visual draw position.</summary>
|
2018-12-25 02:58:20 +08:00
|
|
|
public virtual void updateDrawPosition(int x, int y)
|
2018-12-22 07:28:52 +08:00
|
|
|
{
|
2018-12-25 02:58:20 +08:00
|
|
|
this.info.drawPosition = new Vector2((int)(x / Game1.tileSize), (int)(y / Game1.tileSize));
|
|
|
|
//this.info.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.animationManager.currentAnimation.sourceRectangle.Height * Game1.pixelZoom - this.boundingBox.Height)));
|
2018-12-22 07:28:52 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Gets a clone of the game object.</summary>
|
2018-12-21 05:34:08 +08:00
|
|
|
public override Item getOne()
|
|
|
|
{
|
2019-08-27 07:34:03 +08:00
|
|
|
return new CustomObject(this.data, this.info);
|
2018-12-21 05:34:08 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>What happens when the object is drawn at a tile location.</summary>
|
2018-12-22 07:28:52 +08:00
|
|
|
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
|
2018-12-21 05:34:08 +08:00
|
|
|
{
|
2019-08-27 12:14:37 +08:00
|
|
|
this.updateInfo();
|
2018-12-25 02:58:20 +08:00
|
|
|
if (x <= -1)
|
2018-12-22 07:28:52 +08:00
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
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));
|
2018-12-22 07:28:52 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//The actual planter box being drawn.
|
2018-12-30 18:00:05 +08:00
|
|
|
if (this.animationManager == null)
|
2018-12-22 07:28:52 +08:00
|
|
|
{
|
|
|
|
if (this.animationManager.getExtendedTexture() == null)
|
|
|
|
ModCore.ModMonitor.Log("Tex Extended is null???");
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(this.TileLocation.Y * Game1.tileSize) / 10000f));
|
2018-12-22 07:28:52 +08:00
|
|
|
// Log.AsyncG("ANIMATION IS NULL?!?!?!?!");
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Log.AsyncC("Animation Manager is working!");
|
2019-01-09 14:15:58 +08:00
|
|
|
int addedDepth = 0;
|
|
|
|
if (this.info.ignoreBoundingBox) addedDepth++;
|
2019-08-27 07:34:03 +08:00
|
|
|
if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this) addedDepth++;
|
2019-08-23 11:04:49 +08:00
|
|
|
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));
|
2018-12-22 07:28:52 +08:00
|
|
|
try
|
|
|
|
{
|
|
|
|
this.animationManager.tickAnimation();
|
|
|
|
// Log.AsyncC("Tick animation");
|
|
|
|
}
|
|
|
|
catch (Exception err)
|
|
|
|
{
|
|
|
|
ModCore.ModMonitor.Log(err.ToString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0));
|
|
|
|
}
|
2018-12-21 05:34:08 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Draw the game object at a non-tile spot. Aka like debris.</summary>
|
2018-12-22 07:28:52 +08:00
|
|
|
public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1f)
|
2018-12-21 05:34:08 +08:00
|
|
|
{
|
2019-08-27 12:14:37 +08:00
|
|
|
this.updateInfo();
|
2019-08-27 07:34:03 +08:00
|
|
|
/*
|
|
|
|
if (Game1.eventUp && Game1.CurrentEvent.isTileWalkedOn(xNonTile / 64, yNonTile / 64))
|
2018-12-22 07:28:52 +08:00
|
|
|
return;
|
2019-08-27 07:34:03 +08:00
|
|
|
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);
|
|
|
|
*/
|
2019-08-23 11:04:49 +08:00
|
|
|
//The actual planter box being drawn.
|
|
|
|
if (this.animationManager == null)
|
|
|
|
{
|
2019-08-27 12:14:37 +08:00
|
|
|
this.syncObject.MarkDirty();
|
2019-08-23 11:04:49 +08:00
|
|
|
if (this.animationManager.getExtendedTexture() == null)
|
|
|
|
ModCore.ModMonitor.Log("Tex Extended is null???");
|
|
|
|
|
|
|
|
spriteBatch.Draw(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));
|
|
|
|
// Log.AsyncG("ANIMATION IS NULL?!?!?!?!");
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Log.AsyncC("Animation Manager is working!");
|
|
|
|
int addedDepth = 0;
|
|
|
|
if (this.info.ignoreBoundingBox) addedDepth++;
|
2019-08-27 07:34:03 +08:00
|
|
|
if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this) addedDepth++;
|
2019-08-23 11:04:49 +08:00
|
|
|
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
|
|
|
|
{
|
|
|
|
this.animationManager.tickAnimation();
|
|
|
|
// Log.AsyncC("Tick animation");
|
|
|
|
}
|
|
|
|
catch (Exception err)
|
|
|
|
{
|
|
|
|
ModCore.ModMonitor.Log(err.ToString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0));
|
|
|
|
|
2018-12-21 05:34:08 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>What happens when the object is drawn in a menu.</summary>
|
2018-12-22 07:28:52 +08:00
|
|
|
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow)
|
2018-12-21 05:34:08 +08:00
|
|
|
{
|
2019-08-27 12:14:37 +08:00
|
|
|
this.updateInfo();
|
2018-12-22 07:28:52 +08:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581);
|
|
|
|
spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth);
|
|
|
|
}
|
2019-08-23 10:09:58 +08:00
|
|
|
spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize * 4f, SpriteEffects.None, layerDepth);
|
2018-12-21 05:34:08 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>What happens when the object is drawn when held by a player.</summary>
|
2018-12-22 07:28:52 +08:00
|
|
|
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f)
|
2018-12-21 05:34:08 +08:00
|
|
|
{
|
2019-08-27 12:14:37 +08:00
|
|
|
this.updateInfo();
|
|
|
|
if (this.animationManager == null)
|
|
|
|
{
|
|
|
|
Revitalize.ModCore.log("Animation Manager Null");
|
|
|
|
}
|
2019-01-11 04:44:10 +08:00
|
|
|
if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
|
2018-12-22 07:28:52 +08:00
|
|
|
if (f.ActiveObject.bigCraftable.Value)
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
|
2018-12-22 07:28:52 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
|
2018-12-22 07:28:52 +08:00
|
|
|
if (f.ActiveObject != null && f.ActiveObject.Name.Contains("="))
|
|
|
|
{
|
|
|
|
spriteBatch.Draw(this.displayTexture, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), this.animationManager.currentAnimation.sourceRectangle, Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
|
|
|
|
if (Math.Abs(Game1.starCropShimmerPause) <= 0.05f && Game1.random.NextDouble() < 0.97)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Game1.starCropShimmerPause += 0.04f;
|
|
|
|
if (Game1.starCropShimmerPause >= 0.8f)
|
|
|
|
{
|
|
|
|
Game1.starCropShimmerPause = -0.8f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//base.drawWhenHeld(spriteBatch, objectPosition, f);
|
2018-12-21 05:34:08 +08:00
|
|
|
}
|
|
|
|
|
2019-08-23 11:04:49 +08:00
|
|
|
public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location)
|
|
|
|
{
|
|
|
|
//Do nothing because this shouldn't be placeable anywhere.
|
|
|
|
}
|
2019-08-25 06:14:10 +08:00
|
|
|
|
2019-08-27 07:34:03 +08:00
|
|
|
public void InitNetFields()
|
|
|
|
{
|
2019-01-11 03:09:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-16 17:09:42 +08:00
|
|
|
|
2019-08-22 10:06:17 +08:00
|
|
|
public virtual void replaceAfterLoad()
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(this.info.locationName) == false)
|
|
|
|
{
|
2019-08-23 04:43:11 +08:00
|
|
|
//ModCore.log("Replace an object!");
|
2019-08-22 10:06:17 +08:00
|
|
|
this.location.removeObject(this.TileLocation, false);
|
|
|
|
this.placementAction(this.location, (int)this.TileLocation.X * Game1.tileSize, (int)this.TileLocation.Y * Game1.tileSize);
|
2019-07-16 17:09:42 +08:00
|
|
|
|
2019-08-23 04:43:11 +08:00
|
|
|
//ModCore.log("Do I ingnore BB? " + this.info.ignoreBoundingBox);
|
|
|
|
//ModCore.log("This is my BB: " + this.boundingBox.Value);
|
2019-08-22 10:06:17 +08:00
|
|
|
}
|
|
|
|
}
|
2019-08-23 11:04:49 +08:00
|
|
|
|
2019-07-16 17:09:42 +08:00
|
|
|
|
2018-12-21 05:34:08 +08:00
|
|
|
public string getDisplayNameFromStringsFile(string objectID)
|
|
|
|
{
|
|
|
|
//Load in a file that has all object names referenced here or something.
|
2018-12-30 18:00:05 +08:00
|
|
|
return this.info.name;
|
2018-12-21 05:34:08 +08:00
|
|
|
}
|
2019-08-27 12:14:37 +08:00
|
|
|
|
2019-08-27 14:32:30 +08:00
|
|
|
public virtual void updateInfo()
|
2019-08-27 12:14:37 +08:00
|
|
|
{
|
|
|
|
if (this.info == null)
|
|
|
|
{
|
|
|
|
this.ItemInfo = this.text;
|
|
|
|
ModCore.log("Updated item info!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-28 07:47:22 +08:00
|
|
|
if (this.requiresUpdate())
|
|
|
|
{
|
|
|
|
this.ItemInfo = this.text;
|
|
|
|
this.text = this.ItemInfo;
|
|
|
|
this.info.cleanAfterUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void forceUpdate()
|
|
|
|
{
|
|
|
|
if (this.info == null)
|
|
|
|
{
|
|
|
|
this.ItemInfo = this.text;
|
|
|
|
ModCore.log("Updated item info!");
|
|
|
|
return;
|
|
|
|
}
|
2019-08-27 12:46:36 +08:00
|
|
|
this.ItemInfo = this.text;
|
|
|
|
this.text = this.ItemInfo;
|
2019-08-28 07:47:22 +08:00
|
|
|
this.info.cleanAfterUpdate();
|
|
|
|
this.info.forceUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual bool requiresUpdate()
|
|
|
|
{
|
|
|
|
if (this.info.requiresSyncUpdate())
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2019-08-27 12:14:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~//
|
|
|
|
// PyTk Functions //
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~//
|
|
|
|
#region
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Rebuilds the data from saves.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="additionalSaveData"></param>
|
|
|
|
/// <param name="replacement"></param>
|
|
|
|
public override void rebuild(Dictionary<string, string> additionalSaveData, object replacement)
|
|
|
|
{
|
2019-08-28 10:27:34 +08:00
|
|
|
//CustomObjectData data = CustomObjectData.collection[additionalSaveData["id"]];
|
|
|
|
//BasicItemInformation info = Revitalize.ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
|
2019-08-27 12:14:37 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Prepares the data for saves.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public override Dictionary<string, string> getAdditionalSaveData()
|
|
|
|
{
|
|
|
|
Dictionary<string, string> serializedInfo = new Dictionary<string, string>();
|
|
|
|
serializedInfo.Add("id", this.ItemInfo);
|
|
|
|
serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info));
|
2019-08-28 10:27:34 +08:00
|
|
|
Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this);
|
2019-08-27 12:14:37 +08:00
|
|
|
return serializedInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets all of the data necessary for syncing.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public override Dictionary<string, string> getSyncData()
|
|
|
|
{
|
|
|
|
Dictionary<string, string> syncData = new Dictionary<string, string>();
|
|
|
|
//syncData.Add("ID", this.ItemInfo);
|
|
|
|
//syncData.Add("BasicItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info));
|
|
|
|
syncData.Add("Greeting:", "Hello from: " + Game1.player.Name);
|
|
|
|
ModCore.log("Send off SYNC DATA!");
|
|
|
|
return syncData;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Syncs all of the info to all players.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="syncData"></param>
|
|
|
|
public override void sync(Dictionary<string, string> syncData)
|
|
|
|
{
|
|
|
|
//Revitalize.ModCore.log("SYNC OBJECT DATA!");
|
|
|
|
|
|
|
|
//this.info = Revitalize.ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(syncData["BasicItemInfo"]);
|
|
|
|
//this.ItemInfo = syncData["ID"];
|
|
|
|
string greeting = syncData["Greeting"];
|
|
|
|
ModCore.log(greeting);
|
|
|
|
}
|
|
|
|
#endregion
|
2018-12-21 05:34:08 +08:00
|
|
|
}
|
|
|
|
}
|