Sunday, May 8, 2016

How do I check whether a level ID exists from the Abiathar API?

While rigging up EasyAslev, I noticed a little infelicity in the Abiathar extension API. It's actually kind of tricky to check whether an IAbiatharLevelSetWrapper contains a level at a certain ID - there's no Contains method. (Oops.) Attempting to get the At property for a nonexistent ID results in an exception, so iterating to find the first empty level would be slow.

The best way to check for a level's presence is to use that interface's List function, which returns a list containing the taken IDs. You can then use the Contains method on that, or iterate over it.

I'll make sure to add a cleaner way of testing for level presence via the API in the next version of Abiathar.

No comments:

Post a Comment