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:
@@ -1,4 +1,4 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.GameObjects.EntitySystems.StationEvents;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
@@ -17,23 +17,27 @@ namespace Content.IntegrationTests.Tests.StationEvents
|
||||
|
||||
server.Assert(() =>
|
||||
{
|
||||
// Idle each event once
|
||||
// Idle each event
|
||||
var stationEventsSystem = EntitySystem.Get<StationEventSystem>();
|
||||
var dummyFrameTime = (float) IoCManager.Resolve<IGameTiming>().TickPeriod.TotalSeconds;
|
||||
|
||||
foreach (var stationEvent in stationEventsSystem.StationEvents)
|
||||
{
|
||||
stationEvent.Announce();
|
||||
stationEvent.Update(dummyFrameTime);
|
||||
stationEvent.Startup();
|
||||
stationEvent.Update(dummyFrameTime);
|
||||
stationEvent.Running = false;
|
||||
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();
|
||||
|
||||
foreach (var stationEvent in stationEventsSystem.StationEvents)
|
||||
{
|
||||
Assert.That(stationEvent.Occurrences == 0);
|
||||
Assert.That(stationEvent.Occurrences, Is.EqualTo(0));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ namespace Content.Server.Commands.StationEvents
|
||||
{
|
||||
public string Command => "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";
|
||||
|
||||
@@ -38,6 +40,9 @@ namespace Content.Server.Commands.StationEvents
|
||||
case "list":
|
||||
List(shell, player);
|
||||
break;
|
||||
case "running":
|
||||
Running(shell, player);
|
||||
break;
|
||||
// Didn't use a "toggle" so it's explicit
|
||||
case "pause":
|
||||
Pause(shell, player);
|
||||
@@ -74,6 +79,19 @@ namespace Content.Server.Commands.StationEvents
|
||||
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)
|
||||
{
|
||||
var resultText = "Random\n" + EntitySystem.Get<StationEventSystem>().GetEventNames();
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Interfaces.GameTicking;
|
||||
using Content.Server.StationEvents;
|
||||
using Content.Server.Interfaces.GameTicking;
|
||||
using Content.Shared;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Network.NetMessages;
|
||||
@@ -34,7 +35,7 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
public StationEvent CurrentEvent { get; private set; }
|
||||
public StationEvent? CurrentEvent { get; private set; }
|
||||
public IReadOnlyCollection<StationEvent> StationEvents => _stationEvents;
|
||||
|
||||
private readonly List<StationEvent> _stationEvents = new();
|
||||
@@ -105,7 +106,7 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
|
||||
|
||||
CurrentEvent?.Shutdown();
|
||||
CurrentEvent = stationEvent;
|
||||
stationEvent.Startup();
|
||||
stationEvent.Announce();
|
||||
return Loc.GetString("Running event ") + stationEvent.Name;
|
||||
}
|
||||
|
||||
@@ -114,13 +115,12 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Randomly run a valid event immediately, ignoring earlieststart
|
||||
/// Randomly run a valid event <b>immediately</b>, ignoring earlieststart
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string RunRandomEvent()
|
||||
{
|
||||
var availableEvents = AvailableEvents(true);
|
||||
var randomEvent = FindEvent(availableEvents);
|
||||
var randomEvent = PickRandomEvent();
|
||||
|
||||
if (randomEvent == null)
|
||||
{
|
||||
@@ -134,6 +134,15 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
|
||||
return Loc.GetString("Running ") + randomEvent.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Randomly picks a valid event.
|
||||
/// </summary>
|
||||
public StationEvent? PickRandomEvent()
|
||||
{
|
||||
var availableEvents = AvailableEvents(true);
|
||||
return FindEvent(availableEvents);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Admins can stop the currently running event (if applicable) and reset the timer
|
||||
/// </summary>
|
||||
@@ -246,7 +255,7 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
|
||||
else
|
||||
{
|
||||
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.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private StationEvent FindEvent(List<StationEvent> availableEvents)
|
||||
private StationEvent? FindEvent(List<StationEvent> availableEvents)
|
||||
{
|
||||
if (availableEvents.Count == 0)
|
||||
{
|
||||
@@ -347,13 +356,13 @@ namespace Content.Server.GameObjects.EntitySystems.StationEvents
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
CurrentEvent?.Shutdown();
|
||||
base.Shutdown();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (CurrentEvent != null && CurrentEvent.Running)
|
||||
if (CurrentEvent?.Running == true)
|
||||
{
|
||||
CurrentEvent.Shutdown();
|
||||
CurrentEvent = null;
|
||||
|
||||
30
Content.Server/StationEvents/FalseAlarm.cs
Normal file
30
Content.Server/StationEvents/FalseAlarm.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
||||
using JetBrains.Annotations;
|
||||
@@ -16,59 +17,54 @@ namespace Content.Server.StationEvents
|
||||
public sealed class PowerGridCheck : StationEvent
|
||||
{
|
||||
public override string Name => "PowerGridCheck";
|
||||
|
||||
public override StationEventWeight Weight => StationEventWeight.Normal;
|
||||
|
||||
public override int? MaxOccurrences => 2;
|
||||
|
||||
protected override string StartAnnouncement => Loc.GetString(
|
||||
public override float Weight => WeightNormal;
|
||||
public override int? MaxOccurrences => 3;
|
||||
public 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.");
|
||||
|
||||
protected override string EndAnnouncement => Loc.GetString(
|
||||
"Power has been restored to the station. We apologize for the inconvenience.");
|
||||
public override string? StartAudio => "/Audio/Announcements/power_off.ogg";
|
||||
|
||||
private float _elapsedTime;
|
||||
private int _failDuration;
|
||||
// If you need EndAudio it's down below. Not set here because we can't play it at the normal time without spamming sounds.
|
||||
|
||||
/// <summary>
|
||||
/// So we don't overlap the announcement with power-down sounds we'll delay it a few seconds.
|
||||
/// </summary>
|
||||
private bool _announced;
|
||||
protected override float StartAfter => 12.0f;
|
||||
|
||||
private CancellationTokenSource _announceCancelToken;
|
||||
private CancellationTokenSource? _announceCancelToken;
|
||||
|
||||
private readonly List<IEntity> _powered = new();
|
||||
|
||||
public override void Announce()
|
||||
{
|
||||
base.Announce();
|
||||
EndAfter = IoCManager.Resolve<IRobustRandom>().Next(60, 120);
|
||||
}
|
||||
|
||||
public override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
|
||||
_announced = false;
|
||||
_elapsedTime = 0.0f;
|
||||
_failDuration = IoCManager.Resolve<IRobustRandom>().Next(60, 120);
|
||||
var componentManager = IoCManager.Resolve<IComponentManager>();
|
||||
|
||||
foreach (PowerReceiverComponent component in componentManager.EntityQuery<PowerReceiverComponent>())
|
||||
foreach (var component in componentManager.EntityQuery<PowerReceiverComponent>())
|
||||
{
|
||||
component.PowerDisabled = true;
|
||||
_powered.Add(component.Owner);
|
||||
}
|
||||
|
||||
base.Startup();
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
foreach (var entity in _powered)
|
||||
{
|
||||
if (entity.Deleted) continue;
|
||||
|
||||
if (entity.TryGetComponent(out PowerReceiverComponent powerReceiverComponent))
|
||||
if (entity.TryGetComponent(out PowerReceiverComponent? powerReceiverComponent))
|
||||
{
|
||||
powerReceiverComponent.PowerDisabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Can't use the default EndAudio
|
||||
_announceCancelToken?.Cancel();
|
||||
_announceCancelToken = new CancellationTokenSource();
|
||||
Timer.Spawn(3000, () =>
|
||||
@@ -76,29 +72,8 @@ namespace Content.Server.StationEvents
|
||||
EntitySystem.Get<AudioSystem>().PlayGlobal("/Audio/Announcements/power_on.ogg");
|
||||
}, _announceCancelToken.Token);
|
||||
_powered.Clear();
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
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;
|
||||
base.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#nullable enable
|
||||
using JetBrains.Annotations;
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Server.GameObjects.Components.StationEvents;
|
||||
using Content.Server.Interfaces.GameTicking;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Shared.Utility;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Server.Interfaces.Timing;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
@@ -26,24 +25,14 @@ namespace Content.Server.StationEvents
|
||||
[Dependency] private IRobustRandom _robustRandom = default!;
|
||||
|
||||
public override string Name => "RadiationStorm";
|
||||
|
||||
protected override string StartAnnouncement => Loc.GetString(
|
||||
public override string StartAnnouncement => Loc.GetString(
|
||||
"High levels of radiation detected near the station. Evacuate any areas containing abnormal green energy fields.");
|
||||
|
||||
protected override string EndAnnouncement => Loc.GetString(
|
||||
"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>
|
||||
/// 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;
|
||||
// Event specific details
|
||||
private float _timeUntilPulse;
|
||||
private const float MinPulseDelay = 0.2f;
|
||||
private const float MaxPulseDelay = 0.8f;
|
||||
@@ -53,15 +42,15 @@ namespace Content.Server.StationEvents
|
||||
_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()
|
||||
{
|
||||
base.Startup();
|
||||
EntitySystem.Get<AudioSystem>().PlayGlobal("/Audio/Announcements/radiation.ogg");
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
ResetTimeUntilPulse();
|
||||
_timeElapsed = 0.0f;
|
||||
_pulsesRemaining = _robustRandom.Next(30, 100);
|
||||
|
||||
var componentManager = IoCManager.Resolve<IComponentManager>();
|
||||
|
||||
@@ -69,42 +58,26 @@ namespace Content.Server.StationEvents
|
||||
{
|
||||
overlay.AddOverlay(SharedOverlayID.RadiationPulseOverlay);
|
||||
}
|
||||
|
||||
base.Startup();
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
// IOC uninject?
|
||||
_entityManager = null;
|
||||
_robustRandom = null;
|
||||
|
||||
var componentManager = IoCManager.Resolve<IComponentManager>();
|
||||
|
||||
foreach (var overlay in componentManager.EntityQuery<ServerOverlayEffectsComponent>())
|
||||
{
|
||||
overlay.RemoveOverlay(SharedOverlayID.RadiationPulseOverlay);
|
||||
}
|
||||
base.Shutdown();
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
_timeElapsed += frameTime;
|
||||
base.Update(frameTime);
|
||||
|
||||
if (_pulsesRemaining == 0)
|
||||
{
|
||||
Running = false;
|
||||
}
|
||||
|
||||
if (!Running)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_timeElapsed < StartupTime)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!Started || !Running) return;
|
||||
|
||||
_timeUntilPulse -= frameTime;
|
||||
|
||||
@@ -129,7 +102,6 @@ namespace Content.Server.StationEvents
|
||||
var pulse = _entityManager.SpawnEntity("RadiationPulse", coordinates);
|
||||
pulse.GetComponent<RadiationPulseComponent>().DoPulse();
|
||||
ResetTimeUntilPulse();
|
||||
_pulsesRemaining -= 1;
|
||||
}
|
||||
|
||||
private bool TryFindRandomGrid(IMapGrid mapGrid, out EntityCoordinates coordinates)
|
||||
|
||||
@@ -1,76 +1,135 @@
|
||||
#nullable enable
|
||||
using Content.Server.Interfaces.Chat;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.StationEvents
|
||||
{
|
||||
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>
|
||||
/// If the event has started and is currently running
|
||||
/// If the event has started and is currently running.
|
||||
/// </summary>
|
||||
public bool Running { get; protected set; }
|
||||
|
||||
public bool Running { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Human-readable name for the event
|
||||
/// Human-readable name for the event.
|
||||
/// </summary>
|
||||
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>
|
||||
/// 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>
|
||||
protected virtual string StartAnnouncement { get; } = null;
|
||||
public virtual string? StartAnnouncement { get; set; } = null;
|
||||
|
||||
/// <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>
|
||||
protected virtual string EndAnnouncement { get; } = null;
|
||||
protected virtual string? EndAnnouncement { get; } = null;
|
||||
|
||||
/// <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>
|
||||
/// <returns></returns>
|
||||
public virtual int EarliestStart { get; } = 5;
|
||||
|
||||
/// <summary>
|
||||
/// How many players need to be present on station for the event to run
|
||||
/// When in the lifetime to call Start().
|
||||
/// </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;
|
||||
|
||||
/// <summary>
|
||||
/// How many times this event has run this round
|
||||
/// How many times this event has run this round
|
||||
/// </summary>
|
||||
public int Occurrences { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// How many times this even can occur in a single round
|
||||
/// How many times this even can occur in a single round
|
||||
/// </summary>
|
||||
public virtual int? MaxOccurrences { get; } = null;
|
||||
|
||||
/// <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>
|
||||
public virtual void Startup()
|
||||
{
|
||||
Running = true;
|
||||
Started = true;
|
||||
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)
|
||||
{
|
||||
var chatManager = IoCManager.Resolve<IChatManager>();
|
||||
chatManager.DispatchStationAnnouncement(StartAnnouncement);
|
||||
}
|
||||
|
||||
if (StartAudio != null)
|
||||
{
|
||||
EntitySystem.Get<AudioSystem>().PlayGlobal(StartAudio, AudioParams.Default.WithVolume(-10f));
|
||||
}
|
||||
|
||||
Announced = true;
|
||||
Running = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called every tick when this event is active
|
||||
/// </summary>
|
||||
/// <param name="frameTime"></param>
|
||||
public abstract void Update(float frameTime);
|
||||
|
||||
/// <summary>
|
||||
/// Called once when the station event ends
|
||||
/// Called once when the station event ends for any reason.
|
||||
/// </summary>
|
||||
public virtual void Shutdown()
|
||||
{
|
||||
@@ -79,15 +138,34 @@ namespace Content.Server.StationEvents
|
||||
var chatManager = IoCManager.Resolve<IChatManager>();
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user