コード例 #1
0
        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;
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public void OnPartCoupled(Part createdPart, Part tgtPart = null, AttachNode tgtAttachNode = null)
 {
     KIS_Shared.SendKISMessage(createdPart, KIS_Shared.MessageAction.AttachEnd, KISAddonPointer.GetCurrentAttachNode(), tgtPart, tgtAttachNode);
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        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;
        }