Mind Action Container (#21336)

This commit is contained in:
keronshb
2023-11-03 19:55:32 -04:00
committed by GitHub
parent d218fa3d2c
commit 3a788dd8d4
5 changed files with 42 additions and 4 deletions

View File

@@ -1,5 +1,8 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared.Ghost;
using Content.Shared.Mind;
using Content.Shared.Mind.Components;
using Robust.Shared.Containers;
using Robust.Shared.Network;
using Robust.Shared.Timing;
@@ -17,6 +20,7 @@ public sealed class ActionContainerSystem : EntitySystem
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly INetManager _netMan = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
public override void Initialize()
{
@@ -26,6 +30,25 @@ public sealed class ActionContainerSystem : EntitySystem
SubscribeLocalEvent<ActionsContainerComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<ActionsContainerComponent, EntRemovedFromContainerMessage>(OnEntityRemoved);
SubscribeLocalEvent<ActionsContainerComponent, EntInsertedIntoContainerMessage>(OnEntityInserted);
SubscribeLocalEvent<ActionsContainerComponent, MindAddedMessage>(OnMindAdded);
SubscribeLocalEvent<ActionsContainerComponent, MindRemovedMessage>(OnMindRemoved);
}
private void OnMindAdded(EntityUid uid, ActionsContainerComponent component, MindAddedMessage args)
{
if(!_mind.TryGetMind(uid, out var mindId, out _))
return;
if (!TryComp<ActionsContainerComponent>(mindId, out var mindActionContainerComp))
return;
if (!HasComp<GhostComponent>(uid) && mindActionContainerComp.Container.ContainedEntities.Count > 0 )
_actions.GrantContainedActions(uid, mindId);
}
private void OnMindRemoved(EntityUid uid, ActionsContainerComponent component, MindRemovedMessage args)
{
_actions.RemoveProvidedActions(uid, args.Mind);
}
/// <summary>