network experiment: failure. Focusing on single player experience.

This commit is contained in:
JoshuaNavarro 2019-08-24 15:14:10 -07:00
parent b70b4f1813
commit 0f7252e2c5
25 changed files with 513 additions and 235 deletions

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Revitalize.Framework.Crafting;
//using Revitalize.Framework.Crafting;
using Revitalize.Framework.Objects;
using Revitalize.Framework.Utilities;
using StardewValley;

View File

@ -18,11 +18,11 @@ namespace Revitalize.Framework.Hacks
/// </summary>
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("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("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("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("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("Titanium", 1), 300), "Clint");
}
}
}

View File

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

View File

@ -10,6 +10,7 @@ using StardewValley;
using StardewValley.Objects;
using Netcode;
using StardewModdingAPI;
using Revitalize.Framework.Utilities;
namespace Revitalize.Framework.Objects
{
@ -19,7 +20,7 @@ namespace Revitalize.Framework.Objects
// -Inventories
/// <summary>A custom object template.</summary>
public class CustomObject : PySObject
public class CustomObject : StardewValley.Object,ISaveElement
{
public string id
{
@ -85,12 +86,12 @@ namespace Revitalize.Framework.Objects
public CustomObject()
{
this.guid = Guid.NewGuid();
this.InitNetFields();
//this.InitNetFields();
}
/// <summary>Construct an instance.</summary>
public CustomObject(CustomObjectData PyTKData, BasicItemInformation info, int Stack = 1)
: base(PyTKData, Vector2.Zero)
public CustomObject(BasicItemInformation info, int Stack = 1)
: base()
{
this.info = info;
this.initializeBasics();
@ -100,8 +101,8 @@ namespace Revitalize.Framework.Objects
}
/// <summary>Construct an instance.</summary>
public CustomObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, int Stack = 1)
: base(PyTKData, TileLocation)
public CustomObject(BasicItemInformation info, Vector2 TileLocation, int Stack = 1)
: base()
{
this.info = info;
this.initializeBasics();
@ -117,17 +118,21 @@ namespace Revitalize.Framework.Objects
this.Edibility = this.info.edibility;
this.Category = -9; //For crafting.
this.displayName = this.info.name;
this.setOutdoors.Value = true;
this.setIndoors.Value = true;
this.setOutdoors.Value = this.info.canBeSetOutdoors;
this.setIndoors.Value = this.info.canBeSetIndoors;
this.isLamp.Value = false;
this.Fragility = 0;
this.updateDrawPosition(0, 0);
this.bigCraftable.Value = false;
this.bigCraftable.Value = this.info.bigCraftable;
this.Price = this.info.price;
ModCore.CustomObjects.Add(this.guid, this);
this.NetFields.AddField(new NetGuid(this.guid));
//this.initNetFields();
this.InitNetFields();
//this.InitNetFields();
//if (this.info.ignoreBoundingBox)
// this.boundingBox.Value = new Rectangle(int.MinValue, int.MinValue, 0, 0);
}
@ -136,7 +141,7 @@ namespace Revitalize.Framework.Objects
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)
@ -150,8 +155,6 @@ namespace Revitalize.Framework.Objects
/// <summary>Checks for interaction with the object.</summary>
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false)
{
MouseState mState = Mouse.GetState();
KeyboardState keyboardState = Game1.GetKeyboardState();
@ -172,18 +175,33 @@ namespace Revitalize.Framework.Objects
return this.clicked(who);
}
/*
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
{
CustomObjectData data = CustomObjectData.collection[additionalSaveData["id"]];
BasicItemInformation info = Revitalize.ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
return new CustomObject(data, info, (replacement as Chest).TileLocation);
return new CustomObject(data, info);
}
*/
/*
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));
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>
public virtual bool rightClicked(Farmer who)
@ -328,12 +346,19 @@ namespace Revitalize.Framework.Objects
/// <summary>Gets a clone of the game object.</summary>
public override Item getOne()
{
return new CustomObject(this.data, this.info);
return new CustomObject(this.info);
}
/// <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)
{
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)
{
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));
@ -355,7 +380,6 @@ namespace Revitalize.Framework.Objects
//Log.AsyncC("Animation Manager is working!");
int addedDepth = 0;
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));
try
{
@ -375,25 +399,14 @@ namespace Revitalize.Framework.Objects
/// <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)
{
/*
if (Game1.eventUp && Game1.CurrentEvent.isTileWalkedOn(xNonTile / 64, yNonTile / 64))
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);
*/
if(this.info == null)
{
ModCore.log("Info is null:");
ModCore.log("Need request for guid: " + this.guid);
MultiplayerUtilities.SendRequestForSpecificGUID(this.guid);
return;
}
//The actual planter box being drawn.
if (this.animationManager == null)
{
@ -409,7 +422,6 @@ namespace Revitalize.Framework.Objects
//Log.AsyncC("Animation Manager is working!");
int addedDepth = 0;
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));
try
{
@ -429,6 +441,13 @@ namespace Revitalize.Framework.Objects
/// <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)
{
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)
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)
@ -442,7 +461,37 @@ namespace Revitalize.Framework.Objects
/// <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)
{
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.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
if (f.ActiveObject.bigCraftable.Value)
@ -472,38 +521,36 @@ namespace Revitalize.Framework.Objects
{
//Do nothing because this shouldn't be placeable anywhere.
}
public void InitNetFields()
/*
public virtual bool InitNetFields()
{
if (Game1.IsMultiplayer == false && (Game1.IsClient == false || Game1.IsClient == false)) return;
this.initNetFields();
if (Game1.IsMultiplayer == false)
{
//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.NetFields.AddField(this.syncObject);
this.netItemInfo = new Netcode.NetString(this.ItemInfo);
this.NetFields.AddField(this.netItemInfo);
///this.NetFields.AddField(this.syncObject);
//this.netItemInfo = new Netcode.NetString(this.ItemInfo);
//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>
/// 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!");
base.sync(syncData);
this.info = Revitalize.ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(syncData["BasicItemInfo"]);
}
public virtual void replaceAfterLoad()
@ -516,6 +563,7 @@ namespace Revitalize.Framework.Objects
//ModCore.log("Do I ingnore BB? " + this.info.ignoreBoundingBox);
//ModCore.log("This is my BB: " + this.boundingBox.Value);
//this.InitNetFields();
}
}
@ -526,12 +574,25 @@ namespace Revitalize.Framework.Objects
return this.info.name;
}
public virtual void setNetFieldParent(INetSerializable Parent)
public object getReplacement()
{
this.NetFields.Parent = Parent;
IReflectedProperty<INetRoot> p=ModCore.ModHelper.Reflection.GetProperty<INetRoot>(this.NetFields, "Root", true);
p.SetValue(Parent.Root);
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,13 +71,12 @@ namespace Revitalize.Framework.Objects.Extras
obj.childrenGuids.Remove(pair.Key);
//Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString());
ArcadeCabinetTile component = Revitalize.ModCore.Serializer.DeserializeGUID<ArcadeCabinetTile>(pair.Value.ToString());
component.InitNetFields();
obj.addComponent(pair.Key, component);
}
obj.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"]))
{
@ -105,13 +104,11 @@ namespace Revitalize.Framework.Objects.Extras
{
this.childrenGuids.Remove(pair.Key);
ArcadeCabinetTile component = Revitalize.ModCore.Serializer.DeserializeGUID<ArcadeCabinetTile>(pair.Value.ToString());
component.InitNetFields();
this.removeComponent(pair.Key);
this.addComponent(pair.Key, component);
}
this.InitNetFields();
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(this.guid.ToString()))
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -255,9 +255,23 @@ namespace Revitalize.Framework.Objects.Furniture
if (this.info == null)
{
Revitalize.ModCore.log("info is null");
this.info = this.netInfo.Value;
if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC");
}
if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
if (this.animationManager == 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");
//The actual planter box being drawn.

View File

@ -1,23 +0,0 @@
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

@ -0,0 +1,48 @@
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,16 +177,19 @@ namespace Revitalize.Framework.Objects.Items.Resources
/// <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.updateInfoIfNull();
if (this.info.ignoreBoundingBox == true)
{
x *= -1;
y *= -1;
}
if (this.info == null)
{
Revitalize.ModCore.log("info is null");
if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC");
return;
}
if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
@ -223,6 +226,7 @@ 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)
{
this.updateInfoIfNull();
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)

View File

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

View File

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

View File

@ -4,18 +4,18 @@ namespace Revitalize.Framework.Player
{
public class PlayerInfo
{
public SittingInfo sittingInfo;
//public SittingInfo sittingInfo;
public MagicManager magicManager;
public PlayerInfo()
{
this.sittingInfo = new SittingInfo();
//this.sittingInfo = new SittingInfo();
this.magicManager = new MagicManager();
}
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);
return dimensions;
}
/*
/// <summary>
/// Gets all open positions for this location for this object.
/// </summary>
@ -117,7 +117,7 @@ namespace Revitalize.Framework.Utilities
}
return openTiles;
}
*/
/// <summary>
/// Checks to see if the farm for the game is the hilltop farm.
/// </summary>

View File

@ -0,0 +1,212 @@
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

@ -7,7 +7,7 @@ using System.Threading.Tasks;
using Netcode;
using Newtonsoft.Json;
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.Converters;
using StardewValley;
@ -135,9 +135,10 @@ namespace Revitalize.Framework.Utilities
{
this.deleteAllUnusedFiles();
//this.removeNullObjects();
this.restoreModObjects();
//this.restoreModObjects();
}
/*
/// <summary>
/// Restore mod objects to inventories and world after load.
/// </summary>
@ -166,10 +167,6 @@ namespace Revitalize.Framework.Utilities
if (o is Chest && o.Name != "Chest")
{
Item I = this.GetItemFromChestName(o.Name);
if (I.NetFields != null)
{
(I as CustomObject).setNetFieldParent(o.NetFields);
}
ModCore.log("Found a custom item in a chest!");
toAdd.Add(I);
toRemove.Add(o);
@ -195,10 +192,6 @@ namespace Revitalize.Framework.Utilities
if (o is Chest && o.Name != "Chest")
{
Item I = this.GetItemFromChestName(o.Name);
if (I.NetFields != null)
{
(I as CustomObject).setNetFieldParent(o.NetFields);
}
toAdd.Add(I);
toRemove.Add(o);
}
@ -217,10 +210,6 @@ namespace Revitalize.Framework.Utilities
{
ModCore.log("Found a custom object as a held object!");
Item I = this.GetItemFromChestName(c.heldObject.Value.Name);
if (I.NetFields != null)
{
(I as CustomObject).setNetFieldParent(c.NetFields);
}
c.heldObject.Value = (StardewValley.Object)I;
}
}
@ -233,10 +222,6 @@ namespace Revitalize.Framework.Utilities
{
ModCore.log("Found a custom object as a held object!");
Item I = this.GetItemFromChestName(c.heldObject.Value.Name);
if (I.NetFields != null)
{
(I as CustomObject).setNetFieldParent(c.NetFields);
}
c.heldObject.Value = (StardewValley.Object)I;
}
}
@ -253,10 +238,6 @@ namespace Revitalize.Framework.Utilities
if (I is Chest && I.Name != "Chest")
{
Item ret = this.GetItemFromChestName(I.Name);
if (I.NetFields != null)
{
(ret as CustomObject).setNetFieldParent(I.NetFields);
}
toAdd2.Add(ret);
toRemove2.Add(I);
}
@ -272,7 +253,7 @@ namespace Revitalize.Framework.Utilities
Game1.player.addItemToInventory(I);
}
}
*/
/// <summary>
/// Gets an Item recreated from PYTK's chest replacement objects.
@ -288,10 +269,7 @@ namespace Revitalize.Framework.Utilities
string type = jsonString.Split('|')[2];
Item I = (Item)ModCore.Serializer.DeserializeGUID(guidName, Type.GetType(type));
if (I is MultiTiledObject)
{
(I as MultiTiledObject).recreate();
}
//(I as CustomObject).InitNetFields();
return I;
}

View File

@ -5,12 +5,12 @@ using Microsoft.Xna.Framework;
using PyTK.Extensions;
using PyTK.Types;
using Revitalize.Framework;
using Revitalize.Framework.Crafting;
//using Revitalize.Framework.Crafting;
using Revitalize.Framework.Environment;
using Revitalize.Framework.Factories.Objects;
//using Revitalize.Framework.Factories.Objects;
using Revitalize.Framework.Illuminate;
using Revitalize.Framework.Objects;
using Revitalize.Framework.Objects.Furniture;
//using Revitalize.Framework.Objects.Furniture;
using Revitalize.Framework.Player;
using Revitalize.Framework.Utilities;
using StardewModdingAPI;
@ -19,11 +19,12 @@ using StardewValley.Objects;
using StardustCore.UIUtilities;
using StardustCore.Animations;
using StardewValley.Menus;
using Revitalize.Framework.Objects.Extras;
//using Revitalize.Framework.Objects.Extras;
using Revitalize.Framework.Minigame.SeasideScrambleMinigame;
using Revitalize.Framework.Objects.Items.Resources;
//using Revitalize.Framework.Objects.Items.Resources;
using Revitalize.Framework.Hacks;
using Netcode;
//using Revitalize.Framework.Objects.Items;
namespace Revitalize
{
@ -183,20 +184,23 @@ namespace Revitalize
/// <summary>
/// Keeps track of custom objects.
/// </summary>
public static ObjectManager ObjectManager;
//public static ObjectManager ObjectManager;
/// <summary>
/// Keeps track of all of the extra object groups.
/// </summary>
public static Dictionary<string, MultiTiledObject> ObjectGroups;
//public static Dictionary<string, MultiTiledObject> ObjectGroups;
public static PlayerInfo playerInfo;
public static Serializer Serializer;
public static Dictionary<GameLocation, MultiTiledObject> ObjectsToDraw;
public static VanillaRecipeBook VanillaRecipeBook;
//public static Dictionary<GameLocation, MultiTiledObject> ObjectsToDraw;
//public static VanillaRecipeBook VanillaRecipeBook;
public static Dictionary<Guid, CustomObject> CustomObjects;
public override void Entry(IModHelper helper)
{
ModHelper = helper;
@ -205,6 +209,7 @@ namespace Revitalize
this.createDirectories();
this.initailizeComponents();
CustomObjects = new Dictionary<Guid, CustomObject>();
Serializer = new Serializer();
playerInfo = new PlayerInfo();
@ -212,10 +217,10 @@ namespace Revitalize
this.loadInTextures();
//Loads in objects to be use by the mod.
ObjectGroups = new Dictionary<string, MultiTiledObject>();
ObjectManager = new ObjectManager(Manifest);
ObjectManager.loadInItems();
ObjectsToDraw = new Dictionary<GameLocation, MultiTiledObject>();
//ObjectGroups = new Dictionary<string, MultiTiledObject>();
//ObjectManager = new ObjectManager(Manifest);
//ObjectManager.loadInItems();
//ObjectsToDraw = new Dictionary<GameLocation, MultiTiledObject>();
//Adds in event handling for the mod.
ModHelper.Events.GameLoop.SaveLoaded += this.GameLoop_SaveLoaded;
@ -223,18 +228,24 @@ namespace Revitalize
ModHelper.Events.GameLoop.UpdateTicked += this.GameLoop_UpdateTicked;
ModHelper.Events.GameLoop.ReturnedToTitle += this.GameLoop_ReturnedToTitle;
ModHelper.Events.Input.ButtonPressed += this.Input_ButtonPressed;
ModHelper.Events.Player.Warped += ObjectManager.resources.OnPlayerLocationChanged;
ModHelper.Events.GameLoop.DayStarted += ObjectManager.resources.DailyResourceSpawn;
ModHelper.Events.Input.ButtonPressed += ObjectInteractionHacks.Input_CheckForObjectInteraction;
//ModHelper.Events.Player.Warped += ObjectManager.resources.OnPlayerLocationChanged;
//ModHelper.Events.GameLoop.DayStarted += ObjectManager.resources.DailyResourceSpawn;
//ModHelper.Events.Input.ButtonPressed += ObjectInteractionHacks.Input_CheckForObjectInteraction;
ModHelper.Events.GameLoop.DayEnding += Serializer.DayEnding_CleanUpFilesForDeletion;
ModHelper.Events.Display.RenderedWorld += ObjectInteractionHacks.Render_RenderCustomObjectsHeldInMachines;
//ModHelper.Events.Display.RenderedWorld += ObjectInteractionHacks.Render_RenderCustomObjectsHeldInMachines;
//ModHelper.Events.Multiplayer.PeerContextReceived += MultiplayerUtilities.OnPlayerConnect;
//ModHelper.Events.Multiplayer.PeerDisconnected += MultiplayerUtilities.OnPlayerDisconnect;
//ModHelper.Events.GameLoop.UpdateTicked += MultiplayerUtilities.GameLoop_OneSecondUpdateTicked;
//ModHelper.Events.Display.Rendered += MenuHacks.EndOfDay_OnMenuChanged;
//ModHelper.Events.GameLoop.Saved += MenuHacks.EndOfDay_CleanupForNewDay;
//ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.ModMessageReceived;
//MultiplayerUtilities.onlineFarmers = 1;
//Adds in recipes to the mod.
VanillaRecipeBook = new VanillaRecipeBook();
//VanillaRecipeBook = new VanillaRecipeBook();
}
/// <summary>
/// Loads in textures to be used by the mod.
/// </summary>
@ -273,17 +284,17 @@ namespace Revitalize
private void GameLoop_ReturnedToTitle(object sender, StardewModdingAPI.Events.ReturnedToTitleEventArgs e)
{
Serializer.returnToTitle();
ObjectManager = new ObjectManager(Manifest);
//ObjectManager = new ObjectManager(Manifest);
}
/// <summary>
/// Must be enabled for the tabled to be placed????
/// </summary>
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 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 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 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);
@ -344,6 +355,7 @@ namespace Revitalize
ObjectManager.miscellaneous.Add("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", sscCabinet);
//ModCore.log("Added in SSC!");
*/
}
private void createDirectories()
@ -379,6 +391,7 @@ namespace Revitalize
private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e)
{
MultiplayerUtilities.HasLoadedIn = true;
this.loadContent();
/*
if (Game1.IsServer || Game1.IsMultiplayer || Game1.IsClient)
@ -388,12 +401,16 @@ namespace Revitalize
*/
Serializer.afterLoad();
ShopHacks.AddOreToClintsShop();
MultiplayerUtilities.needToRestore = true;
// 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(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.getObject("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble",ObjectManager.miscellaneous));
@ -406,14 +423,16 @@ namespace Revitalize
*/
//Game1.player.addItemToInventory(ObjectManager.resources.ores["Test"].getOne());
Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin", 19));
//Game1.player.addItemToInventory(ObjectManager.GetItem("TinIngot"));
//Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin", 19));
//Ore tin = ObjectManager.resources.getOre("Tin", 19);
//Game1.player.addItemToInventory(new MyTool());
//ModCore.log("Tin sells for: " + tin.sellToStorePrice());
//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

@ -52,22 +52,10 @@
<Reference Include="System.Xml" />
</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\Environment\DarkerNight.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\ObjectInteractionHacks.cs" />
<Compile Include="Framework\Hacks\ShopHacks.cs" />
<Compile Include="Framework\Illuminate\ColorExtensions.cs" />
<Compile Include="Framework\Illuminate\FakeLightSource.cs" />
@ -109,43 +97,15 @@
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCStatusEffects\StatusEffect.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCStatusEffects\StatusEffectManager.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\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\SittingInfo.cs" />
<Compile Include="Framework\Player\PlayerInfo.cs" />
<Compile Include="Framework\Utilities\BoundingBoxInfo.cs" />
<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" />
@ -375,7 +335,7 @@
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="Framework\Objects\InformationFiles\Extras\" />
<Folder Include="Framework\Factories\Objects\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

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