basic station event commands (#20371)
* basic station event commands * ouagh
This commit is contained in:
@@ -1,8 +1,13 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Content.Server.Administration;
|
||||||
using Content.Server.GameTicking.Rules;
|
using Content.Server.GameTicking.Rules;
|
||||||
using Content.Server.GameTicking.Rules.Components;
|
using Content.Server.GameTicking.Rules.Components;
|
||||||
using Content.Server.StationEvents.Components;
|
using Content.Server.StationEvents.Components;
|
||||||
|
using Content.Shared.Administration;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
using Robust.Shared.Toolshed;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Server.StationEvents
|
namespace Content.Server.StationEvents
|
||||||
{
|
{
|
||||||
@@ -56,4 +61,54 @@ namespace Content.Server.StationEvents
|
|||||||
component.TimeUntilNextEvent = _random.Next(300, 1500);
|
component.TimeUntilNextEvent = _random.Next(300, 1500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ToolshedCommand, AdminCommand(AdminFlags.Debug)]
|
||||||
|
public sealed class StationEventCommand : ToolshedCommand
|
||||||
|
{
|
||||||
|
private EventManagerSystem? _stationEvent;
|
||||||
|
|
||||||
|
[CommandImplementation("lsprob")]
|
||||||
|
public IEnumerable<(string, float)> LsProb()
|
||||||
|
{
|
||||||
|
_stationEvent ??= GetSys<EventManagerSystem>();
|
||||||
|
var events = _stationEvent.AllEvents();
|
||||||
|
|
||||||
|
var totalWeight = events.Sum(x => x.Value.Weight);
|
||||||
|
|
||||||
|
foreach (var (proto, comp) in events)
|
||||||
|
{
|
||||||
|
yield return (proto.ID, comp.Weight / totalWeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandImplementation("lsprobtime")]
|
||||||
|
public IEnumerable<(string, float)> LsProbTime([CommandArgument] float time)
|
||||||
|
{
|
||||||
|
_stationEvent ??= GetSys<EventManagerSystem>();
|
||||||
|
var events = _stationEvent.AllEvents().Where(pair => pair.Value.EarliestStart <= time).ToList();
|
||||||
|
|
||||||
|
var totalWeight = events.Sum(x => x.Value.Weight);
|
||||||
|
|
||||||
|
foreach (var (proto, comp) in events)
|
||||||
|
{
|
||||||
|
yield return (proto.ID, comp.Weight / totalWeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandImplementation("prob")]
|
||||||
|
public float Prob([CommandArgument] string eventId)
|
||||||
|
{
|
||||||
|
_stationEvent ??= GetSys<EventManagerSystem>();
|
||||||
|
var events = _stationEvent.AllEvents();
|
||||||
|
|
||||||
|
var totalWeight = events.Sum(x => x.Value.Weight);
|
||||||
|
var weight = 0f;
|
||||||
|
if (events.TryFirstOrNull(p => p.Key.ID == eventId, out var pair))
|
||||||
|
{
|
||||||
|
weight = pair.Value.Value.Weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
return weight / totalWeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,12 @@ command-description-stations-rename =
|
|||||||
Renames the given station.
|
Renames the given station.
|
||||||
command-description-stations-largestgrid =
|
command-description-stations-largestgrid =
|
||||||
Returns the largest grid the given station has, if any.
|
Returns the largest grid the given station has, if any.
|
||||||
|
command-description-stationevent-lsprob =
|
||||||
|
Lists the probability of different station events occuring out of the entire pool.
|
||||||
|
command-description-stationevent-lsprobtime =
|
||||||
|
Lists the probability of different station events occuring based on the specified length of a round.
|
||||||
|
command-description-stationevent-prob =
|
||||||
|
Returns the probability of a single station event occuring out of the entire pool.
|
||||||
command-description-admins-active =
|
command-description-admins-active =
|
||||||
Returns a list of active admins.
|
Returns a list of active admins.
|
||||||
command-description-admins-all =
|
command-description-admins-all =
|
||||||
|
|||||||
Reference in New Issue
Block a user