ManiaMap.Godot
Procedural generation of metroidvania style maps for Godot .NET.
CollectableGroup.cs
1using Godot;
2using MPewsey.ManiaMap.Exceptions;
3using System;
4using System.Collections.Generic;
5
7{
11 [Tool]
12 [GlobalClass]
13 public partial class CollectableGroup : Resource
14 {
18 [Export] public string GroupName { get; set; } = "<None>";
19
23 [Export] public CollectableGroupEntry[] Entries { get; set; } = Array.Empty<CollectableGroupEntry>();
24
29 public List<int> GetCollectableIds()
30 {
31 var result = new List<int>();
32 var set = new HashSet<int>();
33
34 foreach (var entry in Entries)
35 {
36 if (!set.Add(entry.Collectable.Id))
37 throw new DuplicateIdException($"Duplicate collectable ID: {entry.Collectable.Id}.");
38
39 for (int i = 0; i < entry.Quantity; i++)
40 {
41 result.Add(entry.Collectable.Id);
42 }
43 }
44
45 return result;
46 }
47 }
48}
An entry in a CollectableGroup.
A collection of collectables and quantities for distribution across associated CollectableSpot2D.
string GroupName
The unique group name.
CollectableGroupEntry[] Entries
An array of entries.
List< int > GetCollectableIds()
Returns a list of collectable ID's in the quantities specified in the group's Entries.