Overview
WCGASAICombatSubsystem is a World Subsystem that serves as the central coordination point for the AI combat system in the Wonderscape GAS Ally plugin. It automatically initializes for game worlds, tracks all registered combat components using O(1) TSet operations, broadcasts threat information for squad awareness, provides global combat queries for target aggregation, coordinates boss phase transitions, routes combat events to registered listeners, and manages squad formation and command distribution.
Purpose
The AI Combat Subsystem orchestrates all AI combat coordination by providing:
- Automatic Lifecycle Management: Created automatically for Game/PIE/GamePreview worlds; combat components register/unregister during their BeginPlay/EndPlay
- Combat Component Registry: Tracks all active
UWCGASAICombatComp instances in a TSet for O(1) registration and O(n) queries
- Threat Broadcasting: Shares threat information between squad members within configurable radius, filtered by faction relationships
- Combat Event Routing: Broadcasts combat events to global listeners and routes them to relevant source/target combat components
- Global Combat Queries: Provides aggregated queries for actors in combat, highest threat actors, and targeting status
- Boss Phase Integration: Broadcasts boss phase transitions globally for music, UI, and achievement system reactions
- Squad Coordination: Creates and manages squads with unique IDs, role assignments, formation slots, command distribution, and threat sharing
- Difficulty-Aware Configuration: Loads threat and squad configurations with automatic difficulty-based overrides via the Difficulty Subsystem
How It Works
Initialization Flow
- Subsystem Creation: When a Game/PIE/GamePreview world initializes, this subsystem is automatically created via UE's subsystem lifecycle
- Difficulty Subscription: Subscribes to
UWCGASDifficultySub::OnDifficultyChanged to reload configurations when difficulty changes
- Lazy Configuration Loading: Default threat and squad configurations are loaded on first access (not at startup) to minimize initialization cost
- Ready State: Subsystem is now ready to accept component registrations and process combat events