"""
水花效果
"""

from panda3d.core import Vec3, Point3
from ..core.particle_emitter import ParticleEmitter

class WaterEffect:
    """
    水花效果
    模拟水花飞溅效果
    """
    
    @staticmethod
    def create_effect(world, position: Point3 = None, config: Dict = None) -> str:
        """
        创建水花效果
        
        Args:
            world: 3D世界对象
            position: 发射器位置
            config: 自定义配置
            
        Returns:
            发射器ID
        """
        if position is None:
            position = Point3(0, 0, 0)
            
        if config is None:
            config = {}
            
        # 默认配置
        default_config = {
            'particle_type': 'water',
            'emission_rate': 80,
            'particle_lifetime': 3.0,
            'start_color': Vec3(0.2, 0.6, 1.0),
            'end_color': Vec3(0.1, 0.3, 0.8),
            'start_size': 0.1,
            'end_size': 0.05,
            'velocity': Vec3(0, 0, 3),
            'velocity_variation': 1.0,
            'gravity_scale': 2.0,
            'bounce_factor': 0.3,
            'emitter_shape': 'circle',
            'emitter_radius': 0.2
        }
        
        # 合并自定义配置
        effect_config = {**default_config, **config}
        
        # 创建发射器
        emitter = ParticleEmitter(
            "water_emitter", 
            "water", 
            position, 
            world,
            effect_config
        )
        
        return emitter.emitter_id
        
    @staticmethod
    def update_effect(emitter: ParticleEmitter, config: Dict):
        """
        更新水花效果
        
        Args:
            emitter: 粒子发射器
            config: 更新配置
        """
        # 更新发射器参数
        for key, value in config.items():
            if hasattr(emitter, key):
                setattr(emitter, key, value)
                
    @staticmethod
    def get_default_config() -> Dict:
        """
        获取默认配置
        
        Returns:
            默认配置字典
        """
        return {
            'particle_type': 'water',
            'emission_rate': 80,
            'particle_lifetime': 3.0,
            'start_color': Vec3(0.2, 0.6, 1.0),
            'end_color': Vec3(0.1, 0.3, 0.8),
            'start_size': 0.1,
            'end_size': 0.05,
            'velocity': Vec3(0, 0, 3),
            'velocity_variation': 1.0,
            'gravity_scale': 2.0,
            'bounce_factor': 0.3,
            'emitter_shape': 'circle',
            'emitter_radius': 0.2
        }