Skip to content

Commit

Permalink
Merge pull request #399 from PyotrIgn/fixnuke_and_locale
Browse files Browse the repository at this point in the history
фикс нюкеров и локализации
  • Loading branch information
PyotrIgn authored Feb 10, 2024
2 parents c0dd6e7 + 28dff45 commit 9481c5d
Show file tree
Hide file tree
Showing 14 changed files with 166 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Server.NPC.Components;
using Content.Server.RoundEnd;
using Content.Server.StationEvents.Events;
using Content.Shared.Dataset;
using Content.Shared.Roles;
Expand Down Expand Up @@ -32,10 +33,34 @@ public sealed partial class NukeopsRuleComponent : Component
public int MaxOps = 4;

/// <summary>
/// Whether or not all of the nuclear operatives dying will end the round. Used by LoneOpsSpawn event.
/// What will happen if all of the nuclear operatives will die. Used by LoneOpsSpawn event.
/// </summary>
[DataField("endsRound")]
public bool EndsRound = true;
[DataField]
public RoundEndBehavior RoundEndBehavior = RoundEndBehavior.ShuttleCall;

/// <summary>
/// Text for shuttle call if RoundEndBehavior is ShuttleCall.
/// </summary>
[DataField]
public string RoundEndTextSender = "comms-console-announcement-title-centcom";

/// <summary>
/// Text for shuttle call if RoundEndBehavior is ShuttleCall.
/// </summary>
[DataField]
public string RoundEndTextShuttleCall = "nuke-ops-no-more-threat-announcement-shuttle-call";

/// <summary>
/// Text for announcement if RoundEndBehavior is ShuttleCall. Used if shuttle is already called
/// </summary>
[DataField]
public string RoundEndTextAnnouncement = "nuke-ops-no-more-threat-announcement";

/// <summary>
/// Time to emergency shuttle to arrive if RoundEndBehavior is ShuttleCall.
/// </summary>
[DataField]
public TimeSpan EvacShuttleTime = TimeSpan.FromMinutes(3);

/// <summary>
/// Whether or not to spawn the nuclear operative outpost. Used by LoneOpsSpawn event.
Expand Down
15 changes: 10 additions & 5 deletions Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,14 +507,14 @@ private void OnRoundEndText(RoundEndTextAppendEvent ev)
}
}

private void SetWinType(EntityUid uid, WinType type, NukeopsRuleComponent? component = null)
private void SetWinType(EntityUid uid, WinType type, NukeopsRuleComponent? component = null, bool endRound = true)
{
if (!Resolve(uid, ref component))
return;

component.WinType = type;

if (type == WinType.CrewMajor || type == WinType.OpsMajor)
if (endRound && (type == WinType.CrewMajor || type == WinType.OpsMajor))
_roundEndSystem.EndRound();
}

Expand All @@ -526,7 +526,7 @@ private void CheckRoundShouldEnd()
if (!GameTicker.IsGameRuleAdded(uid, gameRule))
continue;

if (!nukeops.EndsRound || nukeops.WinType == WinType.CrewMajor || nukeops.WinType == WinType.OpsMajor)
if (nukeops.RoundEndBehavior == RoundEndBehavior.Nothing || nukeops.WinType == WinType.CrewMajor || nukeops.WinType == WinType.OpsMajor)
continue;

// If there are any nuclear bombs that are active, immediately return. We're not over yet.
Expand Down Expand Up @@ -579,7 +579,12 @@ private void CheckRoundShouldEnd()
? WinCondition.NukiesAbandoned
: WinCondition.AllNukiesDead);

SetWinType(uid, WinType.CrewMajor, nukeops);
SetWinType(uid, WinType.CrewMajor, nukeops, false);
_roundEndSystem.DoRoundEndBehavior(
nukeops.RoundEndBehavior, nukeops.EvacShuttleTime, nukeops.RoundEndTextSender, nukeops.RoundEndTextShuttleCall, nukeops.RoundEndTextAnnouncement);

// prevent it called multiple times
nukeops.RoundEndBehavior = RoundEndBehavior.Nothing;
}
}

Expand Down Expand Up @@ -784,7 +789,7 @@ private void OnMindAdded(EntityUid uid, NukeOperativeComponent component, MindAd

foreach (var (nukeops, gameRule) in EntityQuery<NukeopsRuleComponent, GameRuleComponent>())
{
if (nukeops.OperativeMindPendingData.TryGetValue(uid, out var role) || !nukeops.SpawnOutpost || !nukeops.EndsRound)
if (nukeops.OperativeMindPendingData.TryGetValue(uid, out var role) || !nukeops.SpawnOutpost || nukeops.RoundEndBehavior == RoundEndBehavior.Nothing)
{
role ??= nukeops.OperativeRoleProto;
_roles.MindAddRole(mindId, new NukeopsRoleComponent { PrototypeId = role });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ protected override void ActiveTick(EntityUid uid, RevolutionaryRuleComponent com

if (CheckCommandLose())
{
_roundEnd.DoRoundEndBehavior(RoundEndBehavior.ShuttleCall, component.ShuttleCallTime);
GameTicker.EndGameRule(uid, gameRule);
}
}
Expand Down
93 changes: 69 additions & 24 deletions Content.Server/RoundEnd/RoundEndSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ public bool CanCallOrRecall()
return _cooldownTokenSource == null;
}

public void RequestRoundEnd(EntityUid? requester = null, bool checkCooldown = true, bool autoCall = false)
public bool IsRoundEndRequested()
{
return _countdownTokenSource != null;
}

public void RequestRoundEnd(EntityUid? requester = null, bool checkCooldown = true, string text = "round-end-system-shuttle-called-announcement", string name = "Станции")
{
var duration = DefaultCountdownDuration;

Expand All @@ -141,10 +146,10 @@ public void RequestRoundEnd(EntityUid? requester = null, bool checkCooldown = tr
}
}

RequestRoundEnd(duration, requester, checkCooldown, autoCall);
RequestRoundEnd(duration, requester, checkCooldown, text, name);
}

public void RequestRoundEnd(TimeSpan countdownTime, EntityUid? requester = null, bool checkCooldown = true, bool autoCall = false)
public void RequestRoundEnd(TimeSpan countdownTime, EntityUid? requester = null, bool checkCooldown = true, string text = "round-end-system-shuttle-called-announcement", string name = "Станции")
{
if (_gameTicker.RunLevel != GameRunLevel.InRound) return;

Expand Down Expand Up @@ -177,26 +182,13 @@ public void RequestRoundEnd(TimeSpan countdownTime, EntityUid? requester = null,
units = "eta-units-minutes";
}

if (autoCall)
{
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString("round-end-system-shuttle-auto-called-announcement",
("time", time),
("units", Loc.GetString(units))),
Loc.GetString("Station"),
false,
null,
Color.Gold);
}
else
{
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString("round-end-system-shuttle-called-announcement",
("time", time),
("units", Loc.GetString(units))),
Loc.GetString("Station"),
false,
null,
Color.Gold);
}
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString(text,
("time", time),
("units", Loc.GetString(units))),
name,
false,
null,
Color.Gold);

_audio.PlayGlobal("/Audio/Announcements/shuttlecalled.ogg", Filter.Broadcast(), true);

Expand Down Expand Up @@ -301,6 +293,42 @@ public void EndRound(TimeSpan? countdownTime = null)
Timer.Spawn(countdownTime.Value, AfterEndRoundRestart, _countdownTokenSource.Token);
}

/// <summary>
/// Starts a behavior to end the round
/// </summary>
/// <param name="behavior">The way in which the round will end</param>
/// <param name="time"></param>
/// <param name="sender"></param>
/// <param name="textCall"></param>
/// <param name="textAnnounce"></param>
public void DoRoundEndBehavior(RoundEndBehavior behavior,
TimeSpan time,
string sender = "comms-console-announcement-title-centcom",
string textCall = "round-end-system-shuttle-called-announcement",
string textAnnounce = "round-end-system-shuttle-already-called-announcement")
{
switch (behavior)
{
case RoundEndBehavior.InstantEnd:
EndRound();
break;
case RoundEndBehavior.ShuttleCall:
// Check is shuttle called or not. We should only dispatch announcement if it's already called
if (IsRoundEndRequested())
{
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString(textAnnounce),
Loc.GetString(sender),
colorOverride: Color.Gold);
}
else
{
RequestRoundEnd(time, null, false, textCall,
Loc.GetString(sender));
}
break;
}
}

private void AfterEndRoundRestart()
{
if (_gameTicker.RunLevel != GameRunLevel.PostRound) return;
Expand Down Expand Up @@ -329,7 +357,7 @@ public override void Update(float frameTime)
{
if (!_shuttle.EmergencyShuttleArrived && ExpectedCountdownEnd is null)
{
RequestRoundEnd(null, false, true);
RequestRoundEnd(null, false, "round-end-system-shuttle-auto-called-announcement");
_autoCalledBefore = true;
}

Expand All @@ -343,4 +371,21 @@ public sealed class RoundEndSystemChangedEvent : EntityEventArgs
{
public static RoundEndSystemChangedEvent Default { get; } = new();
}
public enum RoundEndBehavior : byte
{
/// <summary>
/// Instantly end round
/// </summary>
InstantEnd,

/// <summary>
/// Call shuttle with custom announcement
/// </summary>
ShuttleCall,

/// <summary>
/// Do nothing
/// </summary>
Nothing
}
}
4 changes: 3 additions & 1 deletion Content.Server/StationEvents/Events/LoneOpsSpawnRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Content.Server.GameTicking.Rules;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.StationEvents.Components;
using Content.Server.RoundEnd;

namespace Content.Server.StationEvents.Events;

Expand Down Expand Up @@ -36,7 +37,8 @@ protected override void Started(EntityUid uid, LoneOpsSpawnRuleComponent compone
var nukeopsEntity = _gameTicker.AddGameRule(component.GameRuleProto);
component.AdditionalRule = nukeopsEntity;
var nukeopsComp = EntityManager.GetComponent<NukeopsRuleComponent>(nukeopsEntity);
nukeopsComp.EndsRound = false;
nukeopsComp.SpawnOutpost = false;
nukeopsComp.RoundEndBehavior = RoundEndBehavior.Nothing;
_gameTicker.StartGameRule(nukeopsEntity);
}

Expand Down
2 changes: 1 addition & 1 deletion Resources/Locale/en-US/nukeops/nuke-ops.ftl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nuke-ops-no-more-threat-announcement-shuttle-call = Based on our scans from our long-range sensors, the nuclear threat is now eliminated. We will call emergency shuttle that will arrive shortly. ETA: {$time} {$units}. You can recall the shuttle to extend the shift.
nuke-ops-no-more-threat-announcement = Based on our scans from our long-range sensors, the nuclear threat is now eliminated. Shuttle is already called.
nuke-ops-no-more-threat-announcement = Based on our scans from our long-range sensors, the nuclear threat is now eliminated. Shuttle is already called.
3 changes: 3 additions & 0 deletions Resources/Locale/ru-RU/ADT/Clothing/Belt/belt.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ ent-ADTClothingBeltSecAuditorHolster = кобура аудитора СБ
ent-ADTClothingBeltQuiverCupidon = колчан купидона
.desc = Для доставки влюбленностей, и пусть никто не уйдет без стрелы в сердце!
.suffix = { "День Святого Валентина" }
ent-ClothingBeltChef = пояс шеф-повара
.desc = Пояс для быстрого доступа к ножу, соусам и приправам.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ent-CryogenicSleepUnit = капсула криогенного сна
.desc = Супер-охлаждаемый контейнер, обеспечивающий сохранность членов экипажа во время космических путешествий.
ent-CryogenicSleepUnitSpawner = { ent-CryogenicSleepUnit }
.suffix = Спавнер, Начало раунда, Все должности
.desc = { ent-CryogenicSleepUnit.desc }
ent-CryogenicSleepUnitSpawnerLateJoin = { ent-CryogenicSleepUnit }
.suffix = Спавнер, Позднее присоединение
.desc = { ent-CryogenicSleepUnit.desc }
1 change: 1 addition & 0 deletions Resources/Locale/ru-RU/administration/ui/actions.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ admin-player-actions-ahelp = ПМ
admin-player-actions-respawn = Респаун
admin-player-actions-teleport = Телепортироваться к
admin-player-actions-confirm = Вы уверены?
admin-player-actions-follow = Следовать за
2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/advertisements/vending/curadrobe.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
advertisement-curadrobe-1 = Очки для глаз? Чтиво для души? CuraDrobe даст вам все!
advertisement-curadrobe-2 = Удивите и очаруйте посетителей библиотеки с расширенной линейкой ручек от CuraDrobe!
30 changes: 27 additions & 3 deletions Resources/Locale/ru-RU/disease/miasma.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
ammonia-smell = Что-то резко попахивает!!
rotting-rotting = [color=orange]Тело гниёт![/color]
rotting-bloated = [color=orangered]Тело вздулось![/color]
rotting-extremely-bloated = [color=red]Тело сильно вздулось![/color]
perishable-1 = [color=green]{ CAPITALIZE(OBJECT($target)) } тело выглядит ещё свежим.[/color]
perishable-2 = [color=orangered]{ CAPITALIZE(OBJECT($target)) } тело выглядит не особо свежим.[/color]
perishable-3 = [color=red]{ CAPITALIZE(OBJECT($target)) } тело выглядит совсем не свежим.[/color]
perishable-1-nonmob = [color=green]{ CAPITALIZE(SUBJECT($target)) } выглядит ещё свежо.[/color]
perishable-2-nonmob = [color=orangered]{ CAPITALIZE(SUBJECT($target)) } выглядит не особо свежо.[/color]
perishable-3-nonmob = [color=red]{ CAPITALIZE(SUBJECT($target)) } выглядит не особо свежо.[/color]
rotting-rotting = [color=orange]{ CAPITALIZE(SUBJECT($target)) } { $gender ->
[male] гниёт
[female] гниёт
[epicene] гниют
*[neuter] гниёт
}![/color]
rotting-bloated = [color=orangered]{ CAPITALIZE(SUBJECT($target)) } { $gender ->
[male] вздулся
[female] вздулась
[epicene] вздулись
*[neuter] вздулось
}![/color]
rotting-extremely-bloated = [color=red]{ CAPITALIZE(SUBJECT($target)) } сильно { $gender ->
[male] вздулся
[female] вздулась
[epicene] вздулись
*[neuter] вздулось
}![/color]
rotting-rotting-nonmob = [color=orange]{ CAPITALIZE(SUBJECT($target)) } гниёт![/color]
rotting-bloated-nonmob = [color=orangered]{ CAPITALIZE(SUBJECT($target)) } вздулось![/color]
rotting-extremely-bloated-nonmob = [color=red]{ CAPITALIZE(SUBJECT($target)) } сильно вздулось![/color]
2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/nukeops/nuke-ops.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nuke-ops-no-more-threat-announcement-shuttle-call = Исходя из показателей наших датчиков дальнего действия, ядерная угроза была устранена. Эвакуационный шаттл прибудет в ближайшее время. Время прибытия: {$time} {$units}. Вы можете отозвать шаттл и продолжить смену.
nuke-ops-no-more-threat-announcement = Исходя из показателей наших датчиков дальнего действия, ядерная угроза была устранена. Эвакуационный шаттл уже вызван.
8 changes: 8 additions & 0 deletions Resources/Locale/ru-RU/round-end/cryostorage.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cryostorage-insert-message-permanent = [color=white]Вы внутри [bold][color=cyan]капсулы криогенного сна[/color][/bold]. Если вы [bold]отключитесь[/bold], [bold]уйдёте в призраки[/bold], или [bold]прождёте { $time } минут[/bold], [color=red]ваше тело будет удалено[/color] и слот вашей должности будет открыт. Чтобы этого не произошло, вы можете в любой момент покинуть капсулу.[/color]
cryostorage-insert-message-temp = [color=white]Вы внутри [bold][color=cyan]капсулы криогенного сна[/color][/bold]. Если вы [bold]уйдёте в призраки[/bold] или [bold]прождёте { $time } минут[/bold], [color=red]ваше тело будет удалено[/color] и слот вашей должности будет открыт. Если вы [bold][color=cyan]отключитесь[/color][/bold], ваше тело будет надёжно храниться до тех пор, пока вы не переподключитесь.[/color]
cryostorage-ui-window-title = Капсула криогенного сна
cryostorage-ui-label-slot-name = [bold]{ CAPITALIZE($slot) }:[/bold]
cryostorage-ui-button-remove = Снять
cryostorage-ui-filler-hand = в руке
cryostorage-ui-label-no-bodies = В криохранилище нет тел
cryostorage-popup-access-denied = Доступ запрещён!
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ ent-PortableFlasher = переносная вспышка
ent-Naa-Leys_Tunbaton = дубинка-шокер На-Леи
.desc = Электрошоковая дубинка На-Леи для обездвиживания людей. Идеально для избиения клоунов.
.suffix = { "Джей" }
ent-SciFlash = вспышка
.desc = Сверхъяркая лампочка с кнопкой включения, вызывает оцепенение и кратковременную потерю зрения. Бесполезна, когда перегорает. Урезанная версия на 2 использования.
.suffix = { "2 заряда" }

0 comments on commit 9481c5d

Please sign in to comment.