CatStation/Content.Shared/Trigger/Systems/WeatherTriggerSystem.cs
Whatstone a8453723d8
Cleanup: ProtoMan Part 1 - remove Shared EntitySystem IPrototypeManager instances (#44386)
* Remove Shared System IPrototypeManager instances

* Remove RecipeManager IPrototypeManager instance

* Fix ItemSystem IPrototypeManager refs, use TryComp

* SharedItemSystem changes, EntWhitelist CompName

* HasComponent->HasComp
2026-06-29 10:18:44 +00:00

27 lines
971 B
C#

using Content.Shared.Trigger.Components.Effects;
using Content.Shared.Weather;
using Robust.Shared.Timing;
namespace Content.Shared.Trigger.Systems;
public sealed partial class WeatherTriggerSystem : XOnTriggerSystem<WeatherOnTriggerComponent>
{
[Dependency] private IGameTiming _timing = 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 (ProtoMan.Resolve(ent.Comp.Weather, out var weatherPrototype))
_weather.TrySetWeather(xform.MapID, weatherPrototype, out _, endTime);
}
}