clean up weather systems (#28792)

* clean up weather systems

* Update WeatherComponent.cs

* Update SharedWeatherSystem.cs

* some fix

* Update SharedWeatherSystem.cs

* Update WeatherComponent.cs

* Update WeatherComponent.cs

* revert autoPause

* Update SharedWeatherSystem.cs
This commit is contained in:
Ed
2024-06-18 13:27:34 +03:00
committed by GitHub
parent 82c4db67bc
commit a1e66cfbb4
5 changed files with 28 additions and 37 deletions

View File

@@ -1,8 +1,7 @@
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
namespace Content.Shared.Weather;
@@ -12,8 +11,8 @@ public sealed partial class WeatherComponent : Component
/// <summary>
/// Currently running weathers
/// </summary>
[ViewVariables, DataField("weather", customTypeSerializer:typeof(PrototypeIdDictionarySerializer<WeatherData, WeatherPrototype>))]
public Dictionary<string, WeatherData> Weather = new();
[DataField]
public Dictionary<ProtoId<WeatherPrototype>, WeatherData> Weather = new();
public static readonly TimeSpan StartupTime = TimeSpan.FromSeconds(15);
public static readonly TimeSpan ShutdownTime = TimeSpan.FromSeconds(15);
@@ -29,19 +28,19 @@ public sealed partial class WeatherData
/// <summary>
/// When the weather started if relevant.
/// </summary>
[ViewVariables, DataField("startTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] //TODO: Remove Custom serializer
public TimeSpan StartTime = TimeSpan.Zero;
/// <summary>
/// When the applied weather will end.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("endTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] //TODO: Remove Custom serializer
public TimeSpan? EndTime;
[ViewVariables]
public TimeSpan Duration => EndTime == null ? TimeSpan.MaxValue : EndTime.Value - StartTime;
[DataField("state")]
[DataField]
public WeatherState State = WeatherState.Invalid;
}