ManiaMap.Godot
Procedural generation of metroidvania style maps for Godot .NET.
CollectableSpot2D.cs
1using Godot;
2
4{
10 [Tool]
11 [GlobalClass]
12 [Icon(ManiaMapResources.Icons.CollectableSpot2Dicon)]
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
25 [Export] public CollectableGroup CollectableGroup { get; set; }
26
28 [Export(PropertyHint.Range, "0,2,0.1,or_greater")] public float Weight { get; set; } = 1;
29
30 private void SetValidatedField<T>(ref T field, T value)
31 {
32 field = value;
33 NotifyPropertyListChanged();
34 }
35
36 public override void _ValidateProperty(Godot.Collections.Dictionary property)
37 {
38 base._ValidateProperty(property);
39 var name = property["name"].AsStringName();
40
41 if (name == PropertyName.Id)
42 {
43 var flag = EditId ? PropertyUsageFlags.None : PropertyUsageFlags.ReadOnly;
44 property["usage"] = (int)(PropertyUsageFlags.Default | flag);
45 }
46 }
47
49 public override void AutoAssign(RoomNode2D room)
50 {
51 base.AutoAssign(room);
53 }
54 }
55}
The base class for elements tied to a RoomNode2D's cell index.
Definition: CellChild2D.cs:11
A collection of collectables and quantities for distribution across associated CollectableSpot2D.
A possible collectable location within a RoomNode2D.
override void AutoAssign(RoomNode2D room)
Assigns the room and any auto assigned values to the object.
bool EditId
If true, the Id property becomes editable in the inspector.
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 node serving as the top level of a 2D room.
Definition: RoomNode2D.cs:17
A possible collectable location within an IRoomNode.