Revert world object refactors

This commit is contained in:
2026-06-27 23:22:45 -07:00
parent 6bdb096e1b
commit 2a99d7ecf3
11 changed files with 72 additions and 99 deletions
+9 -9
View File
@@ -20,8 +20,8 @@ Projectile_Mode :: enum {
acquire_projectile :: proc(world: ^World) -> ^Projectile {
for i in 0 ..< MAX_PROJECTILES {
if !world.combat.projectiles[i].active {
return &world.combat.projectiles[i]
if !world.projectiles[i].active {
return &world.projectiles[i]
}
}
@@ -30,10 +30,10 @@ acquire_projectile :: proc(world: ^World) -> ^Projectile {
enemy_still_on_map :: proc(world: ^World, slot: int) -> (^Enemy, bool) {
if slot < 0 || slot >= MAX_ENEMIES do return nil, false
e := &world.combat.enemies[slot]
e := &world.enemies[slot]
if !e.active do return nil, false
if len(world.world_map.path) == 0 do return nil, false
if e.path_index >= len(world.world_map.path) do return nil, false
if len(world.path) == 0 do return nil, false
if e.path_index >= len(world.path) do return nil, false
return e, true
}
@@ -68,7 +68,7 @@ spawn_ballistic :: proc(world: ^World, from, dir: Vec2, damage: int, splash: f32
hit_enemy_at :: proc(world: ^World, pos: Vec2, damage: int) -> bool {
for i in 0 ..< MAX_ENEMIES {
e := &world.combat.enemies[i]
e := &world.enemies[i]
if !e.active do continue
if distance(pos, e.position) <= PROJECTILE_HIT_RADIUS {
apply_tower_hit(world, e, damage)
@@ -80,7 +80,7 @@ hit_enemy_at :: proc(world: ^World, pos: Vec2, damage: int) -> bool {
update_projectiles :: proc(world: ^World, dt: f32) {
for i in 0 ..< MAX_PROJECTILES {
p := &world.combat.projectiles[i]
p := &world.projectiles[i]
if !p.active do continue
switch p.mode {
@@ -132,7 +132,7 @@ update_ballistic_projectile :: proc(world: ^World, p: ^Projectile, dt: f32) {
render_projectiles :: proc(world: ^World) {
for i in 0 ..< MAX_PROJECTILES {
p := world.combat.projectiles[i]
p := world.projectiles[i]
if !p.active do continue
color := rl.GOLD
radius: f32 = 4
@@ -149,7 +149,7 @@ apply_splash_damage :: proc(world: ^World, center: Vec2, damage: int, radius: f3
hit_any := false
for i in 0 ..< MAX_ENEMIES {
e := &world.combat.enemies[i]
e := &world.enemies[i]
if !e.active do continue
if distance(center, e.position) <= radius {
apply_tower_hit(world, e, damage)