basic ECS spawner

This commit is contained in:
2026-01-15 15:27:48 +01:00
parent 24a781f36a
commit eb737b469c
860 changed files with 58621 additions and 32 deletions

21
GECS/systems/s_spawner.gd Normal file
View File

@@ -0,0 +1,21 @@
class_name SpawnSystem
extends System
func query():
# Find all entities that have both transform and velocity
return q.with_all([C_SpawnPoint]).enabled()
func process(entities: Array[Entity], _components: Array, delta: float):
for entity in entities:
var spawn_point = entity.get_component(C_SpawnPoint) as C_SpawnPoint
if not spawn_point.should_spawn():
spawn_point.spawn_cooldown -= delta
continue
var spawned = spawn_point.spawn_prefab.instantiate() as Entity
get_tree().current_scene.add_child(spawned)
ECS.world.add_entity(spawned)
spawned.global_position = entity.global_position
spawn_point.start_spawn_cooldown()