public void onEditorPartEvent(ConstructionEventType eventType, Part part) { if (eventType != ConstructionEventType.PartAttached) { return; } //Check to see if the tool tip exists and has been shown string toolTipName = part.name; if (!showToolTips) { return; } if (ToolTipViewed(toolTipName)) { return; } if (!toolTips.ContainsKey(toolTipName)) { return; } //Because the event gets triggered a LOT, just record the part so we can display the tip later. if (toolTips.ContainsKey(part.name)) { attachedPart = part; } }
public void EditorPartEvent(ConstructionEventType eventType, Part part) { // ReSharper disable once SwitchStatementMissingSomeCases switch (eventType) { case ConstructionEventType.PartAttached: case ConstructionEventType.PartCreated: case ConstructionEventType.PartTweaked: AddModule(part); if (part.symmetryCounterparts.Count > 0) { foreach (var p in part.symmetryCounterparts) { AddModule(p); } } break; case ConstructionEventType.PartCopied: case ConstructionEventType.PartDeleted: case ConstructionEventType.PartDetached: case ConstructionEventType.PartDropped: RemoveModule(part); break; } }
private void OnPartEvent(ConstructionEventType type, Part part) { if (type == ConstructionEventType.PartCreated && part == EditorLogic.RootPart) { ResetCamera(); } }
/// <summary>Adds default items to the pod's seats.</summary> /// <remarks>Items are only added to a part created in the editor. Thus, reacting on the editor /// event.</remarks> /// <param name="type">Unused.</param> /// <param name="p">A target part.</param> void OnEditPartCreate(ConstructionEventType type, Part p) { if (type != ConstructionEventType.PartCreated && type != ConstructionEventType.PartCopied) { return; } var inventories = p.GetComponents <ModuleKISInventory>(); foreach (var inventory in inventories) { if (inventory.podSeat == 0 && ModuleKISInventory.defaultItemsForTheFirstSeat.Count > 0) { Debug.LogFormat("Adding default item(s) into the first seat of part {0}: {1}", p.name, DbgFormatter.C2S(ModuleKISInventory.defaultItemsForTheFirstSeat)); AddItems(inventory, ModuleKISInventory.defaultItemsForTheFirstSeat); } if (inventory.podSeat != -1 && ModuleKISInventory.defaultItemsForAllSeats.Count > 0) { Debug.LogFormat( "Adding default item(s) into seat's {0} inventory of part {1}: {2}", inventory.podSeat, p.name, DbgFormatter.C2S(ModuleKISInventory.defaultItemsForAllSeats)); AddItems(inventory, ModuleKISInventory.defaultItemsForAllSeats); } } }
private void EditorPartEvent(ConstructionEventType data0, Part data1) { var sectionInfo = data1.FindModuleImplementing <SectionInfo>(); if (data0 == ConstructionEventType.PartDetached) { LogFormatted_DebugOnly("PartDetached."); CopySectionDataToOtherPartInSection(sectionInfo, true); } if (data0 == ConstructionEventType.PartCreated && data1 == EditorLogic.RootPart) { LogFormatted_DebugOnly("Initializing root section."); sectionInfo.isSectionRoot = true; sectionInfo.InitializeAsNewSection(); } if (data0 == ConstructionEventType.PartAttached) { LogFormatted_DebugOnly("PartAttached."); sectionInfo.TrySetSectionBasedOnParent(); if (EditorLogic.fetch.symmetryMode != 1 && sectionInfo.isSectionRoot) { EnsureOnlyOneSectionRoot(sectionInfo); } } }
void onEditorPartEvent(ConstructionEventType evt, Part part) { //MonoBehaviour.print (evt.ToString ()); OnPartChanged(); switch (evt) { case ConstructionEventType.PartPicked: if (part == EditorLogic.RootPart) { OnRootPartPicked(); } break; case ConstructionEventType.PartDropped: if (part == EditorLogic.RootPart) { OnRootPartDropped(); } break; case ConstructionEventType.PartDeleted: if (part == EditorLogic.RootPart) { RCSBuildAid.SetActive(false); } break; } }
void CheckForLight(ConstructionEventType constrE, Part part) { if (constrE == ConstructionEventType.PartCreated) { if (disableCrewAG && !disableAllAG) { if (part.CrewCapacity < 1) { return; } } if (part.Modules.Contains <ModuleColorChanger> () || part.Modules.Contains <ModuleLight> () || part.Modules.Contains <ModuleAnimateGeneric> () || part.Modules.Contains("WBILight") || part.Modules.Contains("ModuleKELight")) { foreach (PartModule partM in part.Modules) { if (partM.Actions.Contains(KSPActionGroup.Light)) { foreach (BaseAction action in partM.Actions) { if (action.actionGroup == KSPActionGroup.Light) { action.actionGroup = KSPActionGroup.None; break; } } } } } } }
void EditorPartEvent(ConstructionEventType eventType, Part part) { if (eventType == ConstructionEventType.PartRotating || eventType == ConstructionEventType.PartOffsetting) { return; } if (eventType == ConstructionEventType.PartDragging) { return; } Log.Debug(string.Format("EditorPartEvent {0} part {1}", eventType, part)); if (eventType == ConstructionEventType.PartAttached) { if (part.parent != null) { Log.Debug("Part parent: " + part.parent.name); Log.Debug("Node attached: " + IsPartNodeAttached(part).ToString()); } else { Log.Debug("Part parent is null"); } } }
public void onEditorPartEvent(ConstructionEventType eventType, Part part) { if (!HighLogic.LoadedSceneIsEditor) { return; } if (createdParts == null) { createdParts = new List <Part>(); } switch (eventType) { case ConstructionEventType.PartCreated: if (!createdParts.Contains(part)) { createdParts.Add(part); } break; case ConstructionEventType.PartDeleted: if (createdParts.Contains(part)) { createdParts.Remove(part); } break; } }
private void ResetSymmetry(ConstructionEventType constrE, Part p) { if (constrE != ConstructionEventType.PartDeleted && p == part) { ResetSymmetry(); } }
void onEditorPartEvent(ConstructionEventType eventType, Part eventPart) { if (eventType != ConstructionEventType.PartDetached || eventPart.FindModuleImplementing <SWBallastTank>() == null) { return; } getHostPart(); }
public void onEditorPartEvent(ConstructionEventType type, Part part) { using (PooledStringBuilder sb = this.getStringBuilder()) { sb.AppendFormat("ConstructionEventType={0}, Part={1}", Enum.GetName(typeof(ConstructionEventType), type), part); Debug.Log(sb.ToString()); } }
// Is called when we interact with a part in the editor. private void OnEditorPartEvent(ConstructionEventType ev, Part part) { try { if (ev != ConstructionEventType.PartCreated && ev != ConstructionEventType.PartDetached && ev != ConstructionEventType.PartAttached && ev != ConstructionEventType.PartDragging) { return; } KRnDUI.selectedPart = part; } catch (Exception e) { Debug.LogError("[KRnD] EditorPartEvent(): " + e); } }
void onEditorPartEvent(ConstructionEventType evt, Part part) { #if DEBUG switch (evt) { case ConstructionEventType.PartDragging: case ConstructionEventType.PartOffsetting: case ConstructionEventType.PartRotating: /* these events are too noisy for logging */ break; default: Debug.Log($"[RCSBA]: Editor Part Event {evt} {part.partInfo.name}"); break; } #endif PartEvent?.Invoke(); switch (evt) { case ConstructionEventType.PartCopied: case ConstructionEventType.PartCreated: OnSelectionChanged(); break; case ConstructionEventType.PartPicked: if (part != EditorLogic.RootPart) { OnSelectionChanged(); } break; case ConstructionEventType.PartDropped: if (part != EditorLogic.RootPart) { OnSelectionChanged(); } break; case ConstructionEventType.PartDeleted: OnSelectionChanged(); break; case ConstructionEventType.PartAttached: case ConstructionEventType.PartDetached: OnVesselPartChanged(); OnSelectionChanged(); break; case ConstructionEventType.PartDragging: PartDrag?.Invoke(); break; } }
private void UpdateWingInteractionsEvent(ConstructionEventType type, Part pEvent) { if (type == ConstructionEventType.PartRotating || type == ConstructionEventType.PartOffsetting || type == ConstructionEventType.PartAttached || type == ConstructionEventType.PartDetached) { if (editorShip == null) { return; } UpdateEditorShipModules(); } }
public void OnEditorPartEvent(ConstructionEventType type, Part part) { if (type == ConstructionEventType.PartDropped || type == ConstructionEventType.PartAttached || type == ConstructionEventType.PartCreated) { if (ScrapYard.Instance.InstanceSelectorUI.IsVisible) { ScrapYard.Instance.InstanceSelectorUI.Show(part, null); } } //Logging.DebugLog(type); shipOrPartModified(); }
public void PartEvent(ConstructionEventType eventType, Part part) { if (showMainWindow || showPlanetWindow || showTargetWindow) { if (eventType == ConstructionEventType.PartAttached) { AntennaListAddItem(part); // Symmetry counterparts foreach (Part symPart in part.symmetryCounterparts) { AntennaListAddItem(symPart); } // Child part foreach (Part childPart in part.children) { AntennaListAddItem(childPart); } DoTheMath(); } else if (eventType == ConstructionEventType.PartDetached) { AntennaListRemoveItem(part); List <ModuleDataTransmitter> remAntenna = new List <ModuleDataTransmitter> (); foreach (ModuleDataTransmitter antennaSym in directAntennaList) { if (antennaSym.part.isSymmetryCounterPart(part)) { remAntenna.Add(antennaSym); } } // Child part foreach (Part childPart in part.children) { AntennaListRemoveItem(childPart); } foreach (ModuleDataTransmitter remA in remAntenna) { AntennaListRemoveItem(remA); } DoTheMath(); } } }
private void UpdateGeometryModule(ConstructionEventType type, Part p) { GeometryPartModule g = p.GetComponent <GeometryPartModule>(); if (g != null && g.Ready) { if (type == ConstructionEventType.Unknown) { g.RebuildAllMeshData(); } else { g.EditorUpdate(); } } }
private void UpdateGeometryEvent(ConstructionEventType type, Part pEvent) { if (type == ConstructionEventType.PartRotated || type == ConstructionEventType.PartOffset || type == ConstructionEventType.PartAttached || type == ConstructionEventType.PartDetached || type == ConstructionEventType.PartRootSelected || type == ConstructionEventType.Unknown) { if (EditorLogic.SortedShipList.Count > 0) { UpdateGeometryModule(type, pEvent); } RequestUpdateVoxel(); } }
/// <summary> /// Here when an event happens to the part in the editor. /// </summary> /// <param name="eventType"></param> /// <param name="part"></param> private void OnEditorPartEvent(ConstructionEventType eventType, Part part) { switch (eventType) { case ConstructionEventType.PartAttached: ModuleRoboticSlave.OnEditorPartAttached(part); break; case ConstructionEventType.PartDetached: ModuleRoboticSlave.OnEditorPartDetached(part); break; default: // don't care about anything else break; } }
/// <summary> /// Here when an event happens to the part in the editor. /// </summary> /// <param name="eventType"></param> /// <param name="part"></param> private void OnEditorPartEvent(ConstructionEventType eventType, Part part) { switch (eventType) { case ConstructionEventType.PartAttached: OnPartAttached(part); break; case ConstructionEventType.PartCopied: OnPartCopied(part); break; default: // don't care about anything else break; } }
private void UpdateWingInteractionsPart(ConstructionEventType type, Part p) { EditorPartsChanged = true; FARWingAerodynamicModel w = p.GetComponent <FARWingAerodynamicModel>(); if ((object)w != null) { if (type == ConstructionEventType.PartAttached) { w.OnWingAttach(); } else if (type == ConstructionEventType.PartDetached) { w.OnWingDetach(); } w.EditorUpdateWingInteractions(); } }
private void OnPartEvent(ConstructionEventType eventType, Part part) { if (eventType == ConstructionEventType.PartCreated) { applyPartCreated(part); } if (eventType == ConstructionEventType.PartDropped) { //TODO Es cuando la dejo tirada } if (eventType == ConstructionEventType.PartAttached) { applyPartAttached(part); } if (eventType == ConstructionEventType.PartDeleted) { //TODO Es cuando la borro } }
/// <summary> /// Here when an event happens to the part in the editor. /// </summary> /// <param name="eventType"></param> /// <param name="part"></param> private void OnEditorPartEvent(ConstructionEventType eventType, Part part) { try { if (eventType != ConstructionEventType.PartAttached) { return; } if (Crewable.CanList(CurrentShipConstruct)) { Logging.Log("Attached " + Logging.ToString(part) + "."); AssignmentLogic.AssignKerbals(CurrentShipConstruct); } } catch (Exception e) { Logging.Exception(e); } }
private void UpdateWingInteractionsEvent(ConstructionEventType type, Part pEvent) { if (type == ConstructionEventType.PartRotating || type == ConstructionEventType.PartOffsetting || type == ConstructionEventType.PartAttached || type == ConstructionEventType.PartDetached) { if (editorShip == null) { return; } FindPartsWithoutFARModel(editorShip); for (int i = 0; i < editorShip.Count; i++) { Part p = editorShip[i]; for (int j = 0; j < p.Modules.Count; j++) { PartModule m = p.Modules[j]; if (m is FARBaseAerodynamics) { (m as FARBaseAerodynamics).ClearShielding(); } } } for (int i = 0; i < editorShip.Count; i++) { Part p = editorShip[i]; for (int j = 0; j < p.Modules.Count; j++) { PartModule m = p.Modules[j]; if (m is FARPartModule) { (m as FARPartModule).ForceOnVesselPartsChange(); } } } part_count_all = editorShip.Count; part_count_ship = EditorLogic.SortedShipList.Count; EditorPartsChanged = false; } }
/// <summary>Adds default items to the pod's seats.</summary> /// <remarks>Items are only added to a part created in the editor. Thus, reacting on the editor /// event.</remarks> /// <param name="type">Unused.</param> /// <param name="p">A target part.</param> void OnEditPartCreate(ConstructionEventType type, Part p) { if (type != ConstructionEventType.PartCreated && type != ConstructionEventType.PartCopied) { return; } var inventories = p.GetComponents<ModuleKISInventory>(); foreach (var inventory in inventories) { if (inventory.podSeat != -1 && ModuleKISInventory.defaultItemsForAllSeats.Count > 0) { Logger.logInfo( "Adding default item(s) into seat's {0} inventory of part {1}: {2}", inventory.podSeat, p.name, Logger.C2S(ModuleKISInventory.defaultItemsForAllSeats)); AddItems(inventory, ModuleKISInventory.defaultItemsForAllSeats); } if (inventory.podSeat == 0 && ModuleKISInventory.defaultItemsForTheFirstSeat.Count > 0) { Logger.logInfo("Adding default item(s) into the first seat of part {0}: {1}", p.name, Logger.C2S(ModuleKISInventory.defaultItemsForTheFirstSeat)); AddItems(inventory, ModuleKISInventory.defaultItemsForTheFirstSeat); } } }
private static void UpdateGeometryModule(ConstructionEventType type, Part p) { if (p is null) { return; } GeometryPartModule g = p.GetComponent <GeometryPartModule>(); if (g == null || !g.Ready) { return; } if (type == ConstructionEventType.Unknown) { g.RebuildAllMeshData(); } else { g.EditorUpdate(); } }
private void EditorPartEvent(ConstructionEventType data0, Part data1) { var sectionInfo = data1.FindModuleImplementing<SectionInfo>(); if (data0 == ConstructionEventType.PartDetached) { CopySectionDataToOtherPartInSection(sectionInfo, true); } if (data0 == ConstructionEventType.PartCreated && data1 == EditorLogic.RootPart) { LogFormatted_DebugOnly("Initializing root section."); sectionInfo.isSectionRoot = true; sectionInfo.InitializeAsNewSection(); } if(data0 == ConstructionEventType.PartAttached) { sectionInfo.TrySetSectionBasedOnParent(); if (EditorLogic.fetch.symmetryMode != 1 && sectionInfo.isSectionRoot) EnsureOnlyOneSectionRoot(sectionInfo); } }
private void OnPartEvent(ConstructionEventType ct, Part p) { if (!HighLogic.CurrentGame.Parameters.CustomParams <KeoCacheOptions>().allowMultipleOnVessel&& p != null && p == this.part) { if (ct == ConstructionEventType.PartAttached) { // count up all the TravelBugs here int numBugs = 0; for (int i = EditorLogic.fetch.ship.parts.Count - 1; i >= 0; i--) { numBugs += (EditorLogic.fetch.ship.parts[i].Modules.GetModules <KeoTravelBugModule>().Count); } Log.Info("numBugs on vessel: " + numBugs); if (numBugs > 1) { ScreenMessages.PostScreenMessage("Multiple TravelBugs on same vessel not allowed!", 10f, ScreenMessageStyle.UPPER_CENTER); ScreenMessages.PostScreenMessage("Deleting extra TravelBug", 10f, ScreenMessageStyle.UPPER_CENTER); EditorLogic.DeletePart(this.part); } } } }
protected void OnEditorEvent(ConstructionEventType eventType, Part eventPart) { if (this.part != eventPart && !part.symmetryCounterparts.Contains(eventPart)) { return; } switch (eventType) { case ConstructionEventType.PartAttached: OnAttach(); break; case ConstructionEventType.PartDetached: OnDetach(); break; case ConstructionEventType.PartOffsetting: case ConstructionEventType.PartRotating: UpdateScale(); break; } }
private void OnEditorPartEvent(ConstructionEventType data, Part part) { if (data == ConstructionEventType.PartCreated) { for (int i = 0; i < part.Modules.Count; i++) { if (part.Modules[i] is ModuleB9PartInfo) { part.Modules[i].enabled = false; part.Modules[i].isEnabled = false; } else if (part.Modules[i] is ModuleB9PartSwitch || part.Modules[i] is ModulePartVariants) { for (int j = 0; j < part.Modules[i].Fields.Count; j++) { part.Modules[i].Fields[j].guiActiveEditor = false; } for (int k = 0; k < part.Modules[i].Events.Count; k++) { if (part.Modules[i].Events[k] != null) { part.Modules[i].Events[k].guiActiveEditor = false; part.Modules[i].Events[k].active = false; } } } } } if (!infoToolTipVisible) { return; } if (data != ConstructionEventType.PartTweaked) { ShowInfoToolTip(false); } }
// ReSharper disable once MemberCanBeMadeStatic.Local -> static does not work with GameEvents private void UpdateGeometryEvent(ConstructionEventType type, Part pEvent) { if (type != ConstructionEventType.PartRotated && type != ConstructionEventType.PartOffset && type != ConstructionEventType.PartAttached && type != ConstructionEventType.PartDetached && type != ConstructionEventType.PartRootSelected && type != ConstructionEventType.Unknown) { return; } if (EditorLogic.SortedShipList.Count > 0) { UpdateGeometryModule(type, pEvent); } RequestUpdateVoxel(); if (type != ConstructionEventType.Unknown) { partMovement = true; } }
private void OnEditorPartEvent(ConstructionEventType cet, Part p) { //Main editor handling! NetworkWorker.fetch.SendEditorPartEvent(cet, p); }
private void UpdateGeometryModule(ConstructionEventType type, Part p) { GeometryPartModule g = p.GetComponent<GeometryPartModule>(); if (g != null && g.Ready) { if (type == ConstructionEventType.Unknown) g.RebuildAllMeshData(); else g.EditorUpdate(); } }
private void UpdateGeometryEvent(ConstructionEventType type, Part pEvent) { if (type == ConstructionEventType.PartRotated || type == ConstructionEventType.PartOffset || type == ConstructionEventType.PartAttached || type == ConstructionEventType.PartDetached || type == ConstructionEventType.PartRootSelected || type == ConstructionEventType.Unknown) { if (EditorLogic.SortedShipList.Count > 0) UpdateGeometryModule(type, pEvent); RequestUpdateVoxel(); } }
void onEditorPartEvent (ConstructionEventType evt, Part part) { //MonoBehaviour.print (evt.ToString ()); OnPartChanged (); switch (evt) { case ConstructionEventType.PartPicked: if (part == EditorLogic.RootPart) { OnRootPartPicked (); } break; case ConstructionEventType.PartDropped: if (part == EditorLogic.RootPart) { OnRootPartDropped (); } break; case ConstructionEventType.PartDeleted: if (part == EditorLogic.RootPart) { RCSBuildAid.SetActive (false); } break; } }
public void onEditorPartEvent(ConstructionEventType type, Part part) { StringBuilder sb = this.getStringBuilder(); sb.AppendFormat("ConstructionEventType={0}, Part={1}", Enum.GetName(typeof(ConstructionEventType), type), part); Debug.Log(sb.ToString()); Tools.PutStringBuilder(sb); }
public void SendEditorPartEvent(ConstructionEventType cet, Part p) { Part pn = new Part(); ConfigNode cn = new ConfigNode(); p.OnSave(cn); pn.OnLoad(cn); }
/// <summary> /// Handle editor events. /// </summary> /// <param name="eventType"></param> /// <param name="part"></param> private void OnPartEvent(ConstructionEventType eventType, Part part) { try { switch (eventType) { case ConstructionEventType.PartCreated: // We need this for the initial root part, since it never // gets an "attached" event. handlePart(part); break; case ConstructionEventType.PartAttached: // This handles everything else, including parts that are copied, or in // symmetry groups, or a child of something else that gets attached. It // does have a bit of a wart in that the default groups will get re-applied // every time you detach and re-attach a part... which bothered me until // a bit of testing showed that the stock game does that too! onPartAttached(part); foreach (Part counterpart in part.symmetryCounterparts) { onPartAttached(counterpart); } break; } } catch (Exception e) { Logging.Exception(e); } }
public void OnEditorPartEvent(ConstructionEventType type, Part part) { switch (type) { case ConstructionEventType.PartRootSelected: //StartCoroutine(RebuildPartAttachments()); Part[] children = childAttach.Select<FreePartAttachment, Part>(x => x.Child).ToArray(); foreach (Part attachment in children) { PartChildDetached(attachment); } foreach (Transform t in transform) { Part child = t.GetComponent<Part>(); if(child != null) PartChildAttached(child); } if (transform.parent == null) PartParentChanged(null); else PartParentChanged(transform.parent.GetComponent<Part>()); break; case ConstructionEventType.PartOffset: foreach (FreePartAttachment ca in childAttach) { if (ca.Child == part || ca.Child.isSymmetryCounterPart(part)) { Vector3 position = ca.Child.transform.TransformPoint(ca.AttachNode.position); //ca.node.nodeType //shape.GetCylindricCoordinates(part.transform.localPosition, out ca.u, out ca.y, out ca.r); shape.GetCylindricCoordinates(transform.InverseTransformPoint(position), ca.Coordinates); //Debug.Log("y: " + ca.y); //Debug.Log("u: " + ca.u); //Debug.Log("r: " + ca.r); //RemovePartAttachment(pa); //childAttachments.Remove(pa); //PartChildAttached(part); //break; } } break; } }
void onEditorPartEvent(ConstructionEventType evt, Part part) { OnPartChanged (); switch (evt) { case ConstructionEventType.PartDeleted: if (part == EditorLogic.RootPart) { RCSBuildAid.SetActive (false); } break; } }
private void OnPartEvent(ConstructionEventType type, Part part) { if (type == ConstructionEventType.PartCreated && part == EditorLogic.RootPart) { ResetCamera (); } }