private void Move(PartContent aPart, int qty, KASModuleContainer destContainer) { if (destContainer.MaxSizeReached(aPart.grabModule, qty)) { fxSndBipWrong.audio.Play(); ScreenMessages.PostScreenMessage("Max size of the destination container reached !", 5, ScreenMessageStyle.UPPER_CENTER); return; } PartContent dest = PartContent.Get(destContainer.contents, aPart.name); if (aPart.pristine_count > 0) { int delta = Math.Min(aPart.pristine_count, qty); aPart.pristine_count -= delta; dest.pristine_count += delta; qty -= delta; } while (qty > 0 && aPart.instances.Count > 0) { dest.Load(aPart.PopInstance()); qty--; } RefreshTotalSize(); destContainer.RefreshTotalSize(); }
private void Take(PartContent avPart) { if (waitAndGrabRunning) { KAS_Shared.DebugError("Take(Container) Take action is already running, please wait !"); return; } if (!FlightGlobals.ActiveVessel.isEVA) { KAS_Shared.DebugError("Take(Container) Can only grab from EVA!"); return; } KASModuleGrab grabbed = KAS_Shared.GetGrabbedPartModule(FlightGlobals.ActiveVessel); if (grabbed && grabbed.part.packed) { KAS_Shared.DebugError("Take(Container) EVA holding a packed part!"); return; } if (avPart.pristine_count <= 0 && avPart.instances.Count > 0) { if (TakeStoredInstance(avPart.instances[0], FlightGlobals.ActiveVessel)) { avPart.PopInstance(); RefreshTotalSize(); } return; } KASModuleGrab prefabGrabModule = avPart.grabModule; // get grabbed position and rotation Vector3 pos = FlightGlobals.ActiveVessel.rootPart.transform.TransformPoint(prefabGrabModule.evaPartPos); Quaternion rot = FlightGlobals.ActiveVessel.rootPart.transform.rotation * Quaternion.Euler(prefabGrabModule.evaPartDir); //Move away the part at creation pos += new Vector3(0f, 0f, 100); //Part newPart = KAS_Shared.CreatePart(avPart, pos, rot, this.part); Part newPart = KAS_Shared.CreatePart(avPart.name, pos, rot, this.part); if (!newPart) { KAS_Shared.DebugError("Take(Container) failed to create the part !"); return; } KASModuleGrab moduleGrab = newPart.GetComponent <KASModuleGrab>(); if (!moduleGrab) { KAS_Shared.DebugError("Take(Container) Cannot grab the part taken, no grab module found !"); return; } avPart.pristine_count--; RefreshTotalSize(); StartCoroutine(WaitAndGrab(moduleGrab, FlightGlobals.ActiveVessel)); }
private void Take(PartContent avPart) { if (waitAndGrabRunning) { KAS_Shared.DebugError("Take(Container) Take action is already running, please wait !"); return; } if (!FlightGlobals.ActiveVessel.isEVA) { KAS_Shared.DebugError("Take(Container) Can only grab from EVA!"); return; } KASModuleGrab grabbed = KAS_Shared.GetGrabbedPartModule(FlightGlobals.ActiveVessel); if (grabbed && grabbed.part.packed) { KAS_Shared.DebugError("Take(Container) EVA holding a packed part!"); return; } if (avPart.pristine_count <= 0 && avPart.instances.Count > 0) { if (TakeStoredInstance(avPart.instances[0], FlightGlobals.ActiveVessel)) { avPart.PopInstance(); RefreshTotalSize(); } return; } KASModuleGrab prefabGrabModule = avPart.grabModule; // get grabbed position and rotation Vector3 pos = FlightGlobals.ActiveVessel.rootPart.transform.TransformPoint(prefabGrabModule.evaPartPos); Quaternion rot = FlightGlobals.ActiveVessel.rootPart.transform.rotation * Quaternion.Euler(prefabGrabModule.evaPartDir); //Move away the part at creation pos += new Vector3(0f, 0f, 100); //Part newPart = KAS_Shared.CreatePart(avPart, pos, rot, this.part); Part newPart = KAS_Shared.CreatePart(avPart.name, pos, rot, this.part); if (!newPart) { KAS_Shared.DebugError("Take(Container) failed to create the part !"); return; } KASModuleGrab moduleGrab = newPart.GetComponent<KASModuleGrab>(); if (!moduleGrab) { KAS_Shared.DebugError("Take(Container) Cannot grab the part taken, no grab module found !"); return; } avPart.pristine_count--; RefreshTotalSize(); StartCoroutine(WaitAndGrab(moduleGrab, FlightGlobals.ActiveVessel)); }