x2 101 ground combat screen systems - GoldhawkInteractive/X2-Modding GitHub Wiki
The Ground Combat Screen is the tactical layer of Xenonauts 2 where turn-based combat takes place. This document outlines the key systems that make up the ground combat gameplay.
The GroundCombatScreen
class inherits from WorldManagedScreen<GameScreens, IScreenParameters>
and is responsible for initializing and managing the Ground Combat screen's ECS World and systems.
public sealed class GroundCombatScreen : WorldManagedScreen<GameScreens, IScreenParameters> {
// Screen initialization, update, and teardown logic
}
The Ground Combat screen systems can be grouped by their functional areas:
These systems handle fundamental ECS functionality and screen management:
// Core ECS systems
World.RegisterSystem<EntityListenerSystem>();
World.RegisterSystem<PromiseEventSystem>();
World.RegisterSystem<DelayedTaskSystem>();
World.RegisterSystem<TemplateRelationshipsSystem>();
World.RegisterSystem<SerializedLinkSystem>();
// Screen management
World.RegisterSystem<ScreenSystem<GameScreens, IScreenParameters>>();
World.RegisterSystem<LocalizationSystem>();
World.RegisterSystem<ScribanSystem>();
// Object pooling and management
World.RegisterSystem<GameObjectPoolSystem>();
World.RegisterSystem<PrototypeGameObjectSystem>();
World.RegisterSystem<GCGameObjectControllerSystem>();
These systems handle user input and selection:
// Input handling
World.RegisterSystem<GCPickingSystem>();
World.RegisterSystem<InputSystem>();
These systems manage the tactical game board and its properties:
// Board and map systems
World.RegisterSystem<GCBoardSystem>();
World.RegisterSystem<GCFallingSystem>();
World.RegisterSystem<FloorOffsetSystem>();
World.RegisterSystem<GCMapLayerSystem>();
These systems manage the units on the battlefield:
// Combatant initialization and state
World.RegisterSystem<CombatantInitializationSystem>();
World.RegisterSystem<CombatantStateSystem>();
World.RegisterSystem<CombatantTurnStatusSystem>();
// Combat abilities
World.RegisterSystem<AbilitySystem>();
World.RegisterSystem<GCAbilitySystem>();
// Animation and visuals
World.RegisterSystem<AnimatorSystem>();
World.RegisterSystem<VisualLightingSystem>();
World.RegisterSystem<IkSystem>();
World.RegisterSystem<MeshMergingSystem>();
World.RegisterSystem<ActorVisualVariationSystem>();
These systems handle the artificial intelligence for enemy units:
// AI systems
World.RegisterSystem<GCAISystem>();
World.RegisterSystem<GCTeamCoordinatorSystem>();
These systems handle line of sight, fog of war, and visibility:
// Visibility systems
World.RegisterSystem<SightSystem>();
World.RegisterSystem<FogOfWarAndShroudVisualizationSystem>();
World.RegisterSystem<SightingStateModelVisibilitySystem>();
World.RegisterSystem<HighlightSystem>();
// Transparency and model visibility
World.RegisterSystem<TransparencySystem>();
World.RegisterSystem<ShroudModelVisibilitySystem>();
World.RegisterSystem<LevelHideSimpleX1System>();
These systems implement the core tactical gameplay:
// Core combat systems
World.RegisterSystem<OverwatchSystem>();
World.RegisterSystem<PathingSystem>();
World.RegisterSystem<LifeStatusSystem>();
World.RegisterSystem<ActionSystem>();
// Damage systems
World.RegisterSystem<DamageSyncSystem>();
World.RegisterSystem<DamageSystem>();
World.RegisterSystem<DamageFrillSystem>();
World.RegisterSystem<TileDestructionMaterialManagementSystem>();
// Status effect systems
World.RegisterSystem<MoraleSystem>();
World.RegisterSystem<SuppressionSystem>();
World.RegisterSystem<BleedingSystem>();
World.RegisterSystem<StunSystem>();
World.RegisterSystem<GCStressSystem>();
World.RegisterSystem<GCInjurySystem>();
These systems handle items, weapons, and inventory management:
// Inventory systems
World.RegisterSystem<ItemRequestSystem>();
World.RegisterSystem<LoadoutProfileSystem>();
World.RegisterSystem<GCInventorySystem>();
World.RegisterSystem<GCWeaponSystem>();
World.RegisterSystem<GCHotKeySystem>();
World.RegisterSystem<GCCarryCapacitySystem>();
// Modifier systems
World.RegisterSystem<ModifierSystem>();
World.RegisterSystem<InventoryModifierSystem>();
These systems handle the user interface and camera:
// Camera systems
World.RegisterSystem<GroundCombatCameraSystem>();
World.RegisterSystem<CameraPanQueueSystem>();
World.RegisterSystem<GroundCombatCameraCutoffSystem>();
// UI systems
World.RegisterSystem<GroundCombatUIStateSystem>();
World.RegisterSystem<EntityMessageTickerSystem>();
World.RegisterSystem<GCWorldSpaceUISystem>();
World.RegisterSystem<ObjectLabelSystem>();
World.RegisterSystem<DialogSystem>();
World.RegisterSystem<ToastSystem>();
World.RegisterSystem<PortraitLayerManagementSystem>();
World.RegisterSystem<TooltipSystem>();
World.RegisterSystem<HyperlinkSystem>();
These systems handle interactive map elements:
// Map interaction systems
World.RegisterSystem<InteractiveItemsSystem>();
World.RegisterSystem<DoorSystem>();
World.RegisterSystem<TeleporterSystem>();
World.RegisterSystem<EnvironmentEffectsSystem>();
These systems handle mission objectives and completion:
// Mission systems
World.RegisterSystem<GCObjectiveSystem>();
World.RegisterSystem<ReinforcementsSystem>();
World.RegisterSystem<EvacuationSystem>();
World.RegisterSystem<UFOCrashSystem>();
World.RegisterSystem<GCSearchAreaSystem>();
These systems handle sound effects and music:
// Audio systems
World.RegisterSystem<GroundCombatAudioSystem>();
World.RegisterSystem<RegionAudioSystem>();
These systems handle character progression:
// Experience and progression
World.RegisterSystem<GCExperienceSystem>();
The Ground Combat screen follows this general lifecycle:
-
Initialization:
-
OnSetup()
is called with parameters from the Strategy screen - The ECS World is created and all systems are registered
- The Unity scene for the map is loaded
-
-
Map Setup:
- For a new mission: The map is loaded based on mission parameters
- For a loaded game: The map and entities are restored from the save
-
Deployment Phase:
- Players position their units for combat
-
GroundCombatDeploymentSystem
manages this phase
-
Combat Phase:
- Turn-based combat ensues
-
ActionSystem
and related systems manage unit actions
-
Mission Completion:
- Objectives are met or failed
- Results are prepared for return to the Strategy screen
-
Teardown:
-
OnExit()
is called when transitioning back to the Strategy screen -
DisposeWorld()
cleans up the ECS World and entities
-
Ground Combat uses a time unit-based turn system:
// Action and turn management
World.RegisterSystem<ActionSystem>();
This system manages each unit's available time units, action costs, and turn progression.
One of the most complex aspects of Ground Combat is visibility management:
// Vision systems
World.RegisterSystem<SightSystem>();
World.RegisterSystem<FogOfWarAndShroudVisualizationSystem>();
These systems control what units can see, how fog of war is revealed, and how line of sight is calculated.
The Action system is the heart of Ground Combat, managing what actions units can take:
World.RegisterSystem<ActionSystem>();
This includes movement, shooting, using items, and specialized abilities. Actions consume time units and can trigger reactions from enemy units.
Ground Combat includes reaction mechanics where units can fire during the enemy's turn:
World.RegisterSystem<OverwatchSystem>();
This system manages when and how units can react to enemy actions.
AI units are controlled by systems that assess the battlefield and make tactical decisions:
World.RegisterSystem<GCAISystem>();
World.RegisterSystem<GCTeamCoordinatorSystem>();
These systems control enemy unit behaviors, target selection, and tactical coordination.
The battlefield can include environmental hazards and effects:
World.RegisterSystem<EnvironmentEffectsSystem>();
This system manages fire, smoke, and other environmental conditions that affect gameplay.