Revert world object refactors
This commit is contained in:
+12
-12
@@ -59,8 +59,8 @@ get_enemy_archetype :: proc(kind: Enemy_Kind, wave: int) -> Enemy_Archetype {
|
||||
acquire_enemy :: proc(world: ^World) -> ^Enemy {
|
||||
// create an object pool with fixed slots to reuse instead of allocate/free every spawn
|
||||
for i in 0 ..< MAX_ENEMIES {
|
||||
if !world.combat.enemies[i].active {
|
||||
return &world.combat.enemies[i]
|
||||
if !world.enemies[i].active {
|
||||
return &world.enemies[i]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,14 +68,14 @@ acquire_enemy :: proc(world: ^World) -> ^Enemy {
|
||||
}
|
||||
|
||||
spawn_enemy :: proc(world: ^World, kind: Enemy_Kind) {
|
||||
if len(world.world_map.path) == 0 do return // don't spawn enemies if no paths exist
|
||||
if len(world.path) == 0 do return // don't spawn enemies if no paths exist
|
||||
|
||||
e := acquire_enemy(world) // grab a free slot
|
||||
if e == nil do return // if there are no slots, skil spawning
|
||||
|
||||
arch := get_enemy_archetype(kind, world.wave.current_wave)
|
||||
arch := get_enemy_archetype(kind, world.wave)
|
||||
e^ = Enemy {
|
||||
position = world.world_map.path[0],
|
||||
position = world.path[0],
|
||||
health = arch.health,
|
||||
max_health = arch.health,
|
||||
base_speed = arch.speed,
|
||||
@@ -87,19 +87,19 @@ spawn_enemy :: proc(world: ^World, kind: Enemy_Kind) {
|
||||
}
|
||||
|
||||
update_enemies :: proc(world: ^World, dt: f32) {
|
||||
if len(world.world_map.path) < 2 do return
|
||||
if len(world.path) < 2 do return
|
||||
|
||||
for i in 0 ..< MAX_ENEMIES {
|
||||
e := &world.combat.enemies[i]
|
||||
e := &world.enemies[i]
|
||||
if !e.active do continue
|
||||
|
||||
if e.path_index >= len(world.world_map.path) {
|
||||
world.player.base_health -= 1
|
||||
if e.path_index >= len(world.path) {
|
||||
world.base_health -= 1
|
||||
e.active = false
|
||||
continue
|
||||
}
|
||||
|
||||
target := world.world_map.path[e.path_index]
|
||||
target := world.path[e.path_index]
|
||||
move_speed := e.base_speed
|
||||
if e.slow_timer > 0 {
|
||||
move_speed *= ICE_SLOW_FACTOR
|
||||
@@ -118,7 +118,7 @@ update_enemies :: proc(world: ^World, dt: f32) {
|
||||
active_enemy_count :: proc(world: ^World) -> int {
|
||||
count := 0
|
||||
for i in 0 ..< MAX_ENEMIES {
|
||||
if world.combat.enemies[i].active do count += 1
|
||||
if world.enemies[i].active do count += 1
|
||||
}
|
||||
|
||||
return count
|
||||
@@ -126,7 +126,7 @@ active_enemy_count :: proc(world: ^World) -> int {
|
||||
|
||||
render_enemies :: proc(world: ^World) {
|
||||
for i in 0 ..< MAX_ENEMIES {
|
||||
e := world.combat.enemies[i]
|
||||
e := world.enemies[i]
|
||||
if !e.active do continue
|
||||
color := rl.MAROON
|
||||
size := 11
|
||||
|
||||
Reference in New Issue
Block a user