void OnMouseGrabExitPart(Part p) { if (grabActive) { KISAddonCursor.CursorEnable("KIS/Textures/grab", "Grab", ""); } else { KISAddonCursor.CursorDefault(); } p.SetHighlight(false, false); grabOk = false; }
void OnVesselChange(Vessel vesselChange) { if (KISAddonPointer.isRunning) { KISAddonPointer.StopPointer(); } grabActive = false; draggedItem = null; draggedPart = null; movingPart = null; KISAddonCursor.StopPartDetection(); KISAddonCursor.CursorDefault(); }
public void DisableGrabMode() { if (!KISAddonPointer.isRunning) { List <ModuleKISPickup> pickupModules = FlightGlobals.ActiveVessel.FindPartModulesImplementing <ModuleKISPickup>(); if (pickupModules.Count > 0) { if (!draggedPart) { grabActive = false; KISAddonCursor.StopPartDetection(); KISAddonCursor.CursorDefault(); } } } }
void OnMouseDetachExitPart(Part p) { if (detachActive) { KISAddonCursor.CursorEnable("KIS/Textures/detach", "Detach", ""); } else { KISAddonCursor.CursorDefault(); } p.SetHighlight(false, false); p.SetHighlightDefault(); if (p.parent) { p.parent.SetHighlight(false, false); p.parent.SetHighlightDefault(); } detachOk = false; }
public void DisableAttachMode() { List <ModuleKISPickup> pickupModules = FlightGlobals.ActiveVessel.FindPartModulesImplementing <ModuleKISPickup>(); if (pickupModules.Count > 0) { if (!draggedPart && !grabActive && !KISAddonPointer.isRunning) { detachActive = false; KISAddonCursor.StopPartDetection(); KISAddonCursor.CursorDefault(); } if (KISAddonPointer.isRunning && KISAddonPickup.instance.pointerMode == KISAddonPickup.PointerMode.Attach) { KISAddonPickup.instance.pointerMode = KISAddonPickup.PointerMode.Drop; KIS_Shared.PlaySoundAtPoint("KIS/Sounds/click", FlightGlobals.ActiveVessel.transform.position); } } }
void OnMouseDetachPartClick(Part part) { if (KISAddonPointer.isRunning) { return; } if (hoverInventoryGui()) { return; } if (!HighLogic.LoadedSceneIsFlight) { return; } if (!detachOk) { return; } if (!HasActivePickupInRange(part)) { return; } detachActive = false; KISAddonCursor.StopPartDetection(); KISAddonCursor.CursorDefault(); ModuleKISItem item = part.GetComponent <ModuleKISItem>(); if (item) { if (item.staticAttached) { item.GroundDetach(); if (item.allowPartAttach == 1) { ModuleKISPickup pickupModule = GetActivePickupNearest(part); KIS_Shared.PlaySoundAtPoint(pickupModule.detachStaticSndPath, pickupModule.part.transform.position); } if (item.allowPartAttach == 2) { ModuleKISPickup pickupModule = GetActivePickupNearest(part, canStaticAttachOnly: true); KIS_Shared.PlaySoundAtPoint(pickupModule.detachStaticSndPath, pickupModule.part.transform.position); } return; } } part.decouple(); if (item) { if (item.allowPartAttach == 1) { ModuleKISPickup pickupModule = GetActivePickupNearest(part); KIS_Shared.PlaySoundAtPoint(pickupModule.detachPartSndPath, pickupModule.part.transform.position); } if (item.allowPartAttach == 2) { ModuleKISPickup pickupModule = GetActivePickupNearest(part, canPartAttachOnly: true); KIS_Shared.PlaySoundAtPoint(pickupModule.detachPartSndPath, pickupModule.part.transform.position); } } else { ModuleKISPickup pickupModule = GetActivePickupNearest(part, canPartAttachOnly: true); KIS_Shared.PlaySoundAtPoint(pickupModule.detachPartSndPath, pickupModule.part.transform.position); } }
void OnDragReleased() { KISAddonCursor.CursorDefault(); if (HighLogic.LoadedSceneIsFlight) { InputLockManager.RemoveControlLock("KISpickup"); // Re-enable jetpack mouse control (workaround as SetControlLock didn't have any effect on this) KerbalEVA Keva = FlightGlobals.ActiveVessel.rootPart.GetComponent <KerbalEVA>(); if (Keva) { if (jetpackLock) { Keva.JetpackDeployed = true; jetpackLock = false; KIS_Shared.DebugLog("Jetpack mouse input re-enabled"); } } } if (hoverInventoryGui()) { // Couroutine to let time to KISModuleInventory to catch the draggedPart StartCoroutine(WaitAndStopDrag()); } else { ModuleKISPartDrag pDrag = null; if (KISAddonCursor.hoveredPart) { if (KISAddonCursor.hoveredPart != draggedPart) { pDrag = KISAddonCursor.hoveredPart.GetComponent <ModuleKISPartDrag>(); } } if (pDrag) { if (draggedItem != null) { draggedItem.DragToPart(KISAddonCursor.hoveredPart); pDrag.OnItemDragged(draggedItem); } else { pDrag.OnPartDragged(draggedPart); } } else { if (HighLogic.LoadedSceneIsEditor) { if (draggedItem != null) { draggedItem.Delete(); } } if (HighLogic.LoadedSceneIsFlight) { if (draggedItem != null) { Drop(draggedItem); } else { movingPart = draggedPart; Drop(movingPart, movingPart); } } } icon = null; draggedPart = null; } KISAddonCursor.StopPartDetection(); }
private void OnPointerAction(KISAddonPointer.PointerTarget pointerTarget, Vector3 pos, Quaternion rot, Part tgtPart, string srcAttachNodeID = null, AttachNode tgtAttachNode = null) { if (pointerTarget == KISAddonPointer.PointerTarget.PartMount) { if (movingPart) { MoveAttach(tgtPart, pos, rot, srcAttachNodeID, tgtAttachNode); } else { CreateAttach(tgtPart, pos, rot, srcAttachNodeID, tgtAttachNode); } ModuleKISPartMount pMount = tgtPart.GetComponent <ModuleKISPartMount>(); if (pMount) { pMount.sndFxStore.audio.Play(); } } if (pointerTarget == KISAddonPointer.PointerTarget.Part || pointerTarget == KISAddonPointer.PointerTarget.PartNode || pointerTarget == KISAddonPointer.PointerTarget.Static || pointerTarget == KISAddonPointer.PointerTarget.KerbalEva) { if (pointerMode == PointerMode.Drop) { if (movingPart) { MoveDrop(tgtPart, pos, rot); } else { CreateDrop(tgtPart, pos, rot); } } if (pointerMode == PointerMode.Attach) { if (movingPart) { MoveAttach(tgtPart, pos, rot, srcAttachNodeID, tgtAttachNode); } else { CreateAttach(tgtPart, pos, rot, srcAttachNodeID, tgtAttachNode); } // sound ModuleKISPickup modulePickup = GetActivePickupNearest(pos); if (tgtPart) { if (modulePickup) { AudioSource.PlayClipAtPoint(GameDatabase.Instance.GetAudioClip(modulePickup.attachPartSndPath), pos); } } } } draggedItem = null; draggedPart = null; movingPart = null; KISAddonCursor.CursorDefault(); }