Skip to content

Commit

Permalink
Merge branch 'master' into AGPL
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidenkrz authored Dec 17, 2024
2 parents 460d6a7 + 412fea7 commit 8d8ac71
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 44 deletions.
2 changes: 2 additions & 0 deletions Content.IntegrationTests/Tests/MappingEditorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public sealed class MappingEditorTest
[Test]
public async Task StopHardCodingWidgetsJesusChristTest()
{
/* Fuck you we do what we want
await using var pair = await PoolManager.GetServerClient(new PoolSettings
{
Connected = true
Expand Down Expand Up @@ -37,5 +38,6 @@ await client.WaitPost(() =>
});
await pair.CleanReturnAsync();
*/
}
}
3 changes: 2 additions & 1 deletion Content.IntegrationTests/Tests/PostMapInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public sealed class PostMapInitTest
// SSS - NEW MAPS
"CentcommSSS",
"ReachSSS",
"TrainSSS"
"TrainSSS",
"CentcommHQSSS"

};

Expand Down
23 changes: 23 additions & 0 deletions Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.CVars.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Content.Shared.CCVar;

namespace Content.Server._SSS.SuspicionGameRule;

public sealed partial class SuspicionRuleSystem
{
private void InitializeCVars()
{
Subs.CVar(_cfg, CCVars.SSSTraitorPercentage, f => _traitorPercentage = f, true);
Subs.CVar(_cfg, CCVars.SSSDetectivePercentage, f => _detectivePercentage = f, true);
Subs.CVar(_cfg, CCVars.SSSPreparingDuration, i => _preparingDuration = i, true);
Subs.CVar(_cfg, CCVars.SSSRoundDuration, i => _roundDuration = i, true);
Subs.CVar(_cfg, CCVars.SSSTimeAddedPerKill, i => _timeAddedPerKill = i, true);
Subs.CVar(_cfg, CCVars.SSSPostRoundDuration, i => _postRoundDuration = i, true);
}

private float _traitorPercentage = 0.25f;
private float _detectivePercentage = 0.25f;
private int _preparingDuration = 30;
private int _roundDuration = 480;
private int _timeAddedPerKill = 30;
private int _postRoundDuration = 30;
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void OnMobStateChanged(EntityUid uid, SuspicionPlayerComponent component
if (sus.GameState != SuspicionGameState.InProgress)
break;

sus.EndAt += TimeSpan.FromSeconds(sus.TimeAddedPerKill);
sus.EndAt += TimeSpan.FromSeconds(_timeAddedPerKill);
sus.AnnouncedTimeLeft.Clear();

RaiseNetworkEvent(new SuspicionRuleTimerUpdate(_gameTicker.RoundDuration() + sus.EndAt));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private void OnGetBriefing(Entity<SuspicionRoleComponent> role, ref GetBriefingE
private void StartRound(EntityUid uid, SuspicionRuleComponent component, GameRuleComponent gameRule)
{
component.GameState = SuspicionGameState.InProgress;
component.EndAt = TimeSpan.FromSeconds(component.RoundDuration);
component.EndAt = TimeSpan.FromSeconds(_roundDuration);

var allPlayerData = _playerManager.GetAllPlayerData().ToList();
var participatingPlayers = new List<(EntityUid mind, SuspicionRoleComponent comp)>();
Expand Down Expand Up @@ -79,8 +79,8 @@ private void StartRound(EntityUid uid, SuspicionRuleComponent component, GameRul
_rejuvenate.PerformRejuvenate(ent.Value);
}

var traitorCount = MathHelper.Clamp((int) (participatingPlayers.Count * component.TraitorPercentage), 1, allPlayerData.Count);
var detectiveCount = MathHelper.Clamp((int) (participatingPlayers.Count * component.DetectivePercentage), 1, allPlayerData.Count);
var traitorCount = MathHelper.Clamp((int) (participatingPlayers.Count * _traitorPercentage), 1, allPlayerData.Count);
var detectiveCount = MathHelper.Clamp((int) (participatingPlayers.Count * _detectivePercentage), 1, allPlayerData.Count);

if (traitorCount + detectiveCount > participatingPlayers.Count)
{
Expand Down Expand Up @@ -222,7 +222,7 @@ private void OnBeforeSpawn(PlayerBeforeSpawnEvent ev)
RaiseNetworkEvent(new SuspicionRulePlayerSpawn()
{
GameState = SuspicionGameState.Preparing,
EndTime = TimeSpan.FromSeconds(sus.PreparingDuration),
EndTime = TimeSpan.FromSeconds(_preparingDuration),
}, ev.Player);

var newMind = _mindSystem.CreateMind(ev.Player.UserId, ev.Profile.Name);
Expand Down
10 changes: 7 additions & 3 deletions Content.Server/_SSS/SuspicionGameRule/SuspicionRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
Expand Down Expand Up @@ -63,6 +64,7 @@ public sealed partial class SuspicionRuleSystem : GameRuleSystem<SuspicionRuleCo
[Dependency] private readonly ContainerSystem _containerSystem = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;

private readonly SoundSpecifier _traitorStartSound = new SoundPathSpecifier("/Audio/Ambience/Antag/traitor_start.ogg");

Expand All @@ -71,6 +73,8 @@ public override void Initialize()
{
base.Initialize();

InitializeCVars();

SubscribeLocalEvent<PlayerBeforeSpawnEvent>(OnBeforeSpawn);
SubscribeLocalEvent<SuspicionRoleComponent, GetBriefingEvent>(OnGetBriefing);
SubscribeLocalEvent<SuspicionPlayerComponent, ExaminedEvent>(OnExamine);
Expand Down Expand Up @@ -129,11 +133,11 @@ protected override void Started(EntityUid uid, SuspicionRuleComponent component,

component.GameState = SuspicionGameState.Preparing;

Timer.Spawn(TimeSpan.FromSeconds(component.PreparingDuration - 5), () => _chatManager.DispatchServerAnnouncement("The round will start in 5 seconds."));
Timer.Spawn(TimeSpan.FromSeconds(component.PreparingDuration), () => StartRound(uid, component, gameRule));
Timer.Spawn(TimeSpan.FromSeconds(_preparingDuration - 5), () => _chatManager.DispatchServerAnnouncement("The round will start in 5 seconds."));
Timer.Spawn(TimeSpan.FromSeconds(_preparingDuration), () => StartRound(uid, component, gameRule));
Log.Debug("Starting a game of Suspicion.");

RaiseNetworkEvent(new SuspicionRulePreroundStarted(TimeSpan.FromSeconds(component.PreparingDuration)));
RaiseNetworkEvent(new SuspicionRulePreroundStarted(TimeSpan.FromSeconds(_preparingDuration)));
}

public override void Update(float frameTime)
Expand Down
39 changes: 38 additions & 1 deletion Content.Shared/_SSS/CCvar/CCVars.SSS.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,45 @@
using Robust.Shared.Configuration;
// ReSharper disable InconsistentNaming rawr

namespace Content.Shared.CCVar;

public sealed partial class CCVars
{
//NONE???
/// <summary>
/// Percentage of total players that will be a traitor.
/// The number of players will be multiplied by this number, and then rounded down.
/// If the result is less than 1 or more than the player count, it is clamped to those values.
/// </summary>
public static readonly CVarDef<float> SSSTraitorPercentage =
CVarDef.Create("sss.traitor_percentage", 0.25f, CVar.SERVERONLY);

/// <summary>
/// Percentage of total players that will be a detective (detective innocent). Handled similar to traitor percentage (rounded down etc).
/// </summary>
public static readonly CVarDef<float> SSSDetectivePercentage =
CVarDef.Create("sss.detective_percentage", 0.25f, CVar.SERVERONLY);

/// <summary>
/// How long to wait before the game starts after the round starts.
/// </summary>
public static readonly CVarDef<int> SSSPreparingDuration =
CVarDef.Create("sss.preparing_duration", 30, CVar.SERVERONLY);

/// <summary>
/// How long the round lasts in seconds.
/// </summary>
public static readonly CVarDef<int> SSSRoundDuration =
CVarDef.Create("sss.round_duration", 480, CVar.SERVERONLY);

/// <summary>
/// How long to add to the round time when a player is killed.
/// </summary>
public static readonly CVarDef<int> SSSTimeAddedPerKill =
CVarDef.Create("sss.time_added_per_kill", 30, CVar.SERVERONLY);

/// <summary>
/// How long to wait before restarting the round after the summary is displayed.
/// </summary>
public static readonly CVarDef<int> SSSPostRoundDuration =
CVarDef.Create("sss.post_round_duration", 30, CVar.SERVERONLY);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,7 @@ public sealed partial class SuspicionRuleComponent : Component

#endregion

/// <summary>
/// Percentage of total players that will be a traitor.
/// The number of players will be multiplied by this number, and then rounded down.
/// If the result is less than 1 or more than the player count, it is clamped to those values.
/// </summary>
[DataField]
public float TraitorPercentage = 0.25f;

/// <summary>
/// Percentage of total players that will be a detective (detective innocent). Handled similar to traitor percentage (rounded down etc).
/// </summary>
[DataField]
public float DetectivePercentage = 0.20f;

/// <summary>
/// How long to wait before the game starts after the round starts.
/// </summary>
[DataField]
public int PreparingDuration = 30;

/// <summary>
/// How long the round lasts in seconds.
/// </summary>
[DataField]
public int RoundDuration = 480;

/// <summary>
/// How long to add to the round time when a player is killed.
/// </summary>
[DataField]
public int TimeAddedPerKill = 30;

/// <summary>
/// How long to wait before restarting the round after the summary is displayed.
/// </summary>
[DataField]
public int PostRoundDuration = 30;

Expand Down

0 comments on commit 8d8ac71

Please sign in to comment.