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

54 lines
1.5 KiB
C#
Raw Permalink Normal View History

using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
2023-03-07 12:28:50 +11:00
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
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>
[DataField]
public Dictionary<ProtoId<WeatherPrototype>, 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>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] //TODO: Remove Custom serializer
public TimeSpan StartTime = TimeSpan.Zero;
/// <summary>
/// When the applied weather will end.
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] //TODO: Remove Custom serializer
2023-03-07 12:28:50 +11:00
public TimeSpan? EndTime;
[ViewVariables]
2023-03-07 12:28:50 +11:00
public TimeSpan Duration => EndTime == null ? TimeSpan.MaxValue : EndTime.Value - StartTime;
[DataField]
public WeatherState State = WeatherState.Invalid;
}
public enum WeatherState : byte
{
Invalid = 0,
Starting,
Running,
Ending,
}