Got objects to not crash when other player connects over multiplayer. HUGE progress!
This commit is contained in:
parent
e1a2a0da47
commit
f7749117e5
|
@ -27,6 +27,16 @@ namespace StardustCore.Animations
|
||||||
|
|
||||||
|
|
||||||
public string animationDataString;
|
public string animationDataString;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Empty constructor.
|
||||||
|
/// </summary>
|
||||||
|
public AnimationManager()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor for Animation Manager class.
|
/// Constructor for Animation Manager class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -6,6 +6,7 @@ using StardewValley.Menus;
|
||||||
using StardewValley.Network;
|
using StardewValley.Network;
|
||||||
using StardustCore.Menus;
|
using StardustCore.Menus;
|
||||||
using StardustCore.ModInfo;
|
using StardustCore.ModInfo;
|
||||||
|
using StardustCore.NetCode;
|
||||||
using StardustCore.Objects;
|
using StardustCore.Objects;
|
||||||
using StardustCore.Objects.Tools;
|
using StardustCore.Objects.Tools;
|
||||||
using StardustCore.Serialization;
|
using StardustCore.Serialization;
|
||||||
|
@ -61,6 +62,9 @@ namespace StardustCore
|
||||||
StardewModdingAPI.Events.MenuEvents.MenuChanged += MenuEvents_MenuChanged;
|
StardewModdingAPI.Events.MenuEvents.MenuChanged += MenuEvents_MenuChanged;
|
||||||
StardewModdingAPI.Events.MenuEvents.MenuClosed += MenuEvents_MenuClosed;
|
StardewModdingAPI.Events.MenuEvents.MenuClosed += MenuEvents_MenuClosed;
|
||||||
|
|
||||||
|
ModHelper.Events.Multiplayer.PeerContextReceived += Multiplayer_PeerContextReceived;
|
||||||
|
ModHelper.Events.Multiplayer.ModMessageReceived += Multiplayer_ModMessageReceived;
|
||||||
|
|
||||||
IlluminateFramework.Colors.initializeColors();
|
IlluminateFramework.Colors.initializeColors();
|
||||||
ContentDirectory = "Content";
|
ContentDirectory = "Content";
|
||||||
if (!Directory.Exists(ContentDirectory)) Directory.CreateDirectory(Path.Combine(ModHelper.DirectoryPath, "Content"));
|
if (!Directory.Exists(ContentDirectory)) Directory.CreateDirectory(Path.Combine(ModHelper.DirectoryPath, "Content"));
|
||||||
|
@ -82,6 +86,31 @@ namespace StardustCore
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Multiplayer_ModMessageReceived(object sender, StardewModdingAPI.Events.ModMessageReceivedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.FromModID == this.ModManifest.UniqueID)
|
||||||
|
{
|
||||||
|
if (e.Type == MultiplayerSupport.CleanUpModObjects)
|
||||||
|
{
|
||||||
|
SerializationManager.cleanUpInventory();
|
||||||
|
SerializationManager.cleanUpWorld();
|
||||||
|
SerializationManager.cleanUpStorageContainers();
|
||||||
|
}
|
||||||
|
else if (e.Type == MultiplayerSupport.RestoreModObjects)
|
||||||
|
{
|
||||||
|
SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Multiplayer_PeerContextReceived(object sender, StardewModdingAPI.Events.PeerContextReceivedEventArgs e)
|
||||||
|
{
|
||||||
|
//ModMonitor.Log("TRY TO CLEAN UP THE MESS!!!!");
|
||||||
|
SerializationManager.cleanUpInventory();
|
||||||
|
SerializationManager.cleanUpWorld();
|
||||||
|
SerializationManager.cleanUpStorageContainers();
|
||||||
|
}
|
||||||
|
|
||||||
private void MenuEvents_MenuClosed(object sender, StardewModdingAPI.Events.EventArgsClickableMenuClosed e)
|
private void MenuEvents_MenuClosed(object sender, StardewModdingAPI.Events.EventArgsClickableMenuClosed e)
|
||||||
{
|
{
|
||||||
if (Game1.IsMasterGame == false && config.enableMultiplayerHack)
|
if (Game1.IsMasterGame == false && config.enableMultiplayerHack)
|
||||||
|
@ -171,6 +200,8 @@ namespace StardustCore
|
||||||
|
|
||||||
SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList);
|
SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList);
|
||||||
|
|
||||||
|
ModHelper.Multiplayer.SendMessage<string>(MultiplayerSupport.RestoreModObjects, MultiplayerSupport.RestoreModObjects,new string[] { ModManifest.UniqueID }, null);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
List<KeyValuePair<Vector2, MultiTileComponent>> objs = new List<KeyValuePair<Vector2, MultiTileComponent>>();
|
List<KeyValuePair<Vector2, MultiTileComponent>> objs = new List<KeyValuePair<Vector2, MultiTileComponent>>();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StardustCore.NetCode
|
||||||
|
{
|
||||||
|
public class MultiplayerSupport
|
||||||
|
{
|
||||||
|
public static string CleanUpModObjects = "Omegasis.StardustCore.MultiplayerSupport.CleanUpModObjects";
|
||||||
|
public static string RestoreModObjects = "Omegasis.StardustCore.MultiplayerSupport.RestoreModObjects";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -99,6 +99,7 @@
|
||||||
<Compile Include="NetCode\Graphics\NetAnimationManager.cs" />
|
<Compile Include="NetCode\Graphics\NetAnimationManager.cs" />
|
||||||
<Compile Include="NetCode\ModdedClient.cs" />
|
<Compile Include="NetCode\ModdedClient.cs" />
|
||||||
<Compile Include="NetCode\ModdedGameServer.cs" />
|
<Compile Include="NetCode\ModdedGameServer.cs" />
|
||||||
|
<Compile Include="NetCode\MultiplayerSupport.cs" />
|
||||||
<Compile Include="NetCode\NetBufferReadStream.cs" />
|
<Compile Include="NetCode\NetBufferReadStream.cs" />
|
||||||
<Compile Include="NetCode\NetBufferWriteStream.cs" />
|
<Compile Include="NetCode\NetBufferWriteStream.cs" />
|
||||||
<Compile Include="NetCode\NetKeyValuePair.cs" />
|
<Compile Include="NetCode\NetKeyValuePair.cs" />
|
||||||
|
|
Loading…
Reference in New Issue