Weather tweaks (#14271)

This commit is contained in:
metalgearsloth
2023-03-07 12:28:50 +11:00
committed by GitHub
parent 84052bb27d
commit 46b27a68ff
7 changed files with 247 additions and 170 deletions

View File

@@ -46,7 +46,7 @@ public sealed class WeatherOverlay : Overlay
return false;
if (!_entManager.TryGetComponent<WeatherComponent>(_mapManager.GetMapEntityId(args.MapId), out var weather) ||
weather.Weather == null)
weather.Weather.Count == 0)
{
return false;
}
@@ -58,15 +58,19 @@ public sealed class WeatherOverlay : Overlay
{
var mapUid = _mapManager.GetMapEntityId(args.MapId);
if (!_entManager.TryGetComponent<WeatherComponent>(mapUid, out var weather) ||
weather.Weather == null ||
!_protoManager.TryIndex<WeatherPrototype>(weather.Weather, out var weatherProto))
if (!_entManager.TryGetComponent<WeatherComponent>(mapUid, out var comp))
{
return;
}
var alpha = _weather.GetPercent(weather, mapUid, weatherProto);
DrawWorld(args, weatherProto, alpha);
foreach (var (proto, weather) in comp.Weather)
{
if (!_protoManager.TryIndex<WeatherPrototype>(proto, out var weatherProto))
continue;
var alpha = _weather.GetPercent(weather, mapUid);
DrawWorld(args, weatherProto, alpha);
}
}
private void DrawWorld(in OverlayDrawArgs args, WeatherPrototype weatherProto, float alpha)