Skip to content
Open
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
50 changes: 50 additions & 0 deletions Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<MindContainerComponent>();
while (entities.MoveNext(out var mind))
{
if (mind.Owner == null)
continue;

EnsureComp<PacifiedComponent>(mind.Owner);
}
}
};
// Ronstation - end of modifications.

Timer.Spawn((int)(TransitTime * 1000) + _bufferTime.Milliseconds, () => _roundEnd.EndRound(), _roundEndCancelToken?.Token ?? default);
}

Expand Down
6 changes: 6 additions & 0 deletions Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
32 changes: 32 additions & 0 deletions Content.Server/Voting/Managers/VoteManager.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<EmergencyShuttleComponent>(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))
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Loading