Ejemplo n.º 1
0
        private void initialize()
        {
            if (!moduleIsEnabled)
            {
                //TODO -- UI disabling
                return;
            }
            if (initialized)
            {
                return;
            }
            initialized = true;
            AnimationData  animData = null;
            ModelSolarData msd      = null;
            ConfigNode     node     = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            if (node.HasValue("modelDefinition"))
            {
                ModelDefinition def = SSTUModelData.getModelDefinition(node.GetStringValue("modelDefinition"));
                if (def == null)
                {
                    MonoBehaviour.print("Could not locate model definition: " + node.GetStringValue("modelDefinition") + " for solar data");
                }
                else
                {
                    animData = def.animationData;
                    msd      = def.solarModuleData;
                }
            }
            //allow local override of animation data
            if (node.HasNode("ANIMATIONDATA"))
            {
                animData = new AnimationData(node.GetNode("ANIMATIONDATA"));
            }
            if (node.HasNode("SOLARDATA"))
            {
                msd = new ModelSolarData(node.GetNode("SOLARDATA"));
            }

            animationModule = new AnimationModule(part, this, nameof(persistentState), null, nameof(extendEvent), nameof(retractEvent));
            animationModule.getSymmetryModule = m => ((SSTUSolarPanelDeployable)m).animationModule;
            animationModule.setupAnimations(animData, part.transform.FindRecursive("model"), animationLayer);

            solarModule = new SolarModule(part, this, animationModule, Fields[nameof(solarPersistentData)], Fields[nameof(guiStatus)]);
            solarModule.getSymmetryModule = m => ((SSTUSolarPanelDeployable)m).solarModule;
            solarModule.setupSolarPanelData(new ModelSolarData[] { msd }, new Transform[] { part.transform.FindRecursive("model") });
            nominalSolarOutput = solarModule.standardPotentialOutput;
        }