Skip to content

solar_system

Data model and query module for the solar-system layer: planets, moons, and asteroids.

tiargus.solar_system

Data model and SavegameModule for the solar-system layer.

The solar-system layer describes the physical bodies of the Sol system — planets, moons, and asteroids — independent of the colonisation entities (hab sites, bases, modules) that sit on top of them in habs.

Provides:

  • SpaceBody — a planet, moon, or asteroid.
  • SpaceBodyModule (key: "space_bodies") — parses every body from the save and exposes them keyed by game-state ID.

SpaceBody dataclass

A planet, moon, or asteroid present in the save file.

Attributes:

Name Type Description
id int

Numeric game-state ID used as a foreign key by other entities.

display_name str

Human-readable name shown in-game (e.g. "Mars").

template_name str

Internal template identifier used to look up the region label in the bundled location map (e.g. "TIMars"). Falls back to display_name when absent.

max_hab_tier int

Maximum hab tier (1–3) that can be built on this body.

barycenter_id Optional[int]

ID of the body this one orbits (its barycenter), or None for Sol, which orbits nothing.

Source code in src/tiargus/solar_system.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@dataclass
class SpaceBody:
    """A planet, moon, or asteroid present in the save file.

    Attributes:
        id: Numeric game-state ID used as a foreign key by other entities.
        display_name: Human-readable name shown in-game (e.g. ``"Mars"``).
        template_name: Internal template identifier used to look up the
            region label in the bundled location map (e.g.
            ``"TIMars"``).  Falls back to ``display_name`` when absent.
        max_hab_tier: Maximum hab tier (1–3) that can be built on this body.
        barycenter_id: ID of the body this one orbits (its barycenter), or
            ``None`` for Sol, which orbits nothing.
    """

    id: int
    display_name: str
    template_name: str
    max_hab_tier: int
    barycenter_id: Optional[int]

SpaceBodyModule

Bases: SavegameModule

Parses every planet, moon, and asteroid from the save.

Provides display names and template names used by other modules to build location labels and resolve body references.

Source code in src/tiargus/solar_system.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
class SpaceBodyModule(SavegameModule):
    """Parses every planet, moon, and asteroid from the save.

    Provides display names and template names used by other modules to build
    location labels and resolve body references.
    """

    KEY = "space_bodies"

    def __init__(self) -> None:
        self._space_bodies: dict[int, SpaceBody] = {}

    @property
    def space_bodies(self) -> dict[int, SpaceBody]:
        """All space bodies keyed by their numeric game-state ID."""
        return self._space_bodies

    def parse(self, gs: dict, modules: dict[str, SavegameModule]) -> None:
        for item in gs[GS_SPACE_BODY]:
            bid = item["Key"]["value"]
            body = item["Value"]
            barycenter = body.get("barycenter")
            barycenter_id = (
                barycenter["value"] if isinstance(barycenter, dict) else None
            )
            self._space_bodies[bid] = SpaceBody(
                id=bid,
                display_name=body["displayName"],
                template_name=body.get("templateName") or body["displayName"],
                max_hab_tier=int(body.get("maxHabTier", 1)),
                barycenter_id=barycenter_id,
            )

space_bodies property

All space bodies keyed by their numeric game-state ID.

__init_subclass__(**kwargs)

Register subclasses in _REGISTRY at definition time.

Raises:

Type Description
TypeError

If a subclass does not define KEY.

Source code in src/tiargus/savegame.py
141
142
143
144
145
146
147
148
149
150
def __init_subclass__(cls, **kwargs: object) -> None:
    """Register subclasses in ``_REGISTRY`` at definition time.

    Raises:
        TypeError: If a subclass does not define ``KEY``.
    """
    super().__init_subclass__(**kwargs)
    if not hasattr(cls, "KEY"):
        raise TypeError(f"{cls.__name__} must define KEY as a class variable")
    SavegameModule._REGISTRY[cls.KEY] = cls

requires() classmethod

Return the KEYs of modules that must be parsed before this one.

Override this in subclasses that need data from other modules. TerraInvictaSave resolves and parses all declared dependencies (and their transitive dependencies) before calling parse() on this module.

Returns:

Type Description
list[str]

A list of KEY strings. The default implementation returns an

list[str]

empty list (no dependencies).

Source code in src/tiargus/savegame.py
152
153
154
155
156
157
158
159
160
161
162
163
164
165
@classmethod
def requires(cls) -> list[str]:
    """Return the KEYs of modules that must be parsed before this one.

    Override this in subclasses that need data from other modules.
    ``TerraInvictaSave`` resolves and parses all declared dependencies
    (and their transitive dependencies) before calling ``parse()`` on this
    module.

    Returns:
        A list of ``KEY`` strings.  The default implementation returns an
        empty list (no dependencies).
    """
    return []