CatStation/Content.Shared/Trigger/Systems/WeatherTriggerSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

29 lines
1.1 KiB
C#

using Content.Shared.Trigger.Components.Effects;
using Content.Shared.Weather;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Content.Shared.Trigger.Systems;
public sealed partial class WeatherTriggerSystem : XOnTriggerSystem<WeatherOnTriggerComponent>
{
[Dependency] private IGameTiming _timing = default!;
[Dependency] private IPrototypeManager _prototypeManager = default!;
[Dependency] private SharedWeatherSystem _weather = default!;
protected override void OnTrigger(Entity<WeatherOnTriggerComponent> ent, EntityUid target, ref TriggerEvent args)
{
var xform = Transform(target);
if (ent.Comp.Weather == null) //Clear weather if nothing is set
{
_weather.TrySetWeather(xform.MapID, null, out _);
return;
}
var endTime = ent.Comp.Duration == null ? null : ent.Comp.Duration + _timing.CurTime;
if (_prototypeManager.Resolve(ent.Comp.Weather, out var weatherPrototype))
_weather.TrySetWeather(xform.MapID, weatherPrototype, out _, endTime);
}
}