MovingAgent - Agent with velocity-based movement

Features:

  • Velocity vector (vx, vy) for realistic movement
  • Speed limits and acceleration control
  • Boundary collision detection and response
  • Momentum and friction simulation

Educational Context: Represents community members who move through the environment with realistic physics, such as people walking, vehicles, or flowing resources.

Hierarchy (view full)

Constructors

Properties

_position: Position

Current position in environment

createdAt: number

Creation timestamp

Unique identifier for this agent

lastUpdated: number

Last update timestamp

movementConfig: MovementConfig

Movement configuration

previousPosition: Position

Previous position for collision detection

properties: Map<string, PropertyValue>

Agent properties with type-safe access

state: AgentState = 'active'

Current agent state

velocity: Velocity

Current velocity vector

prefixed: string | boolean

Accessors

Methods

  • Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns this

  • Calls each of the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Rest ...args: any[]

    Returns boolean

  • Return an array listing the events for which the emitter has registered listeners.

    Returns (string | symbol)[]

  • Handle boundary collision with environment

    Parameters

    • bounds: {
          height: number;
          width: number;
      }
      • height: number
      • width: number

    Returns void

  • Return the number of listeners listening to a given event.

    Parameters

    • event: string | symbol

    Returns number

  • Return the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T

    Returns ((...args) => void)[]

  • Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns this

  • Add a listener for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns this

  • Add a one-time listener for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns this

  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: string | symbol

    Returns this

  • Remove the listeners of a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns this