"""
烟雾效果
"""

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

class SmokeEffect:
    """
    烟雾效果
    模拟烟雾扩散效果
    """
    
    @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': 'smoke',
            'emission_rate': 30,
            'particle_lifetime': 4.0,
            'start_color': Vec3(0.8, 0.8, 0.8),
            'end_color': Vec3(0.3, 0.3, 0.3),
            'start_size': 0.3,
            'end_size': 1.5,
            'velocity': Vec3(0, 0, 1),
            'velocity_variation': 0.3,
            'gravity_scale': -0.1,
            'emitter_shape': 'circle',
            'emitter_radius': 0.5
        }
        
        # 合并自定义配置
        effect_config = {**default_config, **config}
        
        # 创建发射器
        emitter = ParticleEmitter(
            "smoke_emitter", 
            "smoke", 
            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': 'smoke',
            'emission_rate': 30,
            'particle_lifetime': 4.0,
            'start_color': Vec3(0.8, 0.8, 0.8),
            'end_color': Vec3(0.3, 0.3, 0.3),
            'start_size': 0.3,
            'end_size': 1.5,
            'velocity': Vec3(0, 0, 1),
            'velocity_variation': 0.3,
            'gravity_scale': -0.1,
            'emitter_shape': 'circle',
            'emitter_radius': 0.5
        }