Files
tbd-station-14/Content.Shared/Construction/EntitySystems/SharedAnchorableSystem.cs
2022-10-30 17:48:53 +11:00

41 lines
1.4 KiB
C#

using Content.Shared.Construction.Components;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Interaction;
using Content.Shared.Pulling.Components;
using Content.Shared.Tools.Components;
namespace Content.Shared.Construction.EntitySystems;
public abstract class SharedAnchorableSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AnchorableComponent, InteractUsingEvent>(OnInteractUsing,
before: new[] { typeof(ItemSlotsSystem) }, after: new[] { typeof(SharedConstructionSystem) });
}
private void OnInteractUsing(EntityUid uid, AnchorableComponent anchorable, InteractUsingEvent args)
{
if (args.Handled)
return;
// If the used entity doesn't have a tool, return early.
if (!TryComp(args.Used, out ToolComponent? usedTool) || !usedTool.Qualities.Contains(anchorable.Tool))
return;
args.Handled = true;
TryToggleAnchor(uid, args.User, args.Used, anchorable, usingTool: usedTool);
}
public virtual void TryToggleAnchor(EntityUid uid, EntityUid userUid, EntityUid usingUid,
AnchorableComponent? anchorable = null,
TransformComponent? transform = null,
SharedPullableComponent? pullable = null,
ToolComponent? usingTool = null)
{
// Thanks tool system.
}
}