Exchange seems to have been fixed. Needs a bit more testing, but seems to be acting as expected
This commit is contained in:
parent
da9d5a4830
commit
7cb3154256
7 changed files with 106 additions and 19 deletions
|
@ -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;
|
||||||
|
@ -52,7 +54,7 @@ namespace SRMultiplayer.Networking
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
if(Owner == 0)
|
if (Owner == 0)
|
||||||
{
|
{
|
||||||
TakeOwnership();
|
TakeOwnership();
|
||||||
}
|
}
|
||||||
|
@ -68,7 +70,7 @@ namespace SRMultiplayer.Networking
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if(IsLocal)
|
if (IsLocal)
|
||||||
{
|
{
|
||||||
m_MovementUpdateTimer -= Time.deltaTime;
|
m_MovementUpdateTimer -= Time.deltaTime;
|
||||||
if (m_MovementUpdateTimer <= 0)
|
if (m_MovementUpdateTimer <= 0)
|
||||||
|
@ -92,7 +94,7 @@ namespace SRMultiplayer.Networking
|
||||||
}.Send(Lidgren.Network.NetDeliveryMethod.Unreliable);
|
}.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.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.FEAR), m_PreviousEmotions[SlimeEmotions.Emotion.FEAR], 0.1f) ||
|
||||||
!Utils.CloseEnoughForMe(SlimeEat.emotions.GetCurr(SlimeEmotions.Emotion.HUNGER), m_PreviousEmotions[SlimeEmotions.Emotion.HUNGER], 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
|
else
|
||||||
{
|
{
|
||||||
if(m_Rigidbody != null)
|
if (m_Rigidbody != null)
|
||||||
{
|
{
|
||||||
m_Rigidbody.velocity = Vector3.zero;
|
m_Rigidbody.velocity = Vector3.zero;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +229,7 @@ namespace SRMultiplayer.Networking
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var destroyOnTouching = GetComponentInChildren<DestroyOnTouching>();
|
var destroyOnTouching = GetComponentInChildren<DestroyOnTouching>();
|
||||||
if(destroyOnTouching != null)
|
if (destroyOnTouching != null)
|
||||||
{
|
{
|
||||||
if (destroyOnTouching.destroyFX != null)
|
if (destroyOnTouching.destroyFX != null)
|
||||||
{
|
{
|
||||||
|
@ -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>();
|
||||||
|
@ -245,7 +248,7 @@ namespace SRMultiplayer.Networking
|
||||||
SRBehaviour.SpawnAndPlayFX(breakOnImpact.breakFX, breakOnImpact.gameObject.transform.position, breakOnImpact.gameObject.transform.rotation);
|
SRBehaviour.SpawnAndPlayFX(breakOnImpact.breakFX, breakOnImpact.gameObject.transform.position, breakOnImpact.gameObject.transform.rotation);
|
||||||
}
|
}
|
||||||
var quicksilver = GetComponentInChildren<QuicksilverPlortCollector>();
|
var quicksilver = GetComponentInChildren<QuicksilverPlortCollector>();
|
||||||
if(quicksilver != null)
|
if (quicksilver != null)
|
||||||
{
|
{
|
||||||
if (quicksilver.destroyFX != null)
|
if (quicksilver.destroyFX != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -371,8 +370,9 @@ namespace SRMultiplayer.Networking
|
||||||
//send off fireworks
|
//send off fireworks
|
||||||
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,10 +381,7 @@ 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;
|
||||||
SRSingleton<SceneContext>.Instance.ExchangeDirector.OfferDidChange();
|
SRSingleton<SceneContext>.Instance.ExchangeDirector.OfferDidChange();
|
||||||
|
|
|
@ -119,6 +119,7 @@ namespace SRMultiplayer.Networking
|
||||||
case PacketType.ExchangeClear: OnExchangeClear(new PacketExchangeClear(im), player); break;
|
case PacketType.ExchangeClear: OnExchangeClear(new PacketExchangeClear(im), player); break;
|
||||||
case PacketType.ExchangePrepareDaily: OnExchangePrepareDaily(new PacketExchangePrepareDaily(im), player); break;
|
case PacketType.ExchangePrepareDaily: OnExchangePrepareDaily(new PacketExchangePrepareDaily(im), player); break;
|
||||||
case PacketType.ExchangeTryAccept: OnExchangeTryAccept(new PacketExchangeTryAccept(im), player); break;
|
case PacketType.ExchangeTryAccept: OnExchangeTryAccept(new PacketExchangeTryAccept(im), player); break;
|
||||||
|
case PacketType.ExchangeBreak: OnExchangeBreak(new PacketExchangeBreak(im)); break;
|
||||||
//Gordos
|
//Gordos
|
||||||
case PacketType.GordoEat: OnGordoEat(new PacketGordoEat(im), player); break;
|
case PacketType.GordoEat: OnGordoEat(new PacketGordoEat(im), player); break;
|
||||||
//Oasis
|
//Oasis
|
||||||
|
@ -318,7 +319,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();
|
||||||
}
|
}
|
||||||
|
@ -326,6 +337,58 @@ namespace SRMultiplayer.Networking
|
||||||
}
|
}
|
||||||
packet.SendToAllExcept(player);
|
packet.SendToAllExcept(player);
|
||||||
}
|
}
|
||||||
|
private static void OnExchangeBreak(PacketExchangeBreak packet)
|
||||||
|
{
|
||||||
|
//trigger award
|
||||||
|
SRMP.Log($"Notified Exchange Box Break", "EXCHANGE");
|
||||||
|
|
||||||
|
//don't box break as its covered in destroy effects
|
||||||
|
//get link to exchange
|
||||||
|
var exchangeDir = SRSingleton<SceneContext>.Instance.ExchangeDirector;
|
||||||
|
|
||||||
|
//get list of rewards in box
|
||||||
|
List<ExchangeDirector.ItemEntry> offerRewards = exchangeDir.GetOfferRewards(ExchangeDirector.OfferType.GENERAL);
|
||||||
|
|
||||||
|
//trigger award
|
||||||
|
SRMP.Log($"Exchange Box Rewards Located", "EXCHANGE");
|
||||||
|
|
||||||
|
//get local impact handler
|
||||||
|
var exchangeBreakOnImpact = SRSingleton<SceneContext>.Instance.GetComponentInChildren<ExchangeBreakOnImpact>();
|
||||||
|
|
||||||
|
//trigger award
|
||||||
|
SRMP.Log($"Exchange Box Impact Located", "EXCHANGE");
|
||||||
|
|
||||||
|
//set the spawn location
|
||||||
|
if (offerRewards != null)
|
||||||
|
{
|
||||||
|
foreach (ExchangeDirector.ItemEntry item in offerRewards)
|
||||||
|
{
|
||||||
|
if (item.specReward != 0)
|
||||||
|
{
|
||||||
|
exchangeBreakOnImpact.SpawnSpecReward(item.specReward);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameObject prefab = SRSingleton<GameContext>.Instance.LookupDirector.GetPrefab(item.id);
|
||||||
|
for (int i = 0; i < item.count; i++)
|
||||||
|
{
|
||||||
|
SRMP.Log($"Exchange Box Spawn " + prefab.tag + " " + i, "EXCHANGE");
|
||||||
|
|
||||||
|
Vector3 position = packet.Position + UnityEngine.Random.insideUnitSphere * 1f;
|
||||||
|
GameObject gameObject = SRBehaviour.InstantiateActor(prefab, (RegionRegistry.RegionSetId)packet.RegionSet, position, Quaternion.identity);
|
||||||
|
gameObject.transform.DOScale(gameObject.transform.localScale, 0.2f).From(0.01f).SetEase(Ease.Linear);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//trigger award
|
||||||
|
SRMP.Log($"Exchange Box Notify Did Spawn", "CLIENT");
|
||||||
|
//notify rewards spawned
|
||||||
|
exchangeDir.RewardsDidSpawn(ExchangeDirector.OfferType.GENERAL);
|
||||||
|
|
||||||
|
SRMP.Log($"ExchangeBreak", "CLIENT");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static void OnExchangePrepareDaily(PacketExchangePrepareDaily packet, NetworkPlayer player)
|
private static void OnExchangePrepareDaily(PacketExchangePrepareDaily packet, NetworkPlayer player)
|
||||||
{
|
{
|
||||||
|
|
|
@ -97,6 +97,7 @@
|
||||||
ExchangeTryAccept,
|
ExchangeTryAccept,
|
||||||
ExchangeClear,
|
ExchangeClear,
|
||||||
ExchangeOffers,
|
ExchangeOffers,
|
||||||
|
ExchangeBreak,
|
||||||
GordoEat,
|
GordoEat,
|
||||||
Oasis,
|
Oasis,
|
||||||
OasisLive,
|
OasisLive,
|
||||||
|
|
|
@ -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 (!Globals.IsMultiplayer) return true;
|
//if multiplayer, only the server can trigger the impact
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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" )]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue