Files
wwdpublic/Content.Server/Silicon/DeadStartupButtonSystem/DeadStartupButtonSystem.cs
Kai5 091a8ff433 [GoobPort] WIZ REAL (#465)
* Уэээээээ

* Почти настрадались

* Скоро конец....

* СКОРО

* Мышки плакали, кололись, но продолжали упорно жрать кактус

* Все ближе!

* Это такой конец?

* Книжка говна

* фиксики

* ОНО ЖИВОЕ

* Телепорт

* разное

* Added byond

* ивенты теперь работают

* Разфикс телепорта

* Свет мой зеркальце скажи, да всю правду доложи - Я ль робастней всех на свете?

* Разное

* Еще многа всего

* Многа разнава

* Скоро конец....

* ЭТО КОНЕЦ

* Фикс линтера (ну, или я на это надеюсь)

* Еще один фикс линтера

* Победа!

* фиксики

* пу пу пу

* Фикс подмастерья

* Мисклик

* Высокочастотный меч

* Неймспейсы

* Пул способностей мага
2025-04-26 10:18:58 +03:00

80 lines
3.4 KiB
C#

using Content.Server.Lightning;
using Content.Server.Popups;
using Content.Server.PowerCell;
using Content.Server.Silicon.Charge;
using Content.Shared.Silicon.DeadStartupButton;
using Content.Shared.Audio;
using Content.Shared.Damage;
using Content.Shared.Electrocution;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Random;
namespace Content.Server.Silicon.DeadStartupButtonSystem;
public sealed class DeadStartupButtonSystem : SharedDeadStartupButtonSystem
{
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly MobThresholdSystem _mobThreshold = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly LightningSystem _lightning = default!;
[Dependency] private readonly SiliconChargeSystem _siliconChargeSystem = default!;
[Dependency] private readonly PowerCellSystem _powerCell = default!;
/// <inheritdoc/>
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DeadStartupButtonComponent, OnDoAfterButtonPressedEvent>(OnDoAfter);
SubscribeLocalEvent<DeadStartupButtonComponent, ElectrocutedEvent>(OnElectrocuted);
SubscribeLocalEvent<DeadStartupButtonComponent, MobStateChangedEvent>(OnMobStateChanged);
}
private void OnDoAfter(EntityUid uid, DeadStartupButtonComponent comp, OnDoAfterButtonPressedEvent args)
{
if (args.Handled || args.Cancelled
|| !TryComp<MobStateComponent>(uid, out var mobStateComponent)
|| !_mobState.IsDead(uid, mobStateComponent)
|| !TryComp<MobThresholdsComponent>(uid, out var mobThresholdsComponent)
|| !TryComp<DamageableComponent>(uid, out var damageable)
|| !_mobThreshold.TryGetThresholdForState(uid, MobState.Critical, out var criticalThreshold, mobThresholdsComponent))
return;
if (damageable.TotalDamage < criticalThreshold)
_mobState.ChangeMobState(uid, MobState.Alive, mobStateComponent);
else
{
_audio.PlayPvs(comp.BuzzSound, uid, AudioHelpers.WithVariation(0.05f, _robustRandom));
_popup.PopupEntity(Loc.GetString("dead-startup-system-reboot-failed", ("target", MetaData(uid).EntityName)), uid);
Spawn("EffectSparks", Transform(uid).Coordinates);
}
}
private void OnElectrocuted(EntityUid uid, DeadStartupButtonComponent comp, ElectrocutedEvent args)
{
if (!TryComp<MobStateComponent>(uid, out var mobStateComponent)
|| !_mobState.IsDead(uid, mobStateComponent)
|| !_siliconChargeSystem.TryGetSiliconBattery(uid, out var bateria)
|| bateria.CurrentCharge <= 0)
return;
_lightning.ShootRandomLightnings(uid, 2, 4, hitCoordsChance: 0);
_powerCell.TryUseCharge(uid, bateria.CurrentCharge);
}
private void OnMobStateChanged(EntityUid uid, DeadStartupButtonComponent comp, MobStateChangedEvent args)
{
if (args.NewMobState != MobState.Alive)
return;
_popup.PopupEntity(Loc.GetString("dead-startup-system-reboot-success", ("target", MetaData(uid).EntityName)), uid);
_audio.PlayPvs(comp.Sound, uid);
}
}