XSharp

Player equipment profiles

Native pause-menu profiles are described in native pause menus. X1/X2/X3 have native runtime displays/cursors backed by optional asset packages. Normal-resume timing/input gates are integrated. Stage-exit parity remains in progress; X3 hosts can register optional extension controllers and canvases. Built-in settings widgets are not supplied. The custom equipment panel is still available.

The default is the existing custom buster. Stage identity, player physics and buster identity are independent. Choose a buster before loading a level:

engine.PlayerBuster = BusterProfile.X1; // or X2, X3, Custom
engine.CommonAudio = CommonAudioProfile.X3; // or X1, X2, Custom

For the first level, use the initialization callback so selection precedes asset loading:

Action<BaseEngine> configure = engine =>
{
    engine.PlayerBuster = BusterProfile.X1;
    engine.CommonAudio = CommonAudioProfile.X3;
};
BaseEngine.Initialize(hostType, initializers, modules, gameManager, configure);

For X2, the ordinary outgoing damage is 3 / 5 / 8 for normal, semi-charged and charged shots. A normal shot created during dash deals 5, not twice the normal 3. This comes from the original common receiver rows and weapon indexes 00, 01, 03 and 06. The packaged X2 profile and the optional native projectile factory use the same policy. Custom profiles retain their own damage and default double-damage dash rule; a custom subclass can override GetDamage.

These outgoing values do not replace receiver resistance tables. A boss, an armored target or an immune part can have a different original result. Such receiver-specific tables remain part of each actor’s audit. The upgraded arm buster uses another weapon index and is not implemented by this damage change. See the pinned X2 source evidence.

The types live in XSharp.Engine.Players. Environment selection is available as XSHARP_BUSTER=x1|x2|x3|custom and XSHARP_COMMON_AUDIO=x1|x2|x3|custom. Custom remains the default for both. Configuration after level precache throws, so it cannot trigger first-use IO or change shots already in flight.

All three original buster profiles derive from BusterProfile, as does CustomBusterProfile. They select regular, semi-charged and fully charged projectile art from the existing trilogy weapon sheet, source sound context, damage and configurable motion/charge/shot-limit parameters. The existing projectile FSM/entity types and collision integration are reused. The optional X2 native gameplay controller still takes precedence for an X2 buster in an X2 level when that module has registered its factories; it remains optional.

engine.PlayerBuster = new CustomBusterProfile
{
    Name = "MyBuster",
    SourceGame = OriginalGame.X3, // native shot audio; retain custom art prefix
    MaximumShots = 4,
    FullChargeFrames = 80
};
engine.CommonAudio = new CustomCommonAudioProfile
{
    Name = "MixedCombat",
    Explosion = new(OriginalGame.X1, 0x23),
    Reflection = new(OriginalGame.X3, 0x2A)
};

Common audio profiles cover shared enemy explosions, nonlethal enemy/boss hits, shot reflections and Ride Armor punch impacts. Custom preserves each actor’s reviewed native bank/command unless an action is overridden; a game profile selects that game’s equivalent shared cues. Action-specific motor, projectile, boss and mechanical-breakup sounds retain their content ownership.

The complete bank contexts and sprite sequences are prepared during level loading. Playback never resolves or decodes files. Selected profiles are saved in a profiles-v5 envelope before the existing terrain/session state. Default custom saves retain the previous envelope. Older states retain the host’s configured profiles, and old serialized buster callback signatures are kept.

ROM evidence records source selectors and table bytes/hashes. Normal/semi/full commands are 01/04/02 in X1 and 01/04/05 in X2/X3. X2 Stag movie calls independently confirm 01/04/05. Charge sustain and stop commands are distinct and must not be inferred from numeric shot order.

This checkpoint provides functional unarmored buster profiles. Full native OAM, animation/charge timing, armored double/cross shots, native damage tables and whole-game replay parity are not certified. Equipped X2 arms and X3 native charging use their source sustain/stop and stored-shot audio lifecycle; their source particle sprites and stage/clock projection are documented in player-armors.md. Custom legacy charging retains its original procedural presentation/audio.

Validation records 608 selected core tests, 90 audio tests (one optional fixture skipped), all three real DX9 profile/bank combinations, explicit profile recovery after changing host policy, and the existing default mixed-stage audio regression. Backend cropping retains original sheet coordinates/pivots in SpriteSheet.Frame.SourceBox, tested without a GPU.

The player bundle, armor, weapon and pause menu APIs below share the existing physics base and run independently of the renderer and audio backend.

Player bundle configuration

PlayerProfile is a common base with CustomPlayerProfile, MegaManXPlayerProfile, MegaManX2PlayerProfile and MegaManX3PlayerProfile descendants. Select it in the initialization callback (engine.PlayerProfile = PlayerProfile.X2) or with XSHARP_PLAYER=x1|x2|x3|custom. A game bundle selects the matching existing physics, buster and shared audio policies independently of stage identity. Explicit per-system settings in the callback may then override that bundle. Environment-specific physics/buster/audio settings override the environment bundle; the initialization callback runs after environment configuration.

The X1/X2/X3 player bundles also choose the matching Common 08 jump clip. Ground jumps and wall kicks use the prepared player movement channel, even if the level, buster and common audio policies select different games. The custom bundle and missing optional sound banks retain the legacy clip. This changes the audio source at the existing movement gates.

A custom bundle can supply Physics, Buster, Audio, SpriteSheetName and NormalPaletteName. Null custom physics retains the host’s explicit or automatic stage choice. Custom sprite/palette resources must be declared during level precache. The current built-in visual projection remains the legacy X sheet; UsesLegacyVisualProjection reports this explicitly. The X1/X2/X3 bundles share that projection. Game-authored content can configure its own art, armor rules, weapon controllers and pause presentation.

A nondefault player bundle adds a player-v6 envelope before the equipment profiles and existing terrain/session headers. It retains the actual physics parameters and the host’s automatic/explicit physics choice, including an override supplied after selecting a bundle. Physics data is serializable without render/audio devices. Demo metadata also identifies player, buster and common audio profile names alongside the existing physics name.

See asset assemblies for packaging profile data and mounting resources before level loading. Call ApplyPlayerProfileAsset during host configuration to select any equipment and menu described by that package, together with the base player settings. A host can still set individual profiles afterward.

The common audio profile also selects collection sounds independently of the stage. The default custom profile follows the stage for these actions. Custom packs can override each action separately with a collection object in common-audio.json. Supported keys are healthFill, weaponEnergyFill, extraLife, heartTank, subTank, subTankFill and subTankFull. Each entry has a game, a numeric command and an optional context that defaults to Common.

Action X1 X2 X3
HP or weapon energy increment 0C 15 15
Extra life 28 1A 1A
Heart tank or sub-tank 29 19 19
Sub-tank reserve fill 0D 16 16
Sub-tank fully charged 2B 17 17

The collection evidence pins the 15 native queue sites and the ROM hashes. The engine uses the prepared player audio channel. Weapon energy waits for a successful refill to request its cue.

The Sub-tank source record identifies the storage and pause-menu routines in the three USA ROMs. Campaign tanks acquire slots in pickup order and store up to 14 units each. At full HP, a small health drop adds one unit and a large drop adds up to two to the first tank with space. A drop collected below full HP uses the ordinary healing path. Older snapshots preserve their prior slot order and values above 14 restore as full tanks.

A game can enable armor equipment through engine.PlayerArmor and grant individual parts with engine.TryGrantArmor. A session with a game manager holds the acquired parts and restores them with its existing save state. An armor profile can require leg armor for dash, scale incoming damage when body armor is equipped, and select a precached body palette. For an asset assembly, LoadArmorProfileAsset reads a descriptor with schema: 1, kind: "armor" and optional dashRequiresLegs, bodyDamagePercent and bodyPaletteName. Register any custom palette during level loading. The default rules allow dash and use full damage, independent of collected parts. Helmet and arm flags are available to game code for its own equipment interactions.

Special weapons are registered during host configuration. A game can read a descriptor with LoadSpecialWeaponAsset and bind its own firing and precache callbacks with RegisterSpecialWeapon. The data format uses schema: 1, kind: "special-weapon", id, name, energyCapacity and shotCost. The firing callback returns true only after accepting a shot. Register its entity and asset dependencies in the precache callback.

TryUnlockWeapon fills the newly granted weapon. TrySelectWeapon(null) selects the unlimited buster. The existing left and right weapon-switch buttons cycle through available weapons in ID order, including the buster. Energy is deducted for accepted shots. Small and large ammo drops refill a selected special weapon up to its capacity and issue one sound per increment. Game manager snapshots retain the selected weapon and each unlocked weapon’s energy.

Set XSHARP_PAUSE_MENU=1 before launching a host to enable the equipment menu. A host can also set engine.PauseMenu to a profile read by LoadPauseMenuAsset. The descriptor uses schema: 1, kind: "pause-menu" and optional title, busterLabel, resumeLabel and RGBA arrays panel, selection and text. The shared asset assembly contains a default. Start opens and closes the menu. Up/Down or the weapon-switch buttons select an unlocked weapon. The menu displays HP, lives, armor and weapon energy. When a campaign owns Sub-Tanks, Left/Right or Select (Esc on the keyboard) switches to the reserve page. Use the same navigation to pick a tank and Shot to start transferring energy. The custom transfer policy gives one HP per partial-tank unit and up to 28 HP from a full tank. The native X1 menu additionally reproduces the original HP-indexed activation lookup described in native menus, which can choose a different per-step gain. Its result persists during save/load. X1 transfers every four pause updates and shifts the consecutive reserve tail. X2 and X3 transfer every two updates and repack remaining energy from the first slot. A transfer consumes the selected reserve even if X reaches maximum HP along the way. While it is open, menu input leaves the simulation frame, player position and RNG unchanged. Save states preserve an unfinished reserve transfer.

With the native Common banks installed, the DX9 smoke exercises the pickup and menu input paths, including the delayed cue, both reserve compaction policies, and save/load during a pickup or transfer. Run it once with each game’s imported intro and point it at a built host’s content directory to reuse its audio assets.

dotnet run --project tests/XSharp.LevelSmoke -c Release -- XSharp.LevelSandbox/Assets/Levels/X1/00.xlevel 0 --campaign --sub-tank --content-root=XSharp.LevelSandbox/bin/Release/net9.0-windows7.0