mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* Resolve warnings, mostly obsolete
* resolve via the entitymanager directly, not wref
* Ent<T>, why not
* minimize test diff
* StorageTest: consistent print order
* ChameleonProj: use Disguised value consistently
* GasArrayTest: TryComp
* OrganPickingMarker: cache ILocalizationManager
avoids warning from Loc.TryGetString, and avoids multiple IoCManager hits
* FormattedMessage.FromMarkup to FromMarkupOrThrow
* rerun tests 🙏
110 lines
3.6 KiB
C#
110 lines
3.6 KiB
C#
using Content.Shared.Damage.Components;
|
|
using Content.Shared.Damage.Events;
|
|
using Content.Shared.Destructible;
|
|
using Content.Shared.Glue;
|
|
using Content.Shared.Lube;
|
|
using Content.Shared.Nutrition;
|
|
using Content.Shared.Rejuvenate;
|
|
using Content.Shared.Slippery;
|
|
using Content.Shared.StatusEffect;
|
|
using Content.Shared.StatusEffectNew;
|
|
using Content.Shared.StatusEffectNew.Components;
|
|
|
|
namespace Content.Shared.Damage.Systems;
|
|
|
|
public abstract partial class SharedGodmodeSystem : EntitySystem
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<GodmodeComponent, BeforeDamageChangedEvent>(OnBeforeDamageChanged);
|
|
SubscribeLocalEvent<GodmodeComponent, BeforeStatusEffectAddedEvent>(OnBeforeStatusEffect);
|
|
SubscribeLocalEvent<GodmodeComponent, BeforeStaminaDamageEvent>(OnBeforeStaminaDamage);
|
|
SubscribeLocalEvent<GodmodeComponent, IngestibleEvent>(BeforeEdible);
|
|
SubscribeLocalEvent<GodmodeComponent, SlipAttemptEvent>(OnSlipAttempt);
|
|
SubscribeLocalEvent<GodmodeComponent, DestructionAttemptEvent>(OnDestruction);
|
|
}
|
|
|
|
private void OnSlipAttempt(EntityUid uid, GodmodeComponent component, SlipAttemptEvent args)
|
|
{
|
|
args.NoSlip = true;
|
|
}
|
|
|
|
private void OnBeforeDamageChanged(EntityUid uid, GodmodeComponent component, ref BeforeDamageChangedEvent args)
|
|
{
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
private void OnBeforeStatusEffect(EntityUid uid, GodmodeComponent component, ref BeforeStatusEffectAddedEvent args)
|
|
{
|
|
if (ProtoMan.Index(args.Effect).HasComp<RejuvenateRemovedStatusEffectComponent>(Factory))
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
[SubscribeLocalEvent]
|
|
[Obsolete("BeforeOldStatusEffectAddedEvent is obsolete.")]
|
|
private void OnBeforeOldStatusEffect(Entity<GodmodeComponent> ent, ref BeforeOldStatusEffectAddedEvent args)
|
|
{
|
|
// Old status effect system doesn't distinguish between good and bad status effects
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
private void OnBeforeStaminaDamage(EntityUid uid, GodmodeComponent component, ref BeforeStaminaDamageEvent args)
|
|
{
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
private void OnDestruction(Entity<GodmodeComponent> ent, ref DestructionAttemptEvent args)
|
|
{
|
|
args.Cancel();
|
|
}
|
|
|
|
private void BeforeEdible(Entity<GodmodeComponent> ent, ref IngestibleEvent args)
|
|
{
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnGluedEffectAttemptEvent(Entity<GodmodeComponent> entity, ref GluedEffectAttemptEvent args)
|
|
{
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnGluedEffectAttemptEvent(Entity<GodmodeComponent> entity, ref LubedEffectAttemptEvent args)
|
|
{
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
public virtual void EnableGodmode(EntityUid uid, GodmodeComponent? godmode = null)
|
|
{
|
|
// Rejuv to cover other stuff
|
|
RaiseLocalEvent(uid, new RejuvenateEvent());
|
|
}
|
|
|
|
public virtual void DisableGodmode(EntityUid uid, GodmodeComponent? godmode = null)
|
|
{
|
|
if (!Resolve(uid, ref godmode, false))
|
|
return;
|
|
|
|
RemComp<GodmodeComponent>(uid);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Toggles godmode for a given entity.
|
|
/// </summary>
|
|
/// <param name="uid">The entity to toggle godmode for.</param>
|
|
/// <returns>true if enabled, false if disabled.</returns>
|
|
public bool ToggleGodmode(EntityUid uid)
|
|
{
|
|
if (TryComp<GodmodeComponent>(uid, out var godmode))
|
|
{
|
|
DisableGodmode(uid, godmode);
|
|
return false;
|
|
}
|
|
|
|
EnableGodmode(uid, godmode);
|
|
return true;
|
|
}
|
|
}
|