Beispiel #1
0
        MapType(string name, List <TextNode> nodes)
        {
            Name = name;

            var fields = TypeLoader.GetFields(this);

            foreach (var node in nodes)
            {
                switch (node.Key)
                {
                case nameof(TerrainGenerationBase):
                    TerrainGenerationBase = new TerrainGeneratorInfo(node.Convert <int>(), node.Children);

                    break;

                case nameof(NoiseMaps):
                    NoiseMaps = new NoiseMapInfo[node.Children.Count];

                    for (int i = 0; i < NoiseMaps.Length; i++)
                    {
                        var child = node.Children[i];
                        NoiseMaps[i] = new NoiseMapInfo(child.Convert <int>(), child.Children);
                    }

                    break;

                case nameof(PatrolPlacers):
                    PatrolPlacers = new PatrolPlacerInfo[node.Children.Count];

                    for (int i = 0; i < PatrolPlacers.Length; i++)
                    {
                        PatrolPlacers[i] = new PatrolPlacerInfo(node.Children[i].Children);
                    }

                    break;

                case nameof(WeatherEffects):
                    WeatherEffects = new WeatherEffect[node.Children.Count];

                    for (int i = 0; i < WeatherEffects.Length; i++)
                    {
                        WeatherEffects[i] = new WeatherEffect(node.Children[i].Children);
                    }

                    break;

                default:
                    TypeLoader.SetValue(this, fields, node);

                    break;
                }
            }

            if (TerrainGenerationBase == null)
            {
                throw new MissingNodeException(name, "BaseTerrainGeneration");
            }
        }
Beispiel #2
0
 MapType(string overridePiece, int wall, MPos customSize, Color ambient, MissionType[] missionTypes, ObjectiveType[] availableObjectives, int level, int fromLevel, int toLevel, TerrainGeneratorInfo baseTerrainGeneration, IMapGeneratorInfo[] generators, CPos spawnPoint, bool isSave, bool allowWeapons, string missionScript)
 {
     OverridePiece         = overridePiece;
     Wall                  = wall;
     CustomSize            = customSize;
     Ambient               = ambient;
     MissionTypes          = missionTypes;
     AvailableObjectives   = availableObjectives;
     Level                 = level;
     FromLevel             = fromLevel;
     ToLevel               = toLevel;
     TerrainGenerationBase = baseTerrainGeneration;
     Generators            = generators;
     SpawnPoint            = spawnPoint;
     IsSave                = isSave;
     AllowWeapons          = allowWeapons;
     MissionScript         = missionScript;
 }