XSharp

Game content projects

Common enemies and bosses use separate projects for each original game. Applications explicitly reference and register the content they need. The dependency direction is content module -> engine; the engine has no project reference to these six modules.

Project Role Content migrated on this branch
XSharp.Enemies.X1 Mega Man X common enemies Sine Faller and functional roster; Creeper generated native control with host parity pending
XSharp.Enemies.X2 Mega Man X2 common enemies Scriver, opt-in Aclanda and functional roster
XSharp.Enemies.X3 Mega Man X3 common enemies Functional roster and subtype variants
XSharp.Bosses.X1 Mega Man X bosses Bosspider, Petitpider helpers and embedded sprite sheet
XSharp.Bosses.X2 Mega Man X2 bosses Registration entry point ready for migrated/translated bosses
XSharp.Bosses.X3 Mega Man X3 bosses Registration entry point ready for migrated/translated bosses

Application configuration

Add project references to the desired backend and content modules. For the currently migrated X1 content:

<ItemGroup>
  <ProjectReference Include="../XSharpDX9/XSharpDX9.csproj" />
  <ProjectReference Include="../XSharp.Enemies.X1/XSharp.Enemies.X1.csproj" />
  <ProjectReference Include="../XSharp.Bosses.X1/XSharp.Bosses.X1.csproj" />
</ItemGroup>

Register content before initialization loads the level’s object events:

using XSharp.Engine;
using XSharp.Engine.Content;
using XSharp.Enemies.X1;
using XSharp.Bosses.X1;

BaseEngine.Initialize<DX9Engine>(initializers,
    new IGameContentModule[] { new X1EnemiesModule(), new X1BossesModule() });

The WinForms demo registers the X1/X2/X3 enemy modules, with X2EnemiesModule.EnableAclanda enabled, and the X1 bosses module. Other applications select their own module references. X1 event 63 is supplied by the X1 bosses module; an application that omits that module intentionally omits Bosspider. CreateBoss<T> connects an optional boss factory to the core room/defeat lifecycle without introducing an engine dependency on game content.

EnemyContentRegistry belongs to an engine instance. Module registration is transactional: duplicate IDs, invalid entries or failed composite modules leave the existing registry intact. Event IDs are scoped by game. A registered factory may return null for an unsupported subtype, which prevents accidental dispatch through a legacy fallback. Sine Faller event 10 supports airborne subtype zero and the new functional ground subtype one. Other subtypes are rejected.

Port structure

The functional roster records available actors. The assembly conversion ledger separately tracks native-code generation, host adaptation and validation. Available content is not evidence of complete original AI translation.

Put a translated common enemy under XSharp.Enemies.Xn, including its motion/state model, effects specific to that enemy and embedded assets. Put bosses and boss-specific helpers under XSharp.Bosses.Xn. Reusable engine mechanics and the common Enemy/Boss base classes belong to the engine. A game-specific motion model should perform deterministic simulation without creating graphics or audio devices.

The Aclanda port documents the first X2 body-controller milestone, the 726-frame original observation fixture, ROM-byte checks and remaining integration. A validated model alone does not register the enemy or establish full-scene parity.

Register original event/subtype mappings in that project’s Module.cs. Use the assembly-aware overload when loading embedded assets:

sheet.CurrentTexture = engine.CreateImageTextureFromEmbeddedResource(
    typeof(MyEnemy).Assembly, "Sprites.Enemies.X1.MyEnemy.png");

This resolves the image from the selected content assembly rather than assuming it is embedded in XSharp.dll.

X1 bosses that use the fortress/Vile introduction and battle tracks override the computed Boss.UsesSigmaBossMusic property. The common room-entry and health-fill paths then select both Sigma tracks with their existing loop points. Bosspider, Vile/Ride Armor Vile, Rangda Bangda and D-Rex opt in. The shared tracks are precached by Boss, independently of Jedi Sigma’s resources; specialized battle-music overrides remain available.

Save states

Content moves can change assembly-qualified type names. Modules can register explicit aliases for types previously stored in the core assembly. The X1 enemy module registers aliases for Sine Faller, its motion model and state enum. The X1 boss module registers Bosspider, Petitpider and both state enums. The engine serializer resolves these aliases inside ordinary and generic types and normalizes precache-action type keys and parent links. Load the required module before loading its state.

Tests cover the legacy name resolver and new-assembly motion serialization. These checks do not certify every save state written by every intermediate development commit. Future moves must preserve serialized field order and callback identities, add the relevant aliases, and validate complete engine state restoration.

Validation

dotnet test XSharp.Tests/XSharp.Tests.csproj
dotnet build XSharpDemo/XSharpDemo.csproj

The unit suite covers six independent project dependencies, explicit registration, failure rollback, game-scoped IDs, embedded asset ownership, legacy names, and the existing headless Sine Faller lifecycle/motion tests. It initializes no native rendering or audio devices.

For the actual Windows engine/resource/save-state path:

dotnet build tests/XSharp.ContentSmoke/XSharp.ContentSmoke.csproj
Push-Location tests/XSharp.ContentSmoke/bin/Debug/net9.0-windows7.0
try {
    New-Item -ItemType Directory -Force Assets/ROMs | Out-Null
    Copy-Item -LiteralPath 'C:\path\to\Megaman X (USA).sfc' -Destination Assets/ROMs/ShittyDash.mmx
    .\XSharp.ContentSmoke.exe
} finally {
    Pop-Location
}

The ROM filename follows the current Consts.ROM_NAME; update it if that constant changes. This probe uses the normal Direct3D 9/audio runtime, loads the external X1 module and its embedded sheet, spawns the actor through its module factory, and compares 60 simulation frames before and after a save-state restore.

Migration still in progress

Legacy common enemies and bosses remain in XSharp until their concrete factories and cross-entity references are moved. Consequently the core DLL still contains that older content. The six-project structure establishes the destination and registration boundary for all new ports; complete removal of legacy game-specific code from the engine is a separate remaining migration step. The EnemyExtractor console and API prepare original-game data for new ports. The functional common-enemy roster documents newly available actors, variants, validation and presentation limits. Their fine parity and the existing boss work require separate native validation.

Unreviewed content stays idle

The shared content bridge no longer executes its generic movement/attack brain for extracted actors. Their own original control must be reviewed before enabling it. See the idle policy for the opt-in contract, current inventory and validation. This preserves the generic primitives as an explicit custom-game API without enabling approximate trilogy behavior by default.