* Station event system Adds 2 basic events: (Power) GridCheck and RadiationStorm (based on the goonstation version). The system itself to choose events is based on tgstation's implementation. This also adds the event command that can be run to force specific events. There's still some other TODO items for these to be complete, to my knowledge: 1. There's no worldspace DrawCircle method (though the radstorm could look a lot nicer with a shader). 2. The PlayGlobal power_off / power_on audio seems to cut out halfway-through 3. (I think this is a known issue) lights still emit light until you get closer in a gridcheck so PVS range might need bumping. * Invariants for event names * Fix random event shutdown * Mix stereo announcements to mono * Address feedback * Remove redundant client system and use the overlay component instead * Drop the server prefix * Fix radiation overlay enum * use entityquery instead * zum's feedback * Use EntityQuery Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
94 lines
2.8 KiB
C#
94 lines
2.8 KiB
C#
using Content.Server.Interfaces.Chat;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
|
|
namespace Content.Server.StationEvents
|
|
{
|
|
public abstract class StationEvent
|
|
{
|
|
/// <summary>
|
|
/// If the event has started and is currently running
|
|
/// </summary>
|
|
public bool Running { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// Human-readable name for the event
|
|
/// </summary>
|
|
public abstract string Name { get; }
|
|
|
|
public virtual StationEventWeight Weight { get; } = StationEventWeight.Normal;
|
|
|
|
/// <summary>
|
|
/// What should be said in chat when the event starts (if anything).
|
|
/// </summary>
|
|
protected virtual string StartAnnouncement { get; } = null;
|
|
|
|
/// <summary>
|
|
/// What should be said in chat when the event end (if anything).
|
|
/// </summary>
|
|
protected virtual string EndAnnouncement { get; } = null;
|
|
|
|
/// <summary>
|
|
/// In minutes, when is the first time this event can start
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public virtual int EarliestStart { get; } = 20;
|
|
|
|
/// <summary>
|
|
/// How many players need to be present on station for the event to run
|
|
/// </summary>
|
|
/// To avoid running deadly events with low-pop
|
|
public virtual int MinimumPlayers { get; } = 0;
|
|
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
public virtual int? MaxOccurrences { get; } = null;
|
|
|
|
/// <summary>
|
|
/// Called once when the station event starts
|
|
/// </summary>
|
|
public virtual void Startup()
|
|
{
|
|
Running = true;
|
|
Occurrences += 1;
|
|
if (StartAnnouncement != null)
|
|
{
|
|
var chatManager = IoCManager.Resolve<IChatManager>();
|
|
chatManager.DispatchStationAnnouncement(StartAnnouncement);
|
|
}
|
|
}
|
|
|
|
/// <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
|
|
/// </summary>
|
|
public virtual void Shutdown()
|
|
{
|
|
if (EndAnnouncement != null)
|
|
{
|
|
var chatManager = IoCManager.Resolve<IChatManager>();
|
|
chatManager.DispatchStationAnnouncement(EndAnnouncement);
|
|
}
|
|
}
|
|
}
|
|
|
|
public enum StationEventWeight
|
|
{
|
|
VeryLow = 0,
|
|
Low = 5,
|
|
Normal = 10,
|
|
High = 15,
|
|
VeryHigh = 20,
|
|
}
|
|
} |