ManiaMap.Godot
Procedural generation of metroidvania style maps for Godot .NET.
RoomTemplateDatabase Class Reference

Provides lookup of RoomTemplateResource by ID and initialization methods for rooms. More...

Inheritance diagram for RoomTemplateDatabase:

Public Member Functions

RoomNode2D CreateRoom2DInstance (Uid id, LayoutPack layoutPack, Node parent, bool assignLayoutPosition=false)
 Creates a room from the current Layout. Returns the instantiated room. More...
 
async Task< RoomNode2DCreateRoom2DInstanceAsync (Uid id, LayoutPack layoutPack, Node parent, bool assignLayoutPosition=false, bool useSubThreads=false)
 Asynchronously creates a room from the current Layout. Returns the instantiated room. More...
 
List< RoomNode2DCreateRoom2DInstances (Node parent, LayoutPack layoutPack, int? z=null)
 Creates rooms at their layout positions for a layer of the current Layout. Returns a list of the instantiated rooms. More...
 
async Task< List< RoomNode2D > > CreateRoom2DInstancesAsync (Node parent, LayoutPack layoutPack, int? z=null, bool useSubThreads=false)
 Asynchronously creates rooms at their layout positions for a layer of the current Layout. Returns a list of the instantiated rooms. More...
 
RoomNode3D CreateRoom3DInstance (Uid id, LayoutPack layoutPack, Node parent, bool assignLayoutPosition=false)
 Creates a room from the current Layout. Returns the instantiated room. More...
 
async Task< RoomNode3DCreateRoom3DInstanceAsync (Uid id, LayoutPack layoutPack, Node parent, bool assignLayoutPosition=false, bool useSubThreads=false)
 Asynchronously creates a room from the current Layout. Returns the instantiated room. More...
 
List< RoomNode3DCreateRoom3DInstances (Node parent, LayoutPack layoutPack)
 Creates rooms at their layout positions for the current Layout. Returns a list of the instantiated rooms. More...
 
async Task< List< RoomNode3D > > CreateRoom3DInstancesAsync (Node parent, LayoutPack layoutPack, bool useSubThreads=false)
 Asynchronously creates rooms at their layout positions for the current Layout. Returns a list of the instantiated rooms. More...
 
RoomTemplateResource GetRoomTemplate (int id)
 Returns the room template for the specified ID. More...
 
RoomTemplateResource GetRoomTemplate (Uid id, LayoutPack layoutPack)
 Returns the room template for the specified room ID. This method uses the layout from the current ManiaMapManager. More...
 
IReadOnlyDictionary< int, RoomTemplateResourceGetRoomTemplates ()
 Returns a read-only dictionary of room templates by ID. More...
 
void SetDirty ()
 Sets the database as dirty and requiring update. More...
 

Properties

bool IsDirty = true [getprivate set]
 True if the object is currently dirty and requires update. More...
 
Dictionary< int, RoomTemplateResourceRoomTemplates = new Dictionary<int, RoomTemplateResource>() [get]
 A dictionary of room templates by ID. More...
 
TemplateGroup[] TemplateGroups = Array.Empty<TemplateGroup>() [getset]
 An array of template groups containing the rooms to include in queries. More...
 

Private Member Functions

async Task< Dictionary< int, PackedScene > > LoadScenesAsync (IEnumerable< Room > rooms, bool useSubThreads=false)
 Loads the scenes for the specified rooms asynchronously and returns a dictionary of scenes by template ID. More...
 
void PopulateIfDirty ()
 Populates the lookup dictionary if the room is marked as dirty. More...
 
void PopulateRoomTemplates ()
 Clears and populates the room templates dictionary. More...
 

Detailed Description

Provides lookup of RoomTemplateResource by ID and initialization methods for rooms.

The database performs lazy initialization of its lookup dictionary. If you edit this resource at runtime, you should call the SetDirty method to ensure the database is updated before future queries.

Definition at line 19 of file RoomTemplateDatabase.cs.

Member Function Documentation

◆ CreateRoom2DInstance()

RoomNode2D CreateRoom2DInstance ( Uid  id,
LayoutPack  layoutPack,
Node  parent,
bool  assignLayoutPosition = false 
)

Creates a room from the current Layout. Returns the instantiated room.

Parameters
idThe room ID.
parentThe node serving as the room's parent.
assignLayoutPositionIf true, the layout position will be assigned to the room.

Definition at line 251 of file RoomTemplateDatabase.cs.

◆ CreateRoom2DInstanceAsync()

async Task< RoomNode2D > CreateRoom2DInstanceAsync ( Uid  id,
LayoutPack  layoutPack,
Node  parent,
bool  assignLayoutPosition = false,
bool  useSubThreads = false 
)

Asynchronously creates a room from the current Layout. Returns the instantiated room.

Parameters
idThe room ID.
parentThe node serving as the room's parent.
assignLayoutPositionIf true, the layout position will be assigned to the room.

Definition at line 225 of file RoomTemplateDatabase.cs.

◆ CreateRoom2DInstances()

List< RoomNode2D > CreateRoom2DInstances ( Node  parent,
LayoutPack  layoutPack,
int?  z = null 
)

Creates rooms at their layout positions for a layer of the current Layout. Returns a list of the instantiated rooms.

Parameters
parentThe node serving as the parent of the rooms.
zThe layer coordinate to instantiate.

Definition at line 183 of file RoomTemplateDatabase.cs.

◆ CreateRoom2DInstancesAsync()

async Task< List< RoomNode2D > > CreateRoom2DInstancesAsync ( Node  parent,
LayoutPack  layoutPack,
int?  z = null,
bool  useSubThreads = false 
)

Asynchronously creates rooms at their layout positions for a layer of the current Layout. Returns a list of the instantiated rooms.

Parameters
parentThe node serving as the parent of the rooms.
zThe layer coordinate to instantiate.

Definition at line 141 of file RoomTemplateDatabase.cs.

◆ CreateRoom3DInstance()

RoomNode3D CreateRoom3DInstance ( Uid  id,
LayoutPack  layoutPack,
Node  parent,
bool  assignLayoutPosition = false 
)

Creates a room from the current Layout. Returns the instantiated room.

Parameters
idThe room ID.
parentThe node serving as the room's parent.
assignLayoutPositionIf true, the layout position will be assigned to the room.

Definition at line 264 of file RoomTemplateDatabase.cs.

◆ CreateRoom3DInstanceAsync()

async Task< RoomNode3D > CreateRoom3DInstanceAsync ( Uid  id,
LayoutPack  layoutPack,
Node  parent,
bool  assignLayoutPosition = false,
bool  useSubThreads = false 
)

Asynchronously creates a room from the current Layout. Returns the instantiated room.

Parameters
idThe room ID.
parentThe node serving as the room's parent.
assignLayoutPositionIf true, the layout position will be assigned to the room.

Definition at line 238 of file RoomTemplateDatabase.cs.

◆ CreateRoom3DInstances()

List< RoomNode3D > CreateRoom3DInstances ( Node  parent,
LayoutPack  layoutPack 
)

Creates rooms at their layout positions for the current Layout. Returns a list of the instantiated rooms.

Parameters
parentThe node serving as the parent of the rooms.

Definition at line 205 of file RoomTemplateDatabase.cs.

◆ CreateRoom3DInstancesAsync()

async Task< List< RoomNode3D > > CreateRoom3DInstancesAsync ( Node  parent,
LayoutPack  layoutPack,
bool  useSubThreads = false 
)

Asynchronously creates rooms at their layout positions for the current Layout. Returns a list of the instantiated rooms.

Parameters
parentThe node serving as the parent of the rooms.

Definition at line 162 of file RoomTemplateDatabase.cs.

◆ GetRoomTemplate() [1/2]

RoomTemplateResource GetRoomTemplate ( int  id)

Returns the room template for the specified ID.

Parameters
idThe template ID.

Definition at line 91 of file RoomTemplateDatabase.cs.

◆ GetRoomTemplate() [2/2]

RoomTemplateResource GetRoomTemplate ( Uid  id,
LayoutPack  layoutPack 
)

Returns the room template for the specified room ID. This method uses the layout from the current ManiaMapManager.

Parameters
idThe room ID.

Definition at line 102 of file RoomTemplateDatabase.cs.

◆ GetRoomTemplates()

IReadOnlyDictionary< int, RoomTemplateResource > GetRoomTemplates ( )

Returns a read-only dictionary of room templates by ID.

Definition at line 39 of file RoomTemplateDatabase.cs.

◆ LoadScenesAsync()

async Task< Dictionary< int, PackedScene > > LoadScenesAsync ( IEnumerable< Room >  rooms,
bool  useSubThreads = false 
)
private

Loads the scenes for the specified rooms asynchronously and returns a dictionary of scenes by template ID.

Parameters
roomsThe rooms for which scenes will be loaded.

Definition at line 112 of file RoomTemplateDatabase.cs.

◆ PopulateIfDirty()

void PopulateIfDirty ( )
private

Populates the lookup dictionary if the room is marked as dirty.

Definition at line 56 of file RoomTemplateDatabase.cs.

◆ PopulateRoomTemplates()

void PopulateRoomTemplates ( )
private

Clears and populates the room templates dictionary.

Exceptions
DuplicateIdExceptionThrown if two different room templates have the same ID.

Definition at line 69 of file RoomTemplateDatabase.cs.

◆ SetDirty()

void SetDirty ( )

Sets the database as dirty and requiring update.

Definition at line 48 of file RoomTemplateDatabase.cs.

Property Documentation

◆ IsDirty

bool IsDirty = true
getprivate set

True if the object is currently dirty and requires update.

Definition at line 34 of file RoomTemplateDatabase.cs.

◆ RoomTemplates

Dictionary<int, RoomTemplateResource> RoomTemplates = new Dictionary<int, RoomTemplateResource>()
getprivate

A dictionary of room templates by ID.

Definition at line 29 of file RoomTemplateDatabase.cs.

◆ TemplateGroups

TemplateGroup [] TemplateGroups = Array.Empty<TemplateGroup>()
getset

An array of template groups containing the rooms to include in queries.

Definition at line 24 of file RoomTemplateDatabase.cs.


The documentation for this class was generated from the following file: