x2 101 strategy screen systems - GoldhawkInteractive/X2-Modding GitHub Wiki

Xenonauts 2 Modding - Strategy Screen Systems

Strategy Screen Overview

The Strategy Screen (Geoscape) is the strategic layer of Xenonauts 2 where players manage their global operations. This document outlines the key systems that make up the strategy gameplay.

StrategyScreen Class

The StrategyScreen class inherits from WorldManagedScreen<GameScreens, IScreenParameters> and is responsible for initializing and managing the Strategy screen's ECS World and systems.

public class StrategyScreen : WorldManagedScreen<GameScreens, IScreenParameters> {
    // Screen initialization, update, and teardown logic
}

System Organization by Feature

The Strategy 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<FamilyEventListenerSystem>();
World.RegisterSystem<TemplateRelationshipsSystem>();
World.RegisterSystem<ScopedGuidSystem>();
World.RegisterSystem<PromiseEventSystem>();
World.RegisterSystem<DelayedTaskSystem>();

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

// Object pooling and management
World.RegisterSystem<GameObjectPoolSystem>();
World.RegisterSystem<TweenSystem>();

// Serialization and save systems
World.RegisterSystem<CommonSerializationSystem>();
World.RegisterSystem<StrategySaveGameSystem>();

Game Logic Systems

These systems implement the core gameplay rules and mechanics:

// Game logic foundation
World.RegisterSystem<StrategyLogicSystem>();
World.RegisterSystem<CampaignLogicSystem>();
World.RegisterSystem<CampaignUpliftSystem>();
World.RegisterSystem<GlobalVariableSystem>();
World.RegisterSystem<StrategyDifficultyConfigSystem>();
World.RegisterSystem<CampaignPlayTimeSystem>();

// Tutorial and guidance
World.RegisterSystem<TutorialWaitForSystem>();
World.RegisterSystem<TutorialExplainSystem>();
World.RegisterSystem<StrategyTutorialSystem>();

Project Management Systems

These systems handle research, engineering and other project-related mechanics:

// Project and research mechanics
World.RegisterSystem<ProjectSystem>();
World.RegisterSystem<EngineeringSystem>();
World.RegisterSystem<ResearchSystem>();
World.RegisterSystem<EspionageSystem>();
World.RegisterSystem<CommandPointSystem>();

Geoscape Entity Management

These systems manage the various entities on the geoscape:

// Personnel systems
World.RegisterSystem<ModifierSystem>();
World.RegisterSystem<InventoryModifierSystem>();
World.RegisterSystem<HiringPoolSystem>();
World.RegisterSystem<PersonnelCapacitySystem>();
World.RegisterSystem<PersonnelManagementSystem>();
World.RegisterSystem<ActorAssignmentSystem>();
World.RegisterSystem<ActorRecoverySystem>();
World.RegisterSystem<PersonnelAssignmentSystem>();

// Base systems
World.RegisterSystem<BuildingsManagementSystem>();
World.RegisterSystem<BaseStoresSystem>();
World.RegisterSystem<GeoBaseSystem>();
World.RegisterSystem<TrainingSystem>();
World.RegisterSystem<GeoBaseAirDefenceSystem>();

// Aircraft and squad systems
World.RegisterSystem<StrategyInventorySystem>();
World.RegisterSystem<AircraftInventorySystem>();
World.RegisterSystem<StrikeTeamSystem>();
World.RegisterSystem<LoadoutProfileSystem>();
World.RegisterSystem<AircraftSystem>();
World.RegisterSystem<XenonautAircraftSystem>();
World.RegisterSystem<AlienAircraftSystem>();
World.RegisterSystem<SquadronSystem>();
World.RegisterSystem<WaypointSystem>();

Regional and Global Management

These systems handle global game mechanics and regional interactions:

// Regional management
World.RegisterSystem<RegionalRelationsSystem>();
World.RegisterSystem<RegionalSupportersSystem>();
World.RegisterSystem<RegionalInfiltrationSystem>();
World.RegisterSystem<RegionalRecoverySystem>();

// Global threats and progression
World.RegisterSystem<DoomsdayCounterSystem>();
World.RegisterSystem<OrbitalBombardmentSystem>();
World.RegisterSystem<RadarSystem>();
World.RegisterSystem<AlienThreatSystem>();
World.RegisterSystem<EndgameSystem>();

Character Management Systems

These systems deal with character development and statistics:

// Character stats and development
World.RegisterSystem<StrategyExperienceSystem>();
World.RegisterSystem<StrategyInjurySystem>();
World.RegisterSystem<MedalSystem>();
World.RegisterSystem<StressSystem>();
World.RegisterSystem<StrategyActorHealthSystem>();
World.RegisterSystem<BirthdaySystem>();

UI and Visualization Systems

These systems handle the user interface and visual representation:

// UI systems
World.RegisterSystem<StrategyPortraitLayerManagementSystem>();
World.RegisterSystem<StrategyUISystem>();
World.RegisterSystem<NotificationSystem>();
World.RegisterSystem<DialogSystem>();
World.RegisterSystem<ToastSystem>();
World.RegisterSystem<HyperlinkSystem>();
World.RegisterSystem<TooltipSystem>();

// Geoscape visualization
World.RegisterSystem<GeoscapeCameraSystem>();
World.RegisterSystem<GeoscapePositioningSystem>();
World.RegisterSystem<GeoscapeNavigationSystem>();
World.RegisterSystem<GeoscapeMovementSystem>();

Mission Systems

These systems handle mission generation, management and completion:

// Mission mechanics
World.RegisterSystem<MissionSystem>();
World.RegisterSystem<ActivitySystem>();
World.RegisterSystem<AnomalySystem>();
World.RegisterSystem<StrategyObjectiveSystem>();
World.RegisterSystem<MissionCompleteRequestSystem>();

// Economy and resources
World.RegisterSystem<FundingSystem>();
World.RegisterSystem<XenonautsFundingSystem>();
World.RegisterSystem<TradingSystem>();

Strategy Screen Lifecycle

The Strategy screen follows this general lifecycle:

  1. Initialization:

    • OnSetup() is called with parameters from the previous screen
    • The ECS World is created and all systems are registered
    • InitializeWorld() sets up the World configuration
  2. Startup Logic:

    • If starting a new game: StartNewGame() is called
    • If loading a save: StartLoadSaveGame() is called
    • If returning from ground combat: StartGCToStrategy() is called
  3. Runtime:

    • The Update() method processes the ECS system updates each frame
    • Events are dispatched and handled by registered systems
  4. Teardown:

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

Key Strategy Specific Features

Campaign Management

The Strategy screen maintains the campaign state, which includes:

  • Global time progression
  • Regional relations and funding
  • Research and engineering progress
  • Base construction and management
  • Aircraft operations

Time Management

The Strategy screen handles the passage of time via the clock system:

// Time-related systems
World.RegisterSystem<TimelineSystem>();
World.RegisterSystem<TimeTransitionSystem>();

This controls how time passes, which activities progress, and when time-dependent events trigger.

Geoscape Events

The geoscape generates random events and activities:

World.RegisterSystem<ActivitySystem>();
World.RegisterSystem<AnomalySystem>();

These systems create UFO sightings, terror missions, and other activities that the player needs to respond to.

Strike Team Deployment

When the player engages in ground combat, the strategy screen:

  1. Prepares the combat parameters
  2. Transfers relevant entity data to the ground combat screen
  3. Freezes the strategy world state
  4. Upon return, processes the combat results

This is managed primarily through these systems:

World.RegisterSystem<StrikeTeamSystem>();
World.RegisterSystem<StrategyRequisitionSystem>();