فهرست منبع

add day-night cycle

Kolja Strohm 1 سال پیش
والد
کامیت
674557b8cd

+ 7 - 9
FactoryCraft/BlockType.cpp

@@ -120,17 +120,15 @@ void BlockType::createSuperBlock(Block* zBlock, Item* zItem) const
 void BlockType::createSuperItem(Block* zBlock, Item* zItem) const
 {
     BasicBlockItem* item = dynamic_cast<BasicBlockItem*>(zItem);
-    if (!item)
+    if (item)
     {
-        throw "BlockType::createSuperItem was called with an item witch was "
-              "not an instance of BasicBlockItem";
+        item->transparent = zBlock->transparent;
+        item->passable = zBlock->passable;
+        item->hardness = zBlock->hardness;
+        item->speedModifier = zBlock->speedModifier;
+        item->toolId = zBlock->zTool ? zBlock->zTool->getId() : -1;
+        item->interactable = zBlock->interactable;
     }
-    item->transparent = zBlock->transparent;
-    item->passable = zBlock->passable;
-    item->hardness = zBlock->hardness;
-    item->speedModifier = zBlock->speedModifier;
-    item->toolId = zBlock->zTool ? zBlock->zTool->getId() : -1;
-    item->interactable = zBlock->interactable;
 }
 
 Framework::Text BlockType::getTargetUIML() const

+ 11 - 1
FactoryCraft/Chunk.cpp

@@ -121,6 +121,7 @@ void Chunk::sendLightToClient(Framework::StreamWriter* zWriter)
                             if (x >= 0 && x < CHUNK_SIZE && y >= 0
                                 && y < CHUNK_SIZE)
                             {
+                                cs.lock();
                                 if (i < 4 && zNeighbours[i])
                                 {
                                     Vec3<int> offset
@@ -130,12 +131,13 @@ void Chunk::sendLightToClient(Framework::StreamWriter* zWriter)
                                                  + (pos.y - offset.y))
                                                * WORLD_HEIGHT
                                            + (pos.z - offset.z);
-                                    int type = zNeighbours[i]->blockIds[bi];
+                                     int type = zNeighbours[i]->blockIds[bi];
                                     needSend
                                         |= StaticRegistry<BlockType>::INSTANCE
                                                .zElement(type)
                                                ->doesNeedClientInstance();
                                 }
+                                cs.unlock();
                             }
                         }
                         if (needSend) break;
@@ -178,6 +180,7 @@ void Chunk::sendLightToClient(Framework::StreamWriter* zWriter)
                             dir = getDirectionIndex(SOUTH);
                             index = (x * CHUNK_SIZE) * WORLD_HEIGHT + z;
                         }
+                        cs.lock();
                         if (zNeighbours[dir])
                         {
                             int i = -1;
@@ -190,6 +193,7 @@ void Chunk::sendLightToClient(Framework::StreamWriter* zWriter)
                                         + index * 6),
                                 6);
                         }
+                        cs.unlock();
                     }
                 }
             }
@@ -673,6 +677,7 @@ void Chunk::sendBlockInfo(Framework::Vec3<int> location)
     message->addressChunck(this);
     message->setMessage(msg, 9);
     notifyObservers(message);
+    cs.lock();
     for (int i = 0; i < 6; i++)
     {
         Direction d = getDirectionFromIndex(i);
@@ -697,10 +702,12 @@ void Chunk::sendBlockInfo(Framework::Vec3<int> location)
             notifyObservers(msg);
         }
     }
+    cs.unlock();
 }
 
 void Chunk::setNeighbor(Direction dir, Chunk* zChunk)
 {
+    cs.lock();
     int dirIndex = getDirectionIndex(dir);
     Chunk* old = zNeighbours[dirIndex];
     zNeighbours[dirIndex] = zChunk;
@@ -779,6 +786,7 @@ void Chunk::setNeighbor(Direction dir, Chunk* zChunk)
             }
         }
     }
+    cs.unlock();
 }
 
 void Chunk::load(Framework::StreamReader* zReader)
@@ -960,6 +968,7 @@ Framework::Vec3<int> Chunk::getMax() const
 void Chunk::prepareRemove()
 {
     added = 0;
+    cs.lock();
     for (int i = 0; i < 4; i++)
     {
         if (zNeighbours[i])
@@ -969,6 +978,7 @@ void Chunk::prepareRemove()
             zNeighbours[i] = 0;
         }
     }
+    cs.unlock();
 }
 
 void Chunk::setAdded()

+ 2 - 1
FactoryCraft/Constants.h

@@ -11,4 +11,5 @@
 #define ITEM_CACHE_SIZE          256
 #define DEFAULT_VIEW_DISTANCE    5
 #define MAX_SURFACE_HEIGHT       50
-#define VARIABLE_SURFACE_PART    0.5f
+#define VARIABLE_SURFACE_PART    0.5f
+#define MAX_TICKS_PER_SECOND     20

+ 54 - 3
FactoryCraft/Dimension.cpp

@@ -15,15 +15,20 @@ Dimension::Dimension(int id)
       chunks(new RCTrie<Chunk>()),
       entities(new RCArray<Entity>()),
       map(new DimensionMap(id)),
-      stop(0)
+      stop(0),
+      currentDayTime(0.0),
+      nightDuration(0.0),
+      nightTransitionDuration(0.0),
+      dayDuration(1000.0)
 {
     Datei d;
     d.setDatei(
-        Game::INSTANCE->getWorldDirectory() + "/dim/" + Text(id) + "/nst.id");
+        Game::INSTANCE->getWorldDirectory() + "/dim/" + Text(id) + "/meta.dim");
     if (d.existiert())
     {
         d.open(Datei::Style::lesen);
         d.lese((char*)&nextStructureId, 8);
+        d.lese((char*)&currentDayTime, 8);
         d.close();
     }
     start();
@@ -36,6 +41,14 @@ Dimension::~Dimension()
     map->release();
 }
 
+void Dimension::configureDayNightCyncle(
+    double nightDuration, double nightTransitionDuration, double dayDuration)
+{
+    this->nightDuration = nightDuration;
+    this->nightTransitionDuration = nightTransitionDuration;
+    this->dayDuration = dayDuration;
+}
+
 void Dimension::api(Framework::InMemoryBuffer* zRequest,
     NetworkMessage* zResponse,
     Entity* zSource)
@@ -95,6 +108,13 @@ void Dimension::api(Framework::InMemoryBuffer* zRequest,
 
 void Dimension::tickEntities()
 {
+    this->currentDayTime += 1.0 / MAX_TICKS_PER_SECOND;
+    if (this->currentDayTime
+        > dayDuration + nightDuration + nightTransitionDuration * 2)
+    {
+        this->currentDayTime
+            = dayDuration + nightDuration + nightTransitionDuration * 2;
+    }
     for (auto entity : *entities)
     {
         if (!entity->isRemoved()
@@ -498,10 +518,11 @@ void Dimension::save(Text worldDir) const
 {
     Datei d;
     d.setDatei(Game::INSTANCE->getWorldDirectory() + "/dim/" + Text(dimensionId)
-               + "/nst.id");
+               + "/meta.dim");
     d.erstellen();
     d.open(Datei::Style::schreiben);
     d.schreibe((char*)&nextStructureId, 8);
+    d.schreibe((char*)&currentDayTime, 8);
     d.close();
     for (auto chunk = chunkList.begin(); chunk; chunk++)
     {
@@ -910,4 +931,34 @@ void Dimension::updateMap(int x, int y, int height)
 int Dimension::getChunkCount()
 {
     return chunkList.getEintragAnzahl();
+}
+
+double Dimension::getCurrentDayTime() const
+{
+    return currentDayTime;
+}
+
+double Dimension::getNightDuration() const
+{
+    return nightDuration;
+}
+
+double Dimension::getNightTransitionDuration() const
+{
+    return nightTransitionDuration;
+}
+
+double Dimension::getDayDuration() const
+{
+    return dayDuration;
+}
+
+DimensionFactory::DimensionFactory(int dimensionId)
+    : ReferenceCounter(),
+      dimensionId(dimensionId)
+{}
+
+int DimensionFactory::getDimensionId() const
+{
+    return dimensionId;
 }

+ 30 - 0
FactoryCraft/Dimension.h

@@ -9,6 +9,12 @@
 #include "MultiblockStructure.h"
 #include "NetworkMessage.h"
 
+class DimensionEnum
+{
+public:
+    static const int OVERWORLD = 0;
+};
+
 struct RequestQueue
 {
     Framework::InMemoryBuffer* request;
@@ -38,6 +44,10 @@ private:
     Framework::RCArray<MultiblockStructure> structures;
     DimensionMap* map;
     bool stop;
+    double currentDayTime;
+    double nightDuration;
+    double nightTransitionDuration;
+    double dayDuration;
 
     void getAddrOf(Framework::Punkt cPos, char* addr) const;
     void getAddrOfWorld(Framework::Punkt wPos, char* addr) const;
@@ -47,6 +57,9 @@ public:
     Dimension(int id);
     ~Dimension();
 
+    void configureDayNightCyncle(double nightDuration,
+        double nightTransitionDuration,
+        double dayDuration);
     void api(Framework::InMemoryBuffer* zRequest,
         NetworkMessage* zResponse,
         Entity* zSource);
@@ -86,6 +99,10 @@ public:
     void requestStopAndWait();
     void updateMap(int x, int y, int height);
     int getChunkCount();
+    double getCurrentDayTime() const;
+    double getNightDuration() const;
+    double getNightTransitionDuration() const;
+    double getDayDuration() const;
 
     inline static Framework::Vec3<int> chunkCoordinates(
         Framework::Vec3<int> worldLocation)
@@ -99,4 +116,17 @@ public:
     }
 
     friend DimensionMap;
+};
+
+class DimensionFactory : public virtual Framework::ReferenceCounter
+{
+private:
+    int dimensionId;
+
+public:
+    DimensionFactory(int dimensionId);
+    virtual ~DimensionFactory() = default;
+
+    virtual Dimension* createDimension() = 0;
+    int getDimensionId() const;
 };

+ 0 - 6
FactoryCraft/DimensionGenerator.h

@@ -10,12 +10,6 @@
 #include "JNoise.h"
 #include "JsonExpression.h"
 
-class DimensionEnum
-{
-public:
-    static const int OVERWORLD = 0;
-};
-
 class DimensionGenerator;
 
 class DimensionGeneratorFactory : public virtual Framework::ReferenceCounter

+ 74 - 8
FactoryCraft/Game.cpp

@@ -84,7 +84,10 @@ void GameClient::thread()
             {
                 queueCs.unlock();
                 emptyBackgroundQueueSync.notifyAll();
-                backgroundQueueSync.wait();
+                while (!backgroundQueueSync.wait(1000))
+                {
+                    emptyBackgroundQueueSync.notifyAll();
+                }
             }
         }
         backgroundFinished = 1;
@@ -106,7 +109,10 @@ void GameClient::thread()
         {
             queueCs.unlock();
             emptyForegroundQueueSync.notifyAll();
-            foregroundQueueSync.wait();
+            while (!foregroundQueueSync.wait(1000))
+            {
+                emptyForegroundQueueSync.notifyAll();
+            }
         }
     }
     foregroundFinished = 1;
@@ -196,7 +202,10 @@ void GameClient::sendResponse(NetworkMessage* response)
         if (backgroundQueue.getEintragAnzahl() > 20)
         {
             queueCs.unlock();
-            emptyBackgroundQueueSync.wait();
+            while (!emptyBackgroundQueueSync.wait(1000))
+            {
+                backgroundQueueSync.notify();
+            }
             queueCs.lock();
         }
         backgroundQueue.add(response);
@@ -214,6 +223,7 @@ void GameClient::sendResponse(NetworkMessage* response)
             m.messungStart();
             while (foregroundQueue.getEintragAnzahl() > 0)
             {
+                foregroundQueueSync.notify();
                 emptyForegroundQueueSync.wait(100);
             }
             m.messungEnde();
@@ -349,6 +359,7 @@ void Game::thread()
     total.messungStart();
     double tickTime = 0;
     double sleepTime = 0;
+    int nextTimeSync = MAX_TICKS_PER_SECOND;
     while (!stop)
     {
         m.messungStart();
@@ -368,6 +379,7 @@ void Game::thread()
         waitTotal += waitForLock.getSekunden();
         removeOldClients.messungStart();
         int index = 0;
+        nextTimeSync--;
         for (auto player : *clients)
         {
             if (!player->isOnline())
@@ -395,8 +407,29 @@ void Game::thread()
                         player->zEntity()->getDimensionId(),
                         player->zEntity()->getPosition()));
             }
+            else
+            {
+                if (nextTimeSync <= 0 && player->zEntity())
+                {
+                    Dimension* zDim
+                        = zDimension(player->zEntity()->getDimensionId());
+                    if (zDim)
+                    {
+                        NetworkMessage* msg = new NetworkMessage();
+                        msg->syncTime(zDim->getCurrentDayTime(),
+                            zDim->getNightDuration(),
+                            zDim->getNightTransitionDuration(),
+                            zDim->getDayDuration());
+                        player->sendResponse(msg);
+                    }
+                }
+            }
             index++;
         }
+        if (nextTimeSync <= 0)
+        {
+            nextTimeSync = MAX_TICKS_PER_SECOND;
+        }
         for (auto i : removed)
             clients->remove(i);
         removeOldClients.messungEnde();
@@ -417,8 +450,20 @@ void Game::thread()
                 client->sendWorldUpdate(
                     dynamic_cast<WorldUpdate*>(update->getThis()));
             if (!zDimension(update->getAffectedDimension()))
-                addDimension(new Dimension(update->getAffectedDimension()));
-            update->onUpdate(zDimension(update->getAffectedDimension()));
+            {
+                Dimension* dim = typeRegistry->createDimension(
+                    update->getAffectedDimension());
+                if (dim)
+                    addDimension(dim);
+                else
+                {
+                    std::cout << "ERROR: could not create dimension "
+                              << update->getAffectedDimension()
+                              << ". No Factory was provided.\n";
+                }
+            }
+            if (zDimension(update->getAffectedDimension()))
+                update->onUpdate(zDimension(update->getAffectedDimension()));
             updates->remove(0);
         }
         worldUpdates.messungEnde();
@@ -440,7 +485,7 @@ void Game::thread()
         double sec = m.getSekunden();
         tickCounter++;
         totalTickTime += sec;
-        sleepTime += 1.0 / 20 - tickTime;
+        sleepTime += 1.0 / MAX_TICKS_PER_SECOND - tickTime;
         if (sleepTime > 0)
         {
             Sleep((int)(sleepTime * 1000));
@@ -492,7 +537,14 @@ void Game::api(Framework::InMemoryBuffer* zRequest, GameClient* zOrigin)
             Dimension* dim = zDimension(zOrigin->zEntity()->getDimensionId());
             if (!dim)
             {
-                dim = new Dimension(zOrigin->zEntity()->getDimensionId());
+                dim = typeRegistry->createDimension(
+                    zOrigin->zEntity()->getDimensionId());
+                if (!dim)
+                {
+                    std::cout << "ERROR: could not create dimension "
+							  << zOrigin->zEntity()->getDimensionId() << ". No Factory was provided.\n";
+					return;
+                }
                 addDimension(dim);
             }
             dim->api(zRequest, response, zOrigin->zEntity());
@@ -700,7 +752,21 @@ GameClient* Game::addPlayer(FCKlient* client, Framework::Text name)
     clients->add(gameClient);
     if (!zDimension(player->getDimensionId()))
     {
-        this->addDimension(new Dimension(player->getDimensionId()));
+        Dimension* dim
+            = typeRegistry->createDimension(player->getDimensionId());
+        if (!dim)
+        {
+            std::cout << "ERROR: could not create dimension "
+					  << (int)player->getDimensionId() << ". No Factory was provided.\n";
+			return 0;
+        }
+        NetworkMessage *msg = new NetworkMessage();
+        msg->syncTime(dim->getCurrentDayTime(),
+            dim->getNightDuration(),
+            dim->getNightTransitionDuration(),
+            dim->getDayDuration());
+        gameClient->sendResponse(msg);
+        this->addDimension(dim);
     }
     // subscribe the new player as an observer of the new chunk
     Dimension* dim = zDimension(player->getDimensionId());

+ 6 - 4
FactoryCraft/GrowingPlant.cpp

@@ -76,19 +76,21 @@ void GrowingPlantBlock::onPostTick()
 
 void GrowingPlantBlock::sendModelInfo(NetworkMessage* zMessage)
 {
-    const GrowthState* current = 0;
+    GrowthState current;
+    bool found = 0;
     for (const GrowthState& state : states)
     {
         if (state.percentage <= seblingTicks / (float)seblingTicksMax)
         {
-            current = &state;
+            found = 1;
+            current = state;
         }
     }
-    if (current)
+    if (found)
     {
         zMessage->addressBlock(this);
         InMemoryBuffer buffer;
-        current->model.writeTo(&buffer);
+        current.model.writeTo(&buffer);
         char* msg = new char[(int)buffer.getSize() + 1];
         msg[0] = 1; // hmodel change
         buffer.lese(msg + 1, (int)buffer.getSize());

+ 16 - 0
FactoryCraft/NetworkMessage.cpp

@@ -192,6 +192,22 @@ void NetworkMessage::animateBlockBone(int dimensionId,
     setMessage(msg, 40);
 }
 
+void NetworkMessage::syncTime(
+    double time, double nightLength, double transitionLength, double dayLength)
+{
+    delete[] address;
+    addressLength = 1;
+    address = new char[1];
+    address[0] = 8;
+    delete[] message;
+    msgLength = 8 * 4;
+    message = new char[msgLength];
+    *(double*)(message) = time;
+    *(double*)(message + 8) = nightLength;
+    *(double*)(message + 16) = transitionLength;
+    *(double*)(message + 24) = dayLength;
+}
+
 void NetworkMessage::writeTo(Framework::StreamWriter* zWriter) const
 {
     int total = msgLength + addressLength;

+ 4 - 0
FactoryCraft/NetworkMessage.h

@@ -50,6 +50,10 @@ public:
         double time,
         Framework::Vec3<float> pos,
         Framework::Vec3<float> rotation);
+    void syncTime(double time,
+        double nightLength,
+        double transitionLength,
+        double dayLength);
 
     void writeTo(Framework::StreamWriter* zWriter) const;
     bool isBroadcast() const;

+ 5 - 472
FactoryCraft/OverworldDimension.cpp

@@ -1,478 +1,11 @@
 #include "OverworldDimension.h"
 
-#include "FastNoiseWrapper.h"
-#include "RandNoise.h"
-#include "WormCaveGenerator.h"
-
 OverworldDimensionFactory::OverworldDimensionFactory()
-    : DimensionGeneratorFactory("Overworld", DimensionEnum::OVERWORLD)
+    : DimensionFactory(DimensionEnum::OVERWORLD)
 {}
 
-DimensionGenerator* OverworldDimensionFactory::createDimensionGenerator(
-    int worldSeed, Framework::JSON::JSONValue* config)
-{
-    return new BiomedCavedDimensionGenerator(config, worldSeed);
-}
-
-Framework::JSON::Validator::JSONValidator*
-OverworldDimensionFactory::getConfigValidator()
-{
-    auto validator = Framework::JSON::Validator::JSONValidator::buildForObject()
-                         ->withRequiredString("dimension")
-                         ->withExactMatch("Overworld")
-                         ->finishString();
-    return BiomedCavedDimensionGenerator::addConfigAttributes(validator)
-        ->finishObject();
-}
-
-Framework::JSON::JSONValue* OverworldDimensionFactory::getDefaultConfig()
-{
-    return Framework::JSON::Parser::getValue(
-        "{"
-        "    \"bioms\": ["
-        "        {"
-        "            \"blocks\": ["
-        "                {"
-        "                    \"blockType\": \"Grass\","
-        "                    \"condition\": {"
-        "                        \"operator\": \"&&\","
-        "                        \"type\": \"operator\","
-        "                        \"values\": ["
-        "                            {"
-        "                                \"operator\": \"==\","
-        "                                \"type\": \"operator\","
-        "                                \"values\": ["
-        "                                    {"
-        "                                        \"name\": \"z\","
-        "                                        \"type\": \"variable\""
-        "                                    },"
-        "                                    {"
-        "                                        \"name\": \"h\","
-        "                                        \"type\": \"variable\""
-        "                                    }"
-        "                                ]"
-        "                            },"
-        "                            {"
-        "                                \"blockType\": \"Dirt\","
-        "                                \"type\": \"blockType\","
-        "                                \"x\": {"
-        "                                    \"name\": \"x\","
-        "                                    \"type\": \"variable\""
-        "                                },"
-        "                                \"y\": {"
-        "                                    \"name\": \"y\","
-        "                                    \"type\": \"variable\""
-        "                                },"
-        "                                \"z\": {"
-        "                                    \"operator\": \"-\","
-        "                                    \"type\": \"operator\","
-        "                                    \"values\": ["
-        "                                        {"
-        "                                            \"name\": \"z\","
-        "                                            \"type\": \"variable\""
-        "                                        },"
-        "                                        {"
-        "                                            \"type\": \"constant\","
-        "                                            \"value\": 1"
-        "                                        }"
-        "                                    ]"
-        "                                }"
-        "                            }"
-        "                        ]"
-        "                    },"
-        "                    \"noise\": {"
-        "                        \"seed\": {"
-        "                            \"operator\": \"+\","
-        "                            \"type\": \"operator\","
-        "                            \"values\": ["
-        "                                {"
-        "                                    \"name\": \"dimensionSeed\","
-        "                                    \"type\": \"variable\""
-        "                                },"
-        "                                {"
-        "                                    \"type\": \"constant\","
-        "                                    \"value\": 3"
-        "                                }"
-        "                            ]"
-        "                        },"
-        "                        \"type\": \"random\""
-        "                    },"
-        "                    \"threshold\": 0.25,"
-        "                    \"type\": \"blockType\""
-        "                },"
-        "                {"
-        "                    \"blockType\": \"Gravel\","
-        "                    \"condition\": {"
-        "                        \"operator\": \"<\","
-        "                        \"type\": \"operator\","
-        "                        \"values\": ["
-        "                            {"
-        "                                \"name\": \"z\","
-        "                                \"type\": \"variable\""
-        "                            },"
-        "                            {"
-        "                                \"name\": \"h\","
-        "                                \"type\": \"variable\""
-        "                            }"
-        "                        ]"
-        "                    },"
-        "                    \"noise\": {"
-        "                        \"frequency\": 0.1,"
-        "                        \"seed\": {"
-        "                            \"operator\": \"+\","
-        "                            \"type\": \"operator\","
-        "                            \"values\": ["
-        "                                {"
-        "                                    \"name\": \"dimensionSeed\","
-        "                                    \"type\": \"variable\""
-        "                                },"
-        "                                {"
-        "                                    \"type\": \"constant\","
-        "                                    \"value\": 2"
-        "                                }"
-        "                            ]"
-        "                        },"
-        "                        \"type\": \"ValueCubic\""
-        "                    },"
-        "                    \"threshold\": 0.35,"
-        "                    \"type\": \"blockType\""
-        "                },"
-        "                {"
-        "                    \"blockType\": \"Dirt\","
-        "                    \"condition\": {"
-        "                        \"operator\": \"<\","
-        "                        \"type\": \"operator\","
-        "                        \"values\": ["
-        "                            {"
-        "                                \"name\": \"z\","
-        "                                \"type\": \"variable\""
-        "                            },"
-        "                            {"
-        "                                \"name\": \"h\","
-        "                                \"type\": \"variable\""
-        "                            }"
-        "                        ]"
-        "                    },"
-        "                    \"noise\": {"
-        "                        \"frequency\": 0.125,"
-        "                        \"seed\": {"
-        "                            \"operator\": \"+\","
-        "                            \"type\": \"operator\","
-        "                            \"values\": ["
-        "                                {"
-        "                                    \"name\": \"dimensionSeed\","
-        "                                    \"type\": \"variable\""
-        "                                },"
-        "                                {"
-        "                                    \"type\": \"constant\","
-        "                                    \"value\": 1"
-        "                                }"
-        "                            ]"
-        "                        },"
-        "                        \"type\": \"ValueCubic\""
-        "                    },"
-        "                    \"threshold\": 0.35,"
-        "                    \"type\": \"blockType\""
-        "                },"
-        "                {"
-        "                    \"blockType\": \"Sand\","
-        "                    \"condition\": {"
-        "                        \"operator\": \"&&\","
-        "                        \"type\": \"operator\","
-        "                        \"values\": ["
-        "                            {"
-        "                                \"operator\": \"<\","
-        "                                \"type\": \"operator\","
-        "                                \"values\": ["
-        "                                    {"
-        "                                        \"name\": \"z\","
-        "                                        \"type\": \"variable\""
-        "                                    },"
-        "                                    {"
-        "                                        \"name\": \"h\","
-        "                                        \"type\": \"variable\""
-        "                                    }"
-        "                                ]"
-        "                            },"
-        "                            {"
-        "                                \"operator\": \">\","
-        "                                \"type\": \"operator\","
-        "                                \"values\": ["
-        "                                    {"
-        "                                        \"name\": \"z\","
-        "                                        \"type\": \"variable\""
-        "                                    },"
-        "                                    {"
-        "                                        \"name\": \"underground1\","
-        "                                        \"type\": \"variable\""
-        "                                    }"
-        "                                ]"
-        "                            }"
-        "                        ]"
-        "                    },"
-        "                    \"noise\": {"
-        "                        \"frequency\": 0.125,"
-        "                        \"seed\": {"
-        "                            \"operator\": \"+\","
-        "                            \"type\": \"operator\","
-        "                            \"values\": ["
-        "                                {"
-        "                                    \"name\": \"dimensionSeed\","
-        "                                    \"type\": \"variable\""
-        "                                },"
-        "                                {"
-        "                                    \"type\": \"constant\","
-        "                                    \"value\": 2"
-        "                                }"
-        "                            ]"
-        "                        },"
-        "                        \"type\": \"ValueCubic\""
-        "                    },"
-        "                    \"threshold\": 0.35,"
-        "                    \"type\": \"blockType\""
-        "                },"
-        "                {"
-        "                    \"blockType\": \"Dirt\","
-        "                    \"condition\": {"
-        "                        \"operator\": \"&&\","
-        "                        \"type\": \"operator\","
-        "                        \"values\": ["
-        "                            {"
-        "                                \"operator\": \"<\","
-        "                                \"type\": \"operator\","
-        "                                \"values\": ["
-        "                                    {"
-        "                                        \"name\": \"z\","
-        "                                        \"type\": \"variable\""
-        "                                    },"
-        "                                    {"
-        "                                        \"name\": \"h\","
-        "                                        \"type\": \"variable\""
-        "                                    }"
-        "                                ]"
-        "                            },"
-        "                            {"
-        "                                \"operator\": \">\","
-        "                                \"type\": \"operator\","
-        "                                \"values\": ["
-        "                                    {"
-        "                                        \"name\": \"z\","
-        "                                        \"type\": \"variable\""
-        "                                    },"
-        "                                    {"
-        "                                        \"name\": \"underground1\","
-        "                                        \"type\": \"variable\""
-        "                                    }"
-        "                                ]"
-        "                            }"
-        "                        ]"
-        "                    },"
-        "                    \"type\": \"blockType\""
-        "                },"
-        "                {"
-        "                    \"blockType\": \"Stone\","
-        "                    \"condition\": {"
-        "                        \"operator\": \"<\","
-        "                        \"type\": \"operator\","
-        "                        \"values\": ["
-        "                            {"
-        "                                \"name\": \"z\","
-        "                                \"type\": \"variable\""
-        "                            },"
-        "                            {"
-        "                                \"name\": \"underground1\","
-        "                                \"type\": \"variable\""
-        "                            }"
-        "                        ]"
-        "                    },"
-        "                    \"type\": \"blockType\""
-        "                }"
-        "            ],"
-        "            \"layerModifier\": ["
-        "                {"
-        "                    \"multiplier\": 0.2,"
-        "                    \"name\": \"h\""
-        "                }"
-        "            ],"
-        "            \"name\": \"Grassland\","
-        "            \"structurCollections\": ["
-        "                {"
-        "                    \"noise\": {"
-        "                        \"seed\": {"
-        "                            \"name\": \"dimensionSeed\","
-        "                            \"type\": \"variable\""
-        "                        },"
-        "                        \"type\": \"random\""
-        "                    },"
-        "                    \"structures\": ["
-        "                        {"
-        "                            \"leaves\": \"Birch Wood Leaves\","
-        "                            \"maxSize\": 15,"
-        "                            \"minSize\": 8,"
-        "                            \"propability\": 0.5,"
-        "                            \"type\": \"Tree\","
-        "                            \"wood\": \"Birch Wood\""
-        "                        },"
-        "                        {"
-        "                            \"leaves\": \"Beech Wood Leaves\","
-        "                            \"maxSize\": 13,"
-        "                            \"minSize\": 8,"
-        "                            \"propability\": 0.25,"
-        "                            \"type\": \"Tree\","
-        "                            \"wood\": \"Beech Wood\""
-        "                        },"
-        "                        {"
-        "                            \"leaves\": \"Oak Wood Leaves\","
-        "                            \"maxSize\": 15,"
-        "                            \"minSize\": 10,"
-        "                            \"propability\": 0.125,"
-        "                            \"type\": \"Tree\","
-        "                            \"wood\": \"Oak Wood\""
-        "                        },"
-        "                        {"
-        "                            \"leaves\": \"Pine Wood Leaves\","
-        "                            \"maxSize\": 24,"
-        "                            \"minSize\": 15,"
-        "                            \"propability\": 0.075,"
-        "                            \"type\": \"Tree\","
-        "                            \"wood\": \"Pine Wood\""
-        "                        }"
-        "                    ],"
-        "                    \"threshold\": 0.001"
-        "                }"
-        "            ]"
-        "        }"
-        "    ],"
-        "    \"dimension\": \"Overworld\","
-        "    \"dimensionSeed\": {"
-        "        \"operator\": \"+\","
-        "        \"type\": \"operator\","
-        "        \"values\": ["
-        "            {"
-        "                \"name\": \"worldSeed\","
-        "                \"type\": \"variable\""
-        "            },"
-        "            {"
-        "                \"name\": \"dimensionId\","
-        "                \"type\": \"variable\""
-        "            }"
-        "        ]"
-        "    },"
-        "    \"heightLayers\": ["
-        "        {"
-        "            \"name\": \"h\","
-        "            \"noise\": {"
-        "                \"seed\": {"
-        "                    \"name\": \"dimensionSeed\","
-        "                    \"type\": \"variable\""
-        "                },"
-        "                \"type\": \"ValueCubic\""
-        "            },"
-        "            \"value\": {"
-        "                \"operator\": \"+\","
-        "                \"type\": \"operator\","
-        "                \"values\": ["
-        "                    {"
-        "                        \"type\": \"constant\","
-        "                        \"value\": 50"
-        "                    },"
-        "                    {"
-        "                        \"operator\": \"*\","
-        "                        \"type\": \"operator\","
-        "                        \"values\": ["
-        "                            {"
-        "                                \"type\": \"noise\","
-        "                                \"x\": {"
-        "                                    \"name\": \"x\","
-        "                                    \"type\": \"variable\""
-        "                                },"
-        "                                \"y\": {"
-        "                                    \"name\": \"y\","
-        "                                    \"type\": \"variable\""
-        "                                },"
-        "                                \"z\": {"
-        "                                    \"type\": \"constant\","
-        "                                    \"value\": 0"
-        "                                }"
-        "                            },"
-        "                            {"
-        "                                \"type\": \"constant\","
-        "                                \"value\": 400"
-        "                            }"
-        "                        ]"
-        "                    }"
-        "                ]"
-        "            }"
-        "        },"
-        "        {"
-        "            \"name\": \"underground1\","
-        "            \"noise\": {"
-        "                \"seed\": {"
-        "                    \"name\": \"dimensionSeed\","
-        "                    \"type\": \"variable\""
-        "                },"
-        "                \"type\": \"ValueCubic\""
-        "            },"
-        "            \"value\": {"
-        "                \"operator\": \"-\","
-        "                \"type\": \"operator\","
-        "                \"values\": ["
-        "                    {"
-        "                        \"name\": \"h\","
-        "                        \"type\": \"variable\""
-        "                    },"
-        "                    {"
-        "                        \"type\": \"constant\","
-        "                        \"value\": 5"
-        "                    },"
-        "                    {"
-        "                        \"operator\": \"*\","
-        "                        \"type\": \"operator\","
-        "                        \"values\": ["
-        "                            {"
-        "                                \"type\": \"noise\","
-        "                                \"x\": {"
-        "                                    \"name\": \"x\","
-        "                                    \"type\": \"variable\""
-        "                                },"
-        "                                \"y\": {"
-        "                                    \"name\": \"y\","
-        "                                    \"type\": \"variable\""
-        "                                },"
-        "                                \"z\": {"
-        "                                    \"type\": \"constant\","
-        "                                    \"value\": 0"
-        "                                }"
-        "                            },"
-        "                            {"
-        "                                \"type\": \"constant\","
-        "                                \"value\": 45"
-        "                            }"
-        "                        ]"
-        "                    }"
-        "                ]"
-        "            }"
-        "        }"
-        "    ],"
-        "    \"noiseMaps\": ["
-        "        {"
-        "            \"name\": \"biomNoise\","
-        "            \"noise\": {"
-        "                \"cellularDistanceFunction\": \"Hybrid\","
-        "                \"cellularJitter\": 1,"
-        "                \"cellularReturnType\": \"CellValue\","
-        "                \"domainWarpAmp\": 30,"
-        "                \"domainWarpType\": \"OpenSimplex2Reduced\","
-        "                \"fractalType\": \"None\","
-        "                \"frequency\": 0.015,"
-        "                \"rotationType3D\": \"None\","
-        "                \"seed\": {"
-        "                    \"name\": \"dimensionSeed\","
-        "                    \"type\": \"variable\""
-        "                },"
-        "                \"type\": \"Cellular\""
-        "            }"
-        "        }"
-        "    ]"
-        "}");
+Dimension* OverworldDimensionFactory::createDimension() {
+    Dimension* d = new Dimension(DimensionEnum::OVERWORLD);
+    d->configureDayNightCyncle(300, 30, 600);
+    return d;
 }

+ 4 - 8
FactoryCraft/OverworldDimension.h

@@ -1,15 +1,11 @@
 #pragma once
 
-#include "DimensionGenerator.h"
-#include "Noise.h"
-#include "StaticRegistry.h"
+#include "Dimension.h"
 
-class OverworldDimensionFactory : public DimensionGeneratorFactory
+class OverworldDimensionFactory : public DimensionFactory
 {
 public:
     OverworldDimensionFactory();
-    DimensionGenerator* createDimensionGenerator(
-        int worldSeed, Framework::JSON::JSONValue* config) override;
-    Framework::JSON::Validator::JSONValidator* getConfigValidator() override;
-    Framework::JSON::JSONValue* getDefaultConfig() override;
+
+    Dimension* createDimension() override;
 };

+ 479 - 0
FactoryCraft/OverworldDimensionGenerator.cpp

@@ -0,0 +1,479 @@
+#include "OverworldDimensionGenerator.h"
+
+#include "FastNoiseWrapper.h"
+#include "RandNoise.h"
+#include "WormCaveGenerator.h"
+#include "Dimension.h"
+
+OverworldDimensionGeneratorFactory::OverworldDimensionGeneratorFactory()
+    : DimensionGeneratorFactory("Overworld", DimensionEnum::OVERWORLD)
+{}
+
+DimensionGenerator* OverworldDimensionGeneratorFactory::createDimensionGenerator(
+    int worldSeed, Framework::JSON::JSONValue* config)
+{
+    return new BiomedCavedDimensionGenerator(config, worldSeed);
+}
+
+Framework::JSON::Validator::JSONValidator*
+OverworldDimensionGeneratorFactory::getConfigValidator()
+{
+    auto validator = Framework::JSON::Validator::JSONValidator::buildForObject()
+                         ->withRequiredString("dimension")
+                         ->withExactMatch("Overworld")
+                         ->finishString();
+    return BiomedCavedDimensionGenerator::addConfigAttributes(validator)
+        ->finishObject();
+}
+
+Framework::JSON::JSONValue* OverworldDimensionGeneratorFactory::getDefaultConfig()
+{
+    return Framework::JSON::Parser::getValue(
+        "{"
+        "    \"bioms\": ["
+        "        {"
+        "            \"blocks\": ["
+        "                {"
+        "                    \"blockType\": \"Grass\","
+        "                    \"condition\": {"
+        "                        \"operator\": \"&&\","
+        "                        \"type\": \"operator\","
+        "                        \"values\": ["
+        "                            {"
+        "                                \"operator\": \"==\","
+        "                                \"type\": \"operator\","
+        "                                \"values\": ["
+        "                                    {"
+        "                                        \"name\": \"z\","
+        "                                        \"type\": \"variable\""
+        "                                    },"
+        "                                    {"
+        "                                        \"name\": \"h\","
+        "                                        \"type\": \"variable\""
+        "                                    }"
+        "                                ]"
+        "                            },"
+        "                            {"
+        "                                \"blockType\": \"Dirt\","
+        "                                \"type\": \"blockType\","
+        "                                \"x\": {"
+        "                                    \"name\": \"x\","
+        "                                    \"type\": \"variable\""
+        "                                },"
+        "                                \"y\": {"
+        "                                    \"name\": \"y\","
+        "                                    \"type\": \"variable\""
+        "                                },"
+        "                                \"z\": {"
+        "                                    \"operator\": \"-\","
+        "                                    \"type\": \"operator\","
+        "                                    \"values\": ["
+        "                                        {"
+        "                                            \"name\": \"z\","
+        "                                            \"type\": \"variable\""
+        "                                        },"
+        "                                        {"
+        "                                            \"type\": \"constant\","
+        "                                            \"value\": 1"
+        "                                        }"
+        "                                    ]"
+        "                                }"
+        "                            }"
+        "                        ]"
+        "                    },"
+        "                    \"noise\": {"
+        "                        \"seed\": {"
+        "                            \"operator\": \"+\","
+        "                            \"type\": \"operator\","
+        "                            \"values\": ["
+        "                                {"
+        "                                    \"name\": \"dimensionSeed\","
+        "                                    \"type\": \"variable\""
+        "                                },"
+        "                                {"
+        "                                    \"type\": \"constant\","
+        "                                    \"value\": 3"
+        "                                }"
+        "                            ]"
+        "                        },"
+        "                        \"type\": \"random\""
+        "                    },"
+        "                    \"threshold\": 0.25,"
+        "                    \"type\": \"blockType\""
+        "                },"
+        "                {"
+        "                    \"blockType\": \"Gravel\","
+        "                    \"condition\": {"
+        "                        \"operator\": \"<\","
+        "                        \"type\": \"operator\","
+        "                        \"values\": ["
+        "                            {"
+        "                                \"name\": \"z\","
+        "                                \"type\": \"variable\""
+        "                            },"
+        "                            {"
+        "                                \"name\": \"h\","
+        "                                \"type\": \"variable\""
+        "                            }"
+        "                        ]"
+        "                    },"
+        "                    \"noise\": {"
+        "                        \"frequency\": 0.1,"
+        "                        \"seed\": {"
+        "                            \"operator\": \"+\","
+        "                            \"type\": \"operator\","
+        "                            \"values\": ["
+        "                                {"
+        "                                    \"name\": \"dimensionSeed\","
+        "                                    \"type\": \"variable\""
+        "                                },"
+        "                                {"
+        "                                    \"type\": \"constant\","
+        "                                    \"value\": 2"
+        "                                }"
+        "                            ]"
+        "                        },"
+        "                        \"type\": \"ValueCubic\""
+        "                    },"
+        "                    \"threshold\": 0.35,"
+        "                    \"type\": \"blockType\""
+        "                },"
+        "                {"
+        "                    \"blockType\": \"Dirt\","
+        "                    \"condition\": {"
+        "                        \"operator\": \"<\","
+        "                        \"type\": \"operator\","
+        "                        \"values\": ["
+        "                            {"
+        "                                \"name\": \"z\","
+        "                                \"type\": \"variable\""
+        "                            },"
+        "                            {"
+        "                                \"name\": \"h\","
+        "                                \"type\": \"variable\""
+        "                            }"
+        "                        ]"
+        "                    },"
+        "                    \"noise\": {"
+        "                        \"frequency\": 0.125,"
+        "                        \"seed\": {"
+        "                            \"operator\": \"+\","
+        "                            \"type\": \"operator\","
+        "                            \"values\": ["
+        "                                {"
+        "                                    \"name\": \"dimensionSeed\","
+        "                                    \"type\": \"variable\""
+        "                                },"
+        "                                {"
+        "                                    \"type\": \"constant\","
+        "                                    \"value\": 1"
+        "                                }"
+        "                            ]"
+        "                        },"
+        "                        \"type\": \"ValueCubic\""
+        "                    },"
+        "                    \"threshold\": 0.35,"
+        "                    \"type\": \"blockType\""
+        "                },"
+        "                {"
+        "                    \"blockType\": \"Sand\","
+        "                    \"condition\": {"
+        "                        \"operator\": \"&&\","
+        "                        \"type\": \"operator\","
+        "                        \"values\": ["
+        "                            {"
+        "                                \"operator\": \"<\","
+        "                                \"type\": \"operator\","
+        "                                \"values\": ["
+        "                                    {"
+        "                                        \"name\": \"z\","
+        "                                        \"type\": \"variable\""
+        "                                    },"
+        "                                    {"
+        "                                        \"name\": \"h\","
+        "                                        \"type\": \"variable\""
+        "                                    }"
+        "                                ]"
+        "                            },"
+        "                            {"
+        "                                \"operator\": \">\","
+        "                                \"type\": \"operator\","
+        "                                \"values\": ["
+        "                                    {"
+        "                                        \"name\": \"z\","
+        "                                        \"type\": \"variable\""
+        "                                    },"
+        "                                    {"
+        "                                        \"name\": \"underground1\","
+        "                                        \"type\": \"variable\""
+        "                                    }"
+        "                                ]"
+        "                            }"
+        "                        ]"
+        "                    },"
+        "                    \"noise\": {"
+        "                        \"frequency\": 0.125,"
+        "                        \"seed\": {"
+        "                            \"operator\": \"+\","
+        "                            \"type\": \"operator\","
+        "                            \"values\": ["
+        "                                {"
+        "                                    \"name\": \"dimensionSeed\","
+        "                                    \"type\": \"variable\""
+        "                                },"
+        "                                {"
+        "                                    \"type\": \"constant\","
+        "                                    \"value\": 2"
+        "                                }"
+        "                            ]"
+        "                        },"
+        "                        \"type\": \"ValueCubic\""
+        "                    },"
+        "                    \"threshold\": 0.35,"
+        "                    \"type\": \"blockType\""
+        "                },"
+        "                {"
+        "                    \"blockType\": \"Dirt\","
+        "                    \"condition\": {"
+        "                        \"operator\": \"&&\","
+        "                        \"type\": \"operator\","
+        "                        \"values\": ["
+        "                            {"
+        "                                \"operator\": \"<\","
+        "                                \"type\": \"operator\","
+        "                                \"values\": ["
+        "                                    {"
+        "                                        \"name\": \"z\","
+        "                                        \"type\": \"variable\""
+        "                                    },"
+        "                                    {"
+        "                                        \"name\": \"h\","
+        "                                        \"type\": \"variable\""
+        "                                    }"
+        "                                ]"
+        "                            },"
+        "                            {"
+        "                                \"operator\": \">\","
+        "                                \"type\": \"operator\","
+        "                                \"values\": ["
+        "                                    {"
+        "                                        \"name\": \"z\","
+        "                                        \"type\": \"variable\""
+        "                                    },"
+        "                                    {"
+        "                                        \"name\": \"underground1\","
+        "                                        \"type\": \"variable\""
+        "                                    }"
+        "                                ]"
+        "                            }"
+        "                        ]"
+        "                    },"
+        "                    \"type\": \"blockType\""
+        "                },"
+        "                {"
+        "                    \"blockType\": \"Stone\","
+        "                    \"condition\": {"
+        "                        \"operator\": \"<\","
+        "                        \"type\": \"operator\","
+        "                        \"values\": ["
+        "                            {"
+        "                                \"name\": \"z\","
+        "                                \"type\": \"variable\""
+        "                            },"
+        "                            {"
+        "                                \"name\": \"underground1\","
+        "                                \"type\": \"variable\""
+        "                            }"
+        "                        ]"
+        "                    },"
+        "                    \"type\": \"blockType\""
+        "                }"
+        "            ],"
+        "            \"layerModifier\": ["
+        "                {"
+        "                    \"multiplier\": 0.2,"
+        "                    \"name\": \"h\""
+        "                }"
+        "            ],"
+        "            \"name\": \"Grassland\","
+        "            \"structurCollections\": ["
+        "                {"
+        "                    \"noise\": {"
+        "                        \"seed\": {"
+        "                            \"name\": \"dimensionSeed\","
+        "                            \"type\": \"variable\""
+        "                        },"
+        "                        \"type\": \"random\""
+        "                    },"
+        "                    \"structures\": ["
+        "                        {"
+        "                            \"leaves\": \"Birch Wood Leaves\","
+        "                            \"maxSize\": 15,"
+        "                            \"minSize\": 8,"
+        "                            \"propability\": 0.5,"
+        "                            \"type\": \"Tree\","
+        "                            \"wood\": \"Birch Wood\""
+        "                        },"
+        "                        {"
+        "                            \"leaves\": \"Beech Wood Leaves\","
+        "                            \"maxSize\": 13,"
+        "                            \"minSize\": 8,"
+        "                            \"propability\": 0.25,"
+        "                            \"type\": \"Tree\","
+        "                            \"wood\": \"Beech Wood\""
+        "                        },"
+        "                        {"
+        "                            \"leaves\": \"Oak Wood Leaves\","
+        "                            \"maxSize\": 15,"
+        "                            \"minSize\": 10,"
+        "                            \"propability\": 0.125,"
+        "                            \"type\": \"Tree\","
+        "                            \"wood\": \"Oak Wood\""
+        "                        },"
+        "                        {"
+        "                            \"leaves\": \"Pine Wood Leaves\","
+        "                            \"maxSize\": 24,"
+        "                            \"minSize\": 15,"
+        "                            \"propability\": 0.075,"
+        "                            \"type\": \"Tree\","
+        "                            \"wood\": \"Pine Wood\""
+        "                        }"
+        "                    ],"
+        "                    \"threshold\": 0.001"
+        "                }"
+        "            ]"
+        "        }"
+        "    ],"
+        "    \"dimension\": \"Overworld\","
+        "    \"dimensionSeed\": {"
+        "        \"operator\": \"+\","
+        "        \"type\": \"operator\","
+        "        \"values\": ["
+        "            {"
+        "                \"name\": \"worldSeed\","
+        "                \"type\": \"variable\""
+        "            },"
+        "            {"
+        "                \"name\": \"dimensionId\","
+        "                \"type\": \"variable\""
+        "            }"
+        "        ]"
+        "    },"
+        "    \"heightLayers\": ["
+        "        {"
+        "            \"name\": \"h\","
+        "            \"noise\": {"
+        "                \"seed\": {"
+        "                    \"name\": \"dimensionSeed\","
+        "                    \"type\": \"variable\""
+        "                },"
+        "                \"type\": \"ValueCubic\""
+        "            },"
+        "            \"value\": {"
+        "                \"operator\": \"+\","
+        "                \"type\": \"operator\","
+        "                \"values\": ["
+        "                    {"
+        "                        \"type\": \"constant\","
+        "                        \"value\": 50"
+        "                    },"
+        "                    {"
+        "                        \"operator\": \"*\","
+        "                        \"type\": \"operator\","
+        "                        \"values\": ["
+        "                            {"
+        "                                \"type\": \"noise\","
+        "                                \"x\": {"
+        "                                    \"name\": \"x\","
+        "                                    \"type\": \"variable\""
+        "                                },"
+        "                                \"y\": {"
+        "                                    \"name\": \"y\","
+        "                                    \"type\": \"variable\""
+        "                                },"
+        "                                \"z\": {"
+        "                                    \"type\": \"constant\","
+        "                                    \"value\": 0"
+        "                                }"
+        "                            },"
+        "                            {"
+        "                                \"type\": \"constant\","
+        "                                \"value\": 400"
+        "                            }"
+        "                        ]"
+        "                    }"
+        "                ]"
+        "            }"
+        "        },"
+        "        {"
+        "            \"name\": \"underground1\","
+        "            \"noise\": {"
+        "                \"seed\": {"
+        "                    \"name\": \"dimensionSeed\","
+        "                    \"type\": \"variable\""
+        "                },"
+        "                \"type\": \"ValueCubic\""
+        "            },"
+        "            \"value\": {"
+        "                \"operator\": \"-\","
+        "                \"type\": \"operator\","
+        "                \"values\": ["
+        "                    {"
+        "                        \"name\": \"h\","
+        "                        \"type\": \"variable\""
+        "                    },"
+        "                    {"
+        "                        \"type\": \"constant\","
+        "                        \"value\": 5"
+        "                    },"
+        "                    {"
+        "                        \"operator\": \"*\","
+        "                        \"type\": \"operator\","
+        "                        \"values\": ["
+        "                            {"
+        "                                \"type\": \"noise\","
+        "                                \"x\": {"
+        "                                    \"name\": \"x\","
+        "                                    \"type\": \"variable\""
+        "                                },"
+        "                                \"y\": {"
+        "                                    \"name\": \"y\","
+        "                                    \"type\": \"variable\""
+        "                                },"
+        "                                \"z\": {"
+        "                                    \"type\": \"constant\","
+        "                                    \"value\": 0"
+        "                                }"
+        "                            },"
+        "                            {"
+        "                                \"type\": \"constant\","
+        "                                \"value\": 45"
+        "                            }"
+        "                        ]"
+        "                    }"
+        "                ]"
+        "            }"
+        "        }"
+        "    ],"
+        "    \"noiseMaps\": ["
+        "        {"
+        "            \"name\": \"biomNoise\","
+        "            \"noise\": {"
+        "                \"cellularDistanceFunction\": \"Hybrid\","
+        "                \"cellularJitter\": 1,"
+        "                \"cellularReturnType\": \"CellValue\","
+        "                \"domainWarpAmp\": 30,"
+        "                \"domainWarpType\": \"OpenSimplex2Reduced\","
+        "                \"fractalType\": \"None\","
+        "                \"frequency\": 0.015,"
+        "                \"rotationType3D\": \"None\","
+        "                \"seed\": {"
+        "                    \"name\": \"dimensionSeed\","
+        "                    \"type\": \"variable\""
+        "                },"
+        "                \"type\": \"Cellular\""
+        "            }"
+        "        }"
+        "    ]"
+        "}");
+}

+ 15 - 0
FactoryCraft/OverworldDimensionGenerator.h

@@ -0,0 +1,15 @@
+#pragma once
+
+#include "DimensionGenerator.h"
+#include "Noise.h"
+#include "StaticRegistry.h"
+
+class OverworldDimensionGeneratorFactory : public DimensionGeneratorFactory
+{
+public:
+    OverworldDimensionGeneratorFactory();
+    DimensionGenerator* createDimensionGenerator(
+        int worldSeed, Framework::JSON::JSONValue* config) override;
+    Framework::JSON::Validator::JSONValidator* getConfigValidator() override;
+    Framework::JSON::JSONValue* getDefaultConfig() override;
+};

+ 8 - 8
FactoryCraft/StaticInitializerOrder.cpp

@@ -228,7 +228,7 @@ void initializeBlockTypes()
         ->initializeDefault();
     (new GrassBlockType(BlockTypeEnum::GRASS,
          ItemTypeEnum::GRASS,
-         ModelInfo("grass", "blocks.ltdb/grass.png", 1).setTransparent(),
+         ModelInfo("grass", "blocks.ltdb/grass.png", 1),
          "Grass",
          0x5076C011))
         ->initializeDefault();
@@ -254,22 +254,22 @@ void initializeBlockTypes()
          18000,
          0x5076C011))
         ->addGrowthState(0.2f,
-            ModelInfo("grass", "plants.ltdb/wheatseedsa.png", 16)
+            ModelInfo("grass", "plants.ltdb/wheatseedsa.png", 1)
                 .setTransparent())
         ->addGrowthState(0.4f,
-            ModelInfo("grass", "plants.ltdb/wheatseedsb.png", 16)
+            ModelInfo("grass", "plants.ltdb/wheatseedsb.png", 1)
                 .setTransparent())
         ->addGrowthState(0.6f,
-            ModelInfo("grass", "plants.ltdb/wheatseedsc.png", 16)
+            ModelInfo("grass", "plants.ltdb/wheatseedsc.png", 1)
                 .setTransparent())
         ->addGrowthState(0.8f,
-            ModelInfo("grass", "plants.ltdb/wheatseedsd.png", 16)
+            ModelInfo("grass", "plants.ltdb/wheatseedsd.png", 1)
                 .setTransparent())
         ->initializeDefault();
     (new BasicBlockType(
          BlockTypeEnum::WHEAT,
          ItemTypeEnum::WHEAT,
-         ModelInfo("grass", "plants.ltdb/wheat.png", 16).setTransparent(),
+         ModelInfo("grass", "plants.ltdb/wheat.png", 1),
          [](Vec3<int> pos, int dimensionId) {
              AdditionalItemSpawningBlock* block
                  = new AdditionalItemSpawningBlock(
@@ -557,7 +557,7 @@ void initializeItemTypes()
          "Wheat Seeds",
          0,
          0,
-         ModelInfo("grass", "plants.ltdb/wheatseeds.png", 16),
+         ModelInfo("grass", "plants.ltdb/wheatseeds.png", 1),
          BlockTypeEnum::WHEAT_SEED))
         ->setHardness(0.1f)
         ->setPlacableProof(
@@ -582,7 +582,7 @@ void initializeItemTypes()
         "Wheat",
         0,
         0,
-        ModelInfo("grass", "plants.ltdb/wheat.png", 16),
+        ModelInfo("grass", "plants.ltdb/wheat.png", 1),
         []() {
             Item* item = ItemType::createBasicItem(ItemTypeEnum::WHEAT,
                 "Wheat",

+ 22 - 2
FactoryCraft/TypeRegistry.cpp

@@ -1,14 +1,17 @@
 #include "TypeRegistry.h"
 
 #include "BlockTypeGeneratorRule.h"
-#include "OverworldDimension.h"
+#include "OverworldDimensionGenerator.h"
 #include "TreeTemplate.h"
+#include "OverworldDimension.h"
 
 TypeRegistry::TypeRegistry()
     : ReferenceCounter()
 {
+    // register dimension generators
+    registerDimensionGeneratorFactory(new OverworldDimensionGeneratorFactory());
     // register dimensions
-    registerDimensionGeneratorFactory(new OverworldDimensionFactory());
+    registerDimension(new OverworldDimensionFactory());
     // register rules
     registerGeneratorRuleFactory(new BlockTypeGeneratorRuleFactory());
     // register templates
@@ -92,6 +95,23 @@ TypeRegistry::getDimensionGeneratorFactories() const
     return dimensionGenerators;
 }
 
+void TypeRegistry::registerDimension(DimensionFactory* factory)
+{
+    dimensionFactories.add(factory);
+}
+
+Dimension* TypeRegistry::createDimension(int id)
+{
+    for (DimensionFactory* factory : dimensionFactories)
+    {
+        if (factory->getDimensionId() == id)
+        {
+			return factory->createDimension();
+		}
+    }
+    return 0;
+}
+
 void TypeRegistry::registerGeneratorTemplate(GeneratorTemplateFactory* factory)
 {
     generatorTemplates.add(factory);

+ 5 - 0
FactoryCraft/TypeRegistry.h

@@ -3,12 +3,14 @@
 #include "DimensionGenerator.h"
 #include "GeneratorRule.h"
 #include "GeneratorTemplate.h"
+#include "Dimension.h"
 
 class TypeRegistry : public Framework::ReferenceCounter
 {
 private:
     Framework::RCArray<GeneratorRuleFactory> generatorRules;
     Framework::RCArray<DimensionGeneratorFactory> dimensionGenerators;
+    Framework::RCArray<DimensionFactory> dimensionFactories;
     Framework::RCArray<GeneratorTemplateFactory> generatorTemplates;
 
 public:
@@ -26,6 +28,9 @@ public:
     const Framework::RCArray<DimensionGeneratorFactory>&
     getDimensionGeneratorFactories() const;
 
+    void registerDimension(DimensionFactory* factory);
+    Dimension* createDimension(int id);
+
     void registerGeneratorTemplate(GeneratorTemplateFactory* factory);
     GeneratorTemplate* createGeneratorTemplate(
         Framework::JSON::JSONValue* zConfig);

+ 17 - 8
FactoryCraft/WorldLoader.cpp

@@ -24,16 +24,25 @@ WorldLoader::WorldLoader()
                               + Text(name->getText()) + "/entities");
             if (entities.open(Datei::Style::lesen))
             {
-                Dimension* dim = new Dimension((int)*name);
-                while (!entities.istEnde())
+                Dimension* dim = Game::INSTANCE->zTypeRegistry()->createDimension((int)*name);
+                if (dim)
                 {
-                    int type = 0;
-                    entities.lese((char*)&type, 4);
-                    dim->addEntity(
-                        StaticRegistry<EntityType>::INSTANCE.zElement(type)
-                            ->loadEntity(&entities));
+                    while (!entities.istEnde())
+                    {
+                        int type = 0;
+                        entities.lese((char*)&type, 4);
+                        dim->addEntity(
+                            StaticRegistry<EntityType>::INSTANCE.zElement(type)
+                                ->loadEntity(&entities));
+                    }
+                    Game::INSTANCE->addDimension(dim);
+                }
+                else
+                {
+                    std::cout << "ERROR: could not create dimension "
+                              << *name
+                              << ". No Factory was provided.\n";
                 }
-                Game::INSTANCE->addDimension(dim);
             }
         }
         names->release();

+ 2 - 0
Windows Version/Windows Version.vcxproj

@@ -218,6 +218,7 @@ copy ..\..\..\..\..\Allgemein\Framework\x64\release\Framework.dll Framework.dll<
     <ClCompile Include="..\FactoryCraft\NoBlock.cpp" />
     <ClCompile Include="..\FactoryCraft\Noise.cpp" />
     <ClCompile Include="..\FactoryCraft\OverworldDimension.cpp" />
+    <ClCompile Include="..\FactoryCraft\OverworldDimensionGenerator.cpp" />
     <ClCompile Include="..\FactoryCraft\NoiseInterpolator.cpp" />
     <ClCompile Include="..\FactoryCraft\Player.cpp" />
     <ClCompile Include="..\FactoryCraft\PlayerHand.cpp" />
@@ -311,6 +312,7 @@ copy ..\..\..\..\..\Allgemein\Framework\x64\release\Framework.dll Framework.dll<
     <ClInclude Include="..\FactoryCraft\Noise.h" />
     <ClInclude Include="..\FactoryCraft\NoBlock.h" />
     <ClInclude Include="..\FactoryCraft\OverworldDimension.h" />
+    <ClInclude Include="..\FactoryCraft\OverworldDimensionGenerator.h" />
     <ClInclude Include="..\FactoryCraft\NoiseInterpolator.h" />
     <ClInclude Include="..\FactoryCraft\Player.h" />
     <ClInclude Include="..\FactoryCraft\PlayerHand.h" />

+ 14 - 5
Windows Version/Windows Version.vcxproj.filters

@@ -94,6 +94,9 @@
     <Filter Include="world\generator\biom\rules">
       <UniqueIdentifier>{3a03ed08-0a9d-4887-a1f0-d2a84028c425}</UniqueIdentifier>
     </Filter>
+    <Filter Include="world\dimensions">
+      <UniqueIdentifier>{2ad688cd-aafc-4b2b-8163-964d1e87d087}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\FactoryCraft\Server.cpp">
@@ -123,7 +126,7 @@
     <ClCompile Include="..\FactoryCraft\WorldGenerator.cpp">
       <Filter>world\generator</Filter>
     </ClCompile>
-    <ClCompile Include="..\FactoryCraft\OverworldDimension.cpp">
+    <ClCompile Include="..\FactoryCraft\OverworldDimensionGenerator.cpp">
       <Filter>world\generator\dimensions</Filter>
     </ClCompile>
     <ClCompile Include="..\FactoryCraft\TickWorker.cpp">
@@ -360,6 +363,9 @@
     <ClCompile Include="..\FactoryCraft\BlockInfoCommand.cpp">
       <Filter>chat\commands</Filter>
     </ClCompile>
+    <ClCompile Include="..\FactoryCraft\OverworldDimension.cpp">
+      <Filter>world\dimensions</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\FactoryCraft\Chunk.h">
@@ -419,12 +425,9 @@
     <ClInclude Include="..\FactoryCraft\DimensionGenerator.h">
       <Filter>world\generator</Filter>
     </ClInclude>
-    <ClInclude Include="..\FactoryCraft\OverworldDimension.h">
+    <ClInclude Include="..\FactoryCraft\OverworldDimensionGenerator.h">
       <Filter>world\generator\dimensions</Filter>
     </ClInclude>
-    <ClInclude Include="..\FactoryCraft\Constants.h">
-      <Filter>game</Filter>
-    </ClInclude>
     <ClInclude Include="..\FactoryCraft\TickWorker.h">
       <Filter>world\ticking</Filter>
     </ClInclude>
@@ -638,5 +641,11 @@
     <ClInclude Include="..\FactoryCraft\BlockInfoCommand.h">
       <Filter>chat\commands</Filter>
     </ClInclude>
+    <ClInclude Include="..\FactoryCraft\OverworldDimension.h">
+      <Filter>world\dimensions</Filter>
+    </ClInclude>
+    <ClInclude Include="..\FactoryCraft\Constants.h">
+      <Filter>static</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>

+ 39 - 34
Windows Version/data/generator/overworld.json

@@ -101,44 +101,49 @@
               "factorA": 0.9
             },
             "multiplier": {
-              "type": "scale",
+              "type": "flatten",
               "noise": {
-                "type": "negate",
+                "type": "scale",
                 "noise": {
-                  "type": "scale",
+                  "type": "negate",
                   "noise": {
-                    "type": "Cellular",
-                    "multiplier": 0.4,
-                    "frequency": 0.005,
-                    "rotationType3D": "None",
-                    "fractalType": "DomainWarpIndependent",
-                    "cellularDistanceFunction": "Euclidean",
-                    "cellularReturnType": "Distance",
-                    "cellularJitter": 1.5,
-                    "domainWarpType": "OpenSimplex2Reduced",
-                    "domainWarpAmp": 100,
-                    "fractalOctaves": 3,
-                    "fractalLacunarity": 2,
-                    "fractalGain": 0.5,
-                    "seed": {
-                      "type": "operator",
-                      "operator": "+",
-                      "values": [
-                        {
-                          "type": "variable",
-                          "name": "dimensionSeed"
-                        },
-                        {
-                          "type": "constant",
-                          "value": 20
-                        }
-                      ]
-                    }
-                  },
-                  "factor": 3.5
-                }
+                    "type": "scale",
+                    "noise": {
+                      "type": "Cellular",
+                      "multiplier": 0.4,
+                      "frequency": 0.005,
+                      "rotationType3D": "None",
+                      "fractalType": "DomainWarpIndependent",
+                      "cellularDistanceFunction": "Euclidean",
+                      "cellularReturnType": "Distance",
+                      "cellularJitter": 1.5,
+                      "domainWarpType": "OpenSimplex2Reduced",
+                      "domainWarpAmp": 100,
+                      "fractalOctaves": 3,
+                      "fractalLacunarity": 2,
+                      "fractalGain": 0.5,
+                      "seed": {
+                        "type": "operator",
+                        "operator": "+",
+                        "values": [
+                          {
+                            "type": "variable",
+                            "name": "dimensionSeed"
+                          },
+                          {
+                            "type": "constant",
+                            "value": 20
+                          }
+                        ]
+                      }
+                    },
+                    "factor": 3.5
+                  }
+                },
+                "factor": 1.5
               },
-              "factor": 1.5
+              "factor": 0.95,
+              "addition": 0.05
             }
           },
           "factorA": 0.5