# HG changeset patch # User Steve Losh # Date 1470968333 0 # Node ID 1ce97acb6755ba7faab6cef16f217ce5e9988562 # Parent 65e9a71de7b0e21b5e35bb130c8ce0a109c6ddbe beast: Update site. diff -r 65e9a71de7b0 -r 1ce97acb6755 beast/reference/index.html --- a/beast/reference/index.html Thu Aug 11 04:57:15 2016 +0000 +++ b/beast/reference/index.html Fri Aug 12 02:18:53 2016 +0000 @@ -33,7 +33,6 @@
  • ENTITY-CREATED (generic function)
  • ENTITY-DESTROYED (generic function)
  • -
  • GET-ENTITY (function)
  • MAP-ENTITIES (function)
  • @@ -44,21 +43,62 @@ +

    Destroy all entities.

    +

    destroy-entity will be called for each entity.

    +

    Returns a list of all the destroyed entites.

    CREATE-ENTITY (function)

    -
    (CREATE-ENTITY CLASS &REST INITARGS)
    +
    (CREATE-ENTITY 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.

    DEFINE-ASPECT (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)))
    +
    + +

    DEFINE-ENTITY (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))
    +
    + +

    DEFINE-SYSTEM (macro)

    (DEFINE-SYSTEM NAME-AND-OPTIONS
         ARGLIST
    @@ -67,41 +107,78 @@
     
    +

    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)))
    +
    + +

    DESTROY-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.

    ENTITY (class)

    +

    A single entity in the game world.

    Slot ID

    • Allocation: :INSTANCE
    • Initform: (INCF BEAST::*ENTITY-ID-COUNTER*)
    • Reader: ENTITY-ID
    +

    The unique ID of the entity. This may go away in the future.

    Slot %BEAST/ASPECTS

    • Allocation: :CLASS
    • Initform: NIL
    +

    A list of the aspects this entity class inherits. Don't touch this.

    ENTITY-CREATED (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.

    ENTITY-DESTROYED (generic function)

    (ENTITY-DESTROYED ENTITY)
     
    -

    GET-ENTITY (function)

    -
    (GET-ENTITY ID)
    +

    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.

    +

    MAP-ENTITIES (function)

    +
    (MAP-ENTITIES FUNCTION &OPTIONAL (TYPE 'ENTITY))
     
    -

    MAP-ENTITIES (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.