Пример #1
0
            public void SetForestmapPath(string path, string projectDir = null)
            {
                var finalPath = ForestmapPath(path, projectDir);

                if (!string.IsNullOrEmpty(finalPath))
                {
                    Forestmap = new ImageMapFloat(finalPath);
                    if (!Forestmap.LoadSourceImage() || !Forestmap.CreateMap())
                    {
                        Forestmap = null;
                    }
                }
                else
                {
                    Forestmap = null;
                }
            }
Пример #2
0
            public void SetFlatmapPath(string path, string projectDir = null)
            {
                var finalPath = FlatmapPath(path, projectDir);

                if (!string.IsNullOrEmpty(finalPath) && !UseRoughInvertedAsFlat)
                {
                    Flatmap = new ImageMapFloat(finalPath);
                    if (!Flatmap.LoadSourceImage() || !Flatmap.CreateMap())
                    {
                        Flatmap = null;
                    }
                }
                else
                {
                    Flatmap = null;
                }
            }
Пример #3
0
            private void InitSettings(long worldUId, bool enabled)
            {
                Log($"Init settings for new world");

                Version = LatestVersion;

                WorldUId = worldUId;

                EnabledForThisWorld = enabled;

                if (EnabledForThisWorld)
                {
                    ContinentSize = ConfigContinentSize.Value;
                    SeaLevel      = ConfigSeaLevelAdjustment.Value;

                    var heightmapPath = HeightmapPath(ConfigHeightmapFile.Value, ConfigMapSourceDir.Value);
                    if (!string.IsNullOrEmpty(heightmapPath))
                    {
                        HeightmapAmount      = ConfigHeightmapAmount.Value;
                        HeightmapBlend       = ConfigHeightmapBlend.Value;
                        HeightmapAdd         = ConfigHeightmapAdd.Value;
                        HeightmapMask        = ConfigHeightmapMask.Value;
                        HeightmapOverrideAll = ConfigHeightmapOverrideAll.Value;

                        Heightmap = new ImageMapFloat(heightmapPath);
                        if (!Heightmap.LoadSourceImage() || !Heightmap.CreateMap())
                        {
                            Heightmap = null;
                        }
                    }

                    BaseHeightNoise = NoiseStackSettings.Default();

                    var biomemapPath = BiomemapPath(ConfigBiomemapFile.Value, ConfigMapSourceDir.Value);
                    if (!string.IsNullOrEmpty(biomemapPath))
                    {
                        Biomemap = new ImageMapBiome(biomemapPath);
                        if (!Biomemap.LoadSourceImage() || !Biomemap.CreateMap())
                        {
                            Biomemap = null;
                        }
                    }

                    OceanChannelsEnabled = ConfigOceanChannelsEnabled.Value;
                    RiversEnabled        = ConfigRiversEnabled.Value;

                    ForestScaleFactor            = ConfigForestScale.Value;
                    ForestAmount                 = ConfigForestAmount.Value;
                    ForestFactorOverrideAllTrees = ConfigForestFactorOverrideAllTrees.Value;

                    OverrideStartPosition = ConfigOverrideStartPosition.Value;
                    StartPositionX        = ConfigStartPositionX.Value;
                    StartPositionY        = ConfigStartPositionY.Value;

                    var spawnmapPath = SpawnmapPath(ConfigSpawnmapFile.Value, ConfigMapSourceDir.Value);
                    if (!string.IsNullOrEmpty(spawnmapPath))
                    {
                        Spawnmap = new ImageMapSpawn(spawnmapPath);
                        if (!Spawnmap.LoadSourceImage() || !Spawnmap.CreateMap())
                        {
                            Spawnmap = null;
                        }
                    }

                    var roughmapPath = RoughmapPath(ConfigRoughmapFile.Value, ConfigMapSourceDir.Value);
                    if (!string.IsNullOrEmpty(roughmapPath))
                    {
                        RoughmapBlend = ConfigRoughmapBlend.Value;

                        Roughmap = new ImageMapFloat(roughmapPath);
                        if (!Roughmap.LoadSourceImage() || !Roughmap.CreateMap())
                        {
                            Roughmap = null;
                        }
                    }

                    var forestmapPath = ForestmapPath(ConfigForestmapFile.Value, ConfigMapSourceDir.Value);
                    if (!string.IsNullOrEmpty(forestmapPath))
                    {
                        ForestmapAdd      = ConfigForestmapAdd.Value;
                        ForestmapMultiply = ConfigForestmapMultiply.Value;

                        Forestmap = new ImageMapFloat(forestmapPath);
                        if (!Forestmap.LoadSourceImage() || !Forestmap.CreateMap())
                        {
                            Forestmap = null;
                        }
                    }

                    MapEdgeDropoff           = ConfigMapEdgeDropoff.Value;
                    MountainsAllowedAtCenter = ConfigMountainsAllowedAtCenter.Value;
                }
            }
Пример #4
0
            private void Deserialize(ZPackage pkg)
            {
                Version = pkg.ReadInt();
                if (Version > LatestVersion)
                {
                    LogError($"BetterContinents mod is out of date: world expects config version {Version}, mod config version is {LatestVersion}");
                    throw new Exception($"BetterContinents mod is out of date: world expects config version {Version}, mod config version is {LatestVersion}");
                }

                WorldUId = pkg.ReadLong();

                EnabledForThisWorld = pkg.ReadBool();

                if (EnabledForThisWorld)
                {
                    GlobalScale        = pkg.ReadSingle();
                    MountainsAmount    = pkg.ReadSingle();
                    SeaLevelAdjustment = pkg.ReadSingle();

                    MaxRidgeHeight           = pkg.ReadSingle();
                    RidgeScale               = pkg.ReadSingle();
                    RidgeBlendSigmoidB       = pkg.ReadSingle();
                    RidgeBlendSigmoidXOffset = pkg.ReadSingle();

                    var heightmapFilePath = pkg.ReadString();
                    if (!string.IsNullOrEmpty(heightmapFilePath))
                    {
                        Heightmap = new ImageMapFloat(heightmapFilePath, pkg.ReadByteArray());
                        if (Version <= 4 && !Heightmap.CreateMapLegacy() ||
                            Version > 4 && !Heightmap.CreateMap())
                        {
                            Heightmap = null;
                        }
                        HeightmapAmount = pkg.ReadSingle();
                        HeightmapBlend  = pkg.ReadSingle();
                        HeightmapAdd    = pkg.ReadSingle();
                    }

                    OceanChannelsEnabled = pkg.ReadBool();

                    if (Version >= 2)
                    {
                        RiversEnabled = pkg.ReadBool();
                        //LakesEnabled = pkg.ReadBool();

                        var biomemapFilePath = pkg.ReadString();
                        if (!string.IsNullOrEmpty(biomemapFilePath))
                        {
                            Biomemap = new ImageMapBiome(biomemapFilePath, pkg.ReadByteArray());
                            if (!Biomemap.CreateMap())
                            {
                                Biomemap = null;
                            }
                        }

                        ForestScale        = pkg.ReadSingle();
                        ForestAmountOffset = pkg.ReadSingle();

                        OverrideStartPosition = pkg.ReadBool();
                        StartPositionX        = pkg.ReadSingle();
                        StartPositionY        = pkg.ReadSingle();
                    }
                    else
                    {
                        RiversEnabled         = true;
                        ForestScale           = 1;
                        ForestAmountOffset    = 0;
                        OverrideStartPosition = false;
                        StartPositionX        = 0;
                        StartPositionY        = 0;
                        //LakesEnabled = true;
                    }

                    // Version 3
                    if (Version >= 3)
                    {
                        var spawnmapFilePath = pkg.ReadString();
                        if (!string.IsNullOrEmpty(spawnmapFilePath))
                        {
                            Spawnmap = new ImageMapSpawn(spawnmapFilePath, pkg);
                        }
                    }

                    // Version 4
                    // (nothing)

                    // Version 5
                    if (Version >= 5)
                    {
                        var roughmapFilePath = pkg.ReadString();
                        if (!string.IsNullOrEmpty(roughmapFilePath))
                        {
                            Roughmap = new ImageMapFloat(roughmapFilePath, pkg.ReadByteArray());
                            if (!Roughmap.CreateMap())
                            {
                                Roughmap = null;
                            }
                            RoughmapBlend = pkg.ReadSingle();
                        }

                        UseRoughInvertedAsFlat = pkg.ReadBool();
                        FlatmapBlend           = pkg.ReadSingle();
                        if (!UseRoughInvertedAsFlat)
                        {
                            var flatmapFilePath = pkg.ReadString();
                            if (!string.IsNullOrEmpty(flatmapFilePath))
                            {
                                Flatmap = new ImageMapFloat(flatmapFilePath, pkg.ReadByteArray());
                                if (!Flatmap.CreateMap())
                                {
                                    Flatmap = null;
                                }
                            }
                        }

                        var forestmapFilePath = pkg.ReadString();
                        if (!string.IsNullOrEmpty(forestmapFilePath))
                        {
                            Forestmap = new ImageMapFloat(forestmapFilePath, pkg.ReadByteArray());
                            if (!Forestmap.CreateMap())
                            {
                                Forestmap = null;
                            }
                            ForestmapMultiply = pkg.ReadSingle();
                            ForestmapAdd      = pkg.ReadSingle();
                        }

                        DisableMapEdgeDropoff        = pkg.ReadBool();
                        MountainsAllowedAtCenter     = pkg.ReadBool();
                        ForestFactorOverrideAllTrees = pkg.ReadBool();
                    }

                    // Version 6
                    if (Version >= 6)
                    {
                        HeightmapOverrideAll = pkg.ReadBool();
                        HeightmapMask        = pkg.ReadSingle();
                    }
                    else
                    {
                        HeightmapOverrideAll = false;
                        HeightmapMask        = 0;
                    }
                }
            }
Пример #5
0
 public void DisableForestmap() => Forestmap = null;
Пример #6
0
 public void DisableFlatmap() => Flatmap = null;
Пример #7
0
 public void DisableRoughmap() => Roughmap = null;
Пример #8
0
 public void DisableHeightmap() => Heightmap = null;
Пример #9
0
            private void InitSettings(long worldUId, bool enabled)
            {
                Log($"Init settings for new world");

                Version = LatestVersion;

                WorldUId = worldUId;

                EnabledForThisWorld = enabled;

                if (EnabledForThisWorld)
                {
                    SetContinentSize(ConfigContinentSize.Value);
                    SetMountainsAmount(ConfigMountainsAmount.Value);
                    SetSeaLevelAdjustment(ConfigSeaLevelAdjustment.Value);

                    SetMaxRidgeHeight(ConfigMaxRidgeHeight.Value);
                    SetRidgeSize(ConfigRidgeSize.Value);
                    SetRidgeBlend(ConfigRidgeBlend.Value);
                    SetRidgeAmount(ConfigRidgeAmount.Value);

                    var heightmapPath = HeightmapPath(ConfigHeightmapFile.Value, ConfigMapSourceDir.Value);
                    if (!string.IsNullOrEmpty(heightmapPath))
                    {
                        SetHeightmapAmount(ConfigHeightmapAmount.Value);
                        SetHeightmapBlend(ConfigHeightmapBlend.Value);
                        SetHeightmapAdd(ConfigHeightmapAdd.Value);
                        SetHeightmapMask(ConfigHeightmapMask.Value);
                        SetHeightmapOverrideAll(ConfigHeightmapOverrideAll.Value);

                        Heightmap = new ImageMapFloat(heightmapPath);
                        if (!Heightmap.LoadSourceImage() || !Heightmap.CreateMap())
                        {
                            Heightmap = null;
                        }
                    }

                    var biomemapPath = BiomemapPath(ConfigBiomemapFile.Value, ConfigMapSourceDir.Value);
                    if (!string.IsNullOrEmpty(biomemapPath))
                    {
                        Biomemap = new ImageMapBiome(biomemapPath);
                        if (!Biomemap.LoadSourceImage() || !Biomemap.CreateMap())
                        {
                            Biomemap = null;
                        }
                    }

                    SetOceanChannelsEnabled(ConfigOceanChannelsEnabled.Value);
                    SetRiversEnabled(ConfigRiversEnabled.Value);

                    SetForestScale(ConfigForestScale.Value);
                    SetForestAmount(ConfigForestAmount.Value);
                    SetForestFactorOverrideAllTrees(ConfigForestFactorOverrideAllTrees.Value);

                    SetOverrideStartPosition(ConfigOverrideStartPosition.Value);
                    SetStartPositionX(ConfigStartPositionX.Value);
                    SetStartPositionY(ConfigStartPositionY.Value);
                    //LakesEnabled = ConfigLakesEnabled.Value;

                    var spawnmapPath = SpawnmapPath(ConfigSpawnmapFile.Value, ConfigMapSourceDir.Value);
                    if (!string.IsNullOrEmpty(spawnmapPath))
                    {
                        Spawnmap = new ImageMapSpawn(spawnmapPath);
                        if (!Spawnmap.LoadSourceImage() || !Spawnmap.CreateMap())
                        {
                            Spawnmap = null;
                        }
                    }

                    var roughmapPath = RoughmapPath(ConfigRoughmapFile.Value, ConfigMapSourceDir.Value);
                    if (!string.IsNullOrEmpty(roughmapPath))
                    {
                        SetRoughmapBlend(ConfigRoughmapBlend.Value);

                        Roughmap = new ImageMapFloat(roughmapPath);
                        if (!Roughmap.LoadSourceImage() || !Roughmap.CreateMap())
                        {
                            Roughmap = null;
                        }
                    }

                    var flatmapPath = ConfigUseRoughInvertedForFlat.Value ? null : FlatmapPath(ConfigFlatmapFile.Value, ConfigMapSourceDir.Value);
                    if (ConfigUseRoughInvertedForFlat.Value && Roughmap != null ||
                        !ConfigUseRoughInvertedForFlat.Value && !string.IsNullOrEmpty(flatmapPath))
                    {
                        SetUseRoughInvertedForFlat(ConfigUseRoughInvertedForFlat.Value);
                        SetFlatmapBlend(ConfigFlatmapBlend.Value);
                        if (!string.IsNullOrEmpty(flatmapPath) && !UseRoughInvertedAsFlat)
                        {
                            Flatmap = new ImageMapFloat(flatmapPath);
                            if (!Flatmap.LoadSourceImage() || !Flatmap.CreateMap())
                            {
                                Flatmap = null;
                            }
                        }
                    }

                    var forestmapPath = ForestmapPath(ConfigForestmapFile.Value, ConfigMapSourceDir.Value);
                    if (!string.IsNullOrEmpty(forestmapPath))
                    {
                        SetForestmapAdd(ConfigForestmapAdd.Value);
                        SetForestmapMultiply(ConfigForestmapMultiply.Value);

                        Forestmap = new ImageMapFloat(forestmapPath);
                        if (!Forestmap.LoadSourceImage() || !Forestmap.CreateMap())
                        {
                            Forestmap = null;
                        }
                    }

                    SetMapEdgeDropoff(ConfigMapEdgeDropoff.Value);
                    SetMountainsAllowedAtCenter(ConfigMountainsAllowedAtCenter.Value);
                }
            }