-
Notifications
You must be signed in to change notification settings - Fork 0
Overview
This is an overview of AFMI-Godot plugin to import Azgaar's FMG maps into Godot. Please note that the addon does NOT support all properties exported by the map exporter. Only the following fields are made available as of right now.
-
Default Properties (Properties that are available by default without specifically enabling in importer settings)
- Biome
- Culture
- Religion
- State
- Height
Important
Bit Packed Values: These properties are stored in a single PackedInt32Array to reduce memory usage. As such, biome count is limited to 16, culture,religion,state counts are limited to 128. height value is unaffected as it's always mapped to [0,100]. See _pack_bits referece for technical details.
-
Extensive Properties (Properties that need to be enabled in importer settings as necessary)
- Burgs
- Provinces
- Rivers
- Features
Caution
Extensive Properties: These properties are each stored in their own PackedInt32Array (because there is no upper limit to these values) as opposed to a single bit-packed PackedInt32Array used by default properties. Because of that, enabling one of these arrays will consume an amount of memory equal to all default properties combined.
Important
Supported Export Types: This plugin only supports Full JSON exports exported directly from Azgaar's Fantasy Map Generator. Grid Cells,Pack Cells and Minimal JSON exports from the exporter and direct *.map files are NOT supported.
More fields will not be added unless requested. If you need a specific field added, feel free to open an issue and discuss.
This plugin is implemented in two parts.
- An
EditorImportPluginthat adds to the Godot resource import system an import option for*.jsonfiles. - An
AzgaarMapresource that holds imported map data in a reasonably efficient data structure.
The import option AzgaarMap in Godot import dock. When opening a *.json file, you should see the following screen in the import dock.

-
Sampling Scale: (Default = 1) Specifices scaling applied to the map at importing. This can be used to import a high resolution map into a lower resolution map resource to reduce memory usage. Doesn't affect the cell count.
Example : Importing a 1000x1000 (in FMG options) map with 0.5
Sampling Scalewill give a resource that behaves as if the map was originally generated in 500x500 resolution. -
Burgs: (Default = false) Whether to save
Burgsinformation in map resource. Required if you need to useburg_at_pixel,burg_id_at_cell,burg_by_idmethods. -
Provinces: (Default = false) Whether to save
Provincesinformation in map resource. Required if you need to useprovince_at_pixel,province_id_at_cell,province_by_idmethods. -
Rivers: (Default = false) Whether to save
Riversinformation in map resource. Required if you need to useriver_at_pixel,river_id_at_cell,river_by_idmethods. -
Features: (Default = false) Whether to save
Featuresinformation in map resource. Required if you need to usefeature_at_pixel,feature_id_at_cell,feature_by_idmethods. -
Render Images: (Default = false) Whether to render
pngimage maps ofbiomes,states,provinces,riversandburgsand save them.
Note
Image Formats: Rendered biomes, states, provinces images will be in format Image.FORMAT_RGBF.
rivers and burgs images will be in format Image.FORMAT_R8.
-
Image save path: (Default = "")
A directory path indicating where to export images. Effective only when
Render Imagesis set totrue.
The custom resource AzgaarMap. Saves all map related data and provides methods to get any value by pixel in O(1) time.
Values in the resource are NOT designed to be changed after creation. Although there is nothing preventing a script from modifying data arrays, it's strongly discouraged.

-
Size: Original size of the map as in
[info][height]and[info][width]of JSON file. Must be multplied byscalefor actual pixel count along each direction. -
Mapdata: A
PackedInt32Arrayof sizewidthxheightxscale2. Holds onecell_idper pixel. -
Cell Data: A
PackedInt32Arraywith a size equal to the number of cells in map. Holds a single 32 bit integer per cell that contains bit packed default properties. -
Burgs Array,Provinces Array,Rivers Array,Features Array:
PackedInt32Arrays of size equal to the number of cells in map. Holds a single 32 bit integer per cell per array. Each array contains info about which cell has which property. -
Biomes, Cultures, Religions, States, Burgs, Provinces, Rivers, Features Arrays:
These arrays contain
Dictionariesof metadata about different types ofbiomes,cultures,religions,states,burgs,provincesandrivers. Length of each array depends of how many different types of each property are there in the map.
Note
For memory saving, it's possible to manually clear some of these arrays if it's abosultely certain that relevant *_at_pixel and *_by_id methods will NOT be called. However, this is highly discouraged as the gain is at most a few kilobytes in exchange for unexpected behavior.
Important
Due to the way Azgaar Maps are exported, the coordinate system origin is at top left corner. Since the map is imported as-is the coordinate system remains the same when retrieving values. All pixel coordinates always originate from top left corner of the map.
Note
Dictionary types returned by such returning functions are 1:1 replicas of the ones found in [pack] section of the JSON file with only difference being having hex code color strings converted to Godot native Color types. Allowing direct use of [color] property.
The AzgaarMap resource provides methods to,
- Get Cell ID that owns a pixel
Use
cell_id_at_pixel(pixel:Vector2i)to getintcell ID of the cell that owns the pixel. - Get
biome/culture/religion/state/burg,province/river/featuredictionaries of a pixel. Use*_at_pixel(pixel:Vector2i)(replacing*with property name) to getDictionarytypedbiome/culture/religion/state/burg/province/river/featuredata of the cell that own the pixel.
- Get
biome/culture/religion/state/burg,province/river/featureIDs of a cell. Use*_id_at_cell(cell_id:int)(replacing*with property name) to get integer IDs (e.g.,biome_id_at_cell,culture_id_at_cell,religion_id_at_cell,state_id_at_cell,height_at_cell,burg_id_at_cell,province_id_at_cell,river_id_at_cell,feature_id_at_cell). - Get full details dictionary by ID.
Use
*_by_id(id:int)to retrieve metadata dictionaries for specific entities (biome_by_id,culture_by_id,religion_by_id,state_by_id,burg_by_id,province_by_id,river_by_id,feature_by_id). - Unpack all default properties at once.
Use
def_prop_ids_at_cell(cell_id:int)to return anArraycontaining[biome_id, culture_id, religion_id, state_id, height].
When querying map data during runtime, keep the following best practices in mind:
-
Performance-Critical Code: For checks occurring frequently within
_process()or_physics_process(), prefer fetching integer IDs (*_id_at_cell) rather than full dictionaries to minimize allocation overhead. - Optional Feature Enabling: Ensure that extensive properties (such as burgs, provinces, rivers, and features) are enabled in the import dock before calling their respective lookup methods.
-
Bounds Checking: Always verify that cell IDs and pixel coordinates are valid (i.e. not returning
-1or empty dictionaries) before performing game logic dependent on map regions.