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

33 lines
No EOL
916 B
C#

using HarmonyLib;
using SRMultiplayer.Networking;
using SRMultiplayer.Packets;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace SRMultiplayer.Patches
{
[HarmonyPatch(typeof(DroneAnimator))]
[HarmonyPatch("SetAnimation")]
class DroneAnimator_SetAnimation
{
static bool Prefix(DroneAnimator __instance, DroneAnimator.Id id)
{
if (!Globals.IsMultiplayer || Globals.HandlePacket) return true;
var netDrone = __instance.GetComponentInParent<NetworkDrone>();
if (netDrone != null && netDrone.IsLocal)
{
new PacketDroneAnimation()
{
ID = netDrone.Drone.droneModel.siteId,
Anim = (byte)id
}.Send();
return true;
}
return false;
}
}
}