// TODO: Make sure OnToggle works. static bool OnToggle(UnityModManager.ModEntry _, bool active) { showFloat = active; mod.Logger.Log(string.Format("showFloats toggled to {0}.", showFloat)); if (!showFloat) { Floaties.HideFloatie(); holdingRight = null; // TODO: Check which job data needs to be reset. showing = false; } return(true); }
static void OnUpdate(UnityModManager.ModEntry mod, float delta) { timer += delta; if (!floatLoaded) { floatLoaded = Floaties.Initialize(); } else if (!listenersSetup) { // eyesTransform = PlayerManager.PlayerCamera.transform; if (VRManager.IsVREnabled()) { VRTK_InteractGrab lGrab = VRTK_DeviceFinder.GetControllerLeftHand(true)?.transform.GetComponentInChildren <VRTK_InteractGrab>(); VRTK_InteractGrab rGrab = VRTK_DeviceFinder.GetControllerRightHand(true)?.transform.GetComponentInChildren <VRTK_InteractGrab>(); if (lGrab == null || rGrab == null) { return; } lGrab.ControllerGrabInteractableObject += OnItemGrabbedLeftVR; lGrab.ControllerStartUngrabInteractableObject += OnItemUngrabbedLeftVR; rGrab.ControllerGrabInteractableObject += OnItemGrabbedRightVR; rGrab.ControllerStartUngrabInteractableObject += OnItemUngrabbedRightVR; } else { Grabber grab = PlayerManager.PlayerTransform.GetComponentInChildren <Grabber>(); grab.Grabbed += OnItemGrabbedRightNonVR; grab.Released += OnItemUngrabbedRightNonVR; SingletonBehaviour <Inventory> .Instance.ItemAddedToInventory += OnItemAddedToInventory; } mod.Logger.Log(string.Format("Listeners have been set up, total time elapsed: {0:0.00} seconds.", timer)); listenersSetup = true; } else { if (showing) { if (holdingRight == null || !showFloat) { Floaties.HideFloatie(); showing = false; } else { if (timer > POINTER_INTERVAL) { counter++; timer %= POINTER_INTERVAL; // Calculate tracks that cars are on. holdingRight.UpdateJobCars(); holdingRight.UpdateJobPrivilege(); Floaties.ChangeFloatieText(holdingRight.GetFloatieText(counter)); Floaties.UpdateAttentionTransform(holdingRight.GetPointerAt(counter)); } } } else if (!showing && holdingRight != null && showFloat) { // TODO: Read job information and process text accordingly. Floaties.ShowFloatie(holdingRight.GetFloatieText(counter)); Floaties.UpdateAttentionTransform(holdingRight.GetPointerAt(counter)); showing = true; timer = 0; } } }