EG/plugins/user/weather_season_system/README.md
2025-10-30 11:46:41 +08:00

229 lines
6.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 天气和季节系统插件
## 概述
天气和季节系统插件为EG引擎提供完整的天气和季节模拟功能。该插件包含丰富的天气类型、四季变化、环境效果、粒子系统和音频效果能够创建逼真的自然环境模拟。
## 功能特性
### 1. 季节系统
- **四季变化**:春季、夏季、秋季、冬季循环
- **季节过渡**:平滑的季节过渡效果
- **季节影响**:温度、湿度、日照时间等环境参数变化
- **植被生长**:季节性植被状态变化
### 2. 天气系统
- **多种天气类型**
- 晴朗 (Clear)
- 多云 (Cloudy)
- 下雨 (Rain)
- 暴风雨 (Storm)
- 下雪 (Snow)
- 雾天 (Fog)
- 大风 (Windy)
- 冰雹 (Hail)
- **天气过渡**:自然的天气变化和过渡效果
- **天气影响**:温度、湿度、能见度等环境参数变化
### 3. 环境效果
- **光照系统**:动态光照和阴影
- **雾效系统**:线性、指数级雾效
- **风效系统**:风向和风速模拟
- **后处理效果**:曝光、饱和度、对比度调整
### 4. 粒子效果
- **降水粒子**:雨滴、雪花、冰雹
- **大气粒子**:雾气、尘土
- **季节粒子**:落叶等
- **物理模拟**:重力、风力影响
### 5. 音频系统
- **环境音效**:风声、雨声、雷声等
- **音频过渡**:淡入淡出效果
- **音量控制**:主音量、效果音量、环境音量
### 6. 物理效果
- **表面状态**:湿润度、结冰状态
- **移动影响**:摩擦系数、移动速度
- **声音传播**:声音衰减效果
## 系统架构
```
weather_season_system/
├── plugin.py # 插件主文件
├── core/
│ ├── season_manager.py # 季节管理器
│ └── weather_manager.py # 天气管理器
├── effects/
│ ├── environment_effects.py # 环境效果
│ └── visual_effects.py # 视觉效果
├── audio/
│ └── audio_manager.py # 音频管理器
├── weather/
│ └── weather_system.py # 天气系统
├── seasons/
│ └── season_system.py # 季节系统
├── particles/
│ └── particle_effects.py # 粒子效果
├── editor/
│ ├── weather_editor.py # 天气编辑器
│ └── preset_manager.py # 预设管理器
└── utils/
└── weather_utils.py # 工具类
```
## 使用方法
### 初始化插件
```python
# 创建插件实例
weather_plugin = WeatherSeasonSystemPlugin(engine)
# 初始化插件
if weather_plugin.initialize():
# 启用插件
if weather_plugin.enable():
print("天气和季节系统插件已启用")
```
### 设置季节
```python
# 设置当前季节
season_manager = weather_plugin.season_manager
season_manager.set_current_season('spring')
# 启用季节循环
season_manager.enable_season_cycle(True)
```
### 控制天气
```python
# 设置当前天气
weather_manager = weather_plugin.weather_manager
weather_manager.set_current_weather('rain')
# 启用天气变化
weather_manager.enable_weather_change(True)
```
### 调整环境效果
```python
# 设置时间
environment_effects = weather_plugin.environment_effects
environment_effects.set_time(12.0) # 正午
# 设置地理位置
environment_effects.set_location(30.0, 120.0) # 纬度30°经度120°
```
### 粒子效果控制
```python
# 激活粒子效果
visual_effects = weather_plugin.visual_effects
visual_effects.activate_effect('rain')
```
### 音频控制
```python
# 设置音量
audio_manager = weather_plugin.audio_manager
audio_manager.set_master_volume(0.8)
audio_manager.set_effects_volume(0.7)
```
## 配置选项
### 季节配置
- `season_duration`:每个季节持续天数
- `transition_duration`:季节过渡时间
- `season_cycle_enabled`:是否启用季节循环
### 天气配置
- `weather_duration_min`:天气最短持续时间
- `weather_duration_max`:天气最长持续时间
- `weather_change_probability`:天气变化概率
### 粒子系统配置
- `max_particles`:最大粒子数
- `quality_level`:粒子质量等级
- `collision_detection`:是否启用碰撞检测
### 音频配置
- `master_volume`:主音量
- `effects_volume`:效果音量
- `ambient_volume`:环境音量
## API参考
### 主要类和方法
#### WeatherSeasonSystemPlugin
- `initialize()`:初始化插件
- `enable()`:启用插件
- `disable()`:禁用插件
- `update(dt)`:更新插件状态
#### SeasonManager
- `set_current_season(season)`:设置当前季节
- `enable_season_cycle(enabled)`:启用/禁用季节循环
- `get_current_season()`:获取当前季节
- `get_season_info(season)`:获取季节信息
#### WeatherManager
- `set_current_weather(weather)`:设置当前天气
- `enable_weather_change(enabled)`:启用/禁用天气变化
- `get_current_weather()`:获取当前天气
- `get_weather_info(weather)`:获取天气信息
#### EnvironmentEffects
- `set_time(hour)`:设置当前时间
- `set_location(latitude, longitude)`:设置地理位置
- `get_current_effects()`:获取当前环境效果
#### VisualEffects
- `activate_effect(effect_name)`:激活视觉效果
- `deactivate_effect(effect_name)`:停用视觉效果
- `get_active_effects()`:获取激活的效果列表
#### AudioManager
- `set_master_volume(volume)`:设置主音量
- `set_effects_volume(volume)`:设置效果音量
- `play_sound(sound_name)`:播放音频
- `stop_sound(sound_name)`:停止音频
## 性能优化
1. **LOD系统**:根据距离调整粒子质量和效果细节
2. **缓存机制**:缓存计算结果以提高性能
3. **批量更新**:批量处理粒子和效果更新
4. **资源管理**:及时释放不需要的资源
## 扩展性
### 添加新的天气类型
1. 在`WeatherManager`中添加天气类型定义
2. 在`VisualEffects`中添加对应的粒子效果
3. 在`AudioManager`中添加对应的音频效果
### 添加新的季节
1. 在`SeasonManager`中添加季节定义
2. 调整季节影响的环境参数
3. 添加季节特有的视觉和音频效果
### 自定义粒子效果
1. 在`ParticleEffects`中定义新的粒子类型
2. 创建对应的粒子发射器
3. 设置粒子的物理属性和行为
## 许可证
本插件遵循EG引擎的许可证协议。
## 更新日志
### v1.0.0
- 初始版本发布
- 实现完整的季节和天气系统
- 添加环境效果、粒子效果和音频系统
- 提供编辑器和预设管理功能