The previous post covered the tower core architecture and how tower behaviors are structured across five distinct functional types. This one is about the Agent Profile system, which is responsible for how towers and battle units are initialized and managed at runtime.
BPC_AgentProfile is a component that acts as the central point of ownership for an agent's runtime state. In this context, an agent refers to any active participant in the game world, which in the toolkit means towers and battle units. It holds the agent's name, description, UI thumbnail, team ID, and references to all the components that make up that agent. Every tower and battle unit in the toolkit has one attached to it, and all component setup and initialization flows through it.
There are two specializations of the base agent profile, one for towers and one for battle units. BPC_AgentProfile_TowerUnit handles tower initialization, reading from the tower's data table row and dynamically adding the appropriate components: the hitpoints component, the targeting system, the tower core, and optionally the XP system if the tower supports leveling up.
BPC_AgentProfile_BattleUnit does the same for battle units, adding hitpoints, the appropriate attack modules based on the unit's combat role, the navigation component based on the configured navigation model, and again optionally the XP system for hero units.
The battle unit profile splits further into two child classes. BPC_AgentProfile_EnemyBattleUnit handles enemy units and carries additional data relevant to enemies such as threat rating and score modifiers. BPC_AgentProfile_FriendlyBattleUnit handles friendly units and adds logic for XP carryover on hero respawn. Both override the termination protocols from the parent to handle cleanup and fire the appropriate events when a unit is destroyed.
Initialization in both cases is driven by an init context struct passed in at spawn time. For towers this is Struct_TowerInitContext, which carries the data table row, grid placement info, and any stat modifiers to apply at initialization.
For battle units it is Struct_BattleUnitInitContext, which carries the data table row, team ID, navigation model, and lifespan for temporary summons.
One of the key design goals behind this system is that the base actor classes themselves stay as thin shells. They implement a small set of interface functions for retrieving the agent profile and a few basic primitive components, and everything else lives in the components themselves. Because the base class has no direct knowledge of the components beyond what comes through those interfaces, this decoupled design means towers and battle units are not tied to a specific actor hierarchy, giving anyone building on top of the toolkit the flexibility to use a custom base class that fits their project.
That wraps up the AgentProfile system for v3.0 of Tower Defense Starter Kit.
The next post will cover the changes to the Global Abilities system.




Comments
Post a Comment