40 lines
No EOL
1 KiB
C#
40 lines
No EOL
1 KiB
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(Vacuumable))]
|
|
[HarmonyPatch("capture")]
|
|
class Vacuumable_capture
|
|
{
|
|
static void Prefix(Vacuumable __instance)
|
|
{
|
|
if (!Globals.IsMultiplayer) return;
|
|
|
|
var netActor = __instance.GetComponentInParent<NetworkActor>();
|
|
if (netActor != null && !netActor.IsLocal)
|
|
{
|
|
netActor.TakeOwnership();
|
|
}
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(Vacuumable))]
|
|
[HarmonyPatch("TryConsume")]
|
|
class Vacuumable_TryConsume
|
|
{
|
|
static bool Prefix(Vacuumable __instance)
|
|
{
|
|
if (!Globals.IsMultiplayer || Globals.HandlePacket) return true;
|
|
|
|
var netActor = __instance.GetComponent<NetworkActor>();
|
|
return (netActor != null && netActor.IsLocal);
|
|
}
|
|
}
|
|
} |