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

A database of room templates whose room can be instantiated via Addressables. More...

Inheritance diagram for RoomTemplateDatabase:

Public Member Functions

RoomTemplateResource GetRoomTemplate (int id)
 Returns the room template with the specified ID. More...
 
RoomTemplateResource GetRoomTemplate (Uid id, LayoutPack layoutPack)
 Returns the room template for the specified room ID. More...
 
IReadOnlyDictionary< int, RoomTemplateResourceGetRoomTemplates ()
 Returns the dictionary of room templates by ID. More...
 
List< RoomComponentInstantiateAllRooms (LayoutPack layoutPack, Transform parent=null)
 Instantiates all rooms in the layout and returns a list of them. More...
 
async Task< List< RoomComponent > > InstantiateAllRoomsAsync (LayoutPack layoutPack, Transform parent=null)
 Instantiates all rooms in the layout asynchronously and returns the rooms as a result of the task. More...
 
RoomComponent InstantiateRoom (Uid id, LayoutPack layoutPack, Transform parent=null, bool assignLayoutPosition=false)
 Instantiates the specified room and returns it. More...
 
AsyncOperationHandle< GameObject > InstantiateRoomAsync (Uid id, LayoutPack layoutPack, Transform parent=null, bool assignLayoutPosition=false)
 Instantiates the specified room asynchronously. Returns an operation handle with the result. More...
 
List< RoomComponentInstantiateRooms (LayoutPack layoutPack, Transform parent=null, int? z=null)
 Instantiates the rooms in the specified layer of the layout. More...
 
async Task< List< RoomComponent > > InstantiateRoomsAsync (LayoutPack layoutPack, Transform parent=null, int? z=null)
 Instantiates the rooms in a specified layer of the layout asynchronously. Returns the rooms as a result of the task. More...
 
void MarkDirty ()
 Sets the object as dirty. More...
 

Properties

bool IsDirty = true [getprivate set]
 If true, the object is dirty and requires population. More...
 
Dictionary< int, RoomTemplateResourceRoomTemplates = new Dictionary<int, RoomTemplateResource>() [get]
 A dictionary of room templates by ID. More...
 
List< TemplateGroupTemplateGroups [getset]
 A list of template groups. More...
 

Private Member Functions

void Awake ()
 
void OnValidate ()
 
void PopulateIfDirty ()
 If the object is dirty, populates the room templates dictionary. More...
 
void PopulateRoomTemplates ()
 Populates the room templates dictionary. More...
 

Static Private Member Functions

static void ActivateRooms (List< RoomComponent > rooms)
 Activates the rooms in the specified list. More...
 
static void OnInstantiationComplete (AsyncOperationHandle< GameObject > handle, List< RoomComponent > results)
 Adds the room from the operation handle result to the results list and deactivates it. More...
 

Private Attributes

List< TemplateGroup_templateGroups = new List<TemplateGroup>()
 

Detailed Description

A database of room templates whose room can be instantiated via Addressables.

Definition at line 15 of file RoomTemplateDatabase.cs.

Member Function Documentation

◆ ActivateRooms()

static void ActivateRooms ( List< RoomComponent rooms)
staticprivate

Activates the rooms in the specified list.

Parameters
roomsA list of rooms.

Definition at line 187 of file RoomTemplateDatabase.cs.

◆ Awake()

void Awake ( )
private

Definition at line 34 of file RoomTemplateDatabase.cs.

◆ GetRoomTemplate() [1/2]

RoomTemplateResource GetRoomTemplate ( int  id)

Returns the room template with the specified ID.

Parameters
idThe template ID.

Definition at line 99 of file RoomTemplateDatabase.cs.

◆ GetRoomTemplate() [2/2]

RoomTemplateResource GetRoomTemplate ( Uid  id,
LayoutPack  layoutPack 
)

Returns the room template for the specified room ID.

Parameters
idThe room ID.
layoutPackThe layout pack.

Definition at line 110 of file RoomTemplateDatabase.cs.

◆ GetRoomTemplates()

IReadOnlyDictionary< int, RoomTemplateResource > GetRoomTemplates ( )

Returns the dictionary of room templates by ID.

Definition at line 47 of file RoomTemplateDatabase.cs.

◆ InstantiateAllRooms()

List< RoomComponent > InstantiateAllRooms ( LayoutPack  layoutPack,
Transform  parent = null 
)

Instantiates all rooms in the layout and returns a list of them.

Parameters
layoutPackThe layout pack.
parentThe parent transform.

Definition at line 142 of file RoomTemplateDatabase.cs.

◆ InstantiateAllRoomsAsync()

async Task< List< RoomComponent > > InstantiateAllRoomsAsync ( LayoutPack  layoutPack,
Transform  parent = null 
)

Instantiates all rooms in the layout asynchronously and returns the rooms as a result of the task.

Parameters
layoutPackThe layout pack.
parentThe parent transform.

Definition at line 121 of file RoomTemplateDatabase.cs.

◆ InstantiateRoom()

RoomComponent InstantiateRoom ( Uid  id,
LayoutPack  layoutPack,
Transform  parent = null,
bool  assignLayoutPosition = false 
)

Instantiates the specified room and returns it.

Parameters
idThe room ID.
layoutPackThe layout pack.
parentThe parent transform.
assignLayoutPositionIf true, moves the room's local position to its position in the layout.

Definition at line 252 of file RoomTemplateDatabase.cs.

◆ InstantiateRoomAsync()

AsyncOperationHandle< GameObject > InstantiateRoomAsync ( Uid  id,
LayoutPack  layoutPack,
Transform  parent = null,
bool  assignLayoutPosition = false 
)

Instantiates the specified room asynchronously. Returns an operation handle with the result.

Parameters
idThe room ID.
layoutPackThe layout pack.
parentThe parent transform.
assignLayoutPositionIf true, moves the room's local position to its position in the layout.

Definition at line 239 of file RoomTemplateDatabase.cs.

◆ InstantiateRooms()

List< RoomComponent > InstantiateRooms ( LayoutPack  layoutPack,
Transform  parent = null,
int?  z = null 
)

Instantiates the rooms in the specified layer of the layout.

Parameters
layoutPackThe layout pack.
parentThe parent transform.
zThe layer (z) coordinate.

Definition at line 213 of file RoomTemplateDatabase.cs.

◆ InstantiateRoomsAsync()

async Task< List< RoomComponent > > InstantiateRoomsAsync ( LayoutPack  layoutPack,
Transform  parent = null,
int?  z = null 
)

Instantiates the rooms in a specified layer of the layout asynchronously. Returns the rooms as a result of the task.

Parameters
layoutPackThe layout pack.
parentThe parent transform.
zThe layer (z) coordinate.

Definition at line 163 of file RoomTemplateDatabase.cs.

◆ MarkDirty()

void MarkDirty ( )

Sets the object as dirty.

Definition at line 56 of file RoomTemplateDatabase.cs.

◆ OnInstantiationComplete()

static void OnInstantiationComplete ( AsyncOperationHandle< GameObject >  handle,
List< RoomComponent results 
)
staticprivate

Adds the room from the operation handle result to the results list and deactivates it.

Parameters
handleThe room instantiation operation handle.
resultsThe room results list.

Definition at line 200 of file RoomTemplateDatabase.cs.

◆ OnValidate()

void OnValidate ( )
private

Definition at line 39 of file RoomTemplateDatabase.cs.

◆ PopulateIfDirty()

void PopulateIfDirty ( )
private

If the object is dirty, populates the room templates dictionary.

Definition at line 64 of file RoomTemplateDatabase.cs.

◆ PopulateRoomTemplates()

void PopulateRoomTemplates ( )
private

Populates the room templates dictionary.

Exceptions
DuplicateIdExceptionRaised if two unique templates have the same ID.

Definition at line 77 of file RoomTemplateDatabase.cs.

Member Data Documentation

◆ _templateGroups

List<TemplateGroup> _templateGroups = new List<TemplateGroup>()
private

Definition at line 18 of file RoomTemplateDatabase.cs.

Property Documentation

◆ IsDirty

bool IsDirty = true
getprivate set

If true, the object is dirty and requires population.

Definition at line 32 of file RoomTemplateDatabase.cs.

◆ RoomTemplates

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

A dictionary of room templates by ID.

Definition at line 27 of file RoomTemplateDatabase.cs.

◆ TemplateGroups

List<TemplateGroup> TemplateGroups
getset

A list of template groups.

Definition at line 22 of file RoomTemplateDatabase.cs.


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