diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs index e07b522c5ae91..076bbf20981a6 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs @@ -1,12 +1,17 @@ +// Modified by Ronstation contributor(s), therefore this file is licensed as MIT sublicensed with AGPL-v3.0. using System.Threading; using Content.Server.Screens.Components; using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Events; +using Content.Server.Voting; // Ronstation - modification. +using Content.Server.Voting.Managers; // Ronstation - modification. using Content.Shared.Access; using Content.Shared.CCVar; +using Content.Shared.CombatMode.Pacification; // Ronstation - modification. using Content.Shared.Database; using Content.Shared.DeviceNetwork; using Content.Shared.DeviceNetwork.Components; +using Content.Shared.Mind.Components; // Ronstation - modification. using Content.Shared.Popups; using Content.Shared.Shuttles.BUIStates; using Content.Shared.Shuttles.Events; @@ -220,6 +225,51 @@ private void UpdateEmergencyConsole(float frameTime) ShuttlesLeft = true; _chatSystem.DispatchGlobalAnnouncement(Loc.GetString("emergency-shuttle-left", ("transitTime", $"{TransitTime:0}"))); + // Ronstation - start of modifications. + var options = new VoteOptions + { + Title = Loc.GetString("ui-vote-eorg-title"), + Duration = TimeSpan.FromSeconds(TransitTime), + VoterEligibility = VoteManager.VoterEligibility.OnEvac, + Options = + { + (Loc.GetString("ui-vote-eorg-yes"), "yes"), + (Loc.GetString("ui-vote-eorg-no"), "no"), + (Loc.GetString("ui-vote-eorg-abstain"), "abstain") + } + }; + var vote = _voteManager.CreateVote(options); + + + vote.OnFinished += (_, _) => + { + var votesYes = vote.VotesPerOption["yes"]; + var votesNo = vote.VotesPerOption["no"]; + var total = votesYes + votesNo; + + var ratioRequired = _configManager.GetCVar(CCVars.VoteRestartRequiredRatio); + if (total > 0 && votesYes / (float) total >= ratioRequired) + { + _logger.Add(LogType.Vote, LogImpact.Medium, $"EORG vote succeeded: {votesYes}/{votesNo}"); + _chatManager.DispatchServerAnnouncement(Loc.GetString("ui-vote-eorg-succeeded")); + } + else + { + _logger.Add(LogType.Vote, LogImpact.Medium, $"EORG vote failed: {votesYes}/{votesNo}"); + _chatManager.DispatchServerAnnouncement(Loc.GetString("ui-vote-eorg-failed", ("ratio", ratioRequired))); + + var entities = AllEntityQuery(); + while (entities.MoveNext(out var mind)) + { + if (mind.Owner == null) + continue; + + EnsureComp(mind.Owner); + } + } + }; + // Ronstation - end of modifications. + Timer.Spawn((int)(TransitTime * 1000) + _bufferTime.Milliseconds, () => _roundEnd.EndRound(), _roundEndCancelToken?.Token ?? default); } diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs index e0bbc9d090ce3..41306e8bbdb53 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs @@ -1,9 +1,11 @@ +// Modified by Ronstation contributor(s), therefore this file is licensed as MIT sublicensed with AGPL-v3.0. using System.Linq; using System.Numerics; using System.Threading; using Content.Server.Access.Systems; using Content.Server.Administration.Logs; using Content.Server.Administration.Managers; +using Content.Server.Chat.Managers; // Ronstation - modification. using Content.Server.Chat.Systems; using Content.Server.Communications; using Content.Server.DeviceNetwork.Systems; @@ -17,6 +19,7 @@ using Content.Server.Shuttles.Events; using Content.Server.Station.Events; using Content.Server.Station.Systems; +using Content.Server.Voting.Managers; // Ronstation - modification. using Content.Shared.Access.Systems; using Content.Shared.CCVar; using Content.Shared.Database; @@ -70,6 +73,9 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly TransformSystem _transformSystem = default!; [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; + [Dependency] private readonly IVoteManager _voteManager = default!; + [Dependency] private readonly IChatManager _chatManager = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; private const float ShuttleSpawnBuffer = 1f; diff --git a/Content.Server/Voting/Managers/VoteManager.cs b/Content.Server/Voting/Managers/VoteManager.cs index 94e637638ee4b..532986e00082b 100644 --- a/Content.Server/Voting/Managers/VoteManager.cs +++ b/Content.Server/Voting/Managers/VoteManager.cs @@ -1,3 +1,4 @@ +// Modified by Ronstation contributor(s), therefore this file is licensed as MIT sublicensed with AGPL-v3.0. using System.Collections; using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; @@ -8,15 +9,20 @@ using Content.Server.Chat.Managers; using Content.Server.GameTicking; using Content.Server.Maps; +using Content.Server.Shuttles.Components; // Ronstation - modification. using Content.Shared.Administration; using Content.Shared.CCVar; using Content.Shared.Database; using Content.Shared.Ghost; +using Content.Shared.Mind; // Ronstation - modification. +using Content.Shared.Mobs; // Ronstation - modification. +using Content.Shared.Mobs.Components; // Ronstation - modification. using Content.Shared.Players.PlayTimeTracking; using Content.Shared.Voting; using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Enums; +using Robust.Shared.GameObjects; // Ronstation - modification. using Robust.Shared.Network; using Robust.Shared.Player; using Robust.Shared.Prototypes; @@ -430,6 +436,31 @@ public bool CheckVoterEligibility(ICommonSession player, VoterEligibility eligib if (eligibility == VoterEligibility.All) return true; + // Ronstation - start of modifications. + if (eligibility == VoterEligibility.OnEvac) + { + // Get player's transform + if (!_entityManager.TryGetComponent(player.AttachedEntity, out TransformComponent? transform)) + return false; + + if (transform == null) + return false; + + // Check if player is on the shuttle + if (!_entityManager.HasComponent(transform.GridUid)) + return false; + + if (!_entityManager.TryGetComponent(player.AttachedEntity, out MobStateComponent? mobState)) + return false; + + // Player is gibbed + if (mobState == null) + return false; + + return mobState.CurrentState != MobState.Invalid; + } + // Ronstation - end of modifications. + if (eligibility == VoterEligibility.Ghost || eligibility == VoterEligibility.GhostMinimumPlaytime) { if (!_entityManager.TryGetComponent(player.AttachedEntity, out GhostComponent? ghostComp)) @@ -548,6 +579,7 @@ public VoteEntry(object data, string text) public enum VoterEligibility { All, + OnEvac, // Player needs to be on evac // Ronstation - modification. Ghost, // Player needs to be a ghost GhostMinimumPlaytime, // Player needs to be a ghost, with a minimum playtime and deathtime as defined by votekick CCvars. MinimumPlaytime //Player needs to have a minimum playtime and deathtime as defined by votekick CCvars. diff --git a/Resources/Locale/en-US/_Ronstation/voting/managers/vote-manager.ftl b/Resources/Locale/en-US/_Ronstation/voting/managers/vote-manager.ftl new file mode 100644 index 0000000000000..d60a08d53562f --- /dev/null +++ b/Resources/Locale/en-US/_Ronstation/voting/managers/vote-manager.ftl @@ -0,0 +1,6 @@ +ui-vote-eorg-title = Allow EORG +ui-vote-eorg-succeeded = EORG vote succeeded. +ui-vote-eorg-failed = EORG vote failed (need { TOSTRING($ratio, "P0") }). +ui-vote-eorg-yes = Yes +ui-vote-eorg-no = No +ui-vote-eorg-abstain = Abstain \ No newline at end of file