Adds false alarm and updates events code (#2577)

* oops accedentaly ports how ss13 deals with event randomness. Also renames FakeEvent to FalseAlarm!

* thing

* greytide but it's implemented badly

* fixes&changies, also greytide!

* rng actualy exists now

* resync

* Naming Schemes

* Startup not init

* areas are dead

* very cool vsudio

* this does not exist, wtf

* Cleanup

* Nullables, fixables, and timings

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
Letter N
2021-01-18 18:14:53 +08:00
committed by GitHub
parent 51ad4f6c96
commit c30dc030c5
7 changed files with 226 additions and 140 deletions

View File

@@ -1,4 +1,4 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Server.GameObjects.EntitySystems.StationEvents; using Content.Server.GameObjects.EntitySystems.StationEvents;
using NUnit.Framework; using NUnit.Framework;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
@@ -17,23 +17,27 @@ namespace Content.IntegrationTests.Tests.StationEvents
server.Assert(() => server.Assert(() =>
{ {
// Idle each event once // Idle each event
var stationEventsSystem = EntitySystem.Get<StationEventSystem>(); var stationEventsSystem = EntitySystem.Get<StationEventSystem>();
var dummyFrameTime = (float) IoCManager.Resolve<IGameTiming>().TickPeriod.TotalSeconds; var dummyFrameTime = (float) IoCManager.Resolve<IGameTiming>().TickPeriod.TotalSeconds;
foreach (var stationEvent in stationEventsSystem.StationEvents) foreach (var stationEvent in stationEventsSystem.StationEvents)
{ {
stationEvent.Announce();
stationEvent.Update(dummyFrameTime);
stationEvent.Startup(); stationEvent.Startup();
stationEvent.Update(dummyFrameTime); stationEvent.Update(dummyFrameTime);
stationEvent.Running = false;
stationEvent.Shutdown(); stationEvent.Shutdown();
Assert.That(stationEvent.Occurrences == 1); // Due to timings some events might startup twice when in reality they wouldn't.
Assert.That(stationEvent.Occurrences > 0);
} }
stationEventsSystem.Reset(); stationEventsSystem.Reset();
foreach (var stationEvent in stationEventsSystem.StationEvents) foreach (var stationEvent in stationEventsSystem.StationEvents)
{ {
Assert.That(stationEvent.Occurrences == 0); Assert.That(stationEvent.Occurrences, Is.EqualTo(0));
} }
}); });

View File

@@ -14,7 +14,9 @@ namespace Content.Server.Commands.StationEvents
{ {
public string Command => "events"; public string Command => "events";
public string Description => "Provides admin control to station events"; public string Description => "Provides admin control to station events";
public string Help => $"events <list/pause/resume/stop/run <eventName/random>>\n{ListHelp}\n{PauseHelp}\n{ResumeHelp}\n{RunHelp}"; public string Help => $"events <running/list/pause/resume/stop/run <eventName/random>>\n{RunningHelp}\n{ListHelp}\n{PauseHelp}\n{ResumeHelp}\n{RunHelp}";
private const string RunningHelp = "running: return the current running event";
private const string ListHelp = "list: return all event names that can be run"; private const string ListHelp = "list: return all event names that can be run";
@@ -38,6 +40,9 @@ namespace Content.Server.Commands.StationEvents
case "list": case "list":
List(shell, player); List(shell, player);
break; break;
case "running":
Running(shell, player);
break;
// Didn't use a "toggle" so it's explicit // Didn't use a "toggle" so it's explicit
case "pause": case "pause":
Pause(shell, player); Pause(shell, player);
@@ -74,6 +79,19 @@ namespace Content.Server.Commands.StationEvents
shell.SendText(player, resultText); shell.SendText(player, resultText);
} }
private void Running(IConsoleShell shell, IPlayerSession? player)
{
var eventName = EntitySystem.Get<StationEventSystem>().CurrentEvent?.Name;
if (!string.IsNullOrEmpty(eventName))
{
shell.SendText(player, eventName);
}
else
{
shell.SendText(player, Loc.GetString("No station event running"));
}
}
private void List(IConsoleShell shell, IPlayerSession? player) private void List(IConsoleShell shell, IPlayerSession? player)
{ {
var resultText = "Random\n" + EntitySystem.Get<StationEventSystem>().GetEventNames(); var resultText = "Random\n" + EntitySystem.Get<StationEventSystem>().GetEventNames();

View File

@@ -1,10 +1,11 @@
#nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking;
using Content.Server.StationEvents; using Content.Server.StationEvents;
using Content.Server.Interfaces.GameTicking;
using Content.Shared; using Content.Shared;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Content.Shared.Network.NetMessages; using Content.Shared.Network.NetMessages;
@@ -34,7 +35,7 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
public StationEvent CurrentEvent { get; private set; } public StationEvent? CurrentEvent { get; private set; }
public IReadOnlyCollection<StationEvent> StationEvents => _stationEvents; public IReadOnlyCollection<StationEvent> StationEvents => _stationEvents;
private readonly List<StationEvent> _stationEvents = new(); private readonly List<StationEvent> _stationEvents = new();
@@ -105,7 +106,7 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
CurrentEvent?.Shutdown(); CurrentEvent?.Shutdown();
CurrentEvent = stationEvent; CurrentEvent = stationEvent;
stationEvent.Startup(); stationEvent.Announce();
return Loc.GetString("Running event ") + stationEvent.Name; return Loc.GetString("Running event ") + stationEvent.Name;
} }
@@ -114,13 +115,12 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
} }
/// <summary> /// <summary>
/// Randomly run a valid event immediately, ignoring earlieststart /// Randomly run a valid event <b>immediately</b>, ignoring earlieststart
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public string RunRandomEvent() public string RunRandomEvent()
{ {
var availableEvents = AvailableEvents(true); var randomEvent = PickRandomEvent();
var randomEvent = FindEvent(availableEvents);
if (randomEvent == null) if (randomEvent == null)
{ {
@@ -134,6 +134,15 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
return Loc.GetString("Running ") + randomEvent.Name; return Loc.GetString("Running ") + randomEvent.Name;
} }
/// <summary>
/// Randomly picks a valid event.
/// </summary>
public StationEvent? PickRandomEvent()
{
var availableEvents = AvailableEvents(true);
return FindEvent(availableEvents);
}
/// <summary> /// <summary>
/// Admins can stop the currently running event (if applicable) and reset the timer /// Admins can stop the currently running event (if applicable) and reset the timer
/// </summary> /// </summary>
@@ -246,7 +255,7 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
else else
{ {
CurrentEvent = stationEvent; CurrentEvent = stationEvent;
CurrentEvent.Startup(); CurrentEvent.Announce();
} }
} }
@@ -263,7 +272,7 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
/// Pick a random event from the available events at this time, also considering their weightings. /// Pick a random event from the available events at this time, also considering their weightings.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private StationEvent FindEvent(List<StationEvent> availableEvents) private StationEvent? FindEvent(List<StationEvent> availableEvents)
{ {
if (availableEvents.Count == 0) if (availableEvents.Count == 0)
{ {
@@ -347,13 +356,13 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
public override void Shutdown() public override void Shutdown()
{ {
base.Shutdown();
CurrentEvent?.Shutdown(); CurrentEvent?.Shutdown();
base.Shutdown();
} }
public void Reset() public void Reset()
{ {
if (CurrentEvent != null && CurrentEvent.Running) if (CurrentEvent?.Running == true)
{ {
CurrentEvent.Shutdown(); CurrentEvent.Shutdown();
CurrentEvent = null; CurrentEvent = null;

View File

@@ -0,0 +1,30 @@
#nullable enable
using JetBrains.Annotations;
using Content.Server.GameObjects.EntitySystems.StationEvents;
using Robust.Shared.GameObjects.Systems;
namespace Content.Server.StationEvents
{
[UsedImplicitly]
public sealed class FalseAlarm : StationEvent
{
public override string Name => "FalseAlarm";
public override float Weight => WeightHigh;
protected override float EndAfter => 1.0f;
public override int? MaxOccurrences => 5;
public override void Announce()
{
var stationEventSystem = EntitySystem.Get<StationEventSystem>();
var randomEvent = stationEventSystem.PickRandomEvent();
if (randomEvent != null)
{
StartAnnouncement = randomEvent.StartAnnouncement;
StartAudio = randomEvent.StartAudio;
}
base.Announce();
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; #nullable enable
using System.Collections.Generic;
using System.Threading; using System.Threading;
using Content.Server.GameObjects.Components.Power.ApcNetComponents; using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using JetBrains.Annotations; using JetBrains.Annotations;
@@ -16,59 +17,54 @@ namespace Content.Server.StationEvents
public sealed class PowerGridCheck : StationEvent public sealed class PowerGridCheck : StationEvent
{ {
public override string Name => "PowerGridCheck"; public override string Name => "PowerGridCheck";
public override float Weight => WeightNormal;
public override StationEventWeight Weight => StationEventWeight.Normal; public override int? MaxOccurrences => 3;
public override string StartAnnouncement => Loc.GetString(
public override int? MaxOccurrences => 2;
protected override string StartAnnouncement => Loc.GetString(
"Abnormal activity detected in the station's powernet. As a precautionary measure, the station's power will be shut off for an indeterminate duration."); "Abnormal activity detected in the station's powernet. As a precautionary measure, the station's power will be shut off for an indeterminate duration.");
protected override string EndAnnouncement => Loc.GetString( protected override string EndAnnouncement => Loc.GetString(
"Power has been restored to the station. We apologize for the inconvenience."); "Power has been restored to the station. We apologize for the inconvenience.");
public override string? StartAudio => "/Audio/Announcements/power_off.ogg";
private float _elapsedTime; // If you need EndAudio it's down below. Not set here because we can't play it at the normal time without spamming sounds.
private int _failDuration;
/// <summary> protected override float StartAfter => 12.0f;
/// So we don't overlap the announcement with power-down sounds we'll delay it a few seconds.
/// </summary>
private bool _announced;
private CancellationTokenSource _announceCancelToken; private CancellationTokenSource? _announceCancelToken;
private readonly List<IEntity> _powered = new(); private readonly List<IEntity> _powered = new();
public override void Announce()
{
base.Announce();
EndAfter = IoCManager.Resolve<IRobustRandom>().Next(60, 120);
}
public override void Startup() public override void Startup()
{ {
base.Startup();
_announced = false;
_elapsedTime = 0.0f;
_failDuration = IoCManager.Resolve<IRobustRandom>().Next(60, 120);
var componentManager = IoCManager.Resolve<IComponentManager>(); var componentManager = IoCManager.Resolve<IComponentManager>();
foreach (PowerReceiverComponent component in componentManager.EntityQuery<PowerReceiverComponent>()) foreach (var component in componentManager.EntityQuery<PowerReceiverComponent>())
{ {
component.PowerDisabled = true; component.PowerDisabled = true;
_powered.Add(component.Owner); _powered.Add(component.Owner);
} }
base.Startup();
} }
public override void Shutdown() public override void Shutdown()
{ {
base.Shutdown();
foreach (var entity in _powered) foreach (var entity in _powered)
{ {
if (entity.Deleted) continue; if (entity.Deleted) continue;
if (entity.TryGetComponent(out PowerReceiverComponent powerReceiverComponent)) if (entity.TryGetComponent(out PowerReceiverComponent? powerReceiverComponent))
{ {
powerReceiverComponent.PowerDisabled = false; powerReceiverComponent.PowerDisabled = false;
} }
} }
// Can't use the default EndAudio
_announceCancelToken?.Cancel(); _announceCancelToken?.Cancel();
_announceCancelToken = new CancellationTokenSource(); _announceCancelToken = new CancellationTokenSource();
Timer.Spawn(3000, () => Timer.Spawn(3000, () =>
@@ -76,29 +72,8 @@ namespace Content.Server.StationEvents
EntitySystem.Get<AudioSystem>().PlayGlobal("/Audio/Announcements/power_on.ogg"); EntitySystem.Get<AudioSystem>().PlayGlobal("/Audio/Announcements/power_on.ogg");
}, _announceCancelToken.Token); }, _announceCancelToken.Token);
_powered.Clear(); _powered.Clear();
}
public override void Update(float frameTime) base.Shutdown();
{
if (!Running)
{
return;
}
if (!_announced && _elapsedTime > 3.0f)
{
EntitySystem.Get<AudioSystem>().PlayGlobal("/Audio/Announcements/power_off.ogg");
_announced = true;
}
_elapsedTime += frameTime;
if (_elapsedTime < _failDuration)
{
return;
}
Running = false;
} }
} }
} }

View File

@@ -1,12 +1,11 @@
#nullable enable
using JetBrains.Annotations;
using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.Components.StationEvents; using Content.Server.GameObjects.Components.StationEvents;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Shared.GameObjects.Components.Mobs; using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.Utility; using Content.Shared.Utility;
using JetBrains.Annotations;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.Timing; using Robust.Server.Interfaces.Timing;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
@@ -26,24 +25,14 @@ namespace Content.Server.StationEvents
[Dependency] private IRobustRandom _robustRandom = default!; [Dependency] private IRobustRandom _robustRandom = default!;
public override string Name => "RadiationStorm"; public override string Name => "RadiationStorm";
public override string StartAnnouncement => Loc.GetString(
protected override string StartAnnouncement => Loc.GetString(
"High levels of radiation detected near the station. Evacuate any areas containing abnormal green energy fields."); "High levels of radiation detected near the station. Evacuate any areas containing abnormal green energy fields.");
protected override string EndAnnouncement => Loc.GetString( protected override string EndAnnouncement => Loc.GetString(
"The radiation threat has passed. Please return to your workplaces."); "The radiation threat has passed. Please return to your workplaces.");
public override string StartAudio => "/Audio/Announcements/radiation.ogg";
protected override float StartAfter => 10.0f;
/// <summary> // Event specific details
/// How long until the radiation storm starts
/// </summary>
private const float StartupTime = 5;
/// <summary>
/// How long the radiation storm has been running for
/// </summary>
private float _timeElapsed;
private int _pulsesRemaining;
private float _timeUntilPulse; private float _timeUntilPulse;
private const float MinPulseDelay = 0.2f; private const float MinPulseDelay = 0.2f;
private const float MaxPulseDelay = 0.8f; private const float MaxPulseDelay = 0.8f;
@@ -53,15 +42,15 @@ namespace Content.Server.StationEvents
_timeUntilPulse = _robustRandom.NextFloat() * (MaxPulseDelay - MinPulseDelay) + MinPulseDelay; _timeUntilPulse = _robustRandom.NextFloat() * (MaxPulseDelay - MinPulseDelay) + MinPulseDelay;
} }
public override void Announce()
{
base.Announce();
EndAfter = _robustRandom.Next(30, 80) + StartAfter; // We want to be forgiving about the radstorm.
}
public override void Startup() public override void Startup()
{ {
base.Startup();
EntitySystem.Get<AudioSystem>().PlayGlobal("/Audio/Announcements/radiation.ogg");
IoCManager.InjectDependencies(this);
ResetTimeUntilPulse(); ResetTimeUntilPulse();
_timeElapsed = 0.0f;
_pulsesRemaining = _robustRandom.Next(30, 100);
var componentManager = IoCManager.Resolve<IComponentManager>(); var componentManager = IoCManager.Resolve<IComponentManager>();
@@ -69,42 +58,26 @@ namespace Content.Server.StationEvents
{ {
overlay.AddOverlay(SharedOverlayID.RadiationPulseOverlay); overlay.AddOverlay(SharedOverlayID.RadiationPulseOverlay);
} }
base.Startup();
} }
public override void Shutdown() public override void Shutdown()
{ {
base.Shutdown();
// IOC uninject?
_entityManager = null;
_robustRandom = null;
var componentManager = IoCManager.Resolve<IComponentManager>(); var componentManager = IoCManager.Resolve<IComponentManager>();
foreach (var overlay in componentManager.EntityQuery<ServerOverlayEffectsComponent>()) foreach (var overlay in componentManager.EntityQuery<ServerOverlayEffectsComponent>())
{ {
overlay.RemoveOverlay(SharedOverlayID.RadiationPulseOverlay); overlay.RemoveOverlay(SharedOverlayID.RadiationPulseOverlay);
} }
base.Shutdown();
} }
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
_timeElapsed += frameTime; base.Update(frameTime);
if (_pulsesRemaining == 0) if (!Started || !Running) return;
{
Running = false;
}
if (!Running)
{
return;
}
if (_timeElapsed < StartupTime)
{
return;
}
_timeUntilPulse -= frameTime; _timeUntilPulse -= frameTime;
@@ -129,7 +102,6 @@ namespace Content.Server.StationEvents
var pulse = _entityManager.SpawnEntity("RadiationPulse", coordinates); var pulse = _entityManager.SpawnEntity("RadiationPulse", coordinates);
pulse.GetComponent<RadiationPulseComponent>().DoPulse(); pulse.GetComponent<RadiationPulseComponent>().DoPulse();
ResetTimeUntilPulse(); ResetTimeUntilPulse();
_pulsesRemaining -= 1;
} }
private bool TryFindRandomGrid(IMapGrid mapGrid, out EntityCoordinates coordinates) private bool TryFindRandomGrid(IMapGrid mapGrid, out EntityCoordinates coordinates)

View File

@@ -1,76 +1,135 @@
#nullable enable
using Content.Server.Interfaces.Chat; using Content.Server.Interfaces.Chat;
using Robust.Shared.GameObjects.Systems;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.Audio;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.StationEvents namespace Content.Server.StationEvents
{ {
public abstract class StationEvent public abstract class StationEvent
{ {
public const float WeightVeryLow = 0.0f;
public const float WeightLow = 5.0f;
public const float WeightNormal = 10.0f;
public const float WeightHigh = 15.0f;
public const float WeightVeryHigh = 20.0f;
/// <summary> /// <summary>
/// If the event has started and is currently running /// If the event has started and is currently running.
/// </summary> /// </summary>
public bool Running { get; protected set; } public bool Running { get; set; }
/// <summary> /// <summary>
/// Human-readable name for the event /// Human-readable name for the event.
/// </summary> /// </summary>
public abstract string Name { get; } public abstract string Name { get; }
public virtual StationEventWeight Weight { get; } = StationEventWeight.Normal; /// <summary>
/// The weight this event has in the random-selection process.
/// </summary>
public virtual float Weight => WeightNormal;
/// <summary> /// <summary>
/// What should be said in chat when the event starts (if anything). /// What should be said in chat when the event starts (if anything).
/// </summary> /// </summary>
protected virtual string StartAnnouncement { get; } = null; public virtual string? StartAnnouncement { get; set; } = null;
/// <summary> /// <summary>
/// What should be said in chat when the event end (if anything). /// What should be said in chat when the event ends (if anything).
/// </summary> /// </summary>
protected virtual string EndAnnouncement { get; } = null; protected virtual string? EndAnnouncement { get; } = null;
/// <summary> /// <summary>
/// In minutes, when is the first time this event can start /// Starting audio of the event.
/// </summary>
public virtual string? StartAudio { get; set; } = null;
/// <summary>
/// Ending audio of the event.
/// </summary>
public virtual string? EndAudio { get; } = null;
/// <summary>
/// In minutes, when is the first round time this event can start
/// </summary> /// </summary>
/// <returns></returns>
public virtual int EarliestStart { get; } = 5; public virtual int EarliestStart { get; } = 5;
/// <summary> /// <summary>
/// How many players need to be present on station for the event to run /// When in the lifetime to call Start().
/// </summary> /// </summary>
/// To avoid running deadly events with low-pop protected virtual float StartAfter { get; } = 0.0f;
/// <summary>
/// When in the lifetime the event should end.
/// </summary>
protected virtual float EndAfter { get; set; } = 0.0f;
/// <summary>
/// How long has the event existed. Do not change this.
/// </summary>
private float Elapsed { get; set; } = 0.0f;
/// <summary>
/// How many players need to be present on station for the event to run
/// </summary>
/// <remarks>
/// To avoid running deadly events with low-pop
/// </remarks>
public virtual int MinimumPlayers { get; } = 0; public virtual int MinimumPlayers { get; } = 0;
/// <summary> /// <summary>
/// How many times this event has run this round /// How many times this event has run this round
/// </summary> /// </summary>
public int Occurrences { get; set; } = 0; public int Occurrences { get; set; } = 0;
/// <summary> /// <summary>
/// How many times this even can occur in a single round /// How many times this even can occur in a single round
/// </summary> /// </summary>
public virtual int? MaxOccurrences { get; } = null; public virtual int? MaxOccurrences { get; } = null;
/// <summary> /// <summary>
/// Called once when the station event starts /// Has the startup time elapsed?
/// </summary>
protected bool Started { get; set; } = false;
/// <summary>
/// Has this event commenced (announcement may or may not be used)?
/// </summary>
private bool Announced { get; set; } = false;
/// <summary>
/// Called once to setup the event after StartAfter has elapsed.
/// </summary> /// </summary>
public virtual void Startup() public virtual void Startup()
{ {
Running = true; Started = true;
Occurrences += 1; Occurrences += 1;
}
/// <summary>
/// Called once as soon as an event is active.
/// Can also be used for some initial setup.
/// </summary>
public virtual void Announce()
{
if (StartAnnouncement != null) if (StartAnnouncement != null)
{ {
var chatManager = IoCManager.Resolve<IChatManager>(); var chatManager = IoCManager.Resolve<IChatManager>();
chatManager.DispatchStationAnnouncement(StartAnnouncement); chatManager.DispatchStationAnnouncement(StartAnnouncement);
} }
if (StartAudio != null)
{
EntitySystem.Get<AudioSystem>().PlayGlobal(StartAudio, AudioParams.Default.WithVolume(-10f));
}
Announced = true;
Running = true;
} }
/// <summary> /// <summary>
/// Called every tick when this event is active /// Called once when the station event ends for any reason.
/// </summary>
/// <param name="frameTime"></param>
public abstract void Update(float frameTime);
/// <summary>
/// Called once when the station event ends
/// </summary> /// </summary>
public virtual void Shutdown() public virtual void Shutdown()
{ {
@@ -79,15 +138,34 @@ namespace Content.Server.StationEvents
var chatManager = IoCManager.Resolve<IChatManager>(); var chatManager = IoCManager.Resolve<IChatManager>();
chatManager.DispatchStationAnnouncement(EndAnnouncement); chatManager.DispatchStationAnnouncement(EndAnnouncement);
} }
if (EndAudio != null)
{
EntitySystem.Get<AudioSystem>().PlayGlobal(EndAudio, AudioParams.Default.WithVolume(-10f));
}
Started = false;
Announced = false;
Elapsed = 0;
}
/// <summary>
/// Called every tick when this event is running.
/// </summary>
/// <param name="frameTime"></param>
public virtual void Update(float frameTime)
{
Elapsed += frameTime;
if (!Started && Elapsed >= StartAfter)
{
Startup();
}
if (EndAfter <= Elapsed)
{
Running = false;
}
} }
} }
}
public enum StationEventWeight
{
VeryLow = 0,
Low = 5,
Normal = 10,
High = 15,
VeryHigh = 20,
}
}