Add metadata flags to actions component (#6922)
This commit is contained in:
@@ -10,12 +10,32 @@ namespace Content.Server.Actions
|
|||||||
public sealed class ActionsSystem : SharedActionsSystem
|
public sealed class ActionsSystem : SharedActionsSystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IChatManager _chatMan = default!;
|
[Dependency] private readonly IChatManager _chatMan = default!;
|
||||||
|
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<ActionsComponent, PlayerAttachedEvent>(OnPlayerAttached);
|
SubscribeLocalEvent<ActionsComponent, PlayerAttachedEvent>(OnPlayerAttached);
|
||||||
|
SubscribeLocalEvent<ActionsComponent, ComponentStartup>(OnStartup);
|
||||||
|
SubscribeLocalEvent<ActionsComponent, ComponentShutdown>(OnShutdown);
|
||||||
|
SubscribeLocalEvent<ActionsComponent, MetaFlagRemoveAttemptEvent>(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)
|
private void OnPlayerAttached(EntityUid uid, ActionsComponent component, PlayerAttachedEvent args)
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ namespace Content.Server.Flash
|
|||||||
|
|
||||||
private void OnMetaFlagRemoval(EntityUid uid, FlashableComponent component, ref MetaFlagRemoveAttemptEvent args)
|
private void OnMetaFlagRemoval(EntityUid uid, FlashableComponent component, ref MetaFlagRemoveAttemptEvent args)
|
||||||
{
|
{
|
||||||
if (component.LifeStage > ComponentLifeStage.Initialized) return;
|
if (component.LifeStage == ComponentLifeStage.Running)
|
||||||
args.Cancelled = true;
|
args.Cancelled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFlashableStartup(EntityUid uid, FlashableComponent component, ComponentStartup args)
|
private void OnFlashableStartup(EntityUid uid, FlashableComponent component, ComponentStartup args)
|
||||||
|
|||||||
Reference in New Issue
Block a user