Task #25: arrivals wait for a free character
A planned ground arrival whose type has no free character used to be
skipped (spawn_skipped) and lost. Now it waits and comes in as soon as
one frees, without holding back other types; any still waiting at
sunrise are dropped and counted.
- EnemySystem.can_spawn(type): room and, on foot, a free character
(EnemyCharacters.has_free; a corpse counts), no side effects.
- WaveDirector.step: due arrivals that can't spawn go to a per-type
FIFO; waiting ones are admitted first each tick. waited / dropped
counters next to spawned, reset at nightfall; waiting() for tests.
- GameConfig.character_pool {"thief": 48, "breaker": 20} replaces
EnemyCharacters.POOL; the pools are built from it at setup.
- RULES.md, Night plans: the real limits and the waiting rule.
- test_roster: full thief pool -> the thief waits, crows stay on time,
a freed character (corpse) lets it in, sunrise drops and counts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3bb835f7c3
commit
af48cff80d
6 changed files with 201 additions and 13 deletions
|
|
@ -1,8 +1,9 @@
|
|||
class_name EnemyCharacters
|
||||
extends Node3D
|
||||
## The KayKit characters that draw ground enemies (EnemySystem keeps the simulation; flyers stay
|
||||
## in its MultiMesh). A fixed pool per type is created at load and never grows: a ground enemy
|
||||
## only spawns while its type has a free character.
|
||||
## in its MultiMesh). A fixed pool per type (GameConfig.character_pool) is created at setup and
|
||||
## never grows: a ground enemy only spawns while its type has a free character (has_free; a due
|
||||
## arrival waits for one, WaveDirector).
|
||||
## thief Mannequin_Medium, tinted dark, Rig_Medium clips (player_animations.res)
|
||||
## breaker Mannequin_Large, rust red, scaled down, a club in its right hand, Rig_Large clips
|
||||
## (breaker_animations.res)
|
||||
|
|
@ -12,7 +13,6 @@ extends Node3D
|
|||
## for CORPSE_TIME; a corpse is only for show, so a new enemy can take it over at once when no
|
||||
## other character is free.
|
||||
|
||||
const POOL := {EnemySystem.TYPE_THIEF: 48, EnemySystem.TYPE_BREAKER: 20}
|
||||
const CORPSE_TIME := 1.6
|
||||
const HIT_TIME := 0.35
|
||||
const KIT := "res://assets/kaykit_characters/characters/"
|
||||
|
|
@ -36,6 +36,8 @@ const CLIPS := {
|
|||
|
||||
var enemies: EnemySystem
|
||||
var config: GameConfig
|
||||
## Characters per ground type (EnemySystem type id -> count), from GameConfig.character_pool.
|
||||
var pool := {}
|
||||
## Per character (index into the arrays below): its type, the enemy id it draws (-1 when free),
|
||||
## and timers.
|
||||
var type := PackedByteArray()
|
||||
|
|
@ -55,10 +57,17 @@ func setup(p_enemies: EnemySystem, p_config: GameConfig) -> void:
|
|||
enemies = p_enemies
|
||||
config = p_config
|
||||
var shader := load("res://game/resources/enemy_overlay.gdshader") as Shader
|
||||
for t: int in POOL:
|
||||
pool.clear()
|
||||
for type_name in p_config.character_pool:
|
||||
var t := EnemySystem.TYPE_NAMES.find(String(type_name))
|
||||
if not SCENES.has(t):
|
||||
push_warning("GameConfig.character_pool: '%s' isn't an enemy type on foot" % type_name)
|
||||
continue
|
||||
pool[t] = maxi(int(p_config.character_pool[type_name]), 0)
|
||||
for t: int in pool:
|
||||
var scene := load(SCENES[t]) as PackedScene
|
||||
var library := load(LIBRARIES[t]) as AnimationLibrary
|
||||
for k in POOL[t]:
|
||||
for k in pool[t]:
|
||||
var root := Node3D.new()
|
||||
root.name = "%s_%d" % [EnemySystem.TYPE_NAMES[t], k]
|
||||
root.visible = false
|
||||
|
|
@ -93,6 +102,20 @@ func setup(p_enemies: EnemySystem, p_config: GameConfig) -> void:
|
|||
hit_left.append(0.0)
|
||||
|
||||
|
||||
## The type's characters in all (0 for a type without any).
|
||||
func pool_size(t: int) -> int:
|
||||
return int(pool.get(t, 0))
|
||||
|
||||
|
||||
## Whether acquire(t, ...) would succeed now: a character of the type not drawing a live enemy (a
|
||||
## corpse counts: it can be taken over). No side effects.
|
||||
func has_free(t: int) -> bool:
|
||||
for c in type.size():
|
||||
if type[c] == t and enemy_id[c] < 0:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
## Characters of the type not drawing a live enemy (corpses included: they can be taken over).
|
||||
func free_count(t: int) -> int:
|
||||
var n := 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue