beast

API Reference

beast

Basic Entity/Aspect/System Toolkit

BEAST.QUICKUTILS

Package that contains Quickutil utility functions.
  • Function MAP-PRODUCT (function list &rest more-lists)
    Returns a list containing the results of calling `function` with one argument from `list`, and one from each of `more-lists` for each combination of arguments. In other words, returns the product of `list` and `more-lists` using `function`. Example: (map-product 'list '(1 2) '(3 4) '(5 6)) => ((1 3 5) (1 3 6) (1 4 5) (1 4 6) (2 3 5) (2 3 6) (2 4 5) (2 4 6))
  • Function HASH-TABLE-KEY-EXISTS-P (hash-table key)
    Does `key` exist in `hash-table`?
  • Function HASH-TABLE-VALUES (table)
    Returns a list containing the values of hash table `table`.
  • Macro WITH-GENSYMS (names &body forms)
    Binds each variable named by a symbol in `names` to a unique symbol around `forms`. Each of `names` must either be either a symbol, or of the form: (symbol string-designator) Bare symbols appearing in `names` are equivalent to: (symbol symbol) The string-designator is used as the argument to `gensym` when constructing the unique symbol the named variable will be bound to.
  • Macro WITH-UNIQUE-NAMES (names &body forms)
    Binds each variable named by a symbol in `names` to a unique symbol around `forms`. Each of `names` must either be either a symbol, or of the form: (symbol string-designator) Bare symbols appearing in `names` are equivalent to: (symbol symbol) The string-designator is used as the argument to `gensym` when constructing the unique symbol the named variable will be bound to.
  • Function SYMB (&rest args)
    Receives any number of objects, concatenates all into one string with `#'mkstr` and converts them to symbol. Extracted from _On Lisp_, chapter 4. See also: `symbolicate`
  • Function ENSURE-KEYWORD (x)
    Ensure that a keyword is returned for the string designator `x`.
  • Function ENSURE-LIST (list)
    If `list` is a list, it is returned. Otherwise returns the list designated by `list`.

BEAST

  • Class ENTITY
    A single entity in the game world.
    ID   Reader: ENTITY-ID
    The unique ID of the entity. This may go away in the future.
    %BEAST/ASPECTS
    A list of the aspects this entity class inherits. **Don't touch this.**
  • Generic-Function ENTITY-CREATED (entity)
    Called after an entity has been created and indexed. The default method does nothing, but users can implement their own auxillary methods to run code when entities are created.
  • Method ENTITY-CREATED ((entity entity))
  • Method ENTITY-CREATED ((entity entity))
  • Method ENTITY-CREATED ((entity entity))
  • Generic-Function ENTITY-DESTROYED (entity)
    Called after an entity has been destroyed and unindexed. The default method does nothing, but users can implement their own auxillary methods to run code when entities are destroyed.
  • Method ENTITY-DESTROYED ((entity entity))
  • Method ENTITY-DESTROYED ((entity entity))
  • Method ENTITY-DESTROYED ((entity entity))
  • Function CREATE-ENTITY (class &rest initargs)
    Create an entity of the given entity class and return it. `initargs` will be passed along to `make-instance`. The `entity-created` generic function will be called just before returning the entity.
  • Function DESTROY-ENTITY (entity)
    Destroy `entity` and return it. The `entity-destroyed` generic function will be called after the entity has been destroyed and unindexed.
  • Function CLEAR-ENTITIES
    Destroy all entities. `destroy-entity` will be called for each entity. Returns a list of all the destroyed entites.
  • Function MAP-ENTITIES (function &optional (type 'entity))
    Map `function` over all entities that are subtypes of `type`. Normally you should run code on entities using systems, but this function can be handy for debugging purposes.
  • Macro DEFINE-ENTITY (name aspects &rest slots)
    Define an entity class. `name` should be a symbol that will become the name of the class. `aspects` should be a list of the aspects this entity should inherit from. `slots` can be zero or more extra CLOS slot definitions. Examples: (define-entity potion (drinkable)) (define-entity cheese (edible visible) (flavor :accessor cheese-flavor :initarg :flavor))
  • Macro DEFINE-ASPECT (name &rest fields)
    Define an aspect class. `name` should be a symbol that will become the name of the class. `fields` should be zero or more field definitions. Each field definition can be a symbol (the field name), or a list of the field name and extra CLOS slot options. Field names will have the aspect name and a slash prepended to them to create the slot names. `:initarg` and `:accessor` slot options will also be automatically generated. Example: (define-aspect edible energy (taste :initform nil)) => (defclass edible () ((edible/energy :initarg :edible/energy :accessor edible/energy) (edible/taste :initarg :edible/taste :accessor edible/taste :initform nil)))
  • Macro DEFINE-SYSTEM (name-and-options arglist &body body)
    Define a system. `name-and-options` should be a list of the system name (a symbol) and any system options. A bare symbol can be used if no options are needed. `arglist` should be a list of system arguments. Each argument should be a list of the argument name and zero or more aspect/entity classes. Defining a system `foo` defines two functions: * `foo` runs `body` on a single entity and should only be used for debugging, tracing, or disassembling. * `run-foo` should be called to run the system on all applicable entities. Available system options: * `:inline`: when true, try to inline the system function into the system-running function to avoid the overhead of a function call for every entity. Defaults to `nil`. Examples: (define-system age ((entity lifetime)) (when (> (incf (lifetime/age entity)) (lifetime/lifespan entity)) (destroy-entity entity)))