Weather tweaks (#14271)
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
|
||||
|
||||
namespace Content.Shared.Weather;
|
||||
|
||||
@@ -7,31 +10,45 @@ namespace Content.Shared.Weather;
|
||||
public sealed class WeatherComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Currently running weather.
|
||||
/// Currently running weathers
|
||||
/// </summary>
|
||||
[ViewVariables, DataField("weather")]
|
||||
public string? Weather;
|
||||
[ViewVariables, DataField("weather", customTypeSerializer:typeof(PrototypeIdDictionarySerializer<WeatherData, WeatherPrototype>))]
|
||||
public Dictionary<string, WeatherData> Weather = new();
|
||||
|
||||
// now
|
||||
public static readonly TimeSpan StartupTime = TimeSpan.FromSeconds(15);
|
||||
public static readonly TimeSpan ShutdownTime = TimeSpan.FromSeconds(15);
|
||||
}
|
||||
|
||||
[DataDefinition, Serializable, NetSerializable]
|
||||
public sealed class WeatherData
|
||||
{
|
||||
// Client audio stream.
|
||||
[NonSerialized]
|
||||
public IPlayingAudioStream? Stream;
|
||||
|
||||
/// <summary>
|
||||
/// When the weather started.
|
||||
/// When the weather started if relevant.
|
||||
/// </summary>
|
||||
[ViewVariables, DataField("startTime")]
|
||||
[ViewVariables, DataField("startTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
|
||||
public TimeSpan StartTime = TimeSpan.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// When the applied weather will end.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("endTime")]
|
||||
public TimeSpan EndTime = TimeSpan.Zero;
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("endTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
|
||||
public TimeSpan? EndTime;
|
||||
|
||||
[ViewVariables]
|
||||
public TimeSpan Duration => EndTime - StartTime;
|
||||
public TimeSpan Duration => EndTime == null ? TimeSpan.MaxValue : EndTime.Value - StartTime;
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("state")]
|
||||
public WeatherState State = WeatherState.Invalid;
|
||||
|
||||
[ViewVariables, NonSerialized]
|
||||
public float LastAlpha;
|
||||
|
||||
[ViewVariables, NonSerialized]
|
||||
public float LastOcclusion;
|
||||
}
|
||||
|
||||
public enum WeatherState : byte
|
||||
|
||||
Reference in New Issue
Block a user