![]() |
ManiaMap.Godot
Procedural generation of metroidvania style maps for Godot .NET.
|
A node serving as the top level of a 2D room. More...
Public Member Functions | |
override void | _Ready () |
override void | _ValidateProperty (Godot.Collections.Dictionary property) |
Vector2 | CellCenterGlobalPosition (int row, int column) |
Returns the cell center global position for the specified cell index. More... | |
Vector2 | CellCenterLocalPosition (int row, int column) |
Returns the cell center local position for the specified cell index. More... | |
Error | EmitOnCellAreaEntered (CellArea2D cell, Node collision) |
Error | EmitOnCellAreaExited (CellArea2D cell, Node collection) |
Error | EmitOnCellGridChanged () |
Vector2I | FindClosestActiveCellIndex (Vector2 position) |
Returns the closest active cell index to the specified global position. More... | |
DoorDirection | FindClosestDoorDirection (int row, int column, Vector2 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 (Vector2 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 (Vector2 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 (CellArea2D cell, Node collision) |
Signal emitted when a cell area is entered by a tracked area or body. More... | |
delegate void | OnCellAreaExitedEventHandler (CellArea2D 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 RoomNode2D | 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 RoomNode2D | 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] |
Vector2 | 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] |
![]() | |
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 CellArea2D for all active cells. More... | |
void | SetCellSizeField (ref Vector2 field, Vector2 value) |
void | SetSizeField (ref int field, int value) |
Private Attributes | |
Vector2 | _cellSize = new Vector2(96, 96) |
int | _columns = 1 |
int | _rows = 1 |
A node serving as the top level of a 2D room.
See IRoomNodeExtensions for additional methods usable by this class.
Definition at line 16 of file RoomNode2D.cs.
override void _Ready | ( | ) |
Definition at line 90 of file RoomNode2D.cs.
override void _ValidateProperty | ( | Godot.Collections.Dictionary | property | ) |
Definition at line 107 of file RoomNode2D.cs.
Vector2 CellCenterGlobalPosition | ( | int | row, |
int | column | ||
) |
Returns the cell center global position for the specified cell index.
row | The cell row. |
column | The cell column. |
Definition at line 351 of file RoomNode2D.cs.
Vector2 CellCenterLocalPosition | ( | int | row, |
int | column | ||
) |
Returns the cell center local position for the specified cell index.
row | The cell row. |
column | The cell column. |
Definition at line 361 of file RoomNode2D.cs.
|
private |
Creates CellArea2D for all active cells.
cellCollisionMask | The cell collision mask. |
Definition at line 323 of file RoomNode2D.cs.
|
static |
Creates and initializes an instance of a room.
scene | The room scene. |
parent | The node to which the room will be added as a child. |
layoutPack | The layout pack.. |
roomLayout | The room's layout. |
roomState | The room's state. |
cellCollisionMask | The cell collision mask. |
assignLayoutPosition | If 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 RoomNode2D.cs.
|
static |
Creates and initializes an instance of a room. The layout and layout state are assigned to the room based on the current ManiaMapManager.
id | The room ID. |
layoutPack | The layout pack. |
scene | The room scene. |
parent | The node to which the room will be added as a child. |
assignLayoutPosition | If 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 182 of file RoomNode2D.cs.
Vector2I FindClosestActiveCellIndex | ( | Vector2 | position | ) |
Returns the closest active cell index to the specified global position.
position | The global position. |
Definition at line 243 of file RoomNode2D.cs.
DoorDirection FindClosestDoorDirection | ( | int | row, |
int | column, | ||
Vector2 | 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.
row | The cell row. |
column | The cell column. |
position | The global position. |
Definition at line 283 of file RoomNode2D.cs.
Vector2I GlobalPositionToCellIndex | ( | Vector2 | 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).
position | The global position. |
Definition at line 371 of file RoomNode2D.cs.
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.
layoutPack | The layout pack. |
roomLayout | The room's layout. |
roomState | The room's state. |
cellCollisionMask | The cell collision mask. |
assignLayoutPosition | If 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 221 of file RoomNode2D.cs.
Vector2I LocalPositionToCellIndex | ( | Vector2 | 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).
position | The local position. |
Definition at line 381 of file RoomNode2D.cs.
void MoveToLayoutPosition | ( | ) |
Moves the room to its position in the Layout
.
Definition at line 340 of file RoomNode2D.cs.
delegate void OnCellAreaEnteredEventHandler | ( | CellArea2D | cell, |
Node | collision | ||
) |
Signal emitted when a cell area is entered by a tracked area or body.
cell | The entered cell. |
collision | The entering object. |
delegate void OnCellAreaExitedEventHandler | ( | CellArea2D | cell, |
Node | collision | ||
) |
Signal emitted when a cell area is exited by a tracked area or body.
cell | The exited cell. |
collision | The exiting object. |
|
private |
Definition at line 84 of file RoomNode2D.cs.
|
private |
Definition at line 77 of file RoomNode2D.cs.
|
private |
Definition at line 51 of file RoomNode2D.cs.
|
private |
Definition at line 47 of file RoomNode2D.cs.
|
private |
Definition at line 43 of file RoomNode2D.cs.
|
getset |
Definition at line 58 of file RoomNode2D.cs.
|
getset |
The width and height of the room cells.
Definition at line 55 of file RoomNode2D.cs.
|
getset |
Definition at line 49 of file RoomNode2D.cs.
|
getprivate set |
Definition at line 70 of file RoomNode2D.cs.
|
getprivate set |
Definition at line 61 of file RoomNode2D.cs.
|
getprivate set |
Definition at line 64 of file RoomNode2D.cs.
|
getprivate set |
Definition at line 67 of file RoomNode2D.cs.
|
getset |
Definition at line 41 of file RoomNode2D.cs.
|
getset |
Definition at line 45 of file RoomNode2D.cs.