2020-11-03 21:42:14 +00:00
|
|
|
|
using QSB.EventsCore;
|
2020-09-05 12:24:51 +00:00
|
|
|
|
using QSB.WorldSync;
|
2020-09-06 08:07:31 +00:00
|
|
|
|
using UnityEngine;
|
2020-09-05 12:24:51 +00:00
|
|
|
|
|
|
|
|
|
namespace QSB.OrbSync
|
|
|
|
|
{
|
2020-12-02 21:29:53 +00:00
|
|
|
|
public class OrbPatches : QSBPatch
|
|
|
|
|
{
|
|
|
|
|
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
2020-11-03 21:11:10 +00:00
|
|
|
|
|
2020-12-02 21:29:53 +00:00
|
|
|
|
public static void StartDragCallEvent(bool __result, NomaiInterfaceOrb __instance)
|
|
|
|
|
{
|
|
|
|
|
if (__result)
|
|
|
|
|
{
|
2020-12-11 13:14:58 +00:00
|
|
|
|
GlobalMessenger<int>.FireEvent(EventNames.QSBOrbUser, QSBWorldSync.OldOrbList.FindIndex(x => x == __instance));
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-06 08:07:31 +00:00
|
|
|
|
|
2020-12-02 21:29:53 +00:00
|
|
|
|
public static bool CheckOrbCollision(ref bool __result, NomaiInterfaceSlot __instance, NomaiInterfaceOrb orb,
|
|
|
|
|
bool ____ignoreDraggedOrbs, float ____radius, float ____exitRadius, ref NomaiInterfaceOrb ____occupyingOrb)
|
|
|
|
|
{
|
|
|
|
|
if (____ignoreDraggedOrbs && orb.IsBeingDragged())
|
|
|
|
|
{
|
|
|
|
|
__result = false;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
var orbDistance = Vector3.Distance(orb.transform.position, __instance.transform.position);
|
|
|
|
|
var triggerRadius = orb.IsBeingDragged() ? ____exitRadius : ____radius;
|
|
|
|
|
if (____occupyingOrb == null && orbDistance < ____radius)
|
|
|
|
|
{
|
|
|
|
|
____occupyingOrb = orb;
|
|
|
|
|
if (Time.timeSinceLevelLoad > 1f)
|
|
|
|
|
{
|
2020-12-11 13:14:58 +00:00
|
|
|
|
QSBWorldSync.HandleSlotStateChange(__instance, orb, true);
|
|
|
|
|
QSBWorldSync.RaiseEvent(__instance, "OnSlotActivated");
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
|
|
|
|
__result = true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (____occupyingOrb == null || ____occupyingOrb != orb)
|
|
|
|
|
{
|
|
|
|
|
__result = false;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (orbDistance > triggerRadius)
|
|
|
|
|
{
|
2020-12-11 13:14:58 +00:00
|
|
|
|
QSBWorldSync.HandleSlotStateChange(__instance, orb, false);
|
2020-12-02 21:29:53 +00:00
|
|
|
|
____occupyingOrb = null;
|
2020-12-11 13:14:58 +00:00
|
|
|
|
QSBWorldSync.RaiseEvent(__instance, "OnSlotDeactivated");
|
2020-12-02 21:29:53 +00:00
|
|
|
|
__result = false;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
__result = true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2020-09-07 18:27:56 +00:00
|
|
|
|
|
2020-12-02 21:29:53 +00:00
|
|
|
|
public override void DoPatches()
|
|
|
|
|
{
|
|
|
|
|
QSB.Helper.HarmonyHelper.AddPostfix<NomaiInterfaceOrb>("StartDragFromPosition", typeof(OrbPatches), nameof(StartDragCallEvent));
|
|
|
|
|
QSB.Helper.HarmonyHelper.AddPrefix<NomaiInterfaceSlot>("CheckOrbCollision", typeof(OrbPatches), nameof(CheckOrbCollision));
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
|
}
|