Skip to content

Archmage.AtlasItem

One item of atlas.json: a config source, the object that holds its data, and its load state.

Inherits: RefCounted

For the code generator. ConfigAtlas creates each item with the object of the config source and the mapping of its key in atlas.json:

"hero": Archmage.AtlasItem.new(hero_table, Archmage.AtlasItem.MAPPING_UNIQUE),
const MAPPING_UNIQUE = "unique"

The key maps to one file: "unique": {"hero": "hero.json"}.

const MAPPING_VARIANT = "variant"

The key maps to several files, one per variant, of which one is loaded: "variant": {"game": {"/": "game.json", "dev": "game.dev.json"}}.

const MAPPING_MANY = "many"

The key maps to a list of files that are merged in order: "many": {"skill": ["a.json", "b.json"]}.

const DEFAULT_VARIANT = "/"

The variant loaded when Archmage.AtlasOptions.with_variant() selects none for the item.

var cfg: Object

The object that receives the data. It has these methods:

  • load_json(data: Variant) -> String fills the object. The loader calls it once, with the parsed JSON of all files and overrides of the item merged into one value (see Archmage.AtlasLoader.merge_json()). Godot parses every number as float, so convert integers with int(). Set a field to its default value when its value is null or missing. It returns "" on success. Otherwise, it returns a message for the first invalid value, which starts with the path of the value in the item, such as [3].respawn: invalid duration "abc"; the loader then returns ERR_PARSE_ERROR. Archmage.ParseError builds such a message.
  • apply_keys() -> void sets the ID of each entry from its key. Only regular tables have it; the loader calls it after load_json when the object has it.
  • to_json() -> Variant returns the content as JSON values for Archmage.canonicalize() and Archmage.dump_atlas(), with the keys of the config files, such as critRate. It may return nested objects that have their own to_json(). A reference field is written as its config ID, the zero ID when it references nothing.
var mapping: String

MAPPING_UNIQUE, MAPPING_VARIANT or MAPPING_MANY.

var key: String = ""

The key in atlas.json. The loader sets it.

var variant: String = ""

The variant that the loader loaded for a MAPPING_VARIANT item; empty for other mappings.

var ready: bool = false

Whether the loader has loaded the item.

Archmage.AtlasItem.new(p_cfg: Object, p_mapping: String)