API Reference

January 28, 2026 ยท View on GitHub

Complete reference for all public types in the BulletMLLib namespace.

Classes

Bullet

public abstract class Bullet : IBullet

Base class for all bullets. Inherit from this class and override the abstract members to create your game's bullet type.

Constructor:

protected Bullet(IBulletManager myBulletManager)
ParameterDescription
myBulletManagerThe bullet manager that owns this bullet. Must not be null.

Abstract Members (must override):

MemberTypeDescription
XfloatHorizontal position in pixels from upper-left.
YfloatVertical position in pixels from upper-left.
PostUpdate()voidCalled after Update(). Use for bounds checking, collision, rendering.

Properties:

PropertyTypeDefaultDescription
Speedfloat (virtual)0Bullet speed in pixels/frame.
Directionfloat (virtual)0Direction in radians. Automatically wrapped via MathHelper.WrapAngle.
AccelerationVector2ZeroAcceleration vector in pixels/frame^2. Set by <accel> nodes.
TimeSpeedfloat1.0Time multiplier. Values < 1 slow down, > 1 speed up.
Scalefloat1.0Pattern size multiplier.
InitialVelocityVector2ZeroVelocity inherited from the firing entity. Applied during InitNode.
TasksList<BulletMLTask>[]Runtime tasks defining this bullet's behavior.
MyNodeBulletMLNodenullThe node tree describing this bullet.
MyBulletManagerIBulletManager--The manager that owns this bullet.
Labelstring--Convenience property returning MyNode.Label.

Methods:

MethodReturnsDescription
InitTopNode(BulletMLNode rootNode)voidInitialize from a root node. Finds nodes labeled "top" or "top1" through "top9".
InitNode(BulletMLNode subNode)voidInitialize from a specific sub-node. Clears existing tasks and builds new task tree.
Update()void (virtual)Execute one frame: runs all tasks, then updates position from velocity and acceleration.
UpdateAsync()TaskRuns Update() on a background thread.
GetAimDir()float (virtual)Returns the angle (radians) from this bullet to the player position.
TasksFinished()boolReturns true when all tasks have completed execution.
FindTaskByLabel(string label)BulletMLTaskRecursively searches tasks for a matching label.
FindTaskByLabelAndName(string label, NodeName name)BulletMLTaskSearches tasks matching both label and node name.

Position Update Formula:

Each frame, the bullet's position is updated as:

velocity = (Acceleration + Direction.ToVector2() * Speed * TimeSpeed) * Scale
X += velocity.X
Y += velocity.Y

BulletPattern

public class BulletPattern

Container for a parsed BulletML document. Parse once, use many times to initialize bullets.

Constructor:

public BulletPattern(IBulletManager manager)

Properties:

PropertyTypeDescription
RootNodeBulletMLNodeRoot of the parsed node tree. Pass to Bullet.InitTopNode().
FilenamestringPath of the loaded XML file. Set by ParseXML().
OrientationPatternTypePattern type read from the <bulletml type="..."> attribute.

Methods:

MethodDescription
ParseXML(string xmlFileName, ContentManager content = null)Parse a BulletML XML file. If content is provided, loads via MonoGame Content Pipeline (path should be relative, no extension). Otherwise loads from file system.

BulletMLNode

public class BulletMLNode

Represents a single element in the parsed BulletML document tree. Nodes are shared across bullets; tasks are created per-bullet at runtime.

Properties:

PropertyTypeDescription
NameNodeNameThe type of this node (bullet, action, fire, etc.).
NodeTypeNodeTypeModifier type (none, aim, absolute, relative, sequence).
LabelstringThe label attribute from the XML element.
ChildNodesList<BulletMLNode>Child nodes in the tree.

Methods:

MethodDescription
FindLabelNode(string label, NodeName name)Find a descendant node with matching label and name.
FindParentNode(NodeName name)Walk up the tree to find an ancestor of the given type.
GetChild(NodeName name)Find the first direct child with the given name.

BulletMLTask

public class BulletMLTask

Runtime execution unit created from a BulletMLNode. Each bullet gets its own task tree.

Properties:

PropertyTypeDescription
NodeBulletMLNodeThe node this task was created from.
OwnerBulletMLTaskParent task in the execution tree.
ChildTasksList<BulletMLTask>Child tasks to execute.
TaskFinishedboolWhether this task (and all children) have completed.
ParamListList<float>Parameter values for referenced nodes (accessible as $1, $2, etc.).

FireData

public class FireData

Template data for creating new bullets during pattern execution.

Fields:

FieldTypeDescription
srcSpeedfloatInitial speed for fired bullets.
srcDirfloatInitial direction for fired bullets.
speedInitboolWhether speed has been explicitly set.

Interfaces

IBullet

public interface IBullet

Interface for bullet-like objects. Implement this if you want to wrap a Bullet in another object.

MemberTypeDescription
XfloatHorizontal position (pixels from upper-left).
YfloatVertical position (pixels from upper-left).
SpeedfloatSpeed in pixels/frame.
DirectionfloatDirection in radians.
TasksList<BulletMLTask>Runtime task list.
InitTopNode(BulletMLNode)voidInitialize from a root node.
InitNode(BulletMLNode)voidInitialize from a sub-node.

IBulletManager

public interface IBulletManager

Interface your game implements to manage bullet lifecycle and provide game state to the library.

MemberTypeDescription
RandRandomRandom number generator for $rand in expressions.
GameDifficultyFunctionDelegateReturns difficulty value (typically 0.0-1.0) for $rank in expressions.
CallbackFunctionsDictionary<string, FunctionDelegate>Custom functions accessible as $name in BulletML expressions.
PlayerPosition(IBullet)Vector2Returns the target position for aim-type directions.
CreateBullet()IBulletFactory for regular (visible) bullets. Called by <fire> nodes.
CreateTopBullet()IBulletFactory for top-level controller bullets (usually invisible).
RemoveBullet(IBullet)voidDispose/deactivate a bullet. Called by <vanish> nodes.

Enums

NodeName

Identifies the type of a BulletML XML element.

ValueXML ElementDescription
bulletml<bulletml>Root document element.
bullet<bullet>Bullet definition with direction, speed, and actions.
action<action>Sequence of commands defining bullet behavior.
fire<fire>Fires a new bullet with optional direction/speed.
direction<direction>Direction value (with type modifier).
speed<speed>Speed value (with type modifier).
changeDirection<changeDirection>Gradually change direction over a duration.
changeSpeed<changeSpeed>Gradually change speed over a duration.
accel<accel>Apply acceleration (horizontal/vertical components).
wait<wait>Pause execution for N frames.
repeat<repeat>Repeat child actions N times.
vanish<vanish>Remove the bullet.
horizontal<horizontal>Horizontal acceleration component (inside <accel>).
vertical<vertical>Vertical acceleration component (inside <accel>).
term<term>Duration for changeDirection/changeSpeed/accel.
times<times>Repeat count.
param<param>Parameter value for referenced nodes.
bulletRef<bulletRef>Reference to a labeled <bullet>.
actionRef<actionRef>Reference to a labeled <action>.
fireRef<fireRef>Reference to a labeled <fire>.

NodeType

Modifier for direction and speed values.

ValueDescription
noneNo modifier (default).
aimDirection aimed at the player position.
absoluteAbsolute value (0 = up for vertical patterns, right for horizontal).
relativeRelative to the bullet's current direction or speed.
sequenceAdded to the previous value each time the node fires.

PatternType

Orientation of the bullet pattern, set on the <bulletml> root element.

ValueDescription
verticalBullets travel top-to-bottom. 0 degrees = down.
horizontalBullets travel left-to-right. 0 degrees = right.
noneNo specific orientation.

RunStatus

Internal enum for task execution state.

ValueDescription
ContinueTask is still running.
EndTask has finished.
StopTask has been stopped.

Delegates

PositionDelegate

public delegate Vector2 PositionDelegate();

Callback that returns a Vector2 position.

FloatDelegate

public delegate float FloatDelegate();

Callback that returns a float value.

FunctionDelegate

// From Equationator library
public delegate float FunctionDelegate();

Used for GameDifficulty and entries in CallbackFunctions. Returns a float value that can be referenced in BulletML expressions.