Esempio n. 1
0
        internal ModelVariant(StaticModel baseModel, ConfigNode variantNode)
        {
            origVariantNode = variantNode;
            model           = baseModel;

            variantNode.TryGetValue("name", ref name);

            variantNode.TryGetValue("newMeshName", ref newMeshName);
            variantNode.TryGetValue("deactivateTransforms", ref deactivateTransforms);
            //            variantNode.TryGetValue("activateTransforms", ref activateTransforms);

            //            transforms2Activate = actiateTransforms.Split(seperators, StringSplitOptions.RemoveEmptyEntries).ToList();
            String[] tmpList = deactivateTransforms.Split(seperators, StringSplitOptions.RemoveEmptyEntries);

            foreach (string value in tmpList)
            {
                transforms2Deactivate.Add(value.Trim());
            }


            model.hasVariants = true;

            foreach (ConfigNode tsNode in variantNode.GetNodes("TextureSet"))
            {
                //Log.Normal("found TextureSet:");
                if (!tsNode.HasValue("transforms"))
                {
                    continue;
                }
                TextureSet set = new TextureSet();
                tsNode.TryGetValue("color", ref set.newColor);
                tsNode.TryGetValue("texture", ref set.newTexture);
                set.targetTransforms = tsNode.GetValue("transforms").Split(seperators, StringSplitOptions.RemoveEmptyEntries).ToList();
                textureSets.Add(set);
            }
        }
Esempio n. 2
0
        internal static void WriteModelConfig(StaticModel model, ConfigNode cfgNode)
        {
            foreach (var modelsetting in ConfigUtil.modelFields)
            {
                try
                {
                    if (modelsetting.Value.GetValue(model) == null)
                    {
                        continue;
                    }

                    if (modelsetting.Key == "mesh")
                    {
                        continue;
                    }

                    if (cfgNode.HasValue(modelsetting.Key))
                    {
                        cfgNode.RemoveValue(modelsetting.Key);
                    }

                    switch (modelsetting.Value.FieldType.ToString())
                    {
                    case "System.String":
                        if (string.IsNullOrEmpty((string)modelsetting.Value.GetValue(model)))
                        {
                            continue;
                        }
                        cfgNode.AddValue(modelsetting.Key, (string)modelsetting.Value.GetValue(model));
                        break;

                    case "System.Int32":
                        if ((int)modelsetting.Value.GetValue(model) == 0)
                        {
                            continue;
                        }
                        cfgNode.AddValue(modelsetting.Key, (int)modelsetting.Value.GetValue(model));
                        break;

                    case "System.Single":
                        if ((float)modelsetting.Value.GetValue(model) == 0)
                        {
                            continue;
                        }
                        cfgNode.AddValue(modelsetting.Key, (float)modelsetting.Value.GetValue(model));
                        break;

                    case "System.Double":
                        if ((double)modelsetting.Value.GetValue(model) == 0)
                        {
                            continue;
                        }
                        cfgNode.AddValue(modelsetting.Key, (double)modelsetting.Value.GetValue(model));
                        break;

                    case "System.Boolean":
                        cfgNode.AddValue(modelsetting.Key, (bool)modelsetting.Value.GetValue(model));
                        break;

                    case "UnityEngine.Vector3":
                        cfgNode.AddValue(modelsetting.Key, (Vector3)modelsetting.Value.GetValue(model));
                        break;

                    case "UnityEngine.Vector3d":
                        cfgNode.AddValue(modelsetting.Key, (Vector3d)modelsetting.Value.GetValue(model));
                        break;

                    case "CelestialBody":
                        cfgNode.AddValue(modelsetting.Key, ((CelestialBody)modelsetting.Value.GetValue(model)).name);
                        break;
                    }
                }catch
                {
                    Log.UserError("error in writing modelconfig: " + model.name + " key: " + modelsetting.Key);
                }
            }
        }
Esempio n. 3
0
 internal static List <StaticInstance> GetInstancesFromModel(StaticModel model)
 {
     return((from obj in allStaticInstances where obj.model == model select obj).ToList());
 }