x2 101 ground combat screen systems - GoldhawkInteractive/X2-Modding GitHub Wiki

Xenonauts 2 Modding - Ground Combat Screen Systems

Ground Combat Screen Overview

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.

GroundCombatScreen Class

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
}

System Organization by Feature

The Ground Combat screen systems can be grouped by their functional areas:

Core Systems

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>();

Input and Picking Systems

These systems handle user input and selection:

// Input handling
World.RegisterSystem<GCPickingSystem>();
World.RegisterSystem<InputSystem>();

Game Board Systems

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>();

Combatant Systems

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>();

AI Systems

These systems handle the artificial intelligence for enemy units:

// AI systems
World.RegisterSystem<GCAISystem>();
World.RegisterSystem<GCTeamCoordinatorSystem>();

Visibility and Vision Systems

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>();

Combat Mechanics Systems

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>();

Equipment and Inventory Systems

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>();

Camera and UI Systems

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>();

Map Element Systems

These systems handle interactive map elements:

// Map interaction systems
World.RegisterSystem<InteractiveItemsSystem>();
World.RegisterSystem<DoorSystem>();
World.RegisterSystem<TeleporterSystem>();
World.RegisterSystem<EnvironmentEffectsSystem>();

Mission Systems

These systems handle mission objectives and completion:

// Mission systems
World.RegisterSystem<GCObjectiveSystem>();
World.RegisterSystem<ReinforcementsSystem>();
World.RegisterSystem<EvacuationSystem>();
World.RegisterSystem<UFOCrashSystem>();
World.RegisterSystem<GCSearchAreaSystem>();

Audio Systems

These systems handle sound effects and music:

// Audio systems
World.RegisterSystem<GroundCombatAudioSystem>();
World.RegisterSystem<RegionAudioSystem>();

Experience and Progression Systems

These systems handle character progression:

// Experience and progression
World.RegisterSystem<GCExperienceSystem>();

Ground Combat Screen Lifecycle

The Ground Combat screen follows this general lifecycle:

  1. 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
  2. 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
  3. Deployment Phase:

    • Players position their units for combat
    • GroundCombatDeploymentSystem manages this phase
  4. Combat Phase:

    • Turn-based combat ensues
    • ActionSystem and related systems manage unit actions
  5. Mission Completion:

    • Objectives are met or failed
    • Results are prepared for return to the Strategy screen
  6. Teardown:

    • OnExit() is called when transitioning back to the Strategy screen
    • DisposeWorld() cleans up the ECS World and entities

Key Ground Combat Specific Features

Turn-Based Combat

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.

Line of Sight and Visibility

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.

Action System

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.

Overwatch and Reaction Fire

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 Behavior

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.

Environmental Effects

The battlefield can include environmental hazards and effects:

World.RegisterSystem<EnvironmentEffectsSystem>();

This system manages fire, smoke, and other environmental conditions that affect gameplay.

⚠️ **GitHub.com Fallback** ⚠️