-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spacelaw Change Rule #97
Changes from 3 commits
63bd861
247af59
0720f8a
3032c9b
d9d2e34
0223e54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Content.Server._CorvaxNext.StationEvents.Events; | ||
using Content.Shared.Dataset; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server._CorvaxNext.StationEvents.Components | ||
{ | ||
[RegisterComponent, Access(typeof(SpaceLawChangeRule))] | ||
public sealed partial class SpaceLawChangeRuleComponent : Component | ||
{ | ||
/// <summary> | ||
/// Localization key of a random message selected for the current event | ||
/// </summary> | ||
/// <remarks> | ||
/// Do not set an initial value for this field! | ||
/// </remarks> | ||
[DataField] | ||
public string? RandomMessage { get; set; } | ||
|
||
/// <summary> | ||
/// A localized dataset containing the initial list of all laws for the event | ||
/// </summary> | ||
[DataField] | ||
public ProtoId<LocalizedDatasetPrototype> LawLocalizedDataset { get; set; } | ||
|
||
/// <summary> | ||
/// Time before changes to the law come into force. | ||
/// Necessary for establish the delay in sending information about the law coming into force | ||
/// </summary> | ||
[DataField] | ||
public int AdaptationTime { get; set; } = 10; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,143 @@ | ||||||||||||||||||
using System.Linq; | ||||||||||||||||||
using Content.Server.Chat.Systems; | ||||||||||||||||||
using Content.Server.Fax; | ||||||||||||||||||
using Content.Shared.GameTicking.Components; | ||||||||||||||||||
using Content.Server.GameTicking; | ||||||||||||||||||
using Content.Shared.Paper; | ||||||||||||||||||
using Content.Shared.Dataset; | ||||||||||||||||||
using Robust.Shared.Random; | ||||||||||||||||||
using Content.Shared.Fax.Components; | ||||||||||||||||||
using Content.Server.StationEvents.Events; | ||||||||||||||||||
using Robust.Shared.Timing; | ||||||||||||||||||
using Robust.Shared.Prototypes; | ||||||||||||||||||
using Content.Server._CorvaxNext.StationEvents.Components; | ||||||||||||||||||
|
||||||||||||||||||
namespace Content.Server._CorvaxNext.StationEvents.Events | ||||||||||||||||||
{ | ||||||||||||||||||
public sealed class SpaceLawChangeRule : StationEventSystem<SpaceLawChangeRuleComponent> | ||||||||||||||||||
{ | ||||||||||||||||||
[Dependency] private readonly ChatSystem _chat = default!; | ||||||||||||||||||
[Dependency] private readonly IRobustRandom _robustRandom = default!; | ||||||||||||||||||
[Dependency] private readonly FaxSystem _faxSystem = default!; | ||||||||||||||||||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||||||||||||||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||||||||||||||||||
[Dependency] private readonly GameTicker _gameTicker = default!; | ||||||||||||||||||
[Dependency] private readonly IGameTiming _gameTiming = default!; | ||||||||||||||||||
|
||||||||||||||||||
/// <summary> | ||||||||||||||||||
/// Sequence of laws to be used for the current event | ||||||||||||||||||
/// </summary> | ||||||||||||||||||
private List<string> _sequenceLaws = new(); | ||||||||||||||||||
|
||||||||||||||||||
protected override void Started(EntityUid uid, SpaceLawChangeRuleComponent component, | ||||||||||||||||||
GameRuleComponent gameRule, GameRuleStartedEvent args) | ||||||||||||||||||
{ | ||||||||||||||||||
base.Started(uid, component, gameRule, args); | ||||||||||||||||||
|
||||||||||||||||||
// Loading a prototype dataset | ||||||||||||||||||
if (!_prototypeManager.TryIndex<LocalizedDatasetPrototype>(component.LawLocalizedDataset, out var dataset)) | ||||||||||||||||||
{ | ||||||||||||||||||
Logger.Error($"LocalizedDatasetPrototype not found: {component.LawLocalizedDataset}"); | ||||||||||||||||||
return; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
// Initializing the list of laws if it is empty | ||||||||||||||||||
if (_sequenceLaws.Count == 0) | ||||||||||||||||||
{ | ||||||||||||||||||
_sequenceLaws.AddRange(dataset.Values); | ||||||||||||||||||
} | ||||||||||||||||||
// Getting active laws from currently active rules | ||||||||||||||||||
var activeLaws = GetActiveSpaceLaws(); | ||||||||||||||||||
|
||||||||||||||||||
// Excluding active laws from selection | ||||||||||||||||||
var availableLaws = _sequenceLaws.Except(activeLaws).ToList(); | ||||||||||||||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
if (availableLaws.Count == 0) | ||||||||||||||||||
{ | ||||||||||||||||||
availableLaws = _sequenceLaws; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
// Selecting a random law from the available ones | ||||||||||||||||||
var randomLaw = _robustRandom.Pick(availableLaws); | ||||||||||||||||||
component.RandomMessage = randomLaw; | ||||||||||||||||||
|
||||||||||||||||||
var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan); | ||||||||||||||||||
|
||||||||||||||||||
var message = Loc.GetString("station-event-space-law-change-announcement", | ||||||||||||||||||
("essence", Loc.GetString(component.RandomMessage)), | ||||||||||||||||||
("time", component.AdaptationTime)); | ||||||||||||||||||
|
||||||||||||||||||
var faxMessage = Loc.GetString("station-event-space-law-change-fax-announcement", | ||||||||||||||||||
("faxEssence", message), | ||||||||||||||||||
("stationTime", stationTime.ToString("hh\\:mm\\:ss"))); | ||||||||||||||||||
|
||||||||||||||||||
// Sending a global announcement | ||||||||||||||||||
_chat.DispatchGlobalAnnouncement(message, playSound: true, colorOverride: Color.Gold); | ||||||||||||||||||
SendSpaceLawChangeFax(faxMessage); | ||||||||||||||||||
|
||||||||||||||||||
// Start a timer to send a confirmation message after AdaptationTime minutes | ||||||||||||||||||
Timer.Spawn(TimeSpan.FromMinutes(component.AdaptationTime), () => SendConfirmationMessage(uid)); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
/// <summary> | ||||||||||||||||||
/// Getting active laws from currently active rules | ||||||||||||||||||
/// </summary> | ||||||||||||||||||
private List<string> GetActiveSpaceLaws() | ||||||||||||||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
{ | ||||||||||||||||||
var activeLaws = new List<string>(); | ||||||||||||||||||
foreach (var rule in _gameTicker.GetActiveGameRules()) | ||||||||||||||||||
{ | ||||||||||||||||||
if (_entityManager.TryGetComponent(rule, out SpaceLawChangeRuleComponent? spaceLawComponent)) | ||||||||||||||||||
{ | ||||||||||||||||||
if (!string.IsNullOrEmpty(spaceLawComponent.RandomMessage)) | ||||||||||||||||||
{ | ||||||||||||||||||
activeLaws.Add(spaceLawComponent.RandomMessage); | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
return activeLaws; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
/// <summary> | ||||||||||||||||||
/// Sending a confirmation message about the entry into force of changes in Space Law | ||||||||||||||||||
/// </summary> | ||||||||||||||||||
private void SendConfirmationMessage(EntityUid uid) | ||||||||||||||||||
{ | ||||||||||||||||||
if (!_entityManager.TryGetComponent(uid, out SpaceLawChangeRuleComponent? component) || component.RandomMessage == null) | ||||||||||||||||||
{ | ||||||||||||||||||
Logger.Error($"Failed to send confirmation message for SpaceLawChangeRule for entity {uid}: Component or RandomMessage is null."); | ||||||||||||||||||
return; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
var confirmationMessage = Loc.GetString("station-event-space-law-change-announcement-confirmation", ("essence", Loc.GetString(component.RandomMessage))); | ||||||||||||||||||
var faxConfirmationMessage = Loc.GetString("station-event-space-law-change-announcement-fax-confirmation", ("faxEssence", confirmationMessage)); | ||||||||||||||||||
_chat.DispatchGlobalAnnouncement(confirmationMessage, playSound: true, colorOverride: Color.Gold); | ||||||||||||||||||
SendSpaceLawChangeFax(faxConfirmationMessage); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
/// <summary> | ||||||||||||||||||
/// Sending a fax announcing changes in Space Law | ||||||||||||||||||
/// </summary> | ||||||||||||||||||
private void SendSpaceLawChangeFax(string message) | ||||||||||||||||||
{ | ||||||||||||||||||
var printout = new FaxPrintout( | ||||||||||||||||||
message, | ||||||||||||||||||
Loc.GetString("materials-paper"), | ||||||||||||||||||
null, | ||||||||||||||||||
null, | ||||||||||||||||||
"paper_stamp-centcom", | ||||||||||||||||||
new List<StampDisplayInfo> | ||||||||||||||||||
Comment on lines
+131
to
+135
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
по сути должно работать |
||||||||||||||||||
{ | ||||||||||||||||||
new() { StampedName = Loc.GetString("stamp-component-stamped-name-centcom"), StampedColor = Color.FromHex("#006600") } | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
var faxes = _entityManager.EntityQuery<FaxMachineComponent>(); | ||||||||||||||||||
foreach (var fax in faxes) | ||||||||||||||||||
{ | ||||||||||||||||||
if (!fax.ReceiveStationGoal) | ||||||||||||||||||
continue; | ||||||||||||||||||
_faxSystem.Receive(fax.Owner, printout, Loc.GetString("station-event-space-law-change-fax-sender"), fax); | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,66 @@ | ||||||
station-event-space-law-change-fax-start = [color=#b8972d]███[/color][color=#1d7a1d]░███░░░░██░░░░[/color][color=#b8972d] ★ ★ ★[/color][color=#1d7a1d] | ||||||
░██░████░░░██░░░░ [head=3]Бланк документа[/head] | ||||||
░░█░██░██░░██░█░░ [head=3]NanoTrasen[/head] | ||||||
░░░░██░░██░██░██░ [bold]ЦК-КОМ[/bold] | ||||||
░░░░██░░░████░[/color][color=#b8972d]███[/color][color=#b8972d] ★ ★ ★[/color] | ||||||
==================================================[bold] | ||||||
УВЕДОМЛЕНИЕ О ИЗМЕНЕНИИ КОРПОРАТИВНОГО ЗАКОНА[/bold] | ||||||
================================================== | ||||||
station-event-space-law-change-fax-end = | ||||||
Слава NanoTrasen! | ||||||
==================================================[italic] | ||||||
Место для печати[/italic] | ||||||
|
||||||
station-event-space-law-change-fax-sender = Центральное Командование | ||||||
|
||||||
|
||||||
# Уведомление о начале переходного периода | ||||||
station-event-space-law-change-fax-announcement = | ||||||
{ station-event-space-law-change-fax-start } | ||||||
{ $faxEssence } | ||||||
Продолжительность смены на момент отправки факса: { $stationTime } | ||||||
{ station-event-space-law-change-fax-end } | ||||||
|
||||||
station-event-space-law-change-announcement = В связи с последними изменениями в корпоративной политике, { $essence } теперь признается (или признаются) незаконным(-ыми) по кодовому номеру «XX1» Корпоративного закона. В ваших интересах незамедлительно исправить ситуацию до вступления изменений в силу через { $time } минут. Служба безопасности и Командование обязаны приложить все возможные усилия для обеспечения полного соответствия станции требованиям закона к моменту окончания периода адаптации. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
|
||||||
# Уведомление о завершении переходного периода | ||||||
station-event-space-law-change-announcement-fax-confirmation = | ||||||
{ station-event-space-law-change-fax-start } | ||||||
{ $faxEssence } | ||||||
{ station-event-space-law-change-fax-end } | ||||||
|
||||||
station-event-space-law-change-announcement-confirmation = Уведомляем вас о вступлении в силу изменений в Корпоративном законе, связанных с недавними изменениями в корпоративной политике. Теперь { $essence } признается (или признаются) незаконным(-ыми) по кодовому номеру «XX1» Корпоративного закона. | ||||||
|
||||||
|
||||||
# spaceLawChangeLaws localizedDataset | ||||||
station-event-space-law-change-essence-1 = юбки и шорты | ||||||
station-event-space-law-change-essence-2 = кухонные ножи | ||||||
station-event-space-law-change-essence-3 = шляпы и береты | ||||||
station-event-space-law-change-essence-4 = зимние куртки | ||||||
station-event-space-law-change-essence-5 = алкогольные напитки | ||||||
station-event-space-law-change-essence-6 = сигареты | ||||||
station-event-space-law-change-essence-7 = острая пища | ||||||
station-event-space-law-change-essence-8 = деятельность руководителей отделов, которые не уделяют должного внимания патриотическому воспитанию своих сотрудников во славу NanoTrasen | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-9 = не ношение головного убора | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-10 = неисполнение главой отдела личного приветствия каждого члена экипажа, посещающего его отдел | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+44
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. удалить нахуй |
||||||
station-event-space-law-change-essence-11 = смерть | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-12 = сон | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-13 = безработица | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-14 = не ношение сотрудниками отдела Службы безопаности униформы клоуна | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-15 = обувь | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-16 = ведение бумажной документации | ||||||
station-event-space-law-change-essence-17 = общение не шепотом вне каналов связи | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-18 = попытки убедить Капитана станции в существовании мировых заговоров | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-19 = введение в оборот фруктов и овощей нового урожая без предварительной дегустации каждого вида Главой персонала | ||||||
station-event-space-law-change-essence-20 = общение с ИИ без предварительного соблюдения ритуала "Трижды назови свои законы" | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-21 = попытки объяснить Капитану станции, как работает станция | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-22 = отказ реже чем раз в 5 минут танцевать в присутствии клоуна, если он объявил "Танцевальное безумие" | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-23 = неисполнение приветствия "Привет, товарищи" при входе в Бриг | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-24 = рассказы о событиях, которые противоречат официальным отчетам отдела Службы безопасности | ||||||
station-event-space-law-change-essence-25 = отказ участвовать в поедании любого блюда с заявленным шеф-поваром "секретным NanoTrasen-ингредиентом" | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-26 = обращение к утилизатору не как "Джентльмен глубин" при каждом личном обращении | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-27 = перерывы | ||||||
station-event-space-law-change-essence-28 = проведение хирургических операций | ||||||
station-event-space-law-change-essence-29 = лечение при помощи лекарственных средств | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
station-event-space-law-change-essence-30 = использование оглушающего оружия | ||||||
AwareFoxy marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- type: localizedDataset | ||
id: spaceLawChangeLaws | ||
values: | ||
prefix: station-event-space-law-change-essence- | ||
count: 30 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
- type: entity | ||
id: SpaceLawChange | ||
parent: BaseGameRule | ||
abstract: true | ||
components: | ||
- type: StationEvent | ||
weight: 5 | ||
maxOccurrences: 1 # can only happen 1 time per round | ||
duration: null # the rule has to last the whole round | ||
- type: GameRule | ||
minPlayers: 50 | ||
- type: SpaceLawChangeRule | ||
lawLocalizedDataset: spaceLawChangeLaws | ||
adaptationTime: 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.