Exchange seems to have been fixed. Needs a bit more testing, but seems to be acting as expected

This commit is contained in:
Twirlbug 2023-06-30 18:34:30 -05:00
parent da9d5a4830
commit 56d1005b32
7 changed files with 54 additions and 20 deletions

View file

@ -1,8 +1,10 @@
using MonomiPark.SlimeRancher.Regions; using DG.Tweening;
using MonomiPark.SlimeRancher.Regions;
using SRMultiplayer.Packets; using SRMultiplayer.Packets;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Sockets;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
@ -237,6 +239,7 @@ namespace SRMultiplayer.Networking
var exchangeBreakOnImpact = GetComponentInChildren<ExchangeBreakOnImpact>(); var exchangeBreakOnImpact = GetComponentInChildren<ExchangeBreakOnImpact>();
if (exchangeBreakOnImpact != null) if (exchangeBreakOnImpact != null)
{ {
SRMP.Log("Exchange Box Broke!", "ACTOR");
SRBehaviour.SpawnAndPlayFX(exchangeBreakOnImpact.breakFX, exchangeBreakOnImpact.gameObject.transform.position, exchangeBreakOnImpact.gameObject.transform.rotation); SRBehaviour.SpawnAndPlayFX(exchangeBreakOnImpact.breakFX, exchangeBreakOnImpact.gameObject.transform.position, exchangeBreakOnImpact.gameObject.transform.rotation);
} }
var breakOnImpact = GetComponentInChildren<BreakOnImpactBase>(); var breakOnImpact = GetComponentInChildren<BreakOnImpactBase>();

View file

@ -1,5 +1,4 @@
using Assets.Script.Util.Extensions; using DG.Tweening;
using DG.Tweening;
using Lidgren.Network; using Lidgren.Network;
using MonomiPark.SlimeRancher.DataModel; using MonomiPark.SlimeRancher.DataModel;
using MonomiPark.SlimeRancher.Persist; using MonomiPark.SlimeRancher.Persist;
@ -372,7 +371,8 @@ namespace SRMultiplayer.Networking
SRBehaviour.InstantiateDynamic(eject.awardFX, eject.awardAt.position, eject.awardAt.rotation); SRBehaviour.InstantiateDynamic(eject.awardFX, eject.awardAt.position, eject.awardAt.rotation);
} }
SRSingleton<SceneContext>.Instance.ExchangeDirector.ClearOffer(type); //dont clear out the offer yet, we arent done with it
//SRSingleton<SceneContext>.Instance.ExchangeDirector.ClearOffer(type);
} }
//trigger offer status changed //trigger offer status changed
@ -381,9 +381,6 @@ namespace SRMultiplayer.Networking
} }
} }
} }
private static void OnExchangePrepareDaily(PacketExchangePrepareDaily packet) private static void OnExchangePrepareDaily(PacketExchangePrepareDaily packet)
{ {
SRSingleton<SceneContext>.Instance.ExchangeDirector.worldModel.pendingOfferRancherIds = packet.pendingOfferRancherIds; SRSingleton<SceneContext>.Instance.ExchangeDirector.worldModel.pendingOfferRancherIds = packet.pendingOfferRancherIds;

View file

@ -318,7 +318,17 @@ namespace SRMultiplayer.Networking
{ {
rewarder.AwardIfType(type); rewarder.AwardIfType(type);
} }
SRSingleton<SceneContext>.Instance.ExchangeDirector.ClearOffer(type);
//trigger fireworks
//get ExchangeEjector
foreach (var eject in Resources.FindObjectsOfTypeAll<ExchangeEjector>())
{
//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<SceneContext>.Instance.ExchangeDirector.ClearOffer(type);
} }
SRSingleton<SceneContext>.Instance.ExchangeDirector.OfferDidChange(); SRSingleton<SceneContext>.Instance.ExchangeDirector.OfferDidChange();
} }

View file

@ -97,6 +97,7 @@
ExchangeTryAccept, ExchangeTryAccept,
ExchangeClear, ExchangeClear,
ExchangeOffers, ExchangeOffers,
ExchangeBreak,
GordoEat, GordoEat,
Oasis, Oasis,
OasisLive, OasisLive,

View file

@ -1,9 +1,13 @@
using HarmonyLib; using HarmonyLib;
using MonomiPark.SlimeRancher.Regions;
using SRMultiplayer.Networking; using SRMultiplayer.Networking;
using SRMultiplayer.Packets;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text; using System.Text;
using UnityEngine;
namespace SRMultiplayer.Patches namespace SRMultiplayer.Patches
{ {
@ -11,11 +15,19 @@ namespace SRMultiplayer.Patches
[HarmonyPatch("BreakOpen")] [HarmonyPatch("BreakOpen")]
class ExchangeBreakOnImpact_BreakOpen class ExchangeBreakOnImpact_BreakOpen
{ {
static bool Prefix(ExchangeBreakOnImpact __instance) static bool Prefix(ExchangeBreakOnImpact __instance)
{ {
//if multiplayer, only the server can trigger the impact
if (!Globals.IsMultiplayer) return true; if (!Globals.IsMultiplayer) return true;
var entity = __instance.GetComponent<NetworkActor>(); var entity = __instance.GetComponent<NetworkActor>();
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); return (entity != null && entity.IsLocal);
} }
} }

View file

@ -22,7 +22,18 @@ namespace SRMultiplayer.Patches
{ {
if (Globals.Actors.ContainsKey(netActor.ID)) if (Globals.Actors.ContainsKey(netActor.ID))
{ {
//check if this is an exchange box
var exchangeBreakOnImpact = netActor.GetComponentInChildren<ExchangeBreakOnImpact>();
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); Globals.Actors.Remove(netActor.ID);
new PacketActorDestroy() new PacketActorDestroy()
{ {
ID = netActor.ID ID = netActor.ID

View file

@ -15,7 +15,7 @@ using System.Resources;
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// Version informationr( // Version informationr(
[assembly: AssemblyVersion("0.0.0.1492")] [assembly: AssemblyVersion("0.0.0.1500")]
[assembly: AssemblyFileVersion("0.0.0.1492")] [assembly: AssemblyFileVersion("0.0.0.1500")]
[assembly: NeutralResourcesLanguageAttribute( "en-US" )] [assembly: NeutralResourcesLanguageAttribute( "en-US" )]