public SolarData(ConfigNode node) { name = node.GetStringValue("name"); modelName = node.GetStringValue("modelName", name); def = SSTUModelData.getModelDefinition(modelName); ConfigNode solarNode = def.configNode.GetNode("SOLARDATA"); //loaded from SOLARDATA from model def animationName = solarNode.GetStringValue("animationName"); pivotNames = solarNode.GetStringValue("pivotNames"); secPivotNames = solarNode.GetStringValue("secPivotNames"); sunNames = solarNode.GetStringValue("sunNames"); panelsEnabled = solarNode.GetBoolValue("enabled"); sunAxis = solarNode.GetStringValue("sunAxis", SSTUSolarPanelDeployable.Axis.ZPlus.ToString()); //loaded from SOLARDATA with option of per-model override (energy, tech-unlock-upgrade-name) upgradeName = node.GetStringValue("upgrade", solarNode.GetStringValue("upgrade")); energy = node.GetFloatValue("energy", solarNode.GetFloatValue("energy"));//allow local override of energy ConfigNode[] posNodes = node.GetNodes("POSITION"); int len = posNodes.Length; positions = new SolarPosition[len]; for (int i = 0; i < len; i++) { positions[i] = new SolarPosition(posNodes[i]); } }
public ModelData(ConfigNode node) { name = node.GetStringValue("name"); modelDefinition = SSTUModelData.getModelDefinition(name); if (modelDefinition == null) { MonoBehaviour.print("ERROR: Could not locate model data for name: " + name); } volume = node.GetFloatValue("volume", modelDefinition.volume); minVerticalScale = node.GetFloatValue("minVerticalScale", 1f); maxVerticalScale = node.GetFloatValue("maxVerticalScale", 1f); }
public ModelData(String name) { this.name = name; modelDefinition = SSTUModelData.getModelDefinition(name); if (modelDefinition == null) { MonoBehaviour.print("ERROR: Could not locate model definition data for name: " + name); } currentDiameter = modelDefinition.diameter; currentHeight = modelDefinition.height; volume = modelDefinition.volume; mass = modelDefinition.mass; cost = modelDefinition.cost; }
/// <summary> /// Create a group of model definition layout sets. Loads the model definitions + their supported layout configurations. /// </summary> /// <param name="nodes"></param> /// <returns></returns> public static ModelDefinitionLayoutOptions[] getModelDefinitions(ConfigNode[] nodes) { int len = nodes.Length; List <ModelDefinitionLayoutOptions> options = new List <ModelDefinitionLayoutOptions>(); List <ModelLayoutData> layoutDataList = new List <ModelLayoutData>(); ModelDefinition def; string[] groupedNames; string[] groupedLayouts; int len2; for (int i = 0; i < len; i++) { //because configNode.ToString() reverses the order of values, and model def layouts are always loaded from string-cached config nodes //we need to reverse the order of the model and layout names during parsing groupedNames = nodes[i].GetStringValues("model"); groupedLayouts = nodes[i].GetStringValues("layout", new string[] { "default" }); len2 = groupedNames.Length; for (int k = 0; k < len2; k++) { def = SSTUModelData.getModelDefinition(groupedNames[k]); layoutDataList.AddRange(ModelLayout.findLayouts(groupedLayouts)); if (nodes[i].HasValue("position") || nodes[i].HasValue("rotation") || nodes[i].HasValue("scale")) { Vector3 pos = nodes[i].GetVector3("position", Vector3.zero); Vector3 scale = nodes[i].GetVector3("scale", Vector3.one); Vector3 rot = nodes[i].GetVector3("rotation", Vector3.zero); ModelPositionData mpd = new ModelPositionData(pos, scale, rot); ModelLayoutData custom = new ModelLayoutData("default", new ModelPositionData[] { mpd }); if (layoutDataList.Exists(m => m.name == "default")) { ModelLayoutData del = layoutDataList.Find(m => m.name == "default"); layoutDataList.Remove(del); } layoutDataList.Add(custom); } if (def == null) { error("Model definition was null for name: " + groupedNames[k] + ". Skipping definition during loading of part"); } else { options.Add(new ModelDefinitionLayoutOptions(def, layoutDataList.ToArray())); } layoutDataList.Clear(); } } return(options.ToArray()); }
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; }
public ModelData(ConfigNode node) { name = node.GetStringValue("name"); modelDefinition = SSTUModelData.getModelDefinition(name); if (modelDefinition == null) { MonoBehaviour.print("ERROR: Could not locate model data for name: " + name); } currentDiameter = modelDefinition.diameter; currentHeight = modelDefinition.height; volume = node.GetFloatValue("volume", modelDefinition.volume); mass = node.GetFloatValue("mass", modelDefinition.mass); cost = node.GetFloatValue("cost", modelDefinition.cost); minVerticalScale = node.GetFloatValue("minVerticalScale", 1f); maxVerticalScale = node.GetFloatValue("maxVerticalScale", 1f); baseScale = node.GetFloatValue("scale", baseScale); }
public ModelSwitchData(ConfigNode node, Part owner, ModelSwitchGroup group) { name = node.GetStringValue("name"); modelName = node.GetStringValue("modelName", name); groupName = node.GetStringValue("group", groupName); containerIndex = node.GetIntValue("containerIndex", 0); localPosition = node.GetVector3("localPosition", Vector3.zero); localRotation = node.GetVector3("localRotation", Vector3.zero); scale = node.GetFloatValue("scale", scale); nodes = ModelNodeData.load(node.GetStringValues("node")); suppressNode = nodes.Length > 0; modelDefinition = SSTUModelData.getModelDefinition(modelName); if (modelDefinition == null) { throw new NullReferenceException("Could not locate model data for name: " + modelName + " :: " + name); } this.part = owner; this.group = group; this.group.add(this); }
public SSTUEngineLayout(ConfigNode node) { name = node.GetStringValue("name"); mountSizeMult = node.GetFloatValue("mountSizeMult", mountSizeMult); defaultUpperStageMount = node.GetStringValue("defaultUpperStageMount", defaultUpperStageMount); defaultLowerStageMount = node.GetStringValue("defaultLowerStageMount", defaultLowerStageMount); ConfigNode[] posNodes = node.GetNodes("POSITION"); int len = posNodes.Length; for (int i = 0; i < len; i++) { positions.Add(new SSTUEnginePosition(posNodes[i])); } ConfigNode[] mountNodes = node.GetNodes("MOUNT"); len = mountNodes.Length; List <SSTUEngineLayoutMountOption> mountOptionsList = new List <SSTUEngineLayoutMountOption>(); string mountName; ModelDefinition md; for (int i = 0; i < len; i++) { mountName = mountNodes[i].GetStringValue("name"); md = SSTUModelData.getModelDefinition(mountName); if (md != null) { mountOptionsList.Add(new SSTUEngineLayoutMountOption(mountNodes[i])); } else { MonoBehaviour.print("ERROR: Could not locate mount model data for name: " + mountName + " -- please check your configs for errors."); } } mountOptions = mountOptionsList.ToArray(); }