mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
This is as much as we can do until pydcs actually adds the py.typed file. Once that's added there are a few ugly monkey patching corners that will just need `# type: ignore` for now, but we can't pre-add those since we have mypy warning us about superfluous ignore comments.
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
from typing import Optional
|
|
|
|
from dcs.mission import Mission
|
|
|
|
from game.weather import Clouds, Fog, Conditions, WindConditions
|
|
|
|
|
|
class EnvironmentGenerator:
|
|
def __init__(self, mission: Mission, conditions: Conditions) -> None:
|
|
self.mission = mission
|
|
self.conditions = conditions
|
|
|
|
def set_clouds(self, clouds: Optional[Clouds]) -> None:
|
|
if clouds is None:
|
|
return
|
|
self.mission.weather.clouds_base = clouds.base
|
|
self.mission.weather.clouds_thickness = clouds.thickness
|
|
self.mission.weather.clouds_density = clouds.density
|
|
self.mission.weather.clouds_iprecptns = clouds.precipitation
|
|
self.mission.weather.clouds_preset = clouds.preset
|
|
|
|
def set_fog(self, fog: Optional[Fog]) -> None:
|
|
if fog is None:
|
|
return
|
|
self.mission.weather.fog_visibility = int(fog.visibility.meters)
|
|
self.mission.weather.fog_thickness = fog.thickness
|
|
|
|
def set_wind(self, wind: WindConditions) -> None:
|
|
self.mission.weather.wind_at_ground = wind.at_0m
|
|
self.mission.weather.wind_at_2000 = wind.at_2000m
|
|
self.mission.weather.wind_at_8000 = wind.at_8000m
|
|
|
|
def generate(self) -> None:
|
|
self.mission.start_time = self.conditions.start_time
|
|
self.set_clouds(self.conditions.weather.clouds)
|
|
self.set_fog(self.conditions.weather.fog)
|
|
self.set_wind(self.conditions.weather.wind)
|