SRMP-Public/SRMP/Patches/Patch_QuicksilverEnergyGenerator.cs
2023-05-29 22:23:11 +02:00

69 lines
No EOL
1.9 KiB
C#

using HarmonyLib;
using MonomiPark.SlimeRancher.Regions;
using SRMultiplayer.Networking;
using SRMultiplayer.Packets;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace SRMultiplayer.Patches
{
[HarmonyPatch(typeof(QuicksilverEnergyGenerator))]
[HarmonyPatch("Activate")]
class QuicksilverEnergyGenerator_Activate
{
static void Postfix(QuicksilverEnergyGenerator __instance, ref bool __result)
{
if (!Globals.IsMultiplayer || Globals.HandlePacket) return;
if (__result)
{
new PacketRaceActivate()
{
ID = __instance.id
}.Send();
}
}
}
[HarmonyPatch(typeof(QuicksilverEnergyGenerator))]
[HarmonyPatch("ExtendActiveDuration")]
class QuicksilverEnergyGenerator_ExtendActiveDuration
{
static void Postfix(QuicksilverEnergyGenerator __instance, float hours, ref bool __result)
{
if (!Globals.IsMultiplayer || Globals.HandlePacket) return;
if (__result)
{
new PacketRaceTime()
{
ID = __instance.id,
Time = hours
}.Send();
}
}
}
[HarmonyPatch(typeof(QuicksilverEnergyGenerator))]
[HarmonyPatch("SetState")]
class QuicksilverEnergyGenerator_SetState
{
static void Postfix(QuicksilverEnergyGenerator __instance, QuicksilverEnergyGenerator.State state, bool enableSFX)
{
if (!Globals.IsMultiplayer || Globals.HandlePacket) return;
if(state == QuicksilverEnergyGenerator.State.COOLDOWN && !enableSFX)
{
new PacketRaceEnd()
{
ID = __instance.id
}.Send();
}
}
}
}