Patch_NetworkView_RPC.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using GadgetCore.API;
  2. using HarmonyLib;
  3. using System;
  4. using UnityEngine;
  5. namespace VanitySlots.Patches
  6. {
  7. [HarmonyPatch(typeof(NetworkView))]
  8. [HarmonyPatch("RPC", new Type[] { typeof(string), typeof(RPCMode), typeof(object[]) })]
  9. [HarmonyGadget("VanitySlots")]
  10. public static class Patch_NetworkView_RPC
  11. {
  12. [HarmonyPrefix]
  13. [HarmonyPriority(Priority.High)]
  14. public static void Prefix(NetworkView __instance, ref string name, RPCMode mode, object[] args)
  15. {
  16. if (name == "UA" && args[0] is int[] a && a.Length > 6)
  17. {
  18. if (Core.itemStore.Items[0].id != 0)
  19. if (ItemRegistry.GetItem(GadgetNetwork.ConvertIDToLocal(ItemRegistry.Singleton, Core.itemStore.Items[0].id)).GetName().StartsWith("Original "))
  20. a[1] = 0;
  21. else
  22. a[1] = GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, Core.itemStore.Items[0].id);
  23. if (Core.itemStore.Items[1].id != 0)
  24. if (ItemRegistry.GetItem(GadgetNetwork.ConvertIDToLocal(ItemRegistry.Singleton, Core.itemStore.Items[1].id)).GetName().StartsWith("Original "))
  25. a[2] = 0;
  26. else
  27. a[2] = GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, Core.itemStore.Items[1].id);
  28. if (Core.itemStore.Items[2].id != 0)
  29. if (ItemRegistry.GetItem(GadgetNetwork.ConvertIDToLocal(ItemRegistry.Singleton, Core.itemStore.Items[2].id)).GetName().StartsWith("Original "))
  30. a[3] = 0;
  31. else
  32. a[3] = GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, Core.itemStore.Items[2].id);
  33. }
  34. }
  35. }
  36. }