Cleanup warnings in BasicStationEventSchedulerSystem (#37818)

Cleanup 4 warnings in BasicStationEventSchedulerSystem
This commit is contained in:
Tayrtahn
2025-05-25 14:27:47 -04:00
committed by GitHub
parent e73f1e3a19
commit 6b2c50f4ba

View File

@@ -79,6 +79,7 @@ namespace Content.Server.StationEvents
private EntityTableSystem? _entityTable; private EntityTableSystem? _entityTable;
private IComponentFactory? _compFac; private IComponentFactory? _compFac;
private IRobustRandom? _random; private IRobustRandom? _random;
private IPrototypeManager? _protoMan;
/// <summary> /// <summary>
/// Estimates the expected number of times an event will run over the course of X rounds, taking into account weights and /// Estimates the expected number of times an event will run over the course of X rounds, taking into account weights and
@@ -95,12 +96,13 @@ namespace Content.Server.StationEvents
/// to even exist) so I think it's fine. /// to even exist) so I think it's fine.
/// </remarks> /// </remarks>
[CommandImplementation("simulate")] [CommandImplementation("simulate")]
public IEnumerable<(string, float)> Simulate([CommandArgument] Prototype<EntityPrototype> eventSchedulerProto, [CommandArgument] int rounds, [CommandArgument] int playerCount, [CommandArgument] float roundEndMean, [CommandArgument] float roundEndStdDev) public IEnumerable<(string, float)> Simulate([CommandArgument] EntProtoId eventSchedulerProto, [CommandArgument] int rounds, [CommandArgument] int playerCount, [CommandArgument] float roundEndMean, [CommandArgument] float roundEndStdDev)
{ {
_stationEvent ??= GetSys<EventManagerSystem>(); _stationEvent ??= GetSys<EventManagerSystem>();
_entityTable ??= GetSys<EntityTableSystem>(); _entityTable ??= GetSys<EntityTableSystem>();
_compFac ??= IoCManager.Resolve<IComponentFactory>(); _compFac ??= IoCManager.Resolve<IComponentFactory>();
_random ??= IoCManager.Resolve<IRobustRandom>(); _random ??= IoCManager.Resolve<IRobustRandom>();
_protoMan ??= IoCManager.Resolve<IPrototypeManager>();
var occurrences = new Dictionary<string, int>(); var occurrences = new Dictionary<string, int>();
@@ -109,7 +111,7 @@ namespace Content.Server.StationEvents
occurrences.Add(ev.Key.ID, 0); occurrences.Add(ev.Key.ID, 0);
} }
eventSchedulerProto.Deconstruct(out EntityPrototype eventScheduler); var eventScheduler = _protoMan.Index(eventSchedulerProto);
if (!eventScheduler.TryGetComponent<BasicStationEventSchedulerComponent>(out var basicScheduler, _compFac)) if (!eventScheduler.TryGetComponent<BasicStationEventSchedulerComponent>(out var basicScheduler, _compFac))
{ {
@@ -144,16 +146,17 @@ namespace Content.Server.StationEvents
} }
} }
return occurrences.Select(p => (p.Key, (float) p.Value)).OrderByDescending(p => p.Item2); return occurrences.Select(p => (p.Key, (float)p.Value)).OrderByDescending(p => p.Item2);
} }
[CommandImplementation("lsprob")] [CommandImplementation("lsprob")]
public IEnumerable<(string, float)> LsProb([CommandArgument] Prototype<EntityPrototype> eventSchedulerProto) public IEnumerable<(string, float)> LsProb([CommandArgument] EntProtoId eventSchedulerProto)
{ {
_compFac ??= IoCManager.Resolve<IComponentFactory>(); _compFac ??= IoCManager.Resolve<IComponentFactory>();
_stationEvent ??= GetSys<EventManagerSystem>(); _stationEvent ??= GetSys<EventManagerSystem>();
_protoMan ??= IoCManager.Resolve<IPrototypeManager>();
eventSchedulerProto.Deconstruct(out EntityPrototype eventScheduler); var eventScheduler = _protoMan.Index(eventSchedulerProto);
if (!eventScheduler.TryGetComponent<BasicStationEventSchedulerComponent>(out var basicScheduler, _compFac)) if (!eventScheduler.TryGetComponent<BasicStationEventSchedulerComponent>(out var basicScheduler, _compFac))
yield break; yield break;
@@ -171,12 +174,13 @@ namespace Content.Server.StationEvents
} }
[CommandImplementation("lsprobtheoretical")] [CommandImplementation("lsprobtheoretical")]
public IEnumerable<(string, float)> LsProbTime([CommandArgument] Prototype<EntityPrototype> eventSchedulerProto, [CommandArgument] int playerCount, [CommandArgument] float time) public IEnumerable<(string, float)> LsProbTime([CommandArgument] EntProtoId eventSchedulerProto, [CommandArgument] int playerCount, [CommandArgument] float time)
{ {
_compFac ??= IoCManager.Resolve<IComponentFactory>(); _compFac ??= IoCManager.Resolve<IComponentFactory>();
_stationEvent ??= GetSys<EventManagerSystem>(); _stationEvent ??= GetSys<EventManagerSystem>();
_protoMan ??= IoCManager.Resolve<IPrototypeManager>();
eventSchedulerProto.Deconstruct(out EntityPrototype eventScheduler); var eventScheduler = _protoMan.Index(eventSchedulerProto);
if (!eventScheduler.TryGetComponent<BasicStationEventSchedulerComponent>(out var basicScheduler, _compFac)) if (!eventScheduler.TryGetComponent<BasicStationEventSchedulerComponent>(out var basicScheduler, _compFac))
yield break; yield break;
@@ -198,12 +202,13 @@ namespace Content.Server.StationEvents
} }
[CommandImplementation("prob")] [CommandImplementation("prob")]
public float Prob([CommandArgument] Prototype<EntityPrototype> eventSchedulerProto, [CommandArgument] string eventId) public float Prob([CommandArgument] EntProtoId eventSchedulerProto, [CommandArgument] string eventId)
{ {
_compFac ??= IoCManager.Resolve<IComponentFactory>(); _compFac ??= IoCManager.Resolve<IComponentFactory>();
_stationEvent ??= GetSys<EventManagerSystem>(); _stationEvent ??= GetSys<EventManagerSystem>();
_protoMan ??= IoCManager.Resolve<IPrototypeManager>();
eventSchedulerProto.Deconstruct(out EntityPrototype eventScheduler); var eventScheduler = _protoMan.Index(eventSchedulerProto);
if (!eventScheduler.TryGetComponent<BasicStationEventSchedulerComponent>(out var basicScheduler, _compFac)) if (!eventScheduler.TryGetComponent<BasicStationEventSchedulerComponent>(out var basicScheduler, _compFac))
return 0f; return 0f;