fix new world entities id & initial state of lua random
This commit is contained in:
parent
f7d0ec438f
commit
a68be271c6
@ -306,6 +306,8 @@ end
|
|||||||
stdcomp = require "core:internal/stdcomp"
|
stdcomp = require "core:internal/stdcomp"
|
||||||
entities.get = stdcomp.get_Entity
|
entities.get = stdcomp.get_Entity
|
||||||
|
|
||||||
|
math.randomseed(time.uptime()*1536227939)
|
||||||
|
|
||||||
-- Deprecated functions
|
-- Deprecated functions
|
||||||
block_index = block.index
|
block_index = block.index
|
||||||
block_name = block.name
|
block_name = block.name
|
||||||
|
|||||||
@ -15,10 +15,10 @@
|
|||||||
#include "../items/Inventories.hpp"
|
#include "../items/Inventories.hpp"
|
||||||
|
|
||||||
Level::Level(
|
Level::Level(
|
||||||
std::unique_ptr<World> world,
|
std::unique_ptr<World> worldPtr,
|
||||||
const Content* content,
|
const Content* content,
|
||||||
EngineSettings& settings
|
EngineSettings& settings
|
||||||
) : world(std::move(world)),
|
) : world(std::move(worldPtr)),
|
||||||
content(content),
|
content(content),
|
||||||
chunksStorage(std::make_unique<ChunksStorage>(this)),
|
chunksStorage(std::make_unique<ChunksStorage>(this)),
|
||||||
physics(std::make_unique<PhysicsSolver>(glm::vec3(0, -22.6f, 0))),
|
physics(std::make_unique<PhysicsSolver>(glm::vec3(0, -22.6f, 0))),
|
||||||
@ -26,9 +26,11 @@ Level::Level(
|
|||||||
entities(std::make_unique<Entities>(this)),
|
entities(std::make_unique<Entities>(this)),
|
||||||
settings(settings)
|
settings(settings)
|
||||||
{
|
{
|
||||||
entities->setNextID(this->world->nextEntityId);
|
if (world->nextEntityId) {
|
||||||
|
entities->setNextID(world->nextEntityId);
|
||||||
|
}
|
||||||
auto inv = std::make_shared<Inventory>(
|
auto inv = std::make_shared<Inventory>(
|
||||||
this->world->getNextInventoryId(), DEF_PLAYER_INVENTORY_SIZE
|
world->getNextInventoryId(), DEF_PLAYER_INVENTORY_SIZE
|
||||||
);
|
);
|
||||||
auto player = spawnObject<Player>(
|
auto player = spawnObject<Player>(
|
||||||
this, glm::vec3(0, DEF_PLAYER_Y, 0), DEF_PLAYER_SPEED, inv, 0
|
this, glm::vec3(0, DEF_PLAYER_Y, 0), DEF_PLAYER_SPEED, inv, 0
|
||||||
@ -39,7 +41,7 @@ Level::Level(
|
|||||||
settings.chunks.padding.get()
|
settings.chunks.padding.get()
|
||||||
) * 2;
|
) * 2;
|
||||||
chunks = std::make_unique<Chunks>(
|
chunks = std::make_unique<Chunks>(
|
||||||
matrixSize, matrixSize, 0, 0, this->world->wfile.get(), this
|
matrixSize, matrixSize, 0, 0, world->wfile.get(), this
|
||||||
);
|
);
|
||||||
lighting = std::make_unique<Lighting>(content, chunks.get());
|
lighting = std::make_unique<Lighting>(content, chunks.get());
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user