td

SourceIndexGlossary
Login

SourceIndexGlossary

Home · Architecture · Combat · Extensions · Known gaps · Source index

Source index and glossary

Source snapshot: 1c4f2f89ebf6c70e81dccb412394be06a69fa932.

Scope: every Rust module under src/ and the direct dependencies declared in Cargo.toml at the stated snapshot. This page does not derive claims from plan/ or prose architecture documents. For implementation recipes, see Extension guides.

Module map

Crate root and simulation

Module Responsibility Principal symbols
src/main.rs Binary crate root, module declarations, Macroquad window configuration, frame loop, crate-panel input, and quit handling window_conf, main
src/world.rs Authoritative game state; arena, player, projectile, UI state; registries; entity allocation/spawning; command application and event delivery World, Projectile, Player, Screen, UiAction, Arena, ctx, apply_commands, deliver_events
src/systems.rs Ordered simulation passes, command-buffer wrapper, waves, enemy/tower/projectile/status/death/animation updates, crate UI, and rendering step_world, tick_wave, tick_enemies, tick_tower, tick_projectiles, animation_system, draw_simulation, weapons_crate, apply_action; private run_system, pool_pass, death_sweep
src/types.rs Small shared domain values used across commands, contexts, and entities DamageType, Source, DamageDelivery, DespawnReason, GameEvent, ResourceKind
src/command.rs Deferred write model for behavior effects Command, CommandBuffer, Transform, TransformEntity
src/context.rs Shared behavior capabilities and event-specific contexts; typed damage accumulator BehaviorCtx, DamageEffects, DamageMap, HitContext, FireContext, TickContext, ExpireContext, DeathContext, EventContext, ExpireReason
src/registry.rs Generic string-to-dense-ID content registry and seeded weapon, enemy, damage, and status catalogs ContentKind, Id, Registry, WeaponRegistry, EnemyRegistry, DamageRegistry, StatusRegistry, and their ID/content marker aliases
src/spatial.rs Per-pass enemy snapshots, uniform broad-phase grid, and read-only behavior queries Grid, EnemySnapshot, EnemyRef, SpatialQuery
src/geometry.rs Projectile geometry helpers steer, reflect_dir, normal_off_enemy
src/rng.rs Seeded deterministic random stream and per-pass child streams Rng::seeded, fork, next_u32, f32, range_f32
src/animations.rs Animation data and draw dispatch for enemy death VFX AnimationTypes, Animation, Animation::animate; private animate_enemy_death, draw_weapon_crate

Behavior kernels

Module Responsibility Principal symbols
src/behavior/mod.rs Declares behavior submodules and generates object-safe boxed cloning for behavior traits dyn_clone_trait!
src/behavior/projectile.rs Projectile hook contract, ordering tiers, hit-response fold, and dispatch BehaviorPriority, ProjectileBehavior, HitResponse, DamageResponse, dispatch_enemy_hit, dispatch_wall_hit, dispatch_projectile_tick, dispatch_expire
src/behavior/enemy.rs Enemy passive hook contract and tick/death dispatch EnemyBehavior, dispatch_death, dispatch_enemy_tick
src/behavior/status.rs Status hook contract, periodic-damage implementation, and status retention/removal pass StatusBehavior, PeriodDamage, dispatch_status_tick
src/behavior/damage.rs Declares pure target-aware damage behavior interface and identity implementations Damage, DamageBehavior, Physical, Acid, Poison
src/behavior/pool.rs Ground-pool hook contract and tick dispatch PoolBehavior, dispatch_pool_tick
src/behavior/tower.rs Declares tower-mod hooks corresponding to projectile lifecycle events TowerBehavior

Weapons and tower

Module Responsibility Principal symbols
src/weapons/mod.rs Exports concrete weapon behavior modules impact, poison
src/weapons/impact.rs Base impact behavior that adds tier-scaled physical damage at impact priority TowerBaseWeapon
src/weapons/poison.rs On-hit modifier that appends an attributed periodic-damage status PoisonCoating
src/tower.rs Tower entity, persistent weapon-ID/tier loadout, tower-mod storage, and hit/DoT DPS windows DpsMeter, DamageMeters, Tower, tower_location

Enemies

Module Responsibility Principal symbols
src/enemy.rs Live enemy entity, damage/resistance application, status storage, lifecycle state, and lightweight corpse snapshot EnemyState, Enemy, Corpse
src/enemies/mod.rs Exports concrete enemy modules and defines the enemy-kind factory contract EnemyKind
src/enemies/blob.rs Basic tier-scaled enemy kind, drawing callback, and default passive composition Blob
src/enemies/movement.rs Center-seeking movement behaviors and center-reach despawn emission SeekCenter, ZigZag
src/enemies/behaviors.rs Enemy death passive that queues deterministic radial replication SplitOnDeath

Ground pools

Module Responsibility Principal symbols
src/pool.rs Stationary pool entity and direct constructors for acid and slow configurations GroundPool, GroundPool::acid, GroundPool::slow
src/pools/mod.rs Exports concrete pool behavior modules acid, slow
src/pools/acid.rs Scaffold for continuous damage to enemies within a pool AcidTick
src/pools/slow.rs Scaffold for applying a future movement-modifier status within a pool SlowTick

Major symbol index

Runtime and state

Symbol Kind Role
World struct Owns simulation collections, registries, RNG, grid, arena, UI/player/tower state, time, and the next entity ID
step_world function Runs wave, enemy/status, tower, projectile, death, and animation phases in order
run_system private function Creates one command buffer and forked RNG, runs a pass, applies commands, then delivers events
apply_commands function Sole command-to-world mutation dispatcher
deliver_events function Processes event waves through a guarded cascade and applies commands emitted by handlers
EntityId alias Runtime identity, currently u64 allocated monotonically by World
Player struct Tracks XP, level, pending weapon choices, and crate-close status
Screen enum Selects normal play or weapon-crate panel

Deferred effects and contexts

Symbol Kind Role
Command enum Represents deferred spawn, damage, status, despawn, resource, event, animation, and replication writes
CommandBuffer struct Collects commands while systems hold entity borrows
BehaviorCtx struct Shared command/query/RNG/source/time capability bundle
HitContext struct Hit geometry plus accumulated damage and statuses
FireContext struct Declared muzzle/aim/target data for spawn shaping; not constructed by current runtime
TickContext struct Shared context plus simulation dt
ExpireContext struct Shared context plus expiry reason
DeathContext struct Shared context plus death position and killer
EventContext struct Shared context for event-bus handlers

Content and behavior

Symbol Kind Role
Registry<K> generic struct Interns stable names, stores display metadata/factories, and returns type-distinct dense IDs
Id<K> generic struct Copyable dense content ID whose marker prevents cross-registry mixing
WeaponID, EnemyID, DamageID, StatusID aliases Marker-specialized registry IDs
ProjectileBehavior trait Composable fire/hit/wall/tick/expiry hooks carried by projectiles
EnemyBehavior trait Stateful tick/death hooks carried by enemies
StatusBehavior trait Enemy-attached tick hook whose Boolean result controls removal
DamageBehavior trait Declared pure damage magnitude rule; factories exist but live damage does not call them
PoolBehavior trait Tick hook carried by stationary ground pools
TowerBehavior trait Declared tower-mod lifecycle hooks; no runtime dispatcher exists
BehaviorPriority constants Conventional ordering bands from pre-processing through post-processing
HitResponse struct Per-behavior pierce/reflection response folded by projectile dispatch

Combat and entities

Symbol Kind Role
DamageMap struct Maps each DamageID to its flat, increased, and more/less accumulators
DamageEffects struct Computes one damage kind as flat * max(1 + increased, 0) * more, floored at zero
DamageDelivery enum Tags damage as direct hit or DoT for meter accounting
Source enum Attribution marker, currently Tower or None
Projectile struct Moving behavior carrier with velocity, lifetime, radius, source, and behavior list
Enemy struct Damageable moving entity with statuses, resistance map, passives, kind ID, and draw callback
Corpse struct Copyable death snapshot used as an event payload
GroundPool struct Stationary behavior carrier with position, radius, TTL, and source
Tower struct Aiming/firing entity with persistent weapon levels, undeployed tower mods, and DPS meters
PeriodDamage struct Continuous periodic-damage status that captures source attribution
SplitOnDeath struct Queues child enemies around a dead source using deterministic jitter

Spatial, events, and metrics

Symbol Kind Role
EnemySnapshot struct Owned per-pass row containing ID, position, HP, and collision radius
Grid struct Uniform cells containing indices into the current enemy snapshot
SpatialQuery struct Nearest, radius, and collision queries over snapshot plus grid
EnemyRef struct Copyable query result used to write later by entity ID
GameEvent enum Event payload for enemy death, enemy despawn, or custom strings
DpsMeter struct Trailing timestamp/amount window
DamageMeters struct Separate hit and DoT meters plus combined DPS

Cargo dependency inventory

The classifications below are based on references in the current src/ tree, not on intended future use or transitive dependencies.

Dependency Declared configuration Classification Source-grounded use
macroquad 0.4.15 Used Window/main macro, frame timing/input, Vec2, colors, shapes, text, and rendering across main, systems, entities, geometry, contexts, and animations
hecs 0.11.0 Declared only No hecs path, import, macro, or symbol appears in src/; entities are stored in Vec collections on World
mlua 0.11.6, features lua54, vendored Declared only No Lua or mlua reference appears in src/
serde 1, feature derive Declared only No serde import or serialization derive appears in src/
serde_json 1 Declared only No serde_json reference appears in src/
strum 0.28.0, feature derive Declared only No strum import or derive appears in src/

Cargo.toml source: Cargo.toml.

Architecture glossary

Term Source-grounded definition
Authoritative world The single World value that owns all live mutable simulation collections and registries.
Behavior A cloneable trait object attached to a projectile, enemy, status list, pool, or tower-mod list. A dispatcher invokes its hooks for a lifecycle event.
Behavior context BehaviorCtx plus event-specific fields. It supplies deferred writes, spatial reads, deterministic RNG, source attribution, and simulation time without giving a behavior unrestricted world access.
Behavior priority An integer ordering convention. It is actively used to sort projectile behaviors when a shot is built; priority methods on enemies/statuses and registry metadata are not currently consumed.
Command buffer The pass-local Vec<Command> used to record mutations that cannot safely or deterministically happen while entity collections are borrowed.
Apply point The call to apply_commands after a system closure returns. It is where queued writes become world mutations.
Event wave One batch handled by deliver_events. Commands emitted while handling a batch can emit the next batch; processing stops after eight waves.
Snapshot A per-pass owned copy of selected enemy fields. Spatial reads use it while live entity writes remain deferred or target IDs directly.
Spatial grid A uniform broad-phase index rebuilt from each pass's EnemySnapshot; each cell stores snapshot indices, not entity IDs.
Read by snapshot, write by ID The access rule embodied by SpatialQuery and CommandBuffer: inspect copyable query results, then queue an effect against EnemyRef.id.
Content kind A zero-sized marker implementing ContentKind to specify a registry factory's argument and output types.
Registry ID Id<K>, a dense u32 plus marker type. The marker prevents, for example, passing a weapon ID where a damage ID is required.
Stable content name The string interned by a registry, such as "impact" or "blob", used for source-level lookup. It is distinct from the display name.
Factory The boxed closure stored in a registry definition and invoked by Registry::make to materialize content from its arguments.
Weapon loadout Tower.weapon_levels, a persistent map from WeaponID to tier. It stores identity/progression, while fresh behavior objects are created for every shot.
Projectile behavior pipeline The sorted behavior vector on a projectile and the dispatch functions that fold all hook results for tick, hit, wall-hit, and expiry events.
Accumulate then finalize The hit pattern in which behaviors first add damage/statuses to HitContext, after which tick_projectiles emits one damage command and status-application commands.
Flat damage Base magnitude accumulated for one DamageID.
Increased/reduced Additive percentage pool for one damage kind; all contributions sum before application.
More/less Independently multiplied factors for one damage kind; each call compounds and is floored at zero.
Damage delivery A hit-versus-DoT tag used for separate DPS tracking, independent of DamageID.
Source attribution Source captured on projectiles, pools, damage commands, and periodic statuses to identify tower-originated effects for killer and meter accounting.
Status A boxed StatusBehavior owned by an enemy. Its tick return value decides whether it remains in the status vector.
Enemy kind A registry factory that builds the complete initial Enemy template for a tier, then receives its real EnemyID through make_kind.
Enemy passive An EnemyBehavior object in Enemy.behaviors, invoked on enemy tick and/or death.
Corpse snapshot A small copy of death-relevant enemy data carried by GameEvent::EnemyKilled, avoiding references to a soon-removed live enemy.
Replication Command::Replicate with an enemy transform; command application rebuilds the same kind/tier, clones source behaviors, places it, and assigns a new entity ID.
Ground pool A stationary GroundPool configured with radius, TTL, source, and pool behaviors. It is not registry-backed in this snapshot.
Simulation time World.now and the dt passed through tick contexts. main caps frame dt at 0.05; there is no separate active pause-time implementation beyond UI flow.
Runtime wiring A complete path from declaration and construction through storage, dispatcher invocation, command application, and reachability from normal play. A declared trait, registry entry, or private pass alone is not runtime wiring.
Declared-only system Source that compiles and models an intended extension point but has no caller in the live frame path, such as tower-mod dispatch, projectile on_fire, or the pool pass.

Current runtime boundaries

These distinctions are important when following the extension guides:

Home · Architecture · Combat · Extensions · Known gaps · Source index