コード例 #1
0
 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();
 }
コード例 #2
0
 void OnVesselChange(Vessel vesselChange)
 {
     if (KISAddonPointer.isRunning)
     {
         KISAddonPointer.StopPointer();
     }
     grabActive  = false;
     draggedItem = null;
     draggedPart = null;
     movingPart  = null;
     KISAddonCursor.StopPartDetection();
     KISAddonCursor.CursorDefault();
 }
コード例 #3
0
 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();
             }
         }
     }
 }
コード例 #4
0
        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);
                }
            }
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
 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();
 }