/** * Spatial Awareness Trait * Sprint 4 Priority 4 - Spatial Context Awareness * * HoloScript trait that enables entities to be aware of their spatial * surroundings, including nearby entities, regions, and visibility. */ import { EventEmitter } from 'events'; import type { Vector3, SpatialContext, SpatialEntity, Region, SpatialEvent, SpatialAwarenessConfig, QueryResult } from '@holoscript/engine/spatial'; import { SpatialContextProvider } from '@holoscript/engine/spatial'; /** * Configuration for the spatial awareness trait */ export interface SpatialAwarenessTraitConfig extends SpatialAwarenessConfig { /** Initial position */ initialPosition?: Vector3; /** Auto-start spatial awareness */ autoStart?: boolean; /** Shared context provider (for multi-agent scenarios) */ sharedProvider?: SpatialContextProvider; } /** * Default trait configuration */ export declare const DEFAULT_TRAIT_CONFIG: SpatialAwarenessTraitConfig; /** * Events emitted by the spatial awareness trait */ export interface SpatialAwarenessTraitEvents { /** Entity entered perception radius */ 'entity:entered': (entity: SpatialEntity, distance: number) => void; /** Entity exited perception radius */ 'entity:exited': (entity: SpatialEntity) => void; /** Entered a region */ 'region:entered': (region: Region, previousRegion?: Region) => void; /** Exited a region */ 'region:exited': (region: Region) => void; /** Visibility to entity changed */ 'visibility:changed': (entityId: string, visible: boolean) => void; /** Context updated */ 'context:updated': (context: SpatialContext) => void; } /** * Trait that provides spatial awareness to HoloScript entities * * @example * ```holoscript * agent#patrol_bot { * @spatial_awareness( * updateRate: 30hz, * perceptionRadius: 10m * ) * * @on_entity_entered(entity) { * if (entity.type == "visitor") { * initiate_greeting(entity) * } * } * } * ``` */ export declare class SpatialAwarenessTrait extends EventEmitter { private id; private config; private provider; private ownsProvider; private position; private velocity; private isActive; private lastContext; private visibleEntities; constructor(id: string, config?: Partial); /** * Start spatial awareness */ start(): void; /** * Stop spatial awareness */ stop(): void; /** * Dispose of the trait */ dispose(): void; /** * Get current position */ getPosition(): Vector3; /** * Set position */ setPosition(position: Vector3): void; /** * Get current velocity */ getVelocity(): Vector3; /** * Set velocity */ setVelocity(velocity: Vector3): void; /** * Move by delta */ move(delta: Vector3): void; /** * Get current spatial context */ getContext(): SpatialContext | null; /** * Get nearby entities */ getNearbyEntities(): SpatialEntity[]; /** * Get current regions */ getCurrentRegions(): Region[]; /** * Check if in a specific region */ isInRegion(regionId: string): boolean; /** * Find nearest entity */ findNearest(typeFilter?: string[]): QueryResult | null; /** * Find all entities within radius */ findWithin(radius: number, typeFilter?: string[]): QueryResult[]; /** * Find visible entities */ findVisible(direction?: Vector3, fov?: number, maxDistance?: number): QueryResult[]; /** * Check if entity is visible */ isEntityVisible(entityId: string): boolean; /** * Get distance to entity */ getDistanceTo(entityId: string): number | null; /** * Register an entity for tracking */ registerEntity(entity: SpatialEntity): void; /** * Unregister an entity */ unregisterEntity(entityId: string): void; /** * Batch register entities */ registerEntities(entities: SpatialEntity[]): void; /** * Register a region */ registerRegion(region: Region): void; /** * Unregister a region */ unregisterRegion(regionId: string): void; /** * Subscribe to region events */ watchRegion(regionId: string, callback: (event: SpatialEvent) => void): void; /** * Unsubscribe from region events */ unwatchRegion(regionId: string): void; /** * Update perception radius */ setPerceptionRadius(radius: number): void; /** * Get perception radius */ getPerceptionRadius(): number; /** * Set entity type filter */ setEntityTypeFilter(types: string[]): void; /** * Setup event handlers from provider */ private setupEventHandlers; } /** * Create a spatial awareness trait for an entity */ export declare function createSpatialAwarenessTrait(id: string, config?: Partial): SpatialAwarenessTrait; /** * Create a shared spatial context provider for multiple agents */ export declare function createSharedSpatialProvider(): SpatialContextProvider; import type { TraitHandler } from '@holoscript/core'; export declare const spatialAwarenessHandler: TraitHandler; //# sourceMappingURL=SpatialAwarenessTrait.d.ts.map