Skip to content

Commit

Permalink
какой то щит код, которы можно было заменить офофским.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bolper committed Aug 26, 2024
1 parent 41f6ed2 commit c517ea0
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Content.Server/ADT/Addiction/AddictionSystem.cs
Original file line number Diff line number Diff line change
@@ -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<AddictedComponent>();
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);
}
}
}
37 changes: 37 additions & 0 deletions Content.Server/ADT/Addiction/EntityEffects.cs
Original file line number Diff line number Diff line change
@@ -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<LocId> 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<AddictedComponent>(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<AddictedComponent>(args.TargetEntity);
comp1.PopupMessages.AddRange(PopupMessages);
}
}
}
11 changes: 11 additions & 0 deletions Content.Shared/ADT/Addiction/AddictedComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Content.Shared.ADT.Addiction.Components;

/// <summary>
/// Кароче, это не компонент как я понял, а затычка, для хранения данных. Нихуя не делает, добавлять никуда не нужно. используется для системы курения.
/// </summary>
[RegisterComponent]
public sealed partial class AddictedComponent : Component
{
public List<LocId> PopupMessages = new();
public TimeSpan NextPopup = TimeSpan.Zero;
}
6 changes: 6 additions & 0 deletions Resources/Locale/ru-RU/ADT/Addiction/AddictionEffect.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
addictionEffect-message-1 = Вы чувсвуете привязанность к этому.
addictionEffect-message-2 = Вы чувсвуете себя более спокойно.
addictionEffect-message-3 = Вы чувсвуете себя более расслабленным.
addictionEffect-message-4 = Вы привыкаете к этому.
addictionEffect-message-5 = Вы чувсвуете себя удовлетворенно.
addictionEffect-message-6 = У вас сформировывается зависимость к этому.
11 changes: 11 additions & 0 deletions Resources/Prototypes/Reagents/narcotics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c517ea0

Please sign in to comment.