mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
Spawn different objects withing level
This commit is contained in:
parent
7434cb66e8
commit
4a4b80bef3
9 changed files with 85 additions and 18 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#include "ChunksController.h"
|
||||
|
||||
#include "scripting/scripting.h"
|
||||
#include "../objects/Object.h"
|
||||
|
||||
LevelController::LevelController(EngineSettings& settings, Level* level)
|
||||
: settings(settings), level(level) {
|
||||
|
|
@ -24,6 +25,19 @@ void LevelController::update(float delta, bool input, bool pause) {
|
|||
level->update();
|
||||
chunks->update(settings.chunks.loadSpeed);
|
||||
blocks->update(delta);
|
||||
|
||||
// erease null pointers
|
||||
level->objects.remove_if([](Object* obj) { return obj == nullptr; });
|
||||
|
||||
// update all objects that needed
|
||||
for(Object *obj : level->objects)
|
||||
{
|
||||
if(obj) {
|
||||
if(obj->shouldUpdate) {
|
||||
obj->update(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LevelController::onWorldSave() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue