public override void Update(float frameTime) { base.Update(frameTime); if (!RuleStarted) { return; } if (_timeUntilNextEvent > 0) { _timeUntilNextEvent -= frameTime; return; } // No point hammering this trying to find events if none are available var stationEvent = FindEvent(AvailableEvents()); if (stationEvent == null || !_prototype.TryIndex <GameRulePrototype>(stationEvent.Id, out var proto)) { return; } GameTicker.AddGameRule(proto); ResetTimer(); _sawmill.Info($"Started event {proto.ID}. Next event in {_timeUntilNextEvent} seconds"); }
/// <summary> /// Randomly run a valid event <b>immediately</b>, ignoring earlieststart or whether the event is enabled /// </summary> /// <returns></returns> public string RunRandomEvent() { var randomEvent = PickRandomEvent(); if (randomEvent == null || !_prototype.TryIndex <GameRulePrototype>(randomEvent.Id, out var proto)) { return(Loc.GetString("station-event-system-run-random-event-no-valid-events")); } GameTicker.AddGameRule(proto); return(Loc.GetString("station-event-system-run-event", ("eventName", randomEvent.Id))); }
private void PickRule() { // TODO: This doesn't consider what can't start due to minimum player count, but currently there's no way to know anyway. // as they use cvars. var preset = _prototypeManager.Index <WeightedRandomPrototype>("Secret").Pick(_random); Logger.InfoS("gamepreset", $"Selected {preset} for secret."); foreach (var rule in _prototypeManager.Index <GamePresetPrototype>(preset).Rules) { _ticker.AddGameRule(_prototypeManager.Index <GameRulePrototype>(rule)); } }