mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-03-12 04:14:08 +00:00
prepare item patches
This commit is contained in:
parent
0e3978ecbc
commit
19fd195144
40
QSB/ItemSync/Patches/ItemRemotePatches.cs
Normal file
40
QSB/ItemSync/Patches/ItemRemotePatches.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using HarmonyLib;
|
||||
using QSB.Patches;
|
||||
|
||||
namespace QSB.ItemSync.Patches;
|
||||
|
||||
internal class ItemRemotePatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(OWItem), nameof(OWItem.PickUpItem))]
|
||||
private static bool OWItem_PickUpItem(OWItem __instance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(OWItem), nameof(OWItem.DropItem))]
|
||||
private static bool OWItem_DropItem(OWItem __instance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(OWItem), nameof(OWItem.SocketItem))]
|
||||
private static bool OWItem_SocketItem(OWItem __instance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(OWItemSocket), nameof(OWItemSocket.PlaceIntoSocket))]
|
||||
private static bool OWItemSocket_PlaceIntoSocket(OWItem __instance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(OWItemSocket), nameof(OWItemSocket.RemoveFromSocket))]
|
||||
private static bool OWItemSocket_RemoveFromSocket(OWItem __instance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@ -11,14 +11,14 @@ using UnityEngine;
|
||||
|
||||
namespace QSB.ItemSync.Patches;
|
||||
|
||||
[HarmonyPatch]
|
||||
internal class ItemPatches : QSBPatch
|
||||
[HarmonyPatch(typeof(ItemTool))]
|
||||
internal class ItemToolPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ItemTool), nameof(ItemTool.MoveItemToCarrySocket))]
|
||||
public static void ItemTool_MoveItemToCarrySocket(OWItem item)
|
||||
[HarmonyPatch(nameof(ItemTool.MoveItemToCarrySocket))]
|
||||
public static void MoveItemToCarrySocket(OWItem item)
|
||||
{
|
||||
var qsbItem = item.GetWorldObject<IQSBItem>();
|
||||
QSBPlayerManager.LocalPlayer.HeldItem = qsbItem;
|
||||
@ -26,8 +26,8 @@ internal class ItemPatches : QSBPatch
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ItemTool), nameof(ItemTool.SocketItem))]
|
||||
public static void ItemTool_SocketItem(ItemTool __instance, OWItemSocket socket)
|
||||
[HarmonyPatch(nameof(ItemTool.SocketItem))]
|
||||
public static void SocketItem(ItemTool __instance, OWItemSocket socket)
|
||||
{
|
||||
var item = __instance._heldItem;
|
||||
QSBPlayerManager.LocalPlayer.HeldItem = null;
|
||||
@ -35,8 +35,8 @@ internal class ItemPatches : QSBPatch
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ItemTool), nameof(ItemTool.StartUnsocketItem))]
|
||||
public static void ItemTool_StartUnsocketItem(OWItemSocket socket)
|
||||
[HarmonyPatch(nameof(ItemTool.StartUnsocketItem))]
|
||||
public static void StartUnsocketItem(OWItemSocket socket)
|
||||
{
|
||||
var item = socket.GetSocketedItem();
|
||||
var qsbItem = item.GetWorldObject<IQSBItem>();
|
||||
@ -45,16 +45,16 @@ internal class ItemPatches : QSBPatch
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ItemTool), nameof(ItemTool.CompleteUnsocketItem))]
|
||||
public static void ItemTool_CompleteUnsocketItem(ItemTool __instance)
|
||||
[HarmonyPatch(nameof(ItemTool.CompleteUnsocketItem))]
|
||||
public static void CompleteUnsocketItem(ItemTool __instance)
|
||||
{
|
||||
var item = __instance._heldItem;
|
||||
new SocketItemMessage(SocketMessageType.CompleteUnsocket, null, item).Send();
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ItemTool), nameof(ItemTool.DropItem))]
|
||||
public static bool ItemTool_DropItem(ItemTool __instance, RaycastHit hit, OWRigidbody targetRigidbody, IItemDropTarget customDropTarget)
|
||||
[HarmonyPatch(nameof(ItemTool.DropItem))]
|
||||
public static bool DropItem(ItemTool __instance, RaycastHit hit, OWRigidbody targetRigidbody, IItemDropTarget customDropTarget)
|
||||
{
|
||||
Locator.GetPlayerAudioController().PlayDropItem(__instance._heldItem.GetItemType());
|
||||
var hitGameObject = hit.collider.gameObject;
|
@ -82,6 +82,5 @@ internal class QSBItem<T> : WorldObject<T>, IQSBItem
|
||||
public void DropItem(Vector3 position, Vector3 normal, Sector sector) =>
|
||||
QSBPatch.RemoteCall(() => AttachedObject.DropItem(position, normal, sector.transform, sector, null));
|
||||
|
||||
public void OnCompleteUnsocket() =>
|
||||
QSBPatch.RemoteCall(AttachedObject.OnCompleteUnsocket);
|
||||
public void OnCompleteUnsocket() => AttachedObject.OnCompleteUnsocket();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user