Skip to content

World

Extends: Node2D

Description

The World is the class that holds all visible elements of a map.

Accessed by Global.World.

Properties

Polygon2D Bounds
Polygon2D ExportFX
String Title
int Width
int Height
int GridSize
int TileSize
Vector2 Dimensions
Vector2 WoxelDimensions
Rect2 WorldRect
Vector2 GridCellSize
Level[] levels
int CurrentLevelId
Sprite TraceImage
bool TraceImageVisible
Dictionary NodeLookup
int nextNodeID
Dictionary LevelLookup
int nextLevelID
int nextPrefabID
Dictionary EmbeddedTextures
Texture BuildingWear
bool WallShadow
bool ObjectShadow
int Format

Methods

Dictionary Save ( )
void Load ( Dictionary data )
Dictionary SaveLevels ( )
void LoadLevels ( Dictionary data )
void AssignLevelID ( Level level )
Level GetLevelByID ( int id )
Level CreateLevel ( String label )
void DeleteLevel ( Level level )
void LoadLevel ( int index, Dictionary data )
Level CloneLevel ( Level level, String label )
Level TryGetLevel ( int index )
void SetNewLevelOrder ( Level[] newOrder )
String GetNextPrefabID ( )
int AssignNodeID ( Node node )
void AssignSpecificNodeID ( Node node, int id )
void RemoveNodeID ( int id )
void SetNodeID ( Node node, int id )
bool HasNodeID ( int id )
Node GetNodeByID ( int id )
bool DeleteNodeByID ( int id )
void LevelDown ( )
void LevelUp ( )
void SetLevel ( int level, bool loading = false )
Level GetCurrentLevel ( )
void HideAllLevels ( )
void SetSourceLevel ( int level )
void SetOverlayLevel ( int level, float opacity )
void Start ( )
void SetCompareLevels ( Level referenceLevel, float referenceOpacity, float currentOpacity, bool saveSetting )
void DisableCompareLevels ( )
void RestoreLevelsPostExport ( )
void UpdateLayerMenu ( OptionButton menu, int activeLayer )
void AddTraceImage ( String path, float scale, float opacity )
void RemoveTraceImage ( )
void CenterTraceImage ( )
void HandleTraceImageExportVisibility ( bool exporting )
Dictionary SaveEmbedded ( )
void LoadEmbedded ( Dictionary data )
void SetBuildingWear ( Texture texture )

Property Descriptions

  • Polygon2D Bounds:
    A frame around the map to ensure no map contents draw from over the edge can be seen.

  • Polygon2D ExportFX:
    The pane that adds a post process filter for export like blurring or color grading.

  • String Title:
    Name of the map given by the user. READ ONLY.

  • int Width:
    Width in cells of the map. READ ONLY.

  • int Height:
    Height in cells of the map. READ ONLY.

  • int GridSize:
    Unit size in each grid cell of the map. READ ONLY.

  • int TileSize:
    Unit size in each floor tile of the map. READ ONLY.

  • Vector2 Dimensions:
    Size of the map in grid cells. READ ONLY.

  • Vector2 WoxelDimensions:
    Size of the map in units (pixels if exported at full resolution). READ ONLY.

  • Rect2 WorldRect:
    Rect of the map in world space.

  • Vector2 GridCellSize:
    Size of each grid cell in world space.

  • Level[] levels:
    Get all of the levels of this map.

  • int CurrentLevelId:
    Get the ID of the currently visible level of this map. READ ONLY.

  • Sprite TraceImage:
    The trace image that overlays the map to help draw.

  • bool TraceImageVisible:
    Gets or sets if the trace image is visible.

  • Dictionary NodeLookup:
    Get the table of int key - Node value pair to find an asset instance by its node id.

  • int nextNodeID:
    Gets the next node id available for assignment. DO NOT MODIFY.

  • Dictionary LevelLookup:
    Get the table of int key - Level value pair to find a level by its id.

  • int nextLevelID:
    Gets the next level id available. DO NOT MODIFY.

  • int nextPrefabID:
    Gets the next prefab id available. DO NOT MODIFY.

  • Dictionary EmbeddedTextures:
    Get the table of String key - Texture value pair to find embedded Prop textures.

  • Texture BuildingWear:
    Get the texture used to wear the building walls and floors. Set with SetBuildingWear().

  • bool WallShadow:
    Toggle if the new walls created will have shadows.

  • bool ObjectShadow:
    Toggle if the new props created will have shadows.

  • int Format:
    Get the save format version.

Method Descriptions

  • Dictionary Save ( ):
    Save the world into the save file format and return it as a Dictionary.

  • void Load ( Dictionary data ):
    Load a saved World data. Used by a saved map file to load an existing world.

  • Dictionary SaveLevels ( ):
    Save all levels into the save file format and return it as a Dictionary. Called by Save().

  • void LoadLevels ( Dictionary data ):
    Load a saved data of all levels. Used by a saved map file to load an existing world. Called by Load().

  • void AssignLevelID ( Level level ):
    Assign a new level an id. Called automatically on level creation. No need to manually call.




  • void LoadLevel ( int index, Dictionary data ):
    Load a level data into a specific index. Used by LoadLevels().


  • Level TryGetLevel ( int index ):
    Get a level safely. Will not crash if an invalid index is provided. Just returns null.

  • void SetNewLevelOrder ( Level[] newOrder ):
    Set a new level order by providing it with an array of levels in order and update UI elements to reflect it.


  • int AssignNodeID ( Node node ):
    Assign the input Asset Instance a node id and increment the next available id.


  • void RemoveNodeID ( int id ):
    Delete a node ID from the registry. Called whenever an Asset Instance was deleted.

  • void SetNodeID ( Node node, int id ):
    Register the node id. Called by AssignNodeID() and AssignSpecificNodeID().



  • bool DeleteNodeByID ( int id ):
    Deletes an Asset Instance by providing its id. Returns true if succesful.



  • void SetLevel ( int level, bool loading = false ):
    Change the active level. The parameter loading is set when the level change is from a map load.





  • void Start ( ):
    Called at the start of the map creation to initialize the GridMesh, Bounds, and ExportFX.

  • void SetCompareLevels ( Level referenceLevel, float referenceOpacity, float currentOpacity, bool saveSetting ):
    Set up having two levels disable on top of each other for referencing, like when drawing multiple floors. Set saveSetting to true if called manually.








  • Dictionary SaveEmbedded ( ):
    Saves any embedded images in save data format and return as a Dictionary. Used by Save().