From 964c6a8455207ad0fca7ab4b2481cad081bf8d40 Mon Sep 17 00:00:00 2001 From: Vladislav vakuor Tkachev Date: Sun, 30 Jun 2024 00:46:11 +0300 Subject: [PATCH] goal population settings to pick difficult goals when players count high and low if players count low --- .../StationGoal/StationGoalPaperSystem.cs | 22 ++++++++++++++++--- .../StationGoal/StationGoalPrototype.cs | 12 ++++++++++ .../Prototypes/SS220/Objectives/goals.yml | 3 +++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs b/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs index a84a107f24f2d3..d8257ee6c67d3f 100644 --- a/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs +++ b/Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs @@ -1,5 +1,6 @@ using System.Linq; using Content.Server.Fax; +using Content.Server.GameTicking; using Content.Server.Paper; using Content.Shared.Fax.Components; using Content.Shared.GameTicking; @@ -19,6 +20,12 @@ public sealed class StationGoalPaperSystem : EntitySystem [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly FaxSystem _faxSystem = default!; + [Dependency] private readonly GameTicker _gameTicker = default!; + + /// + /// Idk how to make configs so let's put it here :\ + /// + private const int PlayersCountWhenPopulationIsHigh = 50; public override void Initialize() { @@ -28,12 +35,21 @@ public override void Initialize() private void OnRoundStarted(RoundStartedEvent ev) { - SendRandomGoal(); + if (_gameTicker.PlayersJoinedRoundNormally > PlayersCountWhenPopulationIsHigh) + { + SendRandomGoal(GoalType.HighPopulation); + } + else + { + SendRandomGoal(GoalType.LowPopulation); + } } - public bool SendRandomGoal() + public bool SendRandomGoal(GoalType goalType = GoalType.AnyPopulation) { - var availableGoals = _prototypeManager.EnumeratePrototypes().ToList(); + var availableGoals = _prototypeManager.EnumeratePrototypes() + .Where(goal => goal.GoalType == GoalType.AnyPopulation || goal.GoalType == goalType) + .ToList(); var goal = _random.Pick(availableGoals); return SendStationGoal(goal); } diff --git a/Content.Server/Corvax/StationGoal/StationGoalPrototype.cs b/Content.Server/Corvax/StationGoal/StationGoalPrototype.cs index 79d945f5be6c40..8c0b19754e0bd5 100644 --- a/Content.Server/Corvax/StationGoal/StationGoalPrototype.cs +++ b/Content.Server/Corvax/StationGoal/StationGoalPrototype.cs @@ -8,5 +8,17 @@ public sealed class StationGoalPrototype : IPrototype [IdDataFieldAttribute] public string ID { get; } = default!; [DataField("text")] public string Text { get; set; } = string.Empty; + + [DataField("goalType")] public GoalType GoalType { get; set; } = GoalType.AnyPopulation; + } + + /// + /// Type of goal to divide into goals that can be completed with a large or small number of players. + /// + public enum GoalType + { + AnyPopulation, + HighPopulation, + LowPopulation } } diff --git a/Resources/Prototypes/SS220/Objectives/goals.yml b/Resources/Prototypes/SS220/Objectives/goals.yml index 36973211e1b63b..9277e8ad247f02 100644 --- a/Resources/Prototypes/SS220/Objectives/goals.yml +++ b/Resources/Prototypes/SS220/Objectives/goals.yml @@ -1,14 +1,17 @@ - type: stationGoal id: StationGoalSaveplanet text: station-goal-saveplanet + goalType: LowPopulation - type: stationGoal id: StationGoalExpedition text: station-goal-expedition + goalType: HighPopulation - type: stationGoal id: StationGoalGuests text: station-goal-guests + goalType: AnyPopulation - type: stationGoal id: StationGoalPneumaticTubes