add: new stimulator effects, mood integration

This commit is contained in:
CaYpeN1
2024-03-21 13:11:08 +05:00
parent 20ff7d1588
commit d7b064d900
5 changed files with 104 additions and 2 deletions

View File

@@ -0,0 +1,72 @@
using System.Threading;
using Content.Server.Stunnable;
using Content.Shared._White.Mood;
using Content.Shared.Alert;
using Content.Shared.Damage.Systems;
using Robust.Shared.Random;
using Timer = Robust.Shared.Timing.Timer;
namespace Content.Server._White.Chemistry;
/// <summary>
/// This handles system?
/// </summary>
public sealed class NarcoticEffect : EntitySystem
{
[Dependency] private readonly StunSystem _stun = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly StaminaSystem _stamina = default!;
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
/// <inheritdoc/>
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<NarcoticEffectComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<NarcoticEffectComponent, ComponentRemove>(OnRemove);
}
private void OnInit(EntityUid uid, NarcoticEffectComponent component, ComponentInit args)
{
int index = _robustRandom.Next(0, component.Effects.Count);
Effects(uid, component, index);
}
private void OnRemove(EntityUid uid, NarcoticEffectComponent component, ComponentRemove args)
{
component.cancelTokenSource.Cancel();
_alertsSystem.ClearAlert(uid, AlertType.Bleeding);
}
private void Effects(EntityUid uid, NarcoticEffectComponent component, int index)
{
RaiseLocalEvent(uid, new MoodEffectEvent("Stimulator"));
CancellationToken token = component.cancelTokenSource.Token;
switch (component.Effects[index])
{
case "Stun":
Timer.SpawnRepeating(10000, () => _stun.TryParalyze(uid, TimeSpan.FromSeconds(component.StunTime), true), token);
break;
case "TremorAndShake":
Timer.SpawnRepeating(6000, () => _stamina.TakeStaminaDamage(uid, 20F), token);
_alertsSystem.ShowAlert(uid, AlertType.Bleeding);
break;
case "Tremor":
Timer.SpawnRepeating(6000, () => _stamina.TakeStaminaDamage(uid, 20F), token);
break;
case "Shake":
_alertsSystem.ShowAlert(uid, AlertType.Bleeding);
break;
case "StunAndShake":
Timer.SpawnRepeating(10000, () => _stun.TryParalyze(uid, TimeSpan.FromSeconds(component.StunTime), true), token);
_alertsSystem.ShowAlert(uid, AlertType.Bleeding);
break;
}
}
}

View File

@@ -0,0 +1,19 @@
using System.Threading;
namespace Content.Server._White.Chemistry;
/// <summary>
/// This is used for...
/// </summary>
[RegisterComponent]
public sealed partial class NarcoticEffectComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField]
public float StunTime = 3f;
[ViewVariables(VVAccess.ReadWrite), DataField]
public CancellationTokenSource cancelTokenSource = new();
[ViewVariables(VVAccess.ReadOnly), DataField]
public List<string> Effects = new() { "Stun", "TremorAndShake", "Tremor", "Shake", "StunAndShake" };
}

View File

@@ -76,8 +76,8 @@
Asphyxiation: 2
- !type:Jitter
- !type:GenericStatusEffect
key: BlurryVision
component: BlurryVision
key: NarcoticEffect
component: NarcoticEffect
- !type:GenericStatusEffect
key: Stun
time: 1

View File

@@ -50,3 +50,10 @@
desc: "Знаю правду, славим великого!"
moodChange: enum.MoodChangeLevel.Big
positiveEffect: true
- type: moodEffect
id: Stimulator
desc: "Я ЧУВСТВУЮ ЭТО, В МОЕЙ КРОВИ НЕЧТО УСКОРЯЮЩЕЕ!!"
moodChange: enum.MoodChangeLevel.Medium
positiveEffect: true
timeout: 4

View File

@@ -64,6 +64,10 @@
id: BlurryVision
alwaysAllowed: true
- type: statusEffect
id: NarcoticEffect
alwaysAllowed: true
#WD EDIT
- type: statusEffect
id: Incorporeal