add on_update, on_render to docs & change entities tps to 20
This commit is contained in:
@@ -59,7 +59,8 @@ void Entity::setRig(const rigging::SkeletonConfig* rigConfig) {
|
||||
);
|
||||
}
|
||||
|
||||
Entities::Entities(Level* level) : level(level), sensorsTickClock(20, 3) {
|
||||
Entities::Entities(Level* level)
|
||||
: level(level), sensorsTickClock(20, 3), updateTickClock(20, 3) {
|
||||
}
|
||||
|
||||
template<void(*callback)(const Entity&, size_t, entityid_t)>
|
||||
@@ -440,8 +441,13 @@ void Entities::updatePhysics(float delta) {
|
||||
}
|
||||
}
|
||||
|
||||
void Entities::update() {
|
||||
scripting::on_entities_update();
|
||||
void Entities::update(float delta) {
|
||||
if (updateTickClock.update(delta)) {
|
||||
scripting::on_entities_update(
|
||||
updateTickClock.getTickRate(),
|
||||
updateTickClock.getParts(),
|
||||
updateTickClock.getPart());
|
||||
}
|
||||
}
|
||||
|
||||
static void debug_render_skeleton(
|
||||
@@ -505,10 +511,10 @@ void Entities::renderDebug(
|
||||
}
|
||||
|
||||
void Entities::render(
|
||||
Assets* assets, ModelBatch& batch, const Frustum& frustum, bool pause
|
||||
Assets* assets, ModelBatch& batch, const Frustum& frustum, float delta, bool pause
|
||||
) {
|
||||
if (!pause) {
|
||||
scripting::on_entities_render();
|
||||
scripting::on_entities_render(delta);
|
||||
}
|
||||
|
||||
auto view = registry.view<Transform, rigging::Skeleton>();
|
||||
|
||||
@@ -167,6 +167,7 @@ class Entities {
|
||||
std::unordered_map<entt::entity, entityid_t> uids;
|
||||
entityid_t nextID = 1;
|
||||
util::Clock sensorsTickClock;
|
||||
util::Clock updateTickClock;
|
||||
|
||||
void updateSensors(
|
||||
Rigidbody& body, const Transform& tsf, std::vector<Sensor*>& sensors
|
||||
@@ -183,10 +184,10 @@ public:
|
||||
|
||||
void clean();
|
||||
void updatePhysics(float delta);
|
||||
void update();
|
||||
void update(float delta);
|
||||
|
||||
void renderDebug(LineBatch& batch, const Frustum& frustum, const DrawContext& ctx);
|
||||
void render(Assets* assets, ModelBatch& batch, const Frustum& frustum, bool pause);
|
||||
void render(Assets* assets, ModelBatch& batch, const Frustum& frustum, float delta, bool pause);
|
||||
|
||||
entityid_t spawn(
|
||||
EntityDef& def,
|
||||
|
||||
Reference in New Issue
Block a user