Skip to content

Commit

Permalink
ахуеть
Browse files Browse the repository at this point in the history
  • Loading branch information
lzk228 committed Jun 19, 2024
1 parent 388d023 commit bab8f67
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
15 changes: 14 additions & 1 deletion Content.Server/Corvax/StationGoal/StationGoalPaperSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Shared.Fax.Components;
using Content.Shared.GameTicking;
using Content.Shared.Paper;
using Robust.Server.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;

Expand All @@ -16,6 +17,7 @@ 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 IPlayerManager _playerManager = default!;

public override void Initialize()
{
Expand All @@ -31,7 +33,18 @@ private void OnRoundStarted(RoundStartedEvent ev)
public bool SendRandomGoal()
{
var availableGoals = _prototypeManager.EnumeratePrototypes<StationGoalPrototype>().ToList();
var goal = _random.Pick(availableGoals);
var playerCount = _playerManager.PlayerCount;

var validGoals = availableGoals.Where(goal =>
(!goal.MinPlayers.HasValue || playerCount >= goal.MinPlayers.Value) &&
(!goal.MaxPlayers.HasValue || playerCount <= goal.MaxPlayers.Value)).ToList();

if (!validGoals.Any())
{
return false;
}

var goal = _random.Pick(validGoals);
return SendStationGoal(goal);
}

Expand Down
13 changes: 11 additions & 2 deletions Content.Server/Corvax/StationGoal/StationGoalPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ namespace Content.Server.Corvax.StationGoal
[Serializable, Prototype("stationGoal")]
public sealed class StationGoalPrototype : IPrototype
{
[IdDataFieldAttribute] public string ID { get; } = default!;
[IdDataFieldAttribute]
public string ID { get; } = default!;

[DataField("text")]
public string Text { get; set; } = string.Empty;

[DataField("minPlayers")]
public int? MinPlayers = null;

[DataField("maxPlayers")]
public int? MaxPlayers = null;

[DataField("text")] public string Text { get; set; } = string.Empty;
}
}

0 comments on commit bab8f67

Please sign in to comment.