public ModelLayoutData getLayout(string name) { ModelLayoutData mld = layouts.Find(m => m.name == name); if (mld == null) { error("ERROR: Could not locate layout for name: " + name); } return(mld); }
public static ModelLayoutData[] findLayouts(string[] names) { int len = names.Length; ModelLayoutData[] mlds = new ModelLayoutData[len]; for (int i = 0; i < len; i++) { mlds[i] = findLayout(names[i]); } return(mlds); }
/// <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>(); ROTModelDefinition 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 = ROTModelData.getModelDefinition(groupedNames[k]); layoutDataList.AddRange(ROTModelLayout.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()); }
public static void load() { log("Loading Model Layouts"); layouts.Clear(); ConfigNode[] layoutNodes = GameDatabase.Instance.GetConfigNodes("ROT_MODEL_LAYOUT"); int len = layoutNodes.Length; for (int i = 0; i < len; i++) { ModelLayoutData mld = new ModelLayoutData(layoutNodes[i]); layouts.Add(mld.name, mld); } loaded = true; log("Finished loading Model Layouts"); }