private Part CreateAttach(Part tgtPart, Vector3 pos, Quaternion rot, string srcAttachNodeID = null, AttachNode tgtAttachNode = null) { KIS_Shared.DebugLog("Create part & attach"); Part newPart; draggedItem.StackRemove(1); bool useExternalPartAttach = false; if (draggedItem.prefabModule) { if (draggedItem.prefabModule.useExternalPartAttach) { useExternalPartAttach = true; } } if (tgtPart && !useExternalPartAttach) { newPart = KIS_Shared.CreatePart(draggedItem.partNode, pos, rot, draggedItem.inventory.part, tgtPart, srcAttachNodeID, tgtAttachNode, OnPartCoupled); } else { newPart = KIS_Shared.CreatePart(draggedItem.partNode, pos, rot, draggedItem.inventory.part); KIS_Shared.SendKISMessage(newPart, KIS_Shared.MessageAction.AttachEnd, KISAddonPointer.GetCurrentAttachNode(), tgtPart, tgtAttachNode); } KISAddonPointer.StopPointer(); movingPart = null; draggedItem = null; draggedPart = null; return(newPart); }
public void Drop(Part part, Part fromPart) { if (!KISAddonPointer.isRunning) { ModuleKISPickup pickupModule = GetActivePickupNearest(fromPart); if (pickupModule) { KISAddonPointer.allowPart = KISAddonPointer.allowEva = KISAddonPointer.allowMount = KISAddonPointer.allowStatic = true; KISAddonPointer.allowStack = pickupModule.allowPartStack; KISAddonPointer.maxDist = pickupModule.maxDistance; if (draggedItem != null) { KISAddonPointer.scale = draggedItem.GetScale(); } else { KISAddonPointer.scale = 1; } KISAddonPointer.StartPointer(part, OnPointerAction, OnPointerState, pickupModule.transform); pointerMode = PointerMode.Drop; } else { KIS_Shared.DebugError("No active pickup nearest !"); } } KISAddonCursor.StopPartDetection(); }
private void MoveDrop(Part tgtPart, Vector3 pos, Quaternion rot) { KIS_Shared.DebugLog("Move part"); ModuleKISPickup modulePickup = GetActivePickupNearest(pos); if (modulePickup) { if (movingPart.parent) { bool movingPartMounted = false; ModuleKISPartMount partM = movingPart.parent.GetComponent <ModuleKISPartMount>(); if (partM) { if (partM.PartIsMounted(movingPart)) { movingPartMounted = true; } } if (!movingPartMounted) { AudioSource.PlayClipAtPoint(GameDatabase.Instance.GetAudioClip(modulePickup.detachPartSndPath), movingPart.transform.position); } } AudioSource.PlayClipAtPoint(GameDatabase.Instance.GetAudioClip(modulePickup.dropSndPath), pos); } KIS_Shared.DecoupleFromAll(movingPart); movingPart.transform.position = pos; movingPart.transform.rotation = rot; KIS_Shared.SendKISMessage(movingPart, KIS_Shared.MessageAction.DropEnd, KISAddonPointer.GetCurrentAttachNode(), tgtPart); KISAddonPointer.StopPointer(); movingPart = null; }
private void MoveAttach(Part tgtPart, Vector3 pos, Quaternion rot, string srcAttachNodeID = null, AttachNode tgtAttachNode = null) { KIS_Shared.DebugLog("Move part & attach"); KIS_Shared.SendKISMessage(movingPart, KIS_Shared.MessageAction.AttachStart, KISAddonPointer.GetCurrentAttachNode(), tgtPart, tgtAttachNode); KIS_Shared.DecoupleFromAll(movingPart); movingPart.transform.position = pos; movingPart.transform.rotation = rot; ModuleKISItem moduleItem = movingPart.GetComponent <ModuleKISItem>(); bool useExternalPartAttach = false; if (moduleItem) { if (moduleItem.useExternalPartAttach) { useExternalPartAttach = true; } } if (tgtPart && !useExternalPartAttach) { KIS_Shared.CouplePart(movingPart, tgtPart, srcAttachNodeID, tgtAttachNode); } KIS_Shared.SendKISMessage(movingPart, KIS_Shared.MessageAction.AttachEnd, KISAddonPointer.GetCurrentAttachNode(), tgtPart, tgtAttachNode); KISAddonPointer.StopPointer(); movingPart = null; draggedItem = null; draggedPart = null; }
void OnVesselChange(Vessel vesselChange) { if (KISAddonPointer.isRunning) { KISAddonPointer.StopPointer(); } grabActive = false; draggedItem = null; draggedPart = null; movingPart = null; KISAddonCursor.StopPartDetection(); KISAddonCursor.CursorDefault(); }
public bool isWeldingTool = false; // false => screw tool #endregion Fields #region Methods // apply the screw/weld property public override void OnAttachToolUsed(Part srcPart, Part tgtPart, KISAttachType moveType, KISAddonPointer.PointerTarget pointerTarget) { base.OnAttachToolUsed(srcPart, tgtPart, moveType, pointerTarget); //Debug.Log("OnItemMove2 begin" + (srcPart == null ? "null" : srcPart.name) + " => " + // (tgtPart == null ? "null" : tgtPart.name) + ", " + moveType + ", " + pointerTarget); //set welded if needed if ((moveType == KISAttachType.ATTACH) && srcPart.Modules.Contains("ModuleAttachMode") ) { ModuleAttachMode mkpam = srcPart.Modules["ModuleAttachMode"] as ModuleAttachMode; mkpam.isWelded = isWeldingTool; //Debug.Log("OnItemMove2 " + isWeldingTool); } }
private Part CreateDrop(Part tgtPart, Vector3 pos, Quaternion rot) { KIS_Shared.DebugLog("Create & drop part"); ModuleKISPickup modulePickup = GetActivePickupNearest(pos); draggedItem.StackRemove(1); Part newPart = KIS_Shared.CreatePart(draggedItem.partNode, pos, rot, draggedItem.inventory.part); KIS_Shared.SendKISMessage(newPart, KIS_Shared.MessageAction.DropEnd, KISAddonPointer.GetCurrentAttachNode(), tgtPart); KISAddonPointer.StopPointer(); draggedItem = null; draggedPart = null; if (modulePickup) { AudioSource.PlayClipAtPoint(GameDatabase.Instance.GetAudioClip(modulePickup.dropSndPath), pos); } return(newPart); }
public void OnPartCoupled(Part createdPart, Part tgtPart = null, AttachNode tgtAttachNode = null) { KIS_Shared.SendKISMessage(createdPart, KIS_Shared.MessageAction.AttachEnd, KISAddonPointer.GetCurrentAttachNode(), tgtPart, tgtAttachNode); }
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(); }
private void OnPointerState(KISAddonPointer.PointerTarget pTarget, KISAddonPointer.PointerState pState, Part hoverPart, AttachNode hoverNode) { if (pState == KISAddonPointer.PointerState.OnMouseEnterNode) { if (pTarget == KISAddonPointer.PointerTarget.PartMount) { string keyAnchor = "[" + GameSettings.Editor_toggleSymMethod.name + "]"; KISAddonCursor.CursorEnable("KIS/Textures/mount", "Mount", "(Press " + keyAnchor + " to change node, [Escape] to cancel)"); } if (pTarget == KISAddonPointer.PointerTarget.PartNode) { pointerMode = pointerMode; } } if (pState == KISAddonPointer.PointerState.OnMouseExitNode || pState == KISAddonPointer.PointerState.OnChangeAttachNode) { pointerMode = pointerMode; } }
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 || pointerMode == PointerMode.ReDock) { if (movingPart) { MoveAttach(tgtPart, pos, rot, srcAttachNodeID, tgtAttachNode); } else { CreateAttach(tgtPart, pos, rot, srcAttachNodeID, tgtAttachNode); } KIS_UISoundPlayer.instance.PlayToolAttach(); } } draggedItem = null; draggedPart = null; movingPart = null; KISAddonCursor.CursorDefault(); }