Example #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;
        }
Example #2
0
        public PanelData(ModelSolarData data, Transform root)
        {
            int len = data.pivotDefinitions.Length;

            pivots = new SolarPivotData[len];
            Transform[] pivotTransforms;
            Transform   pivotTransform;

            ModelSolarData.ModelSolarDataPivot pivotData;
            for (int i = 0; i < len; i++)
            {
                pivotData       = data.pivotDefinitions[i];
                pivotTransforms = root.FindChildren(pivotData.transformName);
                pivotTransform  = pivotTransforms[pivotData.pivotIndex];
                pivots[i]       = new SolarPivotData(pivotTransform, pivotData.pivotSpeed, pivotData.sunAxis, pivotData.rotAxis);
            }

            len         = data.suncatcherDefinitions.Length;
            suncatchers = new SuncatcherData[len];
            for (int i = 0; i < len; i++)
            {
                suncatchers[i] = new SuncatcherData(data.suncatcherDefinitions[i], root);
            }
        }