SRMP-Public/SRMP/Patches/Patch_ExchangeBreakOnImpact.cs

34 lines
950 B
C#
Raw Permalink Normal View History

2023-05-29 22:23:11 +02:00
using HarmonyLib;
using MonomiPark.SlimeRancher.Regions;
2023-05-29 22:23:11 +02:00
using SRMultiplayer.Networking;
using SRMultiplayer.Packets;
2023-05-29 22:23:11 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
2023-05-29 22:23:11 +02:00
using System.Text;
using UnityEngine;
2023-05-29 22:23:11 +02:00
namespace SRMultiplayer.Patches
{
[HarmonyPatch(typeof(ExchangeBreakOnImpact))]
[HarmonyPatch("BreakOpen")]
class ExchangeBreakOnImpact_BreakOpen
{
2023-05-29 22:23:11 +02:00
static bool Prefix(ExchangeBreakOnImpact __instance)
{
//if multiplayer, only the server can trigger the impact
if (!Globals.IsMultiplayer) return true;
2023-05-29 22:23:11 +02:00
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
2023-05-29 22:23:11 +02:00
return (entity != null && entity.IsLocal);
}
}
}