// Recurse through the master branch and the newly placed symmetric branch, copying over part info. void UpdatePartAndChildren(Part SourcePart, Part UpdatePart, SymmetryMethod SymMethod) { if (null == SourcePart || null == UpdatePart) { // Null parts were passed to the updater. This should not happen, but just in case... return; } // Fix the bug where staging icons split from each other. UpdatePart.originalStage = SourcePart.originalStage; // This shouldn't be needed anymore. if (0 == UpdatePart.symmetryCounterparts.Count) { // This part has no mirrored parts. No need to copy the action groups. return; } CheckAndAddCounterpart(SourcePart, UpdatePart); PropagateCounterparts(SourcePart); // Propagates symmetry method throughout the branch. If it ever hits radial symmetry, the rest of the // branch needs to be listed as symmetry to prevent editor breakage with nested mirror symmetry. if (SourcePart.symmetryCounterparts.Count > 1) { SymMethod = SymmetryMethod.Radial; } //if(SourcePart.symMethod == SymmetryMethod.Radial) //{ // SymMethod = SymmetryMethod.Radial; //} // Debug.LogWarning("SymmMethod: " + SymMethod); SourcePart.symMethod = SymMethod; UpdatePart.symMethod = SymMethod; if (SourcePart.Modules.Count != UpdatePart.Modules.Count) { Debug.LogError("SAFix.onPartAttach(): Part Copy Error. Module Count Mismatch."); return; } // Loop through all the modules. Action groups are stored inside the PartModules for (int IndexModules = 0; IndexModules < UpdatePart.Modules.Count; IndexModules++) { if (SourcePart.Modules[IndexModules].Actions.Count != UpdatePart.Modules[IndexModules].Actions.Count) { Debug.LogError("SAFix.UpdatePartAndChildren(): Actions Mismatch in Module. Action copy aborted at Module: " + SourcePart.Modules[IndexModules].moduleName); return; } // Loop through all the Actions for this module. for (int IndexActions = 0; IndexActions < SourcePart.Modules[IndexModules].Actions.Count; IndexActions++) { // Copy the Action's triggers. // Debug.LogWarning("Module/Action " + UpdatePart.Modules[IndexModules].Actions[IndexActions].name); UpdatePart.Modules[IndexModules].Actions[IndexActions].actionGroup = SourcePart.Modules[IndexModules].Actions[IndexActions].actionGroup; } if ("ModuleProceduralFairing" == SourcePart.Modules[IndexModules].moduleName) { Debug.Log("SymmetryActionFix: Fixing Procedural Fairing"); ModuleProceduralFairing MPFSource = (ModuleProceduralFairing)SourcePart.Modules[IndexModules]; ModuleProceduralFairing MPFUpdate = (ModuleProceduralFairing)UpdatePart.Modules[IndexModules]; if (MPFSource.xSections.Count != 0) { MPFUpdate.xSections.AddRange(MPFSource.xSections); MethodInfo MPFMethod = MPFUpdate.GetType().GetMethod("SpawnMeshes", BindingFlags.NonPublic | BindingFlags.Instance); if (MPFMethod != null) { MPFMethod.Invoke(MPFUpdate, new object[] { true }); } } } } for (int IndexChild = 0; IndexChild < UpdatePart.children.Count; IndexChild++) { // Go through all the children parts and copy the actions. UpdatePartAndChildren(SourcePart.children[IndexChild], UpdatePart.children[IndexChild], SymMethod); } }
public override void OnStart(StartState state) { missileToRailIndex = new Dictionary<int, int>(); railToMissileIndex = new Dictionary<int, int>(); lengthInterval = maxLength / intervals; heightInterval = maxHeight / intervals; numberOfRails = railCounts[railCountIndex]; rails = new List<Transform>(); rotationTransforms = new List<Transform>(); heightTransforms = new List<Transform>(); lengthTransforms = new List<Transform>(); UpdateModelState(); //MoveEndStackNode(currentLength); if(HighLogic.LoadedSceneIsEditor) { StartCoroutine(DelayedMoveStackNode(currentLength)); part.AddOnMouseEnter(OnPartEnter); part.AddOnMouseExit(OnPartExit); part.OnEditorAttach += OnAttach; previousSymMethod = EditorLogic.fetch.symmetryMethod; } if(HighLogic.LoadedSceneIsFlight) { UpdateMissileChildren(); RotateToIndex(railIndex, true); } }
//editor stuff void OnPartEnter(Part p) { if(EditorLogic.SelectedPart && EditorLogic.SelectedPart!=part) { previousSymMethod = EditorLogic.fetch.symmetryMethod; EditorLogic.fetch.symmetryMethod = SymmetryMethod.Radial; } }
// Recurse through the master branch and the newly placed symmetric branch, copying over part info. void UpdatePartAndChildren(Part SourcePart, Part UpdatePart, SymmetryMethod SymMethod) { if (null == SourcePart || null == UpdatePart) { // Null parts were passed to the updater. This should not happen, but just in case... return; } // Fix the bug where staging icons split from each other. UpdatePart.originalStage = SourcePart.originalStage; // This shouldn't be needed anymore. //if (0 == UpdatePart.symmetryCounterparts.Count) //{ // // This part has no mirrored parts. No need to copy the action groups. // return; //} CheckAndAddCounterpart(SourcePart, UpdatePart); PropagateCounterparts(SourcePart); // Propagates symmetry method throughout the branch. If it ever hits radial symmetry, the rest of the // branch needs to be listed as symmetry to prevent editor breakage with nested mirror symmetry. if (SourcePart.symMethod == SymmetryMethod.Radial) { SymMethod = SymmetryMethod.Radial; } // Debug.LogWarning("SymmMethod: " + SymMethod); SourcePart.symMethod = SymMethod; UpdatePart.symMethod = SymMethod; //if (SourcePart.Modules.Count != UpdatePart.Modules.Count) //{ // Debug.LogWarning("SAFix.onPartAttach(): Part Copy Error. Module Count Mismatch."); // return; //} // Loop through all the modules. Action groups are stored inside the PartModules for (int IndexModules = 0; IndexModules < UpdatePart.Modules.Count; IndexModules++) { if (SourcePart.Modules[IndexModules].Actions.Count != UpdatePart.Modules[IndexModules].Actions.Count) { Debug.LogWarning("SAFix.UpdatePartAndChildren(): Actions Mismatch in Module. Action copy aborted at Module: " + SourcePart.Modules[IndexModules].moduleName); return; } // Loop through all the Actions for this module. for (int IndexActions = 0; IndexActions < SourcePart.Modules[IndexModules].Actions.Count; IndexActions++) { // Copy the Action's triggers. // Debug.LogWarning("Module/Action " + UpdatePart.Modules[IndexModules].Actions[IndexActions].name); UpdatePart.Modules[IndexModules].Actions[IndexActions].actionGroup = SourcePart.Modules[IndexModules].Actions[IndexActions].actionGroup; } } for (int IndexChild = 0; IndexChild < UpdatePart.children.Count; IndexChild++) { // Go through all the children parts and copy the actions. UpdatePartAndChildren(SourcePart.children[IndexChild], UpdatePart.children[IndexChild], SymMethod); } } // UpdatePartAndChild
public void SendSymmetryMethodChange(SymmetryMethod method) { }
private void OnEditorSymmetryMethodChange(SymmetryMethod method) { NetworkWorker.fetch.SendSymmetryMethodChange(method); }
// Recurse through the master branch and the newly placed symmetric branch, copying over part info. void UpdatePartAndChildren(Part SourcePart, Part UpdatePart, SymmetryMethod SymMethod) { if (null == SourcePart || null == UpdatePart) { // Null parts were passed to the updater. This should not happen, but just in case... return; } // Fix the bug where staging icons split from each other. UpdatePart.originalStage = SourcePart.originalStage; // This shouldn't be needed anymore. if (0 == UpdatePart.symmetryCounterparts.Count) { // This part has no mirrored parts. No need to copy the action groups. return; } CheckAndAddCounterpart(SourcePart, UpdatePart); PropagateCounterparts(SourcePart); // Propagates symmetry method throughout the branch. If it ever hits radial symmetry, the rest of the // branch needs to be listed as symmetry to prevent editor breakage with nested mirror symmetry. if (SourcePart.symmetryCounterparts.Count > 1) { SymMethod = SymmetryMethod.Radial; } //if(SourcePart.symMethod == SymmetryMethod.Radial) //{ // SymMethod = SymmetryMethod.Radial; //} // Debug.LogWarning("SymmMethod: " + SymMethod); SourcePart.symMethod = SymMethod; UpdatePart.symMethod = SymMethod; if (SourcePart.Modules.Count != UpdatePart.Modules.Count) { Debug.LogError("SAFix.onPartAttach(): Part Copy Error. Module Count Mismatch."); return; } // Loop through all the modules. Action groups are stored inside the PartModules for (int IndexModules = 0; IndexModules < UpdatePart.Modules.Count; IndexModules++) { if (SourcePart.Modules[IndexModules].Actions.Count != UpdatePart.Modules[IndexModules].Actions.Count) { Debug.LogError("SAFix.UpdatePartAndChildren(): Actions Mismatch in Module. Action copy aborted at Module: " + SourcePart.Modules[IndexModules].moduleName); return; } // Loop through all the Actions for this module. for (int IndexActions = 0; IndexActions < SourcePart.Modules[IndexModules].Actions.Count; IndexActions++) { // Copy the Action's triggers. // Debug.LogWarning("Module/Action " + UpdatePart.Modules[IndexModules].Actions[IndexActions].name); UpdatePart.Modules[IndexModules].Actions[IndexActions].actionGroup = SourcePart.Modules[IndexModules].Actions[IndexActions].actionGroup; } if ("ModuleProceduralFairing" == SourcePart.Modules[IndexModules].moduleName) { Debug.Log("SymmetryActionFix: Fixing Procedural Fairing"); ModuleProceduralFairing MPFSource = (ModuleProceduralFairing)SourcePart.Modules[IndexModules]; ModuleProceduralFairing MPFUpdate = (ModuleProceduralFairing)UpdatePart.Modules[IndexModules]; if (MPFSource.xSections.Count != 0) { MPFUpdate.xSections.AddRange(MPFSource.xSections); MethodInfo MPFMethod = MPFUpdate.GetType().GetMethod("SpawnMeshes", BindingFlags.NonPublic | BindingFlags.Instance); if (MPFMethod != null) { MPFMethod.Invoke(MPFUpdate, new object[] { true }); } } } } for (int IndexChild = 0; IndexChild < UpdatePart.children.Count; IndexChild++) { // Go through all the children parts and copy the actions. UpdatePartAndChildren(SourcePart.children[IndexChild], UpdatePart.children[IndexChild], SymMethod); } } // UpdatePartAndChild