Files
crystall-punk-14/Content.Shared/Weather/WeatherComponent.cs

55 lines
1.7 KiB
C#
Raw Normal View History

using Robust.Shared.Audio;
using Robust.Shared.GameStates;
2023-03-07 12:28:50 +11:00
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
namespace Content.Shared.Weather;
[RegisterComponent, NetworkedComponent]
public sealed partial class WeatherComponent : Component
{
/// <summary>
2023-03-07 12:28:50 +11:00
/// Currently running weathers
/// </summary>
2023-03-07 12:28:50 +11:00
[ViewVariables, DataField("weather", customTypeSerializer:typeof(PrototypeIdDictionarySerializer<WeatherData, WeatherPrototype>))]
public Dictionary<string, WeatherData> Weather = new();
2023-03-07 12:28:50 +11:00
public static readonly TimeSpan StartupTime = TimeSpan.FromSeconds(15);
public static readonly TimeSpan ShutdownTime = TimeSpan.FromSeconds(15);
}
[DataDefinition, Serializable, NetSerializable]
public sealed partial class WeatherData
2023-03-07 12:28:50 +11:00
{
// Client audio stream.
[NonSerialized]
public EntityUid? Stream;
/// <summary>
2023-03-07 12:28:50 +11:00
/// When the weather started if relevant.
/// </summary>
2023-03-07 12:28:50 +11:00
[ViewVariables, DataField("startTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan StartTime = TimeSpan.Zero;
/// <summary>
/// When the applied weather will end.
/// </summary>
2023-03-07 12:28:50 +11:00
[ViewVariables(VVAccess.ReadWrite), DataField("endTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan? EndTime;
[ViewVariables]
2023-03-07 12:28:50 +11:00
public TimeSpan Duration => EndTime == null ? TimeSpan.MaxValue : EndTime.Value - StartTime;
2023-03-07 12:28:50 +11:00
[DataField("state")]
public WeatherState State = WeatherState.Invalid;
}
public enum WeatherState : byte
{
Invalid = 0,
Starting,
Running,
Ending,
}