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,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;
|
||||
|
||||
Reference in New Issue
Block a user