From c517ea0787b0e2c16e6472f26fc145d8a6956169 Mon Sep 17 00:00:00 2001 From: Bolper Date: Mon, 26 Aug 2024 14:44:35 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=B0=D0=BA=D0=BE=D0=B9=20=D1=82=D0=BE?= =?UTF-8?q?=20=D1=89=D0=B8=D1=82=20=D0=BA=D0=BE=D0=B4,=20=D0=BA=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D1=8B=20=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=B1=D1=8B=D0=BB=D0=BE=20=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BE=D1=84=D0=BE=D1=84=D1=81=D0=BA=D0=B8=D0=BC?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ADT/Addiction/AddictionSystem.cs | 29 +++++++++++++++ Content.Server/ADT/Addiction/EntityEffects.cs | 37 +++++++++++++++++++ .../ADT/Addiction/AddictedComponent.cs | 11 ++++++ .../ru-RU/ADT/Addiction/AddictionEffect.ftl | 6 +++ Resources/Prototypes/Reagents/narcotics.yml | 11 ++++++ 5 files changed, 94 insertions(+) create mode 100644 Content.Server/ADT/Addiction/AddictionSystem.cs create mode 100644 Content.Server/ADT/Addiction/EntityEffects.cs create mode 100644 Content.Shared/ADT/Addiction/AddictedComponent.cs create mode 100644 Resources/Locale/ru-RU/ADT/Addiction/AddictionEffect.ftl diff --git a/Content.Server/ADT/Addiction/AddictionSystem.cs b/Content.Server/ADT/Addiction/AddictionSystem.cs new file mode 100644 index 00000000000..d7997e778c5 --- /dev/null +++ b/Content.Server/ADT/Addiction/AddictionSystem.cs @@ -0,0 +1,29 @@ +using Content.Shared.ADT.Addiction.Components; +using Content.Server.ADT.Addiction.EntityEffects; +using Content.Shared.Popups; +using Robust.Shared.Random; +using Robust.Shared.Timing; +namespace Content.Server.ADT.Addiction; + +public sealed partial class AddictionSystem : EntitySystem +{ + [Dependency] private readonly SharedPopupSystem _popup = default!; + [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly IGameTiming _timing = default!; + + public override void Update(float frameTime) + { + base.Update(frameTime); + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var comp)) + { + if (_timing.CurTime < comp.NextPopup) + continue; + if (comp.PopupMessages.Count <= 0) + continue; + var selfMessage = Loc.GetString(_random.Pick(comp.PopupMessages)); + _popup.PopupEntity(selfMessage, uid, uid); + comp.NextPopup = _timing.CurTime + TimeSpan.FromSeconds(10); + } + } +} diff --git a/Content.Server/ADT/Addiction/EntityEffects.cs b/Content.Server/ADT/Addiction/EntityEffects.cs new file mode 100644 index 00000000000..ce1c2f49035 --- /dev/null +++ b/Content.Server/ADT/Addiction/EntityEffects.cs @@ -0,0 +1,37 @@ +using Content.Shared.ADT.Addiction.Components; +using Content.Shared.StatusEffect; +using Content.Shared.EntityEffects; +using Robust.Shared.Prototypes; +namespace Content.Server.ADT.Addiction.EntityEffects; +public sealed partial class AddictionEffect : EntityEffect +{ + [DataField(required: true)] + public List PopupMessages = new(); + + + protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) + { + return Loc.GetString("reagent-effect-addiction",("chance", Probability)); + } + + public override void Effect(EntityEffectBaseArgs ev) + { + if (ev is not EntityEffectReagentArgs args) + return; + + if (args.EntityManager.TryGetComponent(args.TargetEntity, out var comp)) + { + foreach (var item in PopupMessages) + { + if (comp.PopupMessages.Contains(item)) + continue; + comp.PopupMessages.Add(item); + } + } + else + { + var comp1 = args.EntityManager.EnsureComponent(args.TargetEntity); + comp1.PopupMessages.AddRange(PopupMessages); + } + } +} diff --git a/Content.Shared/ADT/Addiction/AddictedComponent.cs b/Content.Shared/ADT/Addiction/AddictedComponent.cs new file mode 100644 index 00000000000..4c72f144d86 --- /dev/null +++ b/Content.Shared/ADT/Addiction/AddictedComponent.cs @@ -0,0 +1,11 @@ +namespace Content.Shared.ADT.Addiction.Components; + +/// +/// Кароче, это не компонент как я понял, а затычка, для хранения данных. Нихуя не делает, добавлять никуда не нужно. используется для системы курения. +/// +[RegisterComponent] +public sealed partial class AddictedComponent : Component +{ + public List PopupMessages = new(); + public TimeSpan NextPopup = TimeSpan.Zero; +} diff --git a/Resources/Locale/ru-RU/ADT/Addiction/AddictionEffect.ftl b/Resources/Locale/ru-RU/ADT/Addiction/AddictionEffect.ftl new file mode 100644 index 00000000000..160b3f7b12b --- /dev/null +++ b/Resources/Locale/ru-RU/ADT/Addiction/AddictionEffect.ftl @@ -0,0 +1,6 @@ +addictionEffect-message-1 = Вы чувсвуете привязанность к этому. +addictionEffect-message-2 = Вы чувсвуете себя более спокойно. +addictionEffect-message-3 = Вы чувсвуете себя более расслабленным. +addictionEffect-message-4 = Вы привыкаете к этому. +addictionEffect-message-5 = Вы чувсвуете себя удовлетворенно. +addictionEffect-message-6 = У вас сформировывается зависимость к этому. diff --git a/Resources/Prototypes/Reagents/narcotics.yml b/Resources/Prototypes/Reagents/narcotics.yml index 8e73eb13955..376f2367579 100644 --- a/Resources/Prototypes/Reagents/narcotics.yml +++ b/Resources/Prototypes/Reagents/narcotics.yml @@ -216,6 +216,17 @@ plantMetabolism: - !type:PlantAdjustHealth amount: -5 + metabolisms: + Narcotic: + effects: + - !type:AddictionEffect + popupMessages: + - addictionEffect-message-1 + - addictionEffect-message-2 + - addictionEffect-message-3 + - addictionEffect-message-4 + - addictionEffect-message-5 + - addictionEffect-message-6 # TODO: Replace these nonstandardized effects with generic brain damage - type: reagent