ManiaMap.Godot
Procedural generation of metroidvania style maps for Godot .NET.
CellChild3D.cs
1using Godot;
2
4{
8 [Tool]
9 [GlobalClass]
10 public abstract partial class CellChild3D : Node3D, ICellChild
11 {
15 [Export] public RoomNode3D Room { get; set; }
16
19
21 [Export] public bool AutoAssignCell { get; set; } = true;
22
24 [Export(PropertyHint.Range, "0,10,1,or_greater")] public int Row { get; set; }
25
27 [Export(PropertyHint.Range, "0,10,1,or_greater")] public int Column { get; set; }
28
33 public virtual void AutoAssign(RoomNode3D room)
34 {
35 Room = room;
36
38 (Row, Column) = room.FindClosestActiveCellIndex(GlobalPosition);
39 }
40
41 public override void _ValidateProperty(Godot.Collections.Dictionary property)
42 {
43 base._ValidateProperty(property);
44 var name = property["name"].AsStringName();
45
46 if (name == PropertyName.Room)
47 property["usage"] = (int)(property["usage"].As<PropertyUsageFlags>() | PropertyUsageFlags.ReadOnly);
48 }
49 }
50}
The base class for elements tied to a RoomNode3D's cell index.
Definition: CellChild3D.cs:11
RoomNode3D Room
The contained room.
Definition: CellChild3D.cs:15
virtual void AutoAssign(RoomNode3D room)
Assigns the room and any auto assigned values to the object.
Definition: CellChild3D.cs:33
A node serving as the top level of a 3D room.
Definition: RoomNode3D.cs:17
Vector2I FindClosestActiveCellIndex(Vector3 position)
Returns the closest active cell index to the specified global position.
Definition: RoomNode3D.cs:329
The interface for elements tied to an IRoomNode's cell index.
Definition: ICellChild.cs:7
The interface for a room node.
Definition: IRoomNode.cs:9