chore: modifiers are aware of parent terrain
This commit is contained in:
parent
80eb6ef4c0
commit
953e4abe5b
3 changed files with 18 additions and 6 deletions
|
|
@ -9,16 +9,27 @@ void Terrain::_bind_methods() {
|
|||
BIND_PROPERTY(Variant::INT, thread_count);
|
||||
}
|
||||
|
||||
void Terrain::ready() {
|
||||
construct_chunk_grid();
|
||||
void Terrain::child_order_changed() {
|
||||
this->modifiers.clear();
|
||||
for (Variant var : get_children()) {
|
||||
if (TerrainModifier * mod{ cast_to<TerrainModifier>(var) }) {
|
||||
mod->set_terrain(this);
|
||||
this->modifiers.push_back(mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Terrain::_notification(int what) {
|
||||
switch (what) {
|
||||
default:
|
||||
return;
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
if (!is_ready()) {
|
||||
connect("child_order_changed", callable_mp(this, &self_type::child_order_changed));
|
||||
}
|
||||
return;
|
||||
case NOTIFICATION_READY:
|
||||
ready();
|
||||
construct_chunk_grid();
|
||||
return;
|
||||
case NOTIFICATION_EXIT_TREE:
|
||||
this->workload_lock.lock();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue