/// <summary> /// Restore the currently selected modules' models, and restore their current texture-set selection /// Removes any existing models from special-named root transforms with no attempt at re-use /// </summary> private void restoreModels() { topDockModule.setupModel(getTopDockRoot(true), ModelOrientation.TOP); topModule.setupModel(getTopRoot(true), ModelOrientation.TOP); coreModule.setupModel(getCoreRoot(false), ModelOrientation.CENTRAL, true);//setup model on prefab part and don't touch it after that bottomModule.setupModel(getBottomRoot(true), ModelOrientation.BOTTOM); bottomDockModule.setupModel(getBottomDockRoot(true), ModelOrientation.BOTTOM); solarModule.enable(getSolarRoot(true), 0); topModule.enableTextureSet(currentTopTexture); coreModule.enableTextureSet(currentCoreTexture); bottomModule.enableTextureSet(currentBottomTexture); //control transforms need to exist during part initialization //else things will explode if one of those transforms is the reference transform when a vessel is reloaded //so create them on prefab and restore on other instances if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) { Transform modelRoot = part.transform.FindRecursive("model"); topDockTransform = new GameObject(topDockName).transform; topDockTransform.NestToParent(modelRoot); topDockTransform.Rotate(-90, 0, 0, Space.Self); topControlTransform = new GameObject(topDockName + "Control").transform; topControlTransform.NestToParent(modelRoot); bottomDockTransform = new GameObject(bottomDockName).transform; bottomDockTransform.NestToParent(modelRoot); bottomDockTransform.Rotate(90, 0, 0, Space.Self); bottomControlTransform = new GameObject(bottomDockName + "Control").transform; bottomControlTransform.NestToParent(modelRoot); bottomControlTransform.Rotate(180, 0, 0, Space.Self); } else { topDockTransform = part.transform.FindRecursive(topDockName); topControlTransform = part.transform.FindRecursive(topDockName + "Control"); bottomDockTransform = part.transform.FindRecursive(bottomDockName); bottomControlTransform = part.transform.FindRecursive(bottomDockName + "Control"); } SSTUStockInterop.updatePartHighlighting(part); }
/// <summary> /// create the models, and restore them to their saved/default state /// </summary> private void initializeModels() { Transform baseTransform = part.transform.FindRecursive("model").FindOrCreate(baseTransformName); baseTransform.NestToParent(part.transform.FindRecursive("model")); targetTransform = baseTransform.FindOrCreate(targetTransformName); targetTransform.NestToParent(baseTransform); targetTransform.rotation = Quaternion.LookRotation(part.transform.up, part.transform.forward); foreach (ParachuteModelData droge in drogueChuteModules) { droge.setupModel(part, baseTransform, targetTransform); } foreach (ParachuteModelData main in mainChuteModules) { main.setupModel(part, baseTransform, targetTransform); } hasDrogueChute = drogueChuteModules.Length > 0; }