Mod API reference

Written by tools/ApiDocs from the game's assemblies and their doc comments each build; do not edit by hand. The guides are in modding.md. Members marked for mods ([ModApi]) come first on Game; the rest of its public surface follows, as the game's own screens use it.

Contents

Writing a mod

A mod's entry point and what it registers at load.

IMod

interface OpenPax.Modding.IMod

A C# mod's entry point (docs/modding.md): a public class with a public constructor taking nothing. The game makes one when it starts and calls IMod.Load once, where the mod says what it changes.

Members

ModContext

class OpenPax.Modding.ModContext

What a C# mod may change (docs/modding.md), given to IMod.Load. A mod's rules run where the game is run: in single player, or on the server of a network game, whose players all hold the same mods (the lobby sees to it), so a game stays one game.

Members

ModStore

class OpenPax.Modding.ModStore

A mod's own saved values in a game (Game.ModState), under keys of its own: "id.key". They are saved with the game, sent to network clients and part of the state hash, so a value set the same way in every game keeps games in step. Numbers are kept as invariant text that reads back exactly.

Members

ModRandom

class OpenPax.Modding.ModRandom

Random numbers for a mod's rules that keep a game deterministic: a stream of its own (xorshift64*), seeded from the game's seed and the mod's id, its state kept in the mod's store ("id.random"), so it is saved, sent to network clients and hashed like the rest of the game. Never use System.Random or the clock in rules: games would part ways. The game's own stream (Game.Random) is left alone, so the original's rules draw as they did.

Members

ModInfo

record OpenPax.Modding.ModInfo

A mod found in the mods folder: its manifest and where it is.

Members

ModManifest

record OpenPax.Modding.ModManifest

A mod's mod.toml (docs/modding.md): who it is, and what it brings: a data pack (its data folder, laid out as the game's), a C# assembly or a Lua script (docs/modding/lua.md), or a pack with either.

Members

The game

The running game, its events and what mods report back to the screens.

Game

class OpenPax.Sim.Game

Advisors over time, and orders about them (docs/sim/advisors.md).

Made for mods

Also public

ModEvent

record OpenPax.Sim.ModEvent

Something that happened in the game, for mods (Game.Happened, ModContext.OnEvent). Raised for every player, computer players too, at the moment it happens inside a step, so a handler sees the game mid step.

ParameterMeaning
PlayerWhose it is: who learned, built, lost the ship, founded, received, offered the treaty or was eliminated.
OtherThe other player, when there is one.
PlaceThe planet, when there is one.
StateFor a treaty: the slot (Treaty.War to Treaty.ShareInformation, or Treaty.None for all).
ValueFor a treaty: the slot's new value (Treaty.Off, InForce, OfferedByMe, OfferedToMe).

Members

ModEventKind

enum OpenPax.Sim.ModEventKind

What happened, in a ModEvent.

ValueMeaning
TechLearned0A player learned a tech (research, a breakthrough, a trade, espionage or a cheat): ModEvent.Tech.
ShipBuilt1A ship was finished at a shipyard, or made when nomads leave a colony: ModEvent.Ship at ModEvent.Place.
ShipDestroyed2A ship was destroyed in a battle or by a mod: ModEvent.Ship, by ModEvent.Other when known.
ColonyFounded3A player founded a colony on ModEvent.Place.
ColonyChangedHands4A colony on ModEvent.Place went to ModEvent.Player from ModEvent.Other (a trade, a capture).
ColonyDestroyed5A colony on ModEvent.Place was destroyed or abandoned.
TreatyChanged6A treaty slot from ModEvent.Player toward ModEvent.Other changed: ModEvent.State to ModEvent.Value (Treaty's constants).
PlayerEliminated7A player was eliminated.

ModFight

record OpenPax.Sim.ModFight

A fight a mod runs outside the battle screen (Game.ReportFights): a fleet in it and what the fight is over, the fleet attacked or the planet besieged. A planet's defenders are reported against it too.

Members

ColonyRating

record OpenPax.Sim.ColonyRating

A colony's fighting strength as a mod rates it (Game.RateColony): what its defenses deal a round, and what they can take.

Members

Fixes

enum OpenPax.Sim.Fixes

Fixes to the original's bugs a game may play with (docs/sim/fix-candidates.md), each Jeff's pick, all off by default: with none, the game plays as the original. A game carries its own set, chosen when it starts; it is saved with the game and sent to network clients with its state.

ValueMeaning
None0
ComputerKeepsShips1Ships given to or stolen by a computer player reach it, not vanish.
ScrapUnderWork2Stop Work scraps only a structure still being built, not one damaged in battle.
ShipyardOverflow4Work left over when a ship finishes reaches the next one as construction.
FleetsJoinBattles8A fleet near a fleet battle joins at its own free slot, rather than being left out.
PlanetBattleSides16Fleets near a planet battle join by their terms with each side, the side they are on terms with.
ShotsHitPlanets32A shot that would step over a planet's block hits it.
ShotsLeadTrue64Shots aim where they meet a moving target, not two steps past.
ExperienceOnce128A battle's experience is given once, not twice.
OwnYardRefits256A refit can be ordered only at the player's own shipyard, where it starts, not accepted at a foreign one and never begun.
ColonizeNeedsShip512The colonize key needs a colony ship in a fleet at the planet.
TradeKeepsAllShips1024A trade of more ships than a fleet holds fills a new fleet for the rest, rather than losing them.
StrangersIndifferent2048An empire that never met the victim of an attack does not hold it against the attacker.

GameNotice

record OpenPax.Sim.GameNotice

Something the game tells a human player: the original calls a player virtual during the tick and the screens make the text. Computer players get none. Not part of the game's state: the screens take them away.

ParameterMeaning
ValueA tech id, or an espionage mission's kind.
OtherThe other player involved.
PlaceThe planet or yard planet involved.
CountHow many things a mission hit; for a failed mission 0 found nothing, 1 was seen, 2 failed unseen.
NamedFor espionage damage: whether the spy's owner is named.
TextFor a mod's message: its words.

Members

NoticeKind

enum OpenPax.Sim.NoticeKind

What a notice to a human player is about; each matches a player notice the original posts (docs/ui/messages.md).

ValueMeaning
ResearchCompleted0
Breakthrough1
ShipFinished2
ColonyLost3
WarChanged4
FirstContact5
PlayerEliminated6
SpySucceeded7
SpyFailed8
SpyStopped9
SpyDamage10
TradeOffered11
TradeFailed12
TradeAccepted13
TradeRejected14
ModMessage15The port's own: a message from a mod (Game.Tell), its words in the notice's Text.

The galaxy

Stars, planets and wormholes.

Universe

class OpenPax.Sim.Galaxy.Universe

The galaxy: stars with their planets and wormholes.

Members

Star

class OpenPax.Sim.Galaxy.Star

A star system (the original's sector, 0x100 bytes).

Members

Planet

class OpenPax.Sim.Galaxy.Planet

A planet as the original creates it (object 0x220 bytes, init).

Members

Wormhole

class OpenPax.Sim.Galaxy.Wormhole

A wormhole, one end of a link between two stars.

Members

ISpaceObject

interface OpenPax.Sim.Galaxy.ISpaceObject

Anything with a position in a star system view: planets, wormholes, fleets.

Members

Players, colonies and ships

Empires and what they own.

Player

class OpenPax.Sim.Players.Player

A player, human or computer (base constructor).

Members

Treaty

class OpenPax.Sim.Players.Treaty

The seven treaty states one player holds toward another (player +0x10 + other * 0x20): 0 War, 1 Neutral, 2 Trade Routes, 3 Repair and Resupply, 4 Allied, 5 Joint Research, 6 Share Information (docs/sim/diplomacy.md). Each slot is Treaty.Off, Treaty.InForce, or pending: offered by this player, or offered to it.

Members

Colony

class OpenPax.Sim.Players.Colony

A colony on a planet; see docs/sim/economy.md.

Members

Structure

class OpenPax.Sim.Players.Structure

A stack of one to five structures of a kind at a colony: shipyards, missile bases, battle stations and the like.

Members

Fleet

class OpenPax.Sim.Players.Fleet

A fleet: ships, newest first, in one star system, with a queue of orders, an orbit and stats from its ships. See docs/sim/ships.md and docs/sim/movement.md.

Members

Design

class OpenPax.Sim.Players.Design

A ship design, or a ship: the original uses one class for both (copy). A ship is a copy of a design with its own Design.ShipId. See docs/sim/ships.md.

Members

Component

class OpenPax.Sim.Players.Component

Some number of one tech fitted to a design or ship.

ParameterMeaning
modeWeapon mode, the firing arc: 0 bow, 1 port, 2 starboard, 3 point defense; -1 for anything not a weapon.

Members

Species

record OpenPax.Sim.Players.Species

A species as the simulation uses it (the original's race template; see docs/formats/tables.md). The caller converts the data records.

Members

IncidentKind

enum OpenPax.Sim.Players.IncidentKind

The kinds of event that move attitude scores (docs/sim/diplomacy.md).

ValueMeaning
TradeRoutes0
JointResearch1
Disposition2
Stronger3
EnemyAttacked4
FriendAttacked5
SpyCaught6
ColonyTaken7
ShipDestroyed8
StructureDestroyed9
PlanetAttacked10
FleetAttacked11
ShipsGiven12
ShipsReceived13
PlanetsGiven14
PlanetsReceived15
TechsGiven16
TechsReceived17
CreditsGiven18
CreditsReceived19
MapGiven20
MapReceived21
TradeRejected22

Game tables

The data every game is made from, which ChangeTables may change.

GameTables

record OpenPax.Sim.Setup.GameTables

Game data a new game reads, supplied by the caller from the data files so the simulation does not depend on file formats.

ParameterMeaning
SpeciesThe RACE records in resource order; AIs pick by index.
AiNamesSTR# 46000, 30 computer player names.
FleetNameTextSTR# 108 entry 10, put between the star name and the fleet number.
TechsEvery technology, by id order.
HullsHulls by type 0 to 5.
DesignNamesSTR# 26000; a design of type t is named by entry t + 27.
ClassNamesSTR# 20005; entry t names the class of a type t design.
SinSine of each whole degree as the original's table holds it (docs/sim/movement.md).
CosCosine likewise.
StolenFleetNameSTR# 112 entry 6, the name of a fleet of stolen ships.
TradedFleetNameSTR# 82 entry 7, the name of a fleet of ships received in trade.
AbandonFleetNameSTR# 82 entry 6, the name of the fleet a nomad species leaves an abandoned colony in.
TransportNameSTR# 100 entry 2, the name of a colony ship design made for abandoning a colony.
CombatSpriteRowsLast visible row of each Image/Combat.img picture: the size of orbital defenses in battle.

Members

GameSetup

record OpenPax.Sim.Setup.GameSetup

A new game's settings (the original's setup structure, see docs/sim/universe.md). Humans come first in the player order; the rest of GameSetup.TotalPlayers are computer players.

ParameterMeaning
Difficulty1 (easiest) to 5.

Members

TechInfo

record OpenPax.Sim.Players.TechInfo

The parts of a technology the simulation reads (see OpenPax.Data TECH records and docs/sim/ships.md). Class fields are 0 for other classes.

ParameterMeaning
KindRole of the tech; for example 5 shipyard, 7 missile base, 24 armor.

Members

HullInfo

record OpenPax.Sim.Players.HullInfo

A hull (HULL 2000 + type) as designs read it.

Members

Loading (the game's side)

How the game finds and loads mods; a mod does not call these.

ModHost

class OpenPax.Modding.ModHost

The mods turned on, loaded once when the game starts (docs/modding.md): their data packs over the game's data, and their C# assemblies, each in its own load context sharing the game's own assemblies.

Members

ModCatalog

static class OpenPax.Modding.ModCatalog

The mods in the mods folders: each a folder with a mod.toml.

Members