Godmode refactor (#14651)

This commit is contained in:
Kara
2023-03-23 11:57:15 -07:00
committed by GitHub
parent 31320a9e9a
commit 48cefca4e4
6 changed files with 114 additions and 64 deletions

View File

@@ -346,6 +346,12 @@ namespace Content.Shared.StatusEffect
// don't log since stuff calling this prolly doesn't care if we don't actually have it
if (!Resolve(uid, ref status, false))
return false;
var ev = new BeforeStatusEffectAddedEvent(key);
RaiseLocalEvent(uid, ref ev);
if (ev.Cancelled)
return false;
if (!_prototypeManager.TryIndex<StatusEffectPrototype>(key, out var proto))
return false;
if (!status.AllowedEffects.Contains(key) && !proto.AlwaysAllowed)
@@ -465,6 +471,12 @@ namespace Content.Shared.StatusEffect
}
}
/// <summary>
/// Raised on an entity before a status effect is added to determine if adding it should be cancelled.
/// </summary>
[ByRefEvent]
public record struct BeforeStatusEffectAddedEvent(string Key, bool Cancelled=false);
public readonly struct StatusEffectAddedEvent
{
public readonly EntityUid Uid;