From 587de74ac3d14ccdb89bc33492aad4182337ffdf Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Mon, 28 Feb 2022 14:21:44 +1300 Subject: [PATCH] Add metadata flags to actions component (#6922) --- Content.Server/Actions/ActionsSystem.cs | 20 ++++++++++++++++++++ Content.Server/Flash/FlashSystem.cs | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Content.Server/Actions/ActionsSystem.cs b/Content.Server/Actions/ActionsSystem.cs index 0b15b5770b..3bb4b24658 100644 --- a/Content.Server/Actions/ActionsSystem.cs +++ b/Content.Server/Actions/ActionsSystem.cs @@ -10,12 +10,32 @@ namespace Content.Server.Actions public sealed class ActionsSystem : SharedActionsSystem { [Dependency] private readonly IChatManager _chatMan = default!; + [Dependency] private readonly MetaDataSystem _metaSystem = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnPlayerAttached); + SubscribeLocalEvent(OnStartup); + SubscribeLocalEvent(OnShutdown); + SubscribeLocalEvent(OnMetaFlagRemoval); + } + + private void OnMetaFlagRemoval(EntityUid uid, ActionsComponent component, ref MetaFlagRemoveAttemptEvent args) + { + if (component.LifeStage == ComponentLifeStage.Running) + args.Cancelled = true; + } + + private void OnStartup(EntityUid uid, ActionsComponent component, ComponentStartup args) + { + _metaSystem.AddFlag(uid, MetaDataFlags.EntitySpecific); + } + + private void OnShutdown(EntityUid uid, ActionsComponent component, ComponentShutdown args) + { + _metaSystem.RemoveFlag(uid, MetaDataFlags.EntitySpecific); } private void OnPlayerAttached(EntityUid uid, ActionsComponent component, PlayerAttachedEvent args) diff --git a/Content.Server/Flash/FlashSystem.cs b/Content.Server/Flash/FlashSystem.cs index d73ef1de48..8b624661df 100644 --- a/Content.Server/Flash/FlashSystem.cs +++ b/Content.Server/Flash/FlashSystem.cs @@ -44,8 +44,8 @@ namespace Content.Server.Flash private void OnMetaFlagRemoval(EntityUid uid, FlashableComponent component, ref MetaFlagRemoveAttemptEvent args) { - if (component.LifeStage > ComponentLifeStage.Initialized) return; - args.Cancelled = true; + if (component.LifeStage == ComponentLifeStage.Running) + args.Cancelled = true; } private void OnFlashableStartup(EntityUid uid, FlashableComponent component, ComponentStartup args)