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

A node serving as the top level of a 3D room. More...

Inheritance diagram for RoomNode3D:
IRoomNode

Public Member Functions

override void _Ready ()
 
override void _ValidateProperty (Godot.Collections.Dictionary property)
 
Vector3 CellCenterGlobalPosition (int row, int column)
 Returns the cell center global position for the specified cell index. More...
 
Vector3 CellCenterLocalPosition (int row, int column)
 Returns the cell center local position for the specified cell index. More...
 
Error EmitOnCellAreaEntered (CellArea3D cell, Node collision)
 
Error EmitOnCellAreaExited (CellArea3D cell, Node collection)
 
Error EmitOnCellGridChanged ()
 
Vector2I FindClosestActiveCellIndex (Vector3 position)
 Returns the closest active cell index to the specified global position. More...
 
DoorDirection FindClosestDoorDirection (int row, int column, Vector3 position)
 Returns the closest door direction based on the cell index and specified global position. The nearest direction is determined based on the change between the specified position and cell center. More...
 
Vector2I GlobalPositionToCellIndex (Vector3 position)
 Returns the row (x) and column (y) index corresponding to the specified global position. If the position is outside the room bounds, returns Vector2I(-1, -1). More...
 
bool Initialize (LayoutPack layoutPack, Room roomLayout, RoomState roomState, uint cellCollisionMask, bool assignLayoutPosition)
 Initializes the room. The room should be initialized before adding it to the scene tree since cell children often require this information on ready. More...
 
Vector2I LocalPositionToCellIndex (Vector3 position)
 Returns the row (x) and column (y) index corresponding to the specified local position. If the position is outside the room bounds, returns Vector2I(-1, -1). More...
 
void MoveToLayoutPosition ()
 Moves the room to its position in the Layout. More...
 
delegate void OnCellAreaEnteredEventHandler (CellArea3D cell, Node collision)
 Signal emitted when a cell area is entered by a tracked area or body. More...
 
delegate void OnCellAreaExitedEventHandler (CellArea3D cell, Node collision)
 Signal emitted when a cell area is exited by a tracked area or body. More...
 
delegate void OnCellGridChangedEventHandler ()
 Signal emitted when the cell grid size or cell sizes are set.
 

Static Public Member Functions

static RoomNode3D CreateInstance (PackedScene scene, Node parent, LayoutPack layoutPack, Room roomLayout, RoomState roomState, uint cellCollisionMask, bool assignLayoutPosition)
 Creates and initializes an instance of a room. More...
 
static RoomNode3D CreateInstance (Uid id, LayoutPack layoutPack, PackedScene scene, Node parent, bool assignLayoutPosition=false)
 Creates and initializes an instance of a room. The layout and layout state are assigned to the room based on the current ManiaMapManager. More...
 

Properties

Godot.Collections.Array< Godot.Collections.Array< bool > > ActiveCells = new Godot.Collections.Array<Godot.Collections.Array<bool>>() [getset]
 
Vector3 CellSize [getset]
 The width and height of the room cells. More...
 
int Columns [getset]
 
bool IsInitialized [getprivate set]
 
LayoutPack LayoutPack [getprivate set]
 
Room RoomLayout [getprivate set]
 
RoomState RoomState [getprivate set]
 
RoomTemplateResource RoomTemplate [getset]
 
int Rows [getset]
 
- Properties inherited from IRoomNode
Godot.Collections.Array< Godot.Collections.Array< bool > > ActiveCells [getset]
 A nested array of room cell activities. More...
 
int Columns [getset]
 The number of cell columns in the room. More...
 
bool IsInitialized [get]
 True if the room has been initialized. More...
 
LayoutPack LayoutPack [get]
 The current layout pack. More...
 
Room RoomLayout [get]
 This room's layout. More...
 
RoomState RoomState [get]
 This room's layout state. More...
 
RoomTemplateResource RoomTemplate [getset]
 The room template used by the procedural generator. More...
 
int Rows [getset]
 The number or cell rows in the room. More...
 

Private Member Functions

void CreateCellAreas (uint cellCollisionMask)
 Creates CellArea3D for all active cells. More...
 
void SetCellSizeField (ref Vector3 field, Vector3 value)
 
void SetSizeField (ref int field, int value)
 

Private Attributes

Vector3 _cellSize = Vector3.One
 
int _columns = 1
 
int _rows = 1
 

Detailed Description

A node serving as the top level of a 3D room.

See IRoomNodeExtensions for additional methods usable by this class.

Definition at line 16 of file RoomNode3D.cs.

Member Function Documentation

◆ _Ready()

override void _Ready ( )

Definition at line 90 of file RoomNode3D.cs.

◆ _ValidateProperty()

override void _ValidateProperty ( Godot.Collections.Dictionary  property)

Definition at line 107 of file RoomNode3D.cs.

◆ CellCenterGlobalPosition()

Vector3 CellCenterGlobalPosition ( int  row,
int  column 
)

Returns the cell center global position for the specified cell index.

Parameters
rowThe cell row.
columnThe cell column.

Definition at line 284 of file RoomNode3D.cs.

◆ CellCenterLocalPosition()

Vector3 CellCenterLocalPosition ( int  row,
int  column 
)

Returns the cell center local position for the specified cell index.

Parameters
rowThe cell row.
columnThe cell column.

Definition at line 294 of file RoomNode3D.cs.

◆ CreateCellAreas()

void CreateCellAreas ( uint  cellCollisionMask)
private

Creates CellArea3D for all active cells.

Parameters
cellCollisionMaskThe cell collision mask.

Definition at line 265 of file RoomNode3D.cs.

◆ CreateInstance() [1/2]

static RoomNode3D CreateInstance ( PackedScene  scene,
Node  parent,
LayoutPack  layoutPack,
Room  roomLayout,
RoomState  roomState,
uint  cellCollisionMask,
bool  assignLayoutPosition 
)
static

Creates and initializes an instance of a room.

Parameters
sceneThe room scene.
parentThe node to which the room will be added as a child.
layoutThe full layout.
layoutStateThe full layout state.
roomLayoutThe room's layout.
roomStateThe room's state.
doorConnectionsThe room's door connections.
cellCollisionMaskThe cell collision mask.
assignLayoutPositionIf true, the position of the room will be set to that of the room layout. Otherwise, it will be initialized at its original position.

Definition at line 220 of file RoomNode3D.cs.

◆ CreateInstance() [2/2]

static RoomNode3D CreateInstance ( Uid  id,
LayoutPack  layoutPack,
PackedScene  scene,
Node  parent,
bool  assignLayoutPosition = false 
)
static

Creates and initializes an instance of a room. The layout and layout state are assigned to the room based on the current ManiaMapManager.

Parameters
idThe room ID.
layoutPackThe layout pack.
sceneThe room scene.
parentThe node to which the room will be added as a child.
assignLayoutPositionIf true, the position of the room will be set to that of the room layout. Otherwise, it will be initialized at its original position.

Definition at line 200 of file RoomNode3D.cs.

◆ FindClosestActiveCellIndex()

Vector2I FindClosestActiveCellIndex ( Vector3  position)

Returns the closest active cell index to the specified global position.

Parameters
positionThe global position.

Definition at line 329 of file RoomNode3D.cs.

◆ FindClosestDoorDirection()

DoorDirection FindClosestDoorDirection ( int  row,
int  column,
Vector3  position 
)

Returns the closest door direction based on the cell index and specified global position. The nearest direction is determined based on the change between the specified position and cell center.

Parameters
rowThe cell row.
columnThe cell column.
positionThe global position.

Definition at line 369 of file RoomNode3D.cs.

◆ GlobalPositionToCellIndex()

Vector2I GlobalPositionToCellIndex ( Vector3  position)

Returns the row (x) and column (y) index corresponding to the specified global position. If the position is outside the room bounds, returns Vector2I(-1, -1).

Parameters
positionThe global position.

Definition at line 304 of file RoomNode3D.cs.

◆ Initialize()

bool Initialize ( LayoutPack  layoutPack,
Room  roomLayout,
RoomState  roomState,
uint  cellCollisionMask,
bool  assignLayoutPosition 
)

Initializes the room. The room should be initialized before adding it to the scene tree since cell children often require this information on ready.

If the room has already been initialized, no action is taken, and this method returns false. Othwerwise, it returns true.

Parameters
layoutThe full layout.
layoutStateThe full layout state.
roomLayoutThe room's layout.
roomStateThe room's state.
doorConnectionsThe room's door connections.
cellCollisionMaskThe cell collision mask.
assignLayoutPositionIf true, the position of the room will be set to that of the room layout. Otherwise, it will be initialized at its original position.

Definition at line 243 of file RoomNode3D.cs.

◆ LocalPositionToCellIndex()

Vector2I LocalPositionToCellIndex ( Vector3  position)

Returns the row (x) and column (y) index corresponding to the specified local position. If the position is outside the room bounds, returns Vector2I(-1, -1).

Parameters
positionThe local position.

Definition at line 314 of file RoomNode3D.cs.

◆ MoveToLayoutPosition()

void MoveToLayoutPosition ( )

Moves the room to its position in the Layout.

Definition at line 412 of file RoomNode3D.cs.

◆ OnCellAreaEnteredEventHandler()

delegate void OnCellAreaEnteredEventHandler ( CellArea3D  cell,
Node  collision 
)

Signal emitted when a cell area is entered by a tracked area or body.

Parameters
cellThe entered cell.
collisionThe entering object.

◆ OnCellAreaExitedEventHandler()

delegate void OnCellAreaExitedEventHandler ( CellArea3D  cell,
Node  collision 
)

Signal emitted when a cell area is exited by a tracked area or body.

Parameters
cellThe exited cell.
collisionThe exiting object.

◆ SetCellSizeField()

void SetCellSizeField ( ref Vector3  field,
Vector3  value 
)
private

Definition at line 84 of file RoomNode3D.cs.

◆ SetSizeField()

void SetSizeField ( ref int  field,
int  value 
)
private

Definition at line 77 of file RoomNode3D.cs.

Member Data Documentation

◆ _cellSize

Vector3 _cellSize = Vector3.One
private

Definition at line 51 of file RoomNode3D.cs.

◆ _columns

int _columns = 1
private

Definition at line 47 of file RoomNode3D.cs.

◆ _rows

int _rows = 1
private

Definition at line 43 of file RoomNode3D.cs.

Property Documentation

◆ ActiveCells

Godot.Collections.Array<Godot.Collections.Array<bool> > ActiveCells = new Godot.Collections.Array<Godot.Collections.Array<bool>>()
getset

Definition at line 58 of file RoomNode3D.cs.

◆ CellSize

Vector3 CellSize
getset

The width and height of the room cells.

Definition at line 55 of file RoomNode3D.cs.

◆ Columns

int Columns
getset

Definition at line 49 of file RoomNode3D.cs.

◆ IsInitialized

bool IsInitialized
getprivate set

Definition at line 70 of file RoomNode3D.cs.

◆ LayoutPack

LayoutPack LayoutPack
getprivate set

Definition at line 61 of file RoomNode3D.cs.

◆ RoomLayout

Room RoomLayout
getprivate set

Definition at line 64 of file RoomNode3D.cs.

◆ RoomState

RoomState RoomState
getprivate set

Definition at line 67 of file RoomNode3D.cs.

◆ RoomTemplate

RoomTemplateResource RoomTemplate
getset

Definition at line 41 of file RoomNode3D.cs.

◆ Rows

int Rows
getset

Definition at line 45 of file RoomNode3D.cs.


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