API Docs for:
Show:

AI Class

A component class responsible for Artificial Intelligence.

Constructor

AI

(
  • friendCollideWith
  • foeCollideWith
)

Parameters:

  • friendCollideWith Number

    A bit mask used when querying the physics engine for friendly entities.

  • foeCollideWith Number

    A bit mask used when querying the physics engine for enemy entities.

Methods

addScript

(
  • script
)

Adding a script object to the AI component causes the component's entity to be processed with the corresponding script function if all other required components are present.

Parameters:

  • script Object

    A script object.

getFoeCollideWith

() Number

Returns:

Number:

getFriendCollideWith

() Number

Returns:

Number:

getScript

(
  • scriptConstructor
)
Object | Null | Undefined

Retrieves a script object.

Parameters:

  • scriptConstructor Function

    Constructor of the script object.

Returns:

Object | Null | Undefined: Returns the script object, if present, otherwise the function will return null or undefined.

hasScript

(
  • scriptConstructor
)
Boolean

Checks if the component has a script attached.

Parameters:

  • scriptConstructor Function

    Constructor of the script object.

Returns:

Boolean: Returns true if the component has the script attached.

removeScript

(
  • scriptConstructor
)

Removes a script object and thus cases the entity to no longer be handled by the corresponding script function.

Parameters:

  • scriptConstructor Function

    Constructor of the script object to be removed.

setFoeCollideWith

(
  • foeCollideWith
)

Parameters:

  • foeCollideWith Number

    A bit mask used when querying the physics engine for enemy entities.

setFriendCollideWith

(
  • friendCollideWith
)

Parameters:

  • friendCollideWith Number

    A bit mask used when querying the physics engine for friendly entities.