mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-04 05:17:28 +00:00
New psionic ablility: Precognition (#2131)
* TESTING enable events for dev enviroment * Add NextEventComponent * Check for schedulers NextEventComponent * Seperate gernateing event to its own method * Add NextEventSystem and use in BasicStationEventSchedulerSystem * TESTING: Override time and player restrictions * Stash events in NextEventComponent (#1) * Add NextEventComponent * Check for schedulers NextEventComponent * Seperate gernateing event to its own method * Add NextEventSystem and use in BasicStationEventSchedulerSystem * Format code * Add nextEvent time perdiction * Use RunTime instead of float minutes * Bug fixes * Add NextEvent to Ramping and Meteors * Fix timing on BasticStationEvents * initialize NextEventComponent when created * Event scheduler caching (#2) * Check for schedulers NextEventComponent * Seperate gernateing event to its own method * Add NextEventSystem and use in BasicStationEventSchedulerSystem * Format code * Add nextEvent time perdiction * Use RunTime instead of float minutes * Bug fixes * Add NextEvent to Ramping and Meteors * Fix timing on BasticStationEvents * initialize NextEventComponent when created --------- Signed-off-by: SolStar <44028047+ewokswagger@users.noreply.github.com> * Revert "Event scheduler caching (#2)" This reverts commitbf9cd26ed4. * Revert "Merge branch 'seer' into stash-next-event" This reverts commit656ca26173, reversing changes made to36f45be10e. * Revert "Caching next exent" This reverts commit9f1bee4131, reversing changes made to82678d9c18. * Reapply "Event scheduler caching (#2)" This reverts commit82678d9c18. * More merge conflict nonsence * oops * oops 2 * Oops 3 * Precognition Psionic ability (#3) * Precognition ability added * Precog get next event * Get soonest event and display * update prototypes with precog results * Add random * Use Timespan for UseDelay * Damage breaks doafter * typo * fix localization * fix do after * Add effects durring do after * Revert "TESTING enable events for dev enviroment" This reverts commit03453133bd. * Revert testing changes * add deltav comments * Cleaning up! * Move NextEvent to server space * Fix NextEventId init value * Reverted upstream file to block scoped namespace * Add precognitnon result messages * reverting testing changes for real * Add admin alert for upcoming events * Add sound effect * make alert more subtule * extended max window size * fix message mixup * yaml fixes * more yaml fixes * Delta Changes * totaly a yaml error trust * remove unsessesary weights --------- Signed-off-by: SolStar <44028047+ewokswagger@users.noreply.github.com>
This commit is contained in:
@@ -11,7 +11,8 @@ using Robust.Shared.Random;
|
||||
using Content.Shared.EntityTable.EntitySelectors;
|
||||
using Content.Shared.EntityTable;
|
||||
using Content.Server.Psionics.Glimmer; // DeltaV
|
||||
using Content.Shared.Psionics.Glimmer; // DeltaV
|
||||
using Content.Shared.Psionics.Glimmer;
|
||||
using System.Diagnostics.CodeAnalysis; // DeltaV
|
||||
|
||||
namespace Content.Server.StationEvents;
|
||||
|
||||
@@ -59,37 +60,67 @@ public sealed class EventManagerSystem : EntitySystem
|
||||
/// </summary>
|
||||
public void RunRandomEvent(EntityTableSelector limitedEventsTable)
|
||||
{
|
||||
if (!TryBuildLimitedEvents(limitedEventsTable, out var limitedEvents))
|
||||
if (TryGenerateRandomEvent(limitedEventsTable, out string? randomLimitedEvent)) // DeltaV - seperated into own method
|
||||
GameTicker.AddGameRule(randomLimitedEvent);
|
||||
}
|
||||
|
||||
// DeltaV - overloaded for backwards compatiblity
|
||||
public bool TryGenerateRandomEvent(EntityTableSelector limitedEventsTable, [NotNullWhen(true)] out string? randomLimitedEvent)
|
||||
{
|
||||
return TryGenerateRandomEvent(limitedEventsTable, out randomLimitedEvent, null);
|
||||
}
|
||||
// DeltaV - end overloaded for backwards compatiblity
|
||||
|
||||
// DeltaV - separate event generation method
|
||||
/// <summary>
|
||||
/// Returns a random event from the list of events given that can be run at a given time.
|
||||
/// </summary>
|
||||
/// <param name="limitedEventsTable">The list of events that can be chosen.</param>
|
||||
/// <param name="randomLimitedEvent">Generated event</param>
|
||||
/// <param name="eventRunTime">The time to use for checking time restrictions. Uses current time if null.</param>
|
||||
/// <returns></returns>
|
||||
public bool TryGenerateRandomEvent(EntityTableSelector limitedEventsTable, [NotNullWhen(true)] out string? randomLimitedEvent, TimeSpan? eventRunTime)
|
||||
{
|
||||
randomLimitedEvent = null;
|
||||
if (!TryBuildLimitedEvents(limitedEventsTable, out var limitedEvents, eventRunTime))
|
||||
{
|
||||
Log.Warning("Provided event table could not build dict!");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
var randomLimitedEvent = FindEvent(limitedEvents); // this picks the event, It might be better to use the GetSpawns to do it, but that will be a major rebalancing fuck.
|
||||
randomLimitedEvent = FindEvent(limitedEvents); // this picks the event, It might be better to use the GetSpawns to do it, but that will be a major rebalancing fuck.
|
||||
// DeltaV - randomLimitedEvent declared by enclosing method
|
||||
if (randomLimitedEvent == null)
|
||||
{
|
||||
Log.Warning("The selected random event is null!");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_prototype.TryIndex(randomLimitedEvent, out _))
|
||||
{
|
||||
Log.Warning("A requested event is not available!");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
GameTicker.AddGameRule(randomLimitedEvent);
|
||||
return true;
|
||||
}
|
||||
// DeltaV - end separate event generation method
|
||||
|
||||
// DeltaV - overloaded for backwards compatiblity
|
||||
public bool TryBuildLimitedEvents(EntityTableSelector limitedEventsTable, out Dictionary<EntityPrototype, StationEventComponent> limitedEvents)
|
||||
{
|
||||
return TryBuildLimitedEvents(limitedEventsTable, out limitedEvents, null);
|
||||
}
|
||||
// DeltaV - end overloaded for backwards compatiblity
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the provided EntityTableSelector gives at least one prototype with a StationEvent comp.
|
||||
/// </summary>
|
||||
public bool TryBuildLimitedEvents(EntityTableSelector limitedEventsTable, out Dictionary<EntityPrototype, StationEventComponent> limitedEvents)
|
||||
public bool TryBuildLimitedEvents(EntityTableSelector limitedEventsTable, out Dictionary<EntityPrototype, StationEventComponent> limitedEvents, TimeSpan? eventRunTime) // DeltaV - Add a time overide
|
||||
{
|
||||
limitedEvents = new Dictionary<EntityPrototype, StationEventComponent>();
|
||||
|
||||
var availableEvents = AvailableEvents(); // handles the player counts and individual event restrictions
|
||||
|
||||
// DeltaV - Overide time for stashing events
|
||||
var availableEvents = AvailableEvents(eventRunTime); // handles the player counts and individual event restrictions
|
||||
if (availableEvents.Count == 0)
|
||||
{
|
||||
Log.Warning("No events were available to run!");
|
||||
@@ -175,6 +206,16 @@ public sealed class EventManagerSystem : EntitySystem
|
||||
return null;
|
||||
}
|
||||
|
||||
// DeltaV - overloaded for backwards compatiblity
|
||||
public Dictionary<EntityPrototype, StationEventComponent> AvailableEvents(
|
||||
bool ignoreEarliestStart = false,
|
||||
int? playerCountOverride = null,
|
||||
TimeSpan? currentTimeOverride = null)
|
||||
{
|
||||
return AvailableEvents(null, ignoreEarliestStart, playerCountOverride, currentTimeOverride);
|
||||
}
|
||||
// DeltaV - end overloaded for backwards compatiblity
|
||||
|
||||
/// <summary>
|
||||
/// Gets the events that have met their player count, time-until start, etc.
|
||||
/// </summary>
|
||||
@@ -182,6 +223,7 @@ public sealed class EventManagerSystem : EntitySystem
|
||||
/// <param name="currentTimeOverride">Override for round time, if using this to simulate events rather than in an actual round.</param>
|
||||
/// <returns></returns>
|
||||
public Dictionary<EntityPrototype, StationEventComponent> AvailableEvents(
|
||||
TimeSpan? eventRunTime,
|
||||
bool ignoreEarliestStart = false,
|
||||
int? playerCountOverride = null,
|
||||
TimeSpan? currentTimeOverride = null)
|
||||
@@ -189,9 +231,12 @@ public sealed class EventManagerSystem : EntitySystem
|
||||
var playerCount = playerCountOverride ?? _playerManager.PlayerCount;
|
||||
|
||||
// playerCount does a lock so we'll just keep the variable here
|
||||
var currentTime = currentTimeOverride ?? (!ignoreEarliestStart
|
||||
? GameTicker.RoundDuration()
|
||||
: TimeSpan.Zero);
|
||||
var currentTime = currentTimeOverride ?? (
|
||||
(!ignoreEarliestStart
|
||||
? eventRunTime // DeltaV - Use eventRunTime instead of RoundDuration if provided
|
||||
?? GameTicker.RoundDuration()
|
||||
: TimeSpan.Zero)
|
||||
);
|
||||
|
||||
var result = new Dictionary<EntityPrototype, StationEventComponent>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user