agentjs-core
Version:
A comprehensive agent-based modeling framework with built-in p5.js visualization
196 lines • 5.11 kB
TypeScript
/**
* ParticleEffectsSystem - Visual feedback through particle effects
*
* Features:
* - Interaction effect particles
* - Network formation visual feedback
* - State change celebration effects
* - Agent movement indicators
* - Efficient particle system implementation
* - Multiple effect types and customization
*/
/// <reference types="@types/p5-global" />
import type { Agent } from '../core/agents/Agent';
import type { Position } from '../types/core';
/** Particle effect types */
export type ParticleEffectType = 'interaction' | 'network_formation' | 'state_change' | 'movement' | 'celebration' | 'warning' | 'resource_transfer' | 'explosion' | 'sparkle' | 'trail' | 'custom';
/** Particle configuration */
export interface ParticleConfig {
type: ParticleEffectType;
count: number;
lifetime: number;
size: number;
speed: number;
spread: number;
gravity: number;
color: Color | string;
fadeOut: boolean;
fadeIn: boolean;
bounce: boolean;
trail: boolean;
blendMode?: BLEND_MODE;
}
/** Effect trigger data */
export interface EffectTrigger {
type: ParticleEffectType;
position: {
x: number;
y: number;
};
config?: Partial<ParticleConfig>;
data?: any;
}
/**
* ParticleEffectsSystem - Advanced particle effects manager
*
* Educational Context: Provides visual feedback for agent
* interactions and system events, making complex behaviors
* more observable and engaging for users.
*/
export declare class ParticleEffectsSystem {
/** Active particle effects */
private effects;
/** Default configurations for different effect types */
private defaultConfigs;
/** p5 instance for rendering */
private p5Instance;
/** Current timestamp */
private currentTime;
/** Performance statistics */
private readonly stats;
/** Particle pool for performance */
private particlePool;
private poolSize;
/** Effect queue for batch processing */
private effectQueue;
constructor();
/**
* Initialize default configurations for effect types
*/
private initializeDefaultConfigs;
/**
* Initialize particle pool for performance
*/
private initializeParticlePool;
/**
* Create empty particle for pool
*/
private createEmptyParticle;
/**
* Set p5 instance for rendering
*/
setP5Instance(p5Instance: p5Instance): void;
/**
* Initialize colors with p5 instance
*/
private initializeColors;
/**
* Update all particle effects
*/
update(deltaTime: number): void;
/**
* Process queued effects
*/
private processEffectQueue;
/**
* Create effect from trigger
*/
private createEffectFromTrigger;
/**
* Update single effect
*/
private updateEffect;
/**
* Update single particle
*/
private updateParticle;
/**
* Get lifetime multiplier for property animation
*/
private getLifetimeMultiplier;
/**
* Apply bounce physics
*/
private applyBounce;
/**
* Get bounds for particle physics
*/
private getBounds;
/**
* Kill particle and return to pool
*/
private killParticle;
/**
* Reset particle for pool reuse
*/
private resetParticle;
/**
* Get particle from pool or create new one
*/
private getParticle;
/**
* Create particle effect
*/
createEffect(type: ParticleEffectType, position: Position, config?: Partial<ParticleConfig>, data?: any): string;
/**
* Create individual particle
*/
private createParticle;
/**
* Queue effect for next update
*/
queueEffect(trigger: EffectTrigger): void;
/**
* Create interaction effect
*/
createInteractionEffect(position: Position, interactionType?: string): string;
/**
* Create network formation effect
*/
createNetworkFormationEffect(sourcePos: Position, targetPos: Position): string;
/**
* Create state change effect
*/
createStateChangeEffect(agent: Agent, changeType: string): string;
/**
* Render all particle effects
*/
render(sketch: p5Instance): void;
/**
* Render single effect
*/
private renderEffect;
/**
* Render single particle
*/
private renderParticle;
/**
* Get effect configuration
*/
getEffectConfig(type: ParticleEffectType): ParticleConfig | undefined;
/**
* Update effect configuration
*/
updateEffectConfig(type: ParticleEffectType, config: Partial<ParticleConfig>): void;
/**
* Stop effect by ID
*/
stopEffect(effectId: string): boolean;
/**
* Stop all effects of type
*/
stopEffectsOfType(type: ParticleEffectType): number;
/**
* Get performance statistics
*/
getStats(): typeof this.stats;
/**
* Clear all effects
*/
clear(): void;
/**
* Destroy the particle system
*/
destroy(): void;
}
//# sourceMappingURL=ParticleEffectsSystem.d.ts.map