Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Goal population settings to pick difficult goals based on players count #1248

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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!;

/// <summary>
/// Idk how to make configs so let's put it here :\
/// </summary>
private const int PlayersCountWhenPopulationIsHigh = 50;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

перенести в CVar


public override void Initialize()
{
Expand All @@ -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<StationGoalPrototype>().ToList();
var availableGoals = _prototypeManager.EnumeratePrototypes<StationGoalPrototype>()
.Where(goal => goal.GoalType == GoalType.AnyPopulation || goal.GoalType == goalType)
.ToList();
var goal = _random.Pick(availableGoals);
return SendStationGoal(goal);
}
Expand Down
12 changes: 12 additions & 0 deletions Content.Server/Corvax/StationGoal/StationGoalPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/// <summary>
/// Type of goal to divide into goals that can be completed with a large or small number of players.
/// </summary>
public enum GoalType
{
AnyPopulation,
HighPopulation,
LowPopulation
}
}
3 changes: 3 additions & 0 deletions Resources/Prototypes/SS220/Objectives/goals.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading