From 3e18800d2f006ee55483a5532b0f35adabbff604 Mon Sep 17 00:00:00 2001 From: Aviu00 Date: Thu, 25 Jan 2024 08:49:08 +0300 Subject: [PATCH] Some fixes --- Content.Server/Antag/AntagSelectionSystem.cs | 6 ++- .../Body/Systems/RespiratorSystem.cs | 2 +- .../White/Reputation/ReputationSystem.cs | 40 +++++++++++-------- .../White/Reputation/ReputationNetMsg.cs | 3 +- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/Content.Server/Antag/AntagSelectionSystem.cs b/Content.Server/Antag/AntagSelectionSystem.cs index 2ad3cc1f8b..81f14bd4f7 100644 --- a/Content.Server/Antag/AntagSelectionSystem.cs +++ b/Content.Server/Antag/AntagSelectionSystem.cs @@ -135,7 +135,11 @@ public sealed class AntagSelectionSystem : GameRuleSystem } else { - chosenPlayer = _random.PickAndTake(prefList); + //chosenPlayer = _random.PickAndTake(prefList); + // WD EDIT START + chosenPlayer = _reputationManager.PickPlayerBasedOnReputation(prefList); + prefList.Remove(chosenPlayer); + // WD EDIT END playerList.Remove(chosenPlayer); } diff --git a/Content.Server/Body/Systems/RespiratorSystem.cs b/Content.Server/Body/Systems/RespiratorSystem.cs index 89a2d74971..8cf76cd53d 100644 --- a/Content.Server/Body/Systems/RespiratorSystem.cs +++ b/Content.Server/Body/Systems/RespiratorSystem.cs @@ -346,7 +346,7 @@ namespace Content.Server.Body.Systems else { component.CPRPerformedBy = null; - component.CPRPlayingStream?.Stop(); + _audio.Stop(component.CPRPlayingStream); } RaiseLocalEvent(args.User, new MoodEffectEvent("SavedLife")); diff --git a/Content.Server/White/Reputation/ReputationSystem.cs b/Content.Server/White/Reputation/ReputationSystem.cs index 88b5a2b0fc..ebb1701c1a 100644 --- a/Content.Server/White/Reputation/ReputationSystem.cs +++ b/Content.Server/White/Reputation/ReputationSystem.cs @@ -1,11 +1,15 @@ using System.Linq; using Content.Server.Administration; using Content.Server.GameTicking; -using Content.Server.Mind.Components; +using Content.Server.Objectives; +using Content.Server.Roles; using Content.Server.UtkaIntegration; using Content.Server.White.AspectsSystem.Base; +using Content.Shared.Mind; +using Content.Shared.Mind.Components; using Content.Shared.Mobs; using Content.Shared.Mobs.Components; +using Content.Shared.Objectives.Components; using Content.Shared.White; using Robust.Server.Player; using Robust.Shared.Configuration; @@ -21,6 +25,8 @@ public sealed class ReputationSystem : EntitySystem [Dependency] private readonly GameTicker _gameTicker = default!; [Dependency] private readonly IPlayerLocator _locator = default!; [Dependency] private readonly IConfigurationManager _cfg = default!; + [Dependency] private readonly RoleSystem _roles = default!; + [Dependency] private readonly ObjectivesSystem _objectives = default!; private const int MinPlayers = 15; private const int MinRoundLength = 25; @@ -109,34 +115,34 @@ public sealed class ReputationSystem : EntitySystem if (TryComp(entity, out var mind) && mind.Mind != null - && mind.Mind.AllRoles.Any(role => role.Antagonist)) + && _roles.MindIsAntagonist(mind.Mind) + && TryComp(mind.Mind, out MindComponent? mindComp)) { - var condCompleted = 0; - var totalCond = 0; - foreach (var obj in mind.Mind.AllObjectives) + var objCompleted = 0; + var totalObj = 0; + foreach (var obj in mindComp.Objectives) { - foreach (var condition in obj.Conditions) - { - totalCond++; + totalObj++; - if (condition.Progress > 0.99f) - condCompleted++; - } + var info = _objectives.GetInfo(obj, mind.Mind.Value, mindComp); + + if (info is {Progress: > 0.99f}) + objCompleted++; } if (aspect) { - if (condCompleted == totalCond) - deltaValue += 1f + condCompleted; + if (objCompleted == totalObj) + deltaValue += 1f + objCompleted; else - deltaValue += 1f + condCompleted * 0.5f; + deltaValue += 1f + objCompleted * 0.5f; } else { - if (condCompleted == totalCond) - deltaValue += 2f + condCompleted * 0.5f; + if (objCompleted == totalObj) + deltaValue += 2f + objCompleted * 0.5f; else - deltaValue += condCompleted * 0.5f; + deltaValue += objCompleted * 0.5f; } } diff --git a/Content.Shared/White/Reputation/ReputationNetMsg.cs b/Content.Shared/White/Reputation/ReputationNetMsg.cs index 1c0ce993e9..5d0436d381 100644 --- a/Content.Shared/White/Reputation/ReputationNetMsg.cs +++ b/Content.Shared/White/Reputation/ReputationNetMsg.cs @@ -22,7 +22,8 @@ public sealed class ReputationNetMsg : NetMessage return; var length = buffer.ReadVariableInt32(); - using var stream = buffer.ReadAlignedMemory(length); + using var stream = new MemoryStream(); + buffer.ReadAlignedMemory(stream, length); serializer.DeserializeDirect(stream, out Info); }