Sunday, July 2, 2017

Abiathar API - Interacting with levels

The LevelGen property on IAbiatharState allows extensions to create levels. The level generator has these functions:

  • NewLevel takes the width, height, and name and produces a level object with those dimensions.
  • NewFromProps creates a new level with the same dimensions and properties as an existing one.
  • NewFromMetadata creates a new blank level with the given width and height, but the other properties provided by an existing level.
You are responsible for making sure the dimensions you supply are within the size restrictions returned by the SizeRestrictions property of the state manager.

Level objects have these properties:
  • Data gets or sets the tile ID at the given X, Y, and plane.
  • Name is the level's name.
  • Signature is the signature written into the level file next to the level. This might be ignored, depending on the level format.
  • Width and Height are exactly what they claim to be.
  • ExtraData gets or sets the value of an extended data field. This is only useful on extended level formats.
Level sets (as returned by the state manager property Levels) have these members:
  • Count is the number of present levels.
  • Add adds a new level object with the given ID.
  • Delete removes the level with the given ID.
  • At gets or sets the level at the given ID. Instead of using this to replace a level, use ReplaceLevel on the state manager.
  • Clear deletes all levels.
  • List gets a list of all present IDs.
  • Create returns a new level object with the given width and height. Use the level generator instead.
  • Exists returns whether there is a level with the given ID.

No comments:

Post a Comment