Class designed as a helper for situations where you need to generate and assign a unique integer to each instance of a class, eg. for a class implementing IHasID.
[PublicAPI] public class IDGenerator
The class may be initialized with a starting unsigned integer -- if none is given, 0 is the default starting point. To assign an ID, call UseID(), and assign the value that it returns. This class is NOT thread-safe on its own -- if it needs to be, you can simply use a lock to wrap any calls to UseID.
Constructors| Improve this Doc View Source
public IDGenerator(uint startingInt = 0U)
Unsigned integer to start at (one that will be returned first time UseID() is called). Defaults to 0.
Methods| Improve this Doc View Source
Call every time you wish to "assign" an ID. The integer returned will never be returned again (each integer returned by this function will be unique).
public uint UseID()
The ID that has been assigned.