/// <summary> /// Refuels kerbal's EVA pack up to the maximum, and decreases canister reserve. /// </summary> /// <param name="item">Item to get fuel from.</param> void RefillEvaPack(KIS_Item item) { var evaFuelResource = item.inventory.part.Resources.Get(StockResourceNames.EvaPropellant); var needsFuel = evaFuelResource.maxAmount - evaFuelResource.amount; if (needsFuel < double.Epsilon) { ScreenMessaging.ShowPriorityScreenMessage(NoNeedToRefillJetpackMsg); return; } var canisterFuelResource = GetCanisterFuelResource(item); if (canisterFuelResource.amount < double.Epsilon) { ScreenMessaging.ShowPriorityScreenMessage(CanisterIsEmptyMsg); UISounds.PlayBipWrong(); return; } var canRefuel = Math.Min(needsFuel, canisterFuelResource.amount); item.UpdateResource(_mainResourceName, -canRefuel, isAmountRelative: true); evaFuelResource.amount += canRefuel; if (canRefuel < needsFuel) { ScreenMessaging.ShowPriorityScreenMessage(JetpackPartiallyRefueledMsg.Format(canRefuel)); } else { ScreenMessaging.ShowPriorityScreenMessage(JetpackFullyRefueledMsg); } UISoundPlayer.instance.Play(refuelSndPath); }
public static void StartPointer(Part rootPart, KIS_Item item, OnPointerClick pClick, OnPointerState pState, Transform from = null) { if (!running) { DebugEx.Fine("StartPointer()"); customRot = Vector3.zero; aboveDistance = 0; partToAttach = rootPart; sourceTransform = from; running = true; SendPointerClick = pClick; SendPointerState = pState; if (rootPart) { MakePointer(rootPart); } else { VariantsUtils.ExecuteAtPartVariant( item.availablePart, VariantsUtils.GetCurrentPartVariant(item.availablePart, item.partNode), MakePointer); pointer.transform.localScale *= KISAPI.PartNodeUtils.GetTweakScaleSizeModifier(item.partNode); } LockUI(); allowedAttachmentParts = allowedAttachmentParts; // Apply selection. SendPointerState(PointerTarget.Nothing, PointerState.OnPointerStarted, null, null); } }
/// <inheritdoc/> public override void OnItemUse(KIS_Item item, KIS_Item.UseFrom useFrom) { pageList.Clear(); var node = KIS_Shared.GetBaseConfigNode(this); foreach (string page in node.GetValues("page")) { pageList.Add(page); } if (pageList.Count > 0) { pageIndex = 0; pageTotal = pageList.Count; guiObj = new GameObject("KISManualDialog-" + part.flightID); var dlg = guiObj.AddComponent <GuiDialog>(); dlg.dialogFunction = GuiReader; pageTexture = GameDatabase.Instance.GetTexture(pageList[0], false); UISoundPlayer.instance.Play(bookOpenSndPath); } else { DebugEx.Info("The book has no pages configured"); } }
public override void OnEquip(KIS_Item item) { KerbalEVA kerbalEva = item.inventory.part.GetComponent<KerbalEVA>(); if (walkSpeed != -1) { orgWalkSpeed = kerbalEva.walkSpeed; kerbalEva.walkSpeed = this.walkSpeed; } if (runSpeed != -1) { orgRunSpeed = kerbalEva.runSpeed; kerbalEva.runSpeed = this.runSpeed; } if (ladderSpeed != -1) { orgLadderSpeed = kerbalEva.ladderClimbSpeed; kerbalEva.ladderClimbSpeed = this.ladderSpeed; } if (swimSpeed != -1) { orgSwimSpeed = kerbalEva.swimSpeed; kerbalEva.swimSpeed = this.swimSpeed; } if (maxJumpForce != -1) { orgMaxJumpForce = kerbalEva.maxJumpForce; kerbalEva.maxJumpForce = this.maxJumpForce; } }
/// <summary>Fills up canister to the maximum capacity.</summary> /// <param name="item">Item to refill.</param> void RefillCanister(KIS_Item item) { var canisterResource = GetCanisterFuelResource(item); var needResource = canisterResource.maxAmount - canisterResource.amount; if (needResource <= double.Epsilon) { ScreenMessaging.ShowPriorityScreenMessage(NoNeedToRefillCanisterMsg); return; } double newAmount; if (_mainResourceName != StockResourceNames.EvaPropellant) { var hasAmount = item.inventory.part.RequestResource(_mainResourceName, needResource); if (hasAmount <= double.Epsilon) { ScreenMessaging.ShowPriorityScreenMessage( NoResourceInVesselMsg.Format(canisterResource.resourceName)); UISounds.PlayBipWrong(); return; } newAmount = canisterResource.amount + hasAmount; ScreenMessaging.ShowPriorityScreenMessage( CanisterPartialRefilledMsg.Format(canisterResource.resourceName, hasAmount)); } else { newAmount = canisterResource.maxAmount; ScreenMessaging.ShowPriorityScreenMessage(CanisterFullyRefilledMsg); } item.UpdateResource(_mainResourceName, newAmount); UISoundPlayer.instance.Play(refuelSndPath); }
public override void OnUnEquip(KIS_Item item) { KerbalEVA kerbalEva = item.inventory.part.GetComponent <KerbalEVA>(); if (walkSpeed != -1) { kerbalEva.walkSpeed = orgWalkSpeed; } if (runSpeed != -1) { kerbalEva.runSpeed = orgRunSpeed; } if (ladderSpeed != -1) { kerbalEva.ladderClimbSpeed = orgLadderSpeed; } if (swimSpeed != -1) { kerbalEva.swimSpeed = orgSwimSpeed; } if (maxJumpForce != -1) { kerbalEva.maxJumpForce = orgMaxJumpForce; } }
/// <summary> /// Refuels kerbal's EVA pack up to the maximum, and decreases canister reserve. /// </summary> /// <param name="item">Item to get fuel from.</param> protected virtual void RefillEVAPack(KIS_Item item) { var canisterFuelResource = GetCanisterFuelResource(item); var evaFuelResource = item.inventory.part.Resources.Get( item.inventory.part.GetComponent <KerbalEVA>().propellantResourceName); var needsFuel = evaFuelResource.maxAmount - evaFuelResource.amount; if (needsFuel < double.Epsilon) { ScreenMessaging.ShowPriorityScreenMessage(NoNeedToRefillMsg); } else { if (canisterFuelResource.amount < double.Epsilon) { ScreenMessaging.ShowPriorityScreenMessage(CanisterIsEmptyMsg); UISounds.PlayBipWrong(); } else { var canRefuel = Math.Min(needsFuel, canisterFuelResource.amount); item.UpdateResource(StockResourceNames.EvaPropellant, canisterFuelResource.amount - canRefuel); evaFuelResource.amount += canRefuel; if (canRefuel < needsFuel) { ScreenMessaging.ShowPriorityScreenMessage(NotEnoughPropellantMsg); } else { ScreenMessaging.ShowPriorityScreenMessage(JetpackRefueledMsg); } UISoundPlayer.instance.Play(refuelSndPath); } } }
/// <summary>Returns KIS resource description for the propellant in the part.</summary> /// <param name="item">Item to get resource for.</param> /// <returns>Resource description.</returns> ProtoPartResourceSnapshot GetCanisterFuelResource(KIS_Item item) { var resources = KISAPI.PartNodeUtils.GetResources(item.partNode); if (resources.Length == 0) { throw new Exception("Bad save state: no resource on the part"); } var itemResource = resources[0]; // Always use the first one. if (itemResource.resourceName == _mainResourceName) { return(itemResource); } // A mod that changes the default resource has been installed or removed. Update the part state. DebugEx.Warning( "Fixing saved state of the resource: oldName={0}, newName={1}", itemResource.resourceName, _mainResourceName); KISAPI.PartNodeUtils.DeleteResource(item.partNode, itemResource.resourceName); itemResource = new ProtoPartResourceSnapshot(part.Resources[0]) { amount = itemResource.amount }; KISAPI.PartNodeUtils.AddResource(item.partNode, itemResource); return(itemResource); }
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; }
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 override void OnItemGUI(KIS_Item item) { if (showPage) { GUI.skin = HighLogic.Skin; currentItem = item; guiWindowPos = GUILayout.Window(GetInstanceID(), guiWindowPos, GuiReader, "Reader"); } }
/// <inheritdoc/> public override void OnItemGUI(KIS_Item item) { if (showPage) { GUI.skin = HighLogic.Skin; guiWindowPos = GUILayout.Window(GetInstanceID(), guiWindowPos, GuiReader, ReaderWindowTitle); } }
public override void OnItemUse(KIS_Item item, KIS_Item.UseFrom useFrom) { // Check if grab key is pressed if (useFrom == KIS_Item.UseFrom.KeyDown) { KISAddonPickup.instance.EnableAttachMode(); } if (useFrom == KIS_Item.UseFrom.KeyUp) { KISAddonPickup.instance.DisableAttachMode(); } }
public override void OnItemUse(KIS_Item item, KIS_Item.UseFrom useFrom) { if (useFrom != KIS_Item.UseFrom.KeyUp) { if (item.inventory.sndFx.audio.isPlaying) { item.inventory.sndFx.audio.Stop(); } else { item.inventory.PlaySound(sndPath, false, false); } } }
void OnVesselChange(Vessel vesselChange) { if (KISAddonPointer.isRunning) { KISAddonPointer.StopPointer(); } grabActive = false; draggedItem = null; draggedPart = null; movingPart = null; KISAddonCursor.StopPartDetection(); KISAddonCursor.CursorDefault(); }
public override void OnItemUse(KIS_Item item, KIS_Item.UseFrom useFrom) { if (useFrom != KIS_Item.UseFrom.KeyUp && item.equippedPart != null) { // Only play if the item is equipped, since we need a real part for this to work. // Multiple modules are not supported! var soundPlayerModule = item.equippedPart.GetComponent <ModuleKISItemSoundPlayer>(); if (soundPlayerModule != null) { soundPlayerModule.TogglePlayStateEvent(); } } }
public override void OnItemUse(KIS_Item item, KIS_Item.UseFrom useFrom) { if (useFrom != KIS_Item.UseFrom.KeyUp) { if (item.inventory.sndFx.audio.isPlaying) { item.inventory.sndFx.audio.Stop(); } else { UISoundPlayer.instance.Play(sndPath); } } }
/// <inheritdoc/> public override void OnItemUse(KIS_Item item, KIS_Item.UseFrom useFrom) { if (useFrom != KIS_Item.UseFrom.KeyUp) { if (item.inventory.invType == ModuleKISInventory.InventoryType.Pod) { RefillCanister(item); // Refuel canister item. } else if (item.inventory.invType == ModuleKISInventory.InventoryType.Eva) { RefillEVAPack(item); // Refuel EVA pack from canister. } } }
public override void OnItemUse(KIS_Item item, KIS_Item.UseFrom useFrom) { if (useFrom != KIS_Item.UseFrom.KeyUp) { if (item.inventory.invType == ModuleKISInventory.InventoryType.Pod) { // Refuel item ScreenMessaging.ShowPriorityScreenMessage("Fuel tank refueled"); foreach (KIS_Item.ResourceInfo itemRessource in item.GetResources()) { if (itemRessource.resourceName == EvaPropellantResource) { item.SetResource(EvaPropellantResource, itemRessource.maxAmount); item.inventory.PlaySound(refuelSndPath, false, false); } } } if (item.inventory.invType == ModuleKISInventory.InventoryType.Eva) { // Refuel eva foreach (KIS_Item.ResourceInfo itemRessource in item.GetResources()) { if (itemRessource.resourceName == EvaPropellantResource) { PartResource evaRessource = item.inventory.part.GetComponent<PartResource>(); if (evaRessource) { double amountToFill = evaRessource.maxAmount - evaRessource.amount; if (itemRessource.amount > amountToFill) { ScreenMessaging.ShowPriorityScreenMessage("EVA pack refueled"); evaRessource.amount = evaRessource.maxAmount; item.SetResource(EvaPropellantResource, (itemRessource.amount - amountToFill)); if (item.equippedPart) { PartResource equippedTankRessource = item.equippedPart.Resources.list.Find( p => p.resourceName == EvaPropellantResource); if (equippedTankRessource) { equippedTankRessource.amount = (itemRessource.amount - amountToFill); } } item.inventory.PlaySound(refuelSndPath, false, false); } else { if (itemRessource.amount == 0) { ScreenMessaging.ShowPriorityScreenMessage( "Fuel tank is empty ! Cannot refuel EVA pack"); } else { ScreenMessaging.ShowPriorityScreenMessage( "Available propellant is not enough to refuel, EVA pack partially refueled"); } evaRessource.amount += itemRessource.amount; item.SetResource("EVA Propellant", 0); item.inventory.PlaySound(refuelSndPath, false, false); } } } } } } }
public override void OnItemUse(KIS_Item item, KIS_Item.UseFrom useFrom) { if (useFrom != KIS_Item.UseFrom.KeyUp) { item.StackRemove(); eatCount++; if (eatCount > 3) { Logger.logInfo("Burp incoming..."); System.Random rnd = new System.Random(); int delay = rnd.Next(1, 5); item.inventory.DelayedAction(Burp, item, delay); eatCount = 0; } item.inventory.PlaySound(eatSndPath, false, false); } }
public override void OnUnEquip(KIS_Item item) { ModuleKISPickup pickupModule = item.inventory.part.GetComponent<ModuleKISPickup>(); if (pickupModule) { pickupModule.allowPartAttach = orgToolPartAttach; pickupModule.allowStaticAttach = orgToolStaticAttach; pickupModule.allowPartStack = orgToolPartStack; pickupModule.attachPartSndPath = orgAttachPartSndPath; pickupModule.detachPartSndPath = orgDetachPartSndPath; pickupModule.attachStaticSndPath = orgAttachStaticSndPath; pickupModule.detachStaticSndPath = orgDetachStaticSndPath; } }
public override void OnItemUse(KIS_Item item, KIS_Item.UseFrom useFrom) { pageList.Clear(); ConfigNode node = KIS_Shared.GetBaseConfigNode(this); foreach (string page in node.GetValues("page")) { pageList.Add(page); } if (pageList.Count > 0) { pageIndex = 0; pageTotal = pageList.Count; pageTexture = GameDatabase.Instance.GetTexture(pageList[0], false); showPage = true; item.inventory.PlaySound(bookOpenSndPath, false, true); } else { Logger.logError("The book has no pages configured"); } }
public override void OnUnEquip(KIS_Item item) { ModuleKISPickup pickupModule = item.inventory.part.GetComponent <ModuleKISPickup>(); if (pickupModule) { pickupModule.allowPartAttach = orgToolPartAttach; pickupModule.allowStaticAttach = orgToolStaticAttach; pickupModule.allowPartStack = orgToolPartStack; pickupModule.attachPartSndPath = orgAttachPartSndPath; pickupModule.detachPartSndPath = orgDetachPartSndPath; pickupModule.attachStaticSndPath = orgAttachStaticSndPath; pickupModule.detachStaticSndPath = orgDetachStaticSndPath; } }
public override void OnItemUse(KIS_Item item, KIS_Item.UseFrom useFrom) { if (useFrom != KIS_Item.UseFrom.KeyUp) { item.StackRemove(); eatCount++; if (eatCount > 3) { DebugEx.Fine("Burp incoming..."); System.Random rnd = new System.Random(); int delay = rnd.Next(1, 5); item.inventory.DelayedAction(Burp, item, delay); eatCount = 0; } UISoundPlayer.instance.Play(eatSndPath); } }
public override void OnItemUse(KIS_Item item, KIS_Item.UseFrom useFrom) { if (useFrom != KIS_Item.UseFrom.KeyUp) { item.StackRemove(1); eatCount++; if (eatCount > 3) { DebugEx.Fine("Burp incoming..."); Random rnd = new System.Random(); int delay = rnd.Next(1, 5); AsyncCall.CallOnTimeout(item.inventory, delay, () => Burp(item)); eatCount = 0; } UISoundPlayer.instance.Play(eatSndPath); } }
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); }
/// <inheritdoc/> public override void OnItemUse(KIS_Item item, KIS_Item.UseFrom useFrom) { pageList.Clear(); var node = KIS_Shared.GetBaseConfigNode(this); foreach (string page in node.GetValues("page")) { pageList.Add(page); } if (pageList.Count > 0) { pageIndex = 0; pageTotal = pageList.Count; pageTexture = GameDatabase.Instance.GetTexture(pageList[0], false); showPage = true; UISoundPlayer.instance.Play(bookOpenSndPath); } else { Debug.LogError("The book has no pages configured"); } }
public virtual void OnDragToInventory(KIS_Item item, ModuleKISInventory destInventory, int destSlot) { }
public void Pickup(KIS_Item item) { draggedPart = item.availablePart.partPrefab; draggedItem = item; Pickup(); }
public KIS_Item AddItem(Part part, float qty = 1, int slot = -1) { KIS_Item item = null; if (items.ContainsKey(slot)) { slot = -1; } int maxSlot = (slotsX * slotsY) - 1; if (slot < 0 || slot > maxSlot) { slot = GetFreeSlot(); if (slot == -1) { KIS_Shared.DebugError("AddItem error : No free slot available for " + part.partInfo.title); return null; } } item = new KIS_Item(part, this, qty); items.Add(slot, item); if (showGui) items[slot].EnableIcon(itemIconResolution); RefreshMassAndVolume(); return item; }
private void GuiContextMenu(int windowID) { GUI.FocusWindow(windowID); GUI.BringWindowToFront(windowID); bool noAction = true; //Equip if (contextItem != null) { if (contextItem.equipable && invType == InventoryType.Eva) { noAction = false; if (contextItem.equipped) { if (GUILayout.Button("Unequip")) { contextItem.Unequip(); contextItem = null; } } else { if (GUILayout.Button("Equip")) { contextItem.Equip(); contextItem = null; } } } } //Carriable if (contextItem != null) { if (contextItem.carriable && invType == InventoryType.Eva) { noAction = false; if (GUILayout.Button("Drop")) { contextItem.Drop(); contextItem = null; } } } //Set stack quantity (editor only) if (contextItem != null && HighLogic.LoadedSceneIsEditor) { if (contextItem.stackable) { noAction = false; GUILayout.BeginHorizontal(); if (GUILayout.Button("-", buttonStyle, GUILayout.Width(20))) { if (Input.GetKey(KeyCode.LeftShift)) { if (contextItem.quantity - 10 > 0) { if (contextItem.StackRemove(10) == false) contextItem = null; } } else if (Input.GetKey(KeyCode.LeftControl)) { if (contextItem.quantity - 100 > 0) { if (contextItem.StackRemove(100) == false) contextItem = null; } } else { if (contextItem.quantity - 1 > 0) { if (contextItem.StackRemove(1) == false) contextItem = null; } } } if (GUILayout.Button("+", buttonStyle, GUILayout.Width(20))) { if (contextItem.stackable) { if (Input.GetKey(KeyCode.LeftShift)) { contextItem.StackAdd(10); } else if (Input.GetKey(KeyCode.LeftControl)) { contextItem.StackAdd(100); } else { contextItem.StackAdd(1); } } } if (contextItem != null) GUILayout.Label("Quantity : " + contextItem.quantity, GUILayout.Width(100)); GUILayout.EndHorizontal(); } } //Split if (contextItem != null && !HighLogic.LoadedSceneIsEditor) { if (contextItem.quantity > 1) { noAction = false; GUILayout.BeginHorizontal(); if (GUILayout.Button("-", buttonStyle, GUILayout.Width(20))) { if (splitQty - 1 > 0) splitQty -= 1; } if (GUILayout.Button("Split (" + splitQty + ")", buttonStyle)) { if (this.isFull() == false) { contextItem.quantity -= splitQty; AddItem(contextItem.availablePart.partPrefab, splitQty); } else { ScreenMessages.PostScreenMessage("Inventory is full, cannot split !", 5, ScreenMessageStyle.UPPER_CENTER); } contextItem = null; } if (GUILayout.Button("+", buttonStyle, GUILayout.Width(20))) { if (splitQty + 1 < contextItem.quantity) splitQty += 1; } GUILayout.EndHorizontal(); } } // Use if (contextItem != null) { if ((HighLogic.LoadedSceneIsFlight && contextItem.usableFromEva && contextItem.inventory.invType == InventoryType.Eva) || (HighLogic.LoadedSceneIsFlight && contextItem.usableFromContainer && contextItem.inventory.invType == InventoryType.Container) || (HighLogic.LoadedSceneIsFlight && contextItem.usableFromPod && contextItem.inventory.invType == InventoryType.Pod) || (HighLogic.LoadedSceneIsEditor && contextItem.usableFromEditor)) { noAction = false; if (GUILayout.Button(contextItem.prefabModule.useName)) { contextItem.Use(KIS_Item.UseFrom.ContextMenu); contextItem = null; } } } //Debug if (debugContextMenu) { if (contextItem != null && !HighLogic.LoadedSceneIsEditor && invType == InventoryType.Eva) { if (contextItem.prefabModule != null) { noAction = false; if (GUILayout.Button("Debug")) { debugItem = contextItem; contextItem = null; } } } } if (noAction) { GUILayout.Label("No action"); } }
public static void MoveItem(KIS_Item srcItem, ModuleKISInventory tgtInventory, int tgtSlot) { ModuleKISInventory srcInventory = srcItem.inventory; int srcSlot = srcItem.slot; tgtInventory.items.Add(tgtSlot, srcItem); srcItem.inventory.items.Remove(srcSlot); srcItem.inventory = tgtInventory; tgtInventory.items[tgtSlot].OnMove(srcInventory, tgtInventory); srcInventory.RefreshMassAndVolume(); tgtInventory.RefreshMassAndVolume(); }
private bool VolumeAvailableFor(KIS_Item item) { RefreshMassAndVolume(); if (KISAddonPickup.draggedItem.inventory == this) { return true; } else { float newTotalVolume = GetContentVolume() + item.stackVolume; if (newTotalVolume > maxVolume) { ScreenMessages.PostScreenMessage("Max destination volume reached. Part volume is : " + item.stackVolume.ToString("0.00 L") + " (+" + (newTotalVolume - maxVolume).ToString("0.00 L") + ")", 5, ScreenMessageStyle.UPPER_CENTER); return false; } else { return true; } } }
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(); }
// check if the pointed part can be attach with our current tool public override void OnItemUse(KIS_Item item, KIS_Item.UseFrom useFrom) { // Check if grab key is pressed //if (useFrom == KIS_Item.UseFrom.KeyDown) //{ // KISAddonPickup.instance.EnableAttachMode(); //} // Check if grab key is pressed if (useFrom == KIS_Item.UseFrom.KeyDown) { if (KISAddonPointer.isRunning && KISAddonPointer.pointerTarget != KISAddonPointer.PointerTarget.PartMount) { //float attachPartMass = KISAddonPointer.partToAttach.mass + KISAddonPointer.partToAttach.GetResourceMass(); //if (attachPartMass < attachMaxMass) { //test if the tool can attach this part (screw or weld) //default (when ModuleAttachMode is not here) : magical yes bool testIfCanAttachPart = true; if (KISAddonPointer.partToAttach.Modules.Contains("ModuleAttachMode")) { ModuleAttachMode mkpam = (KISAddonPointer.partToAttach.Modules["ModuleAttachMode"] as ModuleAttachMode); if (!mkpam.canBeWeld && !mkpam.canBeScrewed) { ScreenMessages.PostScreenMessage("This part can't be attached", 5, ScreenMessageStyle.UPPER_CENTER); testIfCanAttachPart = false; } else { testIfCanAttachPart = isWeldingTool ? mkpam.canBeWeld : mkpam.canBeScrewed; item.PlaySound(KIS_Shared.bipWrongSndPath); if (!testIfCanAttachPart) { ScreenMessages.PostScreenMessage("This part can't be attached with this tool: it need a " + (isWeldingTool ? "screwdriver" : "weld tool"), 5, ScreenMessageStyle.UPPER_CENTER); } } } if (testIfCanAttachPart) { //KISAddonPickup.instance.pointerMode = KISAddonPickup.PointerMode.Attach; //KISAddonPointer.allowStack = allowStack; //item.PlaySound(changeModeSndPath); KISAddonPickup.instance.EnableAttachMode(); } } //else //{ // item.PlaySound(KIS_Shared.bipWrongSndPath); // ScreenMessages.PostScreenMessage("This part is too heavy for this tool", 5, ScreenMessageStyle.UPPER_CENTER); //} } if (useFrom == KIS_Item.UseFrom.KeyUp) { KISAddonPickup.instance.DisableAttachMode(); } } //if (useFrom == KIS_Item.UseFrom.KeyUp) //{ // if (KISAddonPointer.isRunning && KISAddonPickup.instance.pointerMode == KISAddonPickup.PointerMode.Attach) // { // KISAddonPickup.instance.pointerMode = KISAddonPickup.PointerMode.Drop; // KISAddonPointer.allowStack = false; // item.PlaySound(changeModeSndPath); // } //} }
/// <summary>Fills up canister to the maximum capacity.</summary> /// <param name="item">Item to refill.</param> protected virtual void RefillCanister(KIS_Item item) { item.UpdateResource(StockResourceNames.EvaPropellant, GetCanisterFuelResource(item).maxAmount); ScreenMessaging.ShowPriorityScreenMessage(CanisterRefilledMsg); UISoundPlayer.instance.Play(refuelSndPath); }
/// <summary>Returns KIS resource dexcription for the propellant in the part.</summary> /// <param name="item">Item to get resource for.</param> /// <returns>Resource description.</returns> protected static ProtoPartResourceSnapshot GetCanisterFuelResource(KIS_Item item) { return(KISAPI.PartNodeUtils.GetResources(item.partNode) .FirstOrDefault(x => x.resourceName == StockResourceNames.EvaPropellant)); }
public virtual void OnItemGUI(KIS_Item item) { }
public virtual void OnDragToPart(KIS_Item item, Part destPart) { }
public void Drop(KIS_Item item) { draggedItem = item; Drop(item.availablePart.partPrefab, item.inventory.part); }
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(); }
public void Equip() { // Only equip EVA kerbals. if (!prefabModule || !inventory.vessel.isEVA) { return; } Logger.logInfo("Equip item {0}", this.availablePart.name); //Check skill if needed if (!String.IsNullOrEmpty(prefabModule.equipSkill)) { bool skillFound = false; List <ProtoCrewMember> protoCrewMembers = inventory.vessel.GetVesselCrew(); foreach (var expEffect in protoCrewMembers[0].experienceTrait.Effects) { if (expEffect.ToString().Replace("Experience.Effects.", "") == prefabModule.equipSkill) { skillFound = true; break; } } if (!skillFound) { ScreenMessaging.ShowPriorityScreenMessage( "This item can only be used by a kerbal with the skill : {0}", prefabModule.equipSkill); PlaySound(KIS_Shared.bipWrongSndPath); return; } } // Check if already carried if (equipSlot != null) { KIS_Item equippedItem = inventory.GetEquipedItem(equipSlot); if (equippedItem != null) { if (equippedItem.carriable) { ScreenMessaging.ShowPriorityScreenMessage( "Cannot equip item, slot <{0}> already used for carrying {1}", equipSlot, equippedItem.availablePart.title); PlaySound(KIS_Shared.bipWrongSndPath); return; } equippedItem.Unequip(); } } if (equipMode == EquipMode.Model) { GameObject modelGo = availablePart.partPrefab.FindModelTransform("model").gameObject; equippedGameObj = UnityEngine.Object.Instantiate(modelGo); foreach (Collider col in equippedGameObj.GetComponentsInChildren <Collider>()) { UnityEngine.Object.DestroyImmediate(col); } evaTransform = null; var skmrs = new List <SkinnedMeshRenderer>( inventory.part.GetComponentsInChildren <SkinnedMeshRenderer>()); foreach (SkinnedMeshRenderer skmr in skmrs) { if (skmr.name != prefabModule.equipMeshName) { continue; } foreach (Transform bone in skmr.bones) { if (bone.name == prefabModule.equipBoneName) { evaTransform = bone.transform; break; } } } if (!evaTransform) { Logger.logError("evaTransform not found ! "); UnityEngine.Object.Destroy(equippedGameObj); return; } } if (equipMode == EquipMode.Part || equipMode == EquipMode.Physic) { evaTransform = null; var skmrs = new List <SkinnedMeshRenderer>( inventory.part.GetComponentsInChildren <SkinnedMeshRenderer>()); foreach (SkinnedMeshRenderer skmr in skmrs) { if (skmr.name != prefabModule.equipMeshName) { continue; } foreach (Transform bone in skmr.bones) { if (bone.name == prefabModule.equipBoneName) { evaTransform = bone.transform; break; } } } if (!evaTransform) { Logger.logError("evaTransform not found ! "); return; } Part alreadyEquippedPart = this.inventory.part.vessel.Parts.Find(p => p.partInfo.name == this.availablePart.name); if (alreadyEquippedPart) { Logger.logInfo("Part: {0} already found on eva", availablePart.name); equippedPart = alreadyEquippedPart; OnEquippedPartCoupled(equippedPart); } else { Vector3 equipPos = evaTransform.TransformPoint(prefabModule.equipPos); Quaternion equipRot = evaTransform.rotation * Quaternion.Euler(prefabModule.equipDir); equippedPart = KIS_Shared.CreatePart( partNode, equipPos, equipRot, this.inventory.part, this.inventory.part, null, null, OnEquippedPartCoupled); } if (equipMode == EquipMode.Part) { equippedGameObj = equippedPart.gameObject; } } if (prefabModule.equipRemoveHelmet) { inventory.SetHelmet(false); } PlaySound(prefabModule.moveSndPath); equipped = true; prefabModule.OnEquip(this); }
private void GuiInventory(int windowID) { int i = 0; KIS_Item mouseOverItem = null; for (int x = 0; x < slotsY; x++) { GUILayout.BeginHorizontal(); for (int y = 0; y < slotsX; y++) { GUILayout.Box("", GUILayout.Width(slotSize), GUILayout.Height(slotSize)); Rect textureRect = GUILayoutUtility.GetLastRect(); if (items.ContainsKey(i)) { GUI.DrawTexture(textureRect, items[i].icon.texture, ScaleMode.ScaleToFit); if (HighLogic.LoadedSceneIsFlight) { if (FlightGlobals.ActiveVessel.isEVA && FlightGlobals.ActiveVessel == this.part.vessel) { // Keyboard shortcut int slotNb = i + 1; GUI.Label(textureRect, " " + slotNb.ToString(), upperLeftStyle); if (items[i].carried) { GUI.Label(textureRect, " Carried ", upperRightStyle); } else if (items[i].equipped) { GUI.Label(textureRect, " Equip. ", upperRightStyle); } } } if (items[i].stackable) { // Quantity GUI.Label(textureRect, "x" + items[i].quantity.ToString() + " ", lowerRightStyle); } if (Event.current.type == EventType.MouseDown && textureRect.Contains(Event.current.mousePosition)) { // Pickup part if (Event.current.button == 0) { KISAddonPickup.instance.Pickup(items[i]); } // Context menu if (Event.current.button == 1) { contextClick = true; contextItem = items[i]; contextRect = textureRect; contextSlot = i; } } // Mouse over a slot if (Event.current.type == EventType.Repaint && textureRect.Contains(Event.current.mousePosition) && !KISAddonPickup.draggedPart) { mouseOverItem = items[i]; } // Mouse up on used slot if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && textureRect.Contains(Event.current.mousePosition) && KISAddonPickup.draggedPart) { if (KISAddonPickup.draggedItem != items[i]) { ModuleKISInventory srcInventory = null; if (items[i].stackable && items[i].availablePart.name == KISAddonPickup.draggedPart.partInfo.name) { // Stack similar item if (KISAddonPickup.draggedItem != null) { srcInventory = KISAddonPickup.draggedItem.inventory; // Part come from inventory bool checkVolume = true; if (srcInventory == this) checkVolume = false; if (items[i].StackAdd(KISAddonPickup.draggedItem.quantity, checkVolume)) { KISAddonPickup.draggedItem.Delete(); items[i].OnMove(srcInventory, this); } } else { // Part come from scene if (items[i].StackAdd(1)) { KISAddonPickup.draggedPart.Die(); items[i].OnMove(srcInventory, this); } } } else { // Exchange part slot if (KISAddonPickup.draggedItem != null) { if (KISAddonPickup.draggedItem.inventory == items[i].inventory) { KIS_Item srcItem = KISAddonPickup.draggedItem; int srcSlot = srcItem.slot; srcInventory = KISAddonPickup.draggedItem.inventory; KIS_Item destItem = items[i]; int destSlot = i; ModuleKISInventory destInventory = this; // Move src to dest destInventory.items.Remove(destSlot); destInventory.items.Add(destSlot, srcItem); srcItem.inventory = destInventory; destInventory.RefreshMassAndVolume(); // Move dest to src srcInventory.items.Remove(srcSlot); srcInventory.items.Add(srcSlot, destItem); destItem.inventory = srcInventory; srcInventory.RefreshMassAndVolume(); items[i].OnMove(srcInventory, this); } } } } } } else { // Mouse up on a free slot if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && textureRect.Contains(Event.current.mousePosition) && KISAddonPickup.draggedPart) { // Check if part can be carried bool carryPart = false; bool storePart = true; ModuleKISItem draggedItemModule = KISAddonPickup.draggedPart.GetComponent<ModuleKISItem>(); if (!draggedItemModule && KISAddonPickup.draggedItem != null) { draggedItemModule = KISAddonPickup.draggedItem.prefabModule; } if (draggedItemModule) { if (draggedItemModule.carriable && invType == InventoryType.Eva && HighLogic.LoadedSceneIsFlight) { carryPart = true; foreach (KeyValuePair<int, KIS_Item> enumeratedItem in items) { if (enumeratedItem.Value.equipSlot == draggedItemModule.equipSlot && enumeratedItem.Value.carriable) { if (KISAddonPickup.draggedItem != null) { // Ignore self if (enumeratedItem.Value == KISAddonPickup.draggedItem) { break; } } carryPart = false; storePart = false; ScreenMessages.PostScreenMessage("Another part is already carried on slot <" + draggedItemModule.equipSlot + ">", 5, ScreenMessageStyle.UPPER_CENTER); break; } } } } // Store item or part if (storePart) { if (KISAddonPickup.draggedItem != null) { // Picked part from an inventory if (carryPart) { MoveItem(KISAddonPickup.draggedItem, this, i); if (!KISAddonPickup.draggedItem.equipped) { KISAddonPickup.draggedItem.Equip(); } } else { if (VolumeAvailableFor(KISAddonPickup.draggedItem)) { MoveItem(KISAddonPickup.draggedItem, this, i); } } } else if (KISAddonPickup.draggedPart != this.part) { // Picked part from scene if (carryPart) { KIS_Shared.SendKISMessage(KISAddonPickup.draggedPart, KIS_Shared.MessageAction.Store); KIS_Item carryItem = AddItem(KISAddonPickup.draggedPart, 1, i); KISAddonPickup.draggedPart.Die(); carryItem.Equip(); } else { if (VolumeAvailableFor(KISAddonPickup.draggedPart)) { KIS_Shared.SendKISMessage(KISAddonPickup.draggedPart, KIS_Shared.MessageAction.Store); AddItem(KISAddonPickup.draggedPart, 1, i); if (HighLogic.LoadedSceneIsEditor == false) { KISAddonPickup.draggedPart.Die(); } } } } } } } i++; } GUILayout.EndHorizontal(); } // item icon rotation if (Event.current.type == EventType.Repaint) { if (mouseOverItem != null) { mouseOverItem.icon.Rotate(); } if (mouseOverItem != tooltipItem) { if (tooltipItem != null) { tooltipItem.icon.ResetPos(); } tooltipItem = mouseOverItem; } } }
public virtual void OnItemUse(KIS_Item item, KIS_Item.UseFrom useFrom) { }
public virtual void OnItemUpdate(KIS_Item item) { }
private void OnGUI() { if (!showGui) return; // Update GUI of items foreach (KeyValuePair<int, KIS_Item> item in items) { item.Value.GUIUpdate(); } GUIStyles(); // Set title string title = this.part.partInfo.title; if (invType == InventoryType.Pod) { title = this.part.partInfo.title + " | Seat " + podSeat; if (!HighLogic.LoadedSceneIsEditor) { if (this.part.internalModel) { InternalSeat seat = this.part.internalModel.seats[podSeat]; if (seat.taken) { title = seat.kerbalRef.crewMemberName; } } } } if (invType == InventoryType.Eva) { title = this.part.partInfo.title + " | " + kerbalTrait; } if (invType == InventoryType.Container && invName != "") { title = this.part.partInfo.title + " | " + invName; } guiMainWindowPos = GUILayout.Window(GetInstanceID(), guiMainWindowPos, GuiMain, title); if (tooltipItem != null) { if (contextItem == null) { string tooltipName = tooltipItem.availablePart.title; if (tooltipItem.inventoryName != "") tooltipName += " | " + tooltipItem.inventoryName; GUILayout.Window(GetInstanceID() + 780, new Rect(Event.current.mousePosition.x + 5, Event.current.mousePosition.y + 5, 400, 1), GuiTooltip, tooltipName); } } if (contextItem != null) { Rect contextRelativeRect = new Rect(guiMainWindowPos.x + contextRect.x + (contextRect.width / 2), guiMainWindowPos.y + contextRect.y + (contextRect.height / 2), 80, 10); GUILayout.Window(GetInstanceID() + 781, contextRelativeRect, GuiContextMenu, "Action"); if (contextClick) { contextClick = false; splitQty = 1; } else if (Event.current.type == EventType.MouseDown) { contextItem = null; } } if (debugItem != null) { guiDebugWindowPos = GUILayout.Window(GetInstanceID() + 782, guiDebugWindowPos, GuiDebugItem, "Debug item"); } // Disable Click through if (HighLogic.LoadedSceneIsEditor) { if (guiMainWindowPos.Contains(Event.current.mousePosition) && !clickThroughLocked) { EditorTooltip.Instance.HideToolTip(); InputLockManager.SetControlLock(ControlTypes.EDITOR_PAD_PICK_PLACE, "KISInventoryEditorLock"); clickThroughLocked = true; } if (!guiMainWindowPos.Contains(Event.current.mousePosition) && clickThroughLocked) { InputLockManager.RemoveControlLock("KISInventoryEditorLock"); clickThroughLocked = false; } } else if (HighLogic.LoadedSceneIsFlight) { if (guiMainWindowPos.Contains(Event.current.mousePosition) && !clickThroughLocked) { InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS | ControlTypes.MAP, "KISInventoryFlightLock"); clickThroughLocked = true; } if (!guiMainWindowPos.Contains(Event.current.mousePosition) && clickThroughLocked) { InputLockManager.RemoveControlLock("KISInventoryFlightLock"); clickThroughLocked = false; } } }
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; }
private IEnumerator WaitAndDoAction(DelayedActionMethod actionMethod, KIS_Item item, float delay) { yield return new WaitForSeconds(delay); actionMethod(item); }
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 DelayedAction(DelayedActionMethod actionMethod, KIS_Item item, float delay) { StartCoroutine(WaitAndDoAction(actionMethod, item, delay)); }
public void Pickup(Part part) { draggedPart = part; draggedItem = null; Pickup(); }
private void GuiDebugItem(int windowID) { if (debugItem != null) { KIS_Shared.EditField("moveSndPath", ref debugItem.prefabModule.moveSndPath); KIS_Shared.EditField("shortcutKeyAction(drop,equip,custom)", ref debugItem.prefabModule.shortcutKeyAction); KIS_Shared.EditField("usableFromEva", ref debugItem.prefabModule.usableFromEva); KIS_Shared.EditField("usableFromContainer", ref debugItem.prefabModule.usableFromContainer); KIS_Shared.EditField("usableFromPod", ref debugItem.prefabModule.usableFromPod); KIS_Shared.EditField("usableFromEditor", ref debugItem.prefabModule.usableFromEditor); KIS_Shared.EditField("useName", ref debugItem.prefabModule.useName); KIS_Shared.EditField("equipMode(model,physic)", ref debugItem.prefabModule.equipMode); KIS_Shared.EditField("equipSlot", ref debugItem.prefabModule.equipSlot); KIS_Shared.EditField("equipable", ref debugItem.prefabModule.equipable); KIS_Shared.EditField("stackable", ref debugItem.prefabModule.stackable); KIS_Shared.EditField("carriable", ref debugItem.prefabModule.carriable); KIS_Shared.EditField("equipSkill(<blank>,RepairSkill,ScienceSkill,etc...)", ref debugItem.prefabModule.equipSkill); KIS_Shared.EditField("equipRemoveHelmet", ref debugItem.prefabModule.equipRemoveHelmet); KIS_Shared.EditField("volumeOverride(0 = auto)", ref debugItem.prefabModule.volumeOverride); scrollPositionDbg = GUILayout.BeginScrollView(scrollPositionDbg, GUILayout.Width(400), GUILayout.Height(200)); List<SkinnedMeshRenderer> skmrs = new List<SkinnedMeshRenderer>(this.part.GetComponentsInChildren<SkinnedMeshRenderer>() as SkinnedMeshRenderer[]); foreach (SkinnedMeshRenderer skmr in skmrs) { GUILayout.Label("--- " + skmr.name + " ---"); foreach (Transform bone in skmr.bones) { if (GUILayout.Button(new GUIContent(bone.name, ""))) { debugItem.prefabModule.equipMeshName = skmr.name; debugItem.prefabModule.equipBoneName = bone.name; debugItem.ReEquip(); } } } GUILayout.EndScrollView(); if (KIS_Shared.EditField("equipPos", ref debugItem.prefabModule.equipPos)) debugItem.ReEquip(); if (KIS_Shared.EditField("equipDir", ref debugItem.prefabModule.equipDir)) debugItem.ReEquip(); } if (GUILayout.Button("Close")) { debugItem = null; } GUI.DragWindow(); }
public virtual void OnItemDragged(KIS_Item draggedItem) { }
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; }
public virtual void OnUnEquip(KIS_Item item) { }