diff --git a/SRMP/Networking/NetworkActor.cs b/SRMP/Networking/NetworkActor.cs index f0a2feb..dcf6c10 100644 --- a/SRMP/Networking/NetworkActor.cs +++ b/SRMP/Networking/NetworkActor.cs @@ -1,8 +1,10 @@ -using MonomiPark.SlimeRancher.Regions; +using DG.Tweening; +using MonomiPark.SlimeRancher.Regions; using SRMultiplayer.Packets; using System; using System.Collections.Generic; using System.Linq; +using System.Net.Sockets; using System.Text; using System.Threading.Tasks; using UnityEngine; @@ -52,7 +54,7 @@ namespace SRMultiplayer.Networking private void OnEnable() { - if(Owner == 0) + if (Owner == 0) { TakeOwnership(); } @@ -68,7 +70,7 @@ namespace SRMultiplayer.Networking private void Update() { - if(IsLocal) + if (IsLocal) { m_MovementUpdateTimer -= Time.deltaTime; if (m_MovementUpdateTimer <= 0) @@ -92,7 +94,7 @@ namespace SRMultiplayer.Networking }.Send(Lidgren.Network.NetDeliveryMethod.Unreliable); } - if(SlimeEat != null && + if (SlimeEat != null && (!Utils.CloseEnoughForMe(SlimeEat.emotions.GetCurr(SlimeEmotions.Emotion.AGITATION), m_PreviousEmotions[SlimeEmotions.Emotion.AGITATION], 0.1f) || !Utils.CloseEnoughForMe(SlimeEat.emotions.GetCurr(SlimeEmotions.Emotion.FEAR), m_PreviousEmotions[SlimeEmotions.Emotion.FEAR], 0.1f) || !Utils.CloseEnoughForMe(SlimeEat.emotions.GetCurr(SlimeEmotions.Emotion.HUNGER), m_PreviousEmotions[SlimeEmotions.Emotion.HUNGER], 0.1f))) @@ -113,7 +115,7 @@ namespace SRMultiplayer.Networking } else { - if(m_Rigidbody != null) + if (m_Rigidbody != null) { m_Rigidbody.velocity = Vector3.zero; } @@ -227,7 +229,7 @@ namespace SRMultiplayer.Networking } } var destroyOnTouching = GetComponentInChildren(); - if(destroyOnTouching != null) + if (destroyOnTouching != null) { if (destroyOnTouching.destroyFX != null) { @@ -237,6 +239,7 @@ namespace SRMultiplayer.Networking var exchangeBreakOnImpact = GetComponentInChildren(); if (exchangeBreakOnImpact != null) { + SRMP.Log("Exchange Box Broke!", "ACTOR"); SRBehaviour.SpawnAndPlayFX(exchangeBreakOnImpact.breakFX, exchangeBreakOnImpact.gameObject.transform.position, exchangeBreakOnImpact.gameObject.transform.rotation); } var breakOnImpact = GetComponentInChildren(); @@ -245,7 +248,7 @@ namespace SRMultiplayer.Networking SRBehaviour.SpawnAndPlayFX(breakOnImpact.breakFX, breakOnImpact.gameObject.transform.position, breakOnImpact.gameObject.transform.rotation); } var quicksilver = GetComponentInChildren(); - if(quicksilver != null) + if (quicksilver != null) { if (quicksilver.destroyFX != null) { diff --git a/SRMP/Networking/NetworkHandlerClient.cs b/SRMP/Networking/NetworkHandlerClient.cs index 8ded6e6..dd0c9a2 100644 --- a/SRMP/Networking/NetworkHandlerClient.cs +++ b/SRMP/Networking/NetworkHandlerClient.cs @@ -1,5 +1,4 @@ -using Assets.Script.Util.Extensions; -using DG.Tweening; +using DG.Tweening; using Lidgren.Network; using MonomiPark.SlimeRancher.DataModel; using MonomiPark.SlimeRancher.Persist; @@ -371,8 +370,9 @@ namespace SRMultiplayer.Networking //send off fireworks SRBehaviour.InstantiateDynamic(eject.awardFX, eject.awardAt.position, eject.awardAt.rotation); } - - SRSingleton.Instance.ExchangeDirector.ClearOffer(type); + + //dont clear out the offer yet, we arent done with it + //SRSingleton.Instance.ExchangeDirector.ClearOffer(type); } //trigger offer status changed @@ -381,10 +381,7 @@ namespace SRMultiplayer.Networking } } } - - - - private static void OnExchangePrepareDaily(PacketExchangePrepareDaily packet) + private static void OnExchangePrepareDaily(PacketExchangePrepareDaily packet) { SRSingleton.Instance.ExchangeDirector.worldModel.pendingOfferRancherIds = packet.pendingOfferRancherIds; SRSingleton.Instance.ExchangeDirector.OfferDidChange(); diff --git a/SRMP/Networking/NetworkHandlerServer.cs b/SRMP/Networking/NetworkHandlerServer.cs index 1b0f83e..3fb97ae 100644 --- a/SRMP/Networking/NetworkHandlerServer.cs +++ b/SRMP/Networking/NetworkHandlerServer.cs @@ -318,14 +318,24 @@ namespace SRMultiplayer.Networking { rewarder.AwardIfType(type); } - SRSingleton.Instance.ExchangeDirector.ClearOffer(type); + + //trigger fireworks + //get ExchangeEjector + foreach (var eject in Resources.FindObjectsOfTypeAll()) + { + //send off fireworks + SRBehaviour.InstantiateDynamic(eject.awardFX, eject.awardAt.position, eject.awardAt.rotation); + } + + //dont clear out the offer yet, we arent done with it + //SRSingleton.Instance.ExchangeDirector.ClearOffer(type); } SRSingleton.Instance.ExchangeDirector.OfferDidChange(); } } } packet.SendToAllExcept(player); - } + } private static void OnExchangePrepareDaily(PacketExchangePrepareDaily packet, NetworkPlayer player) { diff --git a/SRMP/Packets/_Classes/PacketType.cs b/SRMP/Packets/_Classes/PacketType.cs index a6ca38d..c4e4f07 100644 --- a/SRMP/Packets/_Classes/PacketType.cs +++ b/SRMP/Packets/_Classes/PacketType.cs @@ -97,6 +97,7 @@ ExchangeTryAccept, ExchangeClear, ExchangeOffers, + ExchangeBreak, GordoEat, Oasis, OasisLive, diff --git a/SRMP/Patches/Patch_ExchangeBreakOnImpact.cs b/SRMP/Patches/Patch_ExchangeBreakOnImpact.cs index 219a384..1e29af0 100644 --- a/SRMP/Patches/Patch_ExchangeBreakOnImpact.cs +++ b/SRMP/Patches/Patch_ExchangeBreakOnImpact.cs @@ -1,9 +1,13 @@ using HarmonyLib; +using MonomiPark.SlimeRancher.Regions; using SRMultiplayer.Networking; +using SRMultiplayer.Packets; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; using System.Text; +using UnityEngine; namespace SRMultiplayer.Patches { @@ -11,11 +15,19 @@ namespace SRMultiplayer.Patches [HarmonyPatch("BreakOpen")] class ExchangeBreakOnImpact_BreakOpen { + static bool Prefix(ExchangeBreakOnImpact __instance) { - if (!Globals.IsMultiplayer) return true; + //if multiplayer, only the server can trigger the impact + if (!Globals.IsMultiplayer) return true; + + var entity = __instance.GetComponent(); + + SRMP.Log("Exchange Box Break: " + (entity != null && entity.IsLocal), "EXCHANGE"); + + //if the box exists and the entity is local process the break return (entity != null && entity.IsLocal); } } diff --git a/SRMP/Patches/Patch_Identifiable.cs b/SRMP/Patches/Patch_Identifiable.cs index d9bcd3c..ba109e3 100644 --- a/SRMP/Patches/Patch_Identifiable.cs +++ b/SRMP/Patches/Patch_Identifiable.cs @@ -22,7 +22,18 @@ namespace SRMultiplayer.Patches { if (Globals.Actors.ContainsKey(netActor.ID)) { + //check if this is an exchange box + var exchangeBreakOnImpact = netActor.GetComponentInChildren(); + if (exchangeBreakOnImpact != null) + { + //exchange box was found processing it with the ondestroy command instead of just removing it! + //netActor.OnDestroyEffect(); + //Destroyer.DestroyActor(netActor.gameObject, "NetworkHandlerServer.OnActorDestroy"); + } + + //make sure the actor still gets cleaned up Globals.Actors.Remove(netActor.ID); + new PacketActorDestroy() { ID = netActor.ID diff --git a/SRMP/Properties/AssemblyInfo.cs b/SRMP/Properties/AssemblyInfo.cs index 9520c65..b1bee8b 100644 --- a/SRMP/Properties/AssemblyInfo.cs +++ b/SRMP/Properties/AssemblyInfo.cs @@ -15,7 +15,7 @@ using System.Resources; [assembly: AssemblyCulture("")] // Version informationr( -[assembly: AssemblyVersion("0.0.0.1492")] -[assembly: AssemblyFileVersion("0.0.0.1492")] +[assembly: AssemblyVersion("0.0.0.1500")] +[assembly: AssemblyFileVersion("0.0.0.1500")] [assembly: NeutralResourcesLanguageAttribute( "en-US" )]