ManiaMap.Godot
Procedural generation of metroidvania style maps for Godot .NET.
RoomFlag2D.cs
1using Godot;
2
4{
10 [Tool]
11 [GlobalClass]
12 [Icon(ManiaMapResources.Icons.RoomFlag2DIcon)]
13 public partial class RoomFlag2D : CellChild2D, IRoomFlag
14 {
15 private bool _editId;
19 [Export] public bool EditId { get => _editId; set => SetValidatedField(ref _editId, value); }
20
22 [Export] public int Id { get; set; } = -1;
23
24 private void SetValidatedField<T>(ref T field, T value)
25 {
26 field = value;
27 NotifyPropertyListChanged();
28 }
29
30 public override void _ValidateProperty(Godot.Collections.Dictionary property)
31 {
32 base._ValidateProperty(property);
33 var name = property["name"].AsStringName();
34
35 if (name == PropertyName.Id)
36 {
37 var flag = EditId ? PropertyUsageFlags.None : PropertyUsageFlags.ReadOnly;
38 property["usage"] = (int)(PropertyUsageFlags.Default | flag);
39 }
40 }
41
43 public override void AutoAssign(RoomNode2D room)
44 {
45 base.AutoAssign(room);
47 }
48 }
49}
The base class for elements tied to a RoomNode2D's cell index.
Definition: CellChild2D.cs:11
Contains the random number generator used for ID and random seed assignments.
Definition: Rand.cs:10
static int AutoAssignId(int id)
If the specified ID is less than or equal to zero, returns a new random positive integer ID....
Definition: Rand.cs:18
A room flag that can be set or toggled to alter the LayoutState.
Definition: RoomFlag2D.cs:14
override void AutoAssign(RoomNode2D room)
Assigns the room and any auto assigned values to the object.
Definition: RoomFlag2D.cs:43
bool EditId
If true, the Id property becomes editable in the inspector.
Definition: RoomFlag2D.cs:19
A node serving as the top level of a 2D room.
Definition: RoomNode2D.cs:17
A room flag that can be set or toggled to alter the LayoutState.
Definition: IRoomFlag.cs:7