Move Anchorable to shared. (#7361)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
using Content.Shared.Construction.EntitySystems;
|
||||
|
||||
namespace Content.Client.Construction.EntitySystems;
|
||||
|
||||
public sealed class AnchorableSystem : SharedAnchorableSystem { }
|
||||
@@ -5,7 +5,6 @@ namespace Content.Client.Entry
|
||||
{
|
||||
public static string[] List => new[]
|
||||
{
|
||||
"Anchorable",
|
||||
"AmmoBox",
|
||||
"Pickaxe",
|
||||
"IngestionBlocker",
|
||||
@@ -90,7 +89,6 @@ namespace Content.Client.Entry
|
||||
"SolarPanel",
|
||||
"BodyScanner",
|
||||
"Stunbaton",
|
||||
"Tool",
|
||||
"TilePrying",
|
||||
"RandomSpriteColor",
|
||||
"ConditionalSpawner",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Construction.Components;
|
||||
using Content.Shared.Popups;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Atmos.Piping.Binary.Components;
|
||||
using Content.Server.Atmos.Piping.Unary.Components;
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
using Content.Shared.Atmos.Piping.Unary.Components;
|
||||
using Content.Shared.Construction.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using static Content.Shared.Configurable.SharedConfigurationComponent;
|
||||
|
||||
|
||||
@@ -1,42 +1,22 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Server.Coordinates.Helpers;
|
||||
using Content.Server.Pulling;
|
||||
using Content.Server.Tools;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Shared.Construction.Components;
|
||||
using Content.Shared.Construction.EntitySystems;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Content.Shared.Tools.Components;
|
||||
|
||||
namespace Content.Server.Construction
|
||||
{
|
||||
public sealed class AnchorableSystem : EntitySystem
|
||||
public sealed class AnchorableSystem : SharedAnchorableSystem
|
||||
{
|
||||
[Dependency] private readonly AdminLogSystem _adminLogs = default!;
|
||||
[Dependency] private readonly ToolSystem _toolSystem = default!;
|
||||
[Dependency] private readonly PullingSystem _pullingSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<AnchorableComponent, InteractUsingEvent>(OnInteractUsing, after:new []{typeof(ConstructionSystem)});
|
||||
}
|
||||
|
||||
private async 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;
|
||||
await TryToggleAnchor(uid, args.User, args.Used, anchorable, usingTool:usedTool);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a tool can change the anchored status.
|
||||
/// </summary>
|
||||
@@ -154,7 +134,7 @@ namespace Content.Server.Construction
|
||||
/// Tries to toggle the anchored status of this component's owner.
|
||||
/// </summary>
|
||||
/// <returns>true if toggled, false otherwise</returns>
|
||||
public async Task<bool> TryToggleAnchor(EntityUid uid, EntityUid userUid, EntityUid usingUid,
|
||||
public override async Task<bool> TryToggleAnchor(EntityUid uid, EntityUid userUid, EntityUid usingUid,
|
||||
AnchorableComponent? anchorable = null,
|
||||
TransformComponent? transform = null,
|
||||
SharedPullableComponent? pullable = null,
|
||||
|
||||
@@ -2,9 +2,9 @@ using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Stack;
|
||||
using Content.Server.Tools;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Tools;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ using Content.Server.Popups;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Nutrition.EntitySystems;
|
||||
using Content.Server.Paper;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Server.Power.Components;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Shared.Tools.Components;
|
||||
|
||||
namespace Content.Server.Disease
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Server.Disposal.Unit.Components;
|
||||
using Content.Server.Disposal.Unit.EntitySystems;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Construction.Components;
|
||||
using Content.Shared.Disposal.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Sound;
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Server.Disposal.Tube.Components;
|
||||
using Content.Server.Disposal.Unit.Components;
|
||||
using Content.Server.DoAfter;
|
||||
@@ -13,6 +12,7 @@ using Content.Server.UserInterface;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Construction.Components;
|
||||
using Content.Shared.Disposal;
|
||||
using Content.Shared.Disposal.Components;
|
||||
using Content.Shared.DragDrop;
|
||||
|
||||
@@ -4,7 +4,6 @@ using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Server.Tools;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Server.Doors.Components;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
@@ -20,6 +19,7 @@ using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Player;
|
||||
using Content.Shared.Hands.Components;
|
||||
using System.Linq;
|
||||
using Content.Shared.Tools.Components;
|
||||
|
||||
namespace Content.Server.Doors.Systems;
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Server.Coordinates.Helpers;
|
||||
using Content.Server.Explosion.EntitySystems;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Construction.Components;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Nuke;
|
||||
using Content.Shared.Sound;
|
||||
|
||||
@@ -4,7 +4,6 @@ using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Server.Stunnable;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Shared.Camera;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
@@ -14,6 +13,7 @@ using Content.Shared.PneumaticCannon;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Shared.Construction.Components;
|
||||
using Content.Shared.SubFloor;
|
||||
|
||||
namespace Content.Server.SubFloor;
|
||||
|
||||
@@ -4,13 +4,13 @@ using Content.Server.Popups;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Server.Storage.EntitySystems;
|
||||
using Content.Server.Tools;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Toilet;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Server.Tools.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -18,6 +18,7 @@ using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Tools
|
||||
{
|
||||
// TODO move tool system to shared, and make it a friend of Tool Component.
|
||||
public sealed partial class ToolSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
|
||||
@@ -146,7 +147,7 @@ namespace Content.Server.Tools
|
||||
}
|
||||
|
||||
// This is hilariously long.
|
||||
/// <inheritdoc cref="UseTool(Robust.Shared.GameObjects.EntityUid,Robust.Shared.GameObjects.EntityUid,System.Nullable{Robust.Shared.GameObjects.EntityUid},float,float,System.Collections.Generic.IEnumerable{string},Robust.Shared.GameObjects.EntityUid,object,object,System.Func{bool}?,Content.Server.Tools.Components.ToolComponent?)"/>
|
||||
/// <inheritdoc cref="UseTool(Robust.Shared.GameObjects.EntityUid,Robust.Shared.GameObjects.EntityUid,System.Nullable{Robust.Shared.GameObjects.EntityUid},float,float,System.Collections.Generic.IEnumerable{string},Robust.Shared.GameObjects.EntityUid,object,object,System.Func{bool}?,Content.Shared.Tools.Components.ToolComponent?)"/>
|
||||
public bool UseTool(EntityUid tool, EntityUid user, EntityUid? target, float fuel,
|
||||
float doAfterDelay, string toolQualityNeeded, object doAfterCompleteEvent, object doAfterCancelledEvent, EntityUid? doAfterEventTarget = null,
|
||||
Func<bool>? doAfterCheck = null, ToolComponent? toolComponent = null)
|
||||
@@ -200,7 +201,7 @@ namespace Content.Server.Tools
|
||||
}
|
||||
|
||||
// This is hilariously long.
|
||||
/// <inheritdoc cref="UseTool(Robust.Shared.GameObjects.EntityUid,Robust.Shared.GameObjects.EntityUid,System.Nullable{Robust.Shared.GameObjects.EntityUid},float,float,System.Collections.Generic.IEnumerable{string},Robust.Shared.GameObjects.EntityUid,object,object,System.Func{bool}?,Content.Server.Tools.Components.ToolComponent?)"/>
|
||||
/// <inheritdoc cref="UseTool(Robust.Shared.GameObjects.EntityUid,Robust.Shared.GameObjects.EntityUid,System.Nullable{Robust.Shared.GameObjects.EntityUid},float,float,System.Collections.Generic.IEnumerable{string},Robust.Shared.GameObjects.EntityUid,object,object,System.Func{bool}?,Content.Shared.Tools.Components.ToolComponent?)"/>
|
||||
public Task<bool> UseTool(EntityUid tool, EntityUid user, EntityUid? target, float fuel,
|
||||
float doAfterDelay, string toolQualityNeeded, Func<bool>? doAfterCheck = null,
|
||||
ToolComponent? toolComponent = null)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Threading.Tasks;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Tools;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Server.VendingMachines;
|
||||
using Content.Shared.Interaction;
|
||||
@@ -14,6 +13,7 @@ using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Tools;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Content.Shared.Wires;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.Events;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Tools.Components;
|
||||
|
||||
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems;
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using Content.Shared.Construction.EntitySystems;
|
||||
using Content.Shared.Tools;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Construction.Components
|
||||
namespace Content.Shared.Construction.Components
|
||||
{
|
||||
[RegisterComponent, Friend(typeof(AnchorableSystem))]
|
||||
[RegisterComponent, Friend(typeof(SharedAnchorableSystem))]
|
||||
public sealed class AnchorableComponent : Component
|
||||
{
|
||||
[DataField("tool", customTypeSerializer: typeof(PrototypeIdSerializer<ToolQualityPrototype>))]
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared.Construction.Components;
|
||||
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, after: new[] { typeof(SharedConstructionSystem) });
|
||||
}
|
||||
|
||||
private async 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;
|
||||
await TryToggleAnchor(uid, args.User, args.Used, anchorable, usingTool: usedTool);
|
||||
}
|
||||
|
||||
public virtual async Task<bool> TryToggleAnchor(EntityUid uid, EntityUid userUid, EntityUid usingUid,
|
||||
AnchorableComponent? anchorable = null,
|
||||
TransformComponent? transform = null,
|
||||
SharedPullableComponent? pullable = null,
|
||||
ToolComponent? usingTool = null)
|
||||
{
|
||||
// Thanks tool system.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,9 @@
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Tools;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Tools.Components
|
||||
namespace Content.Shared.Tools.Components
|
||||
{
|
||||
[RegisterComponent, Friend(typeof(ToolSystem))]
|
||||
[RegisterComponent] // TODO move tool system to shared, and make it a friend.
|
||||
public sealed class ToolComponent : Component
|
||||
{
|
||||
[DataField("qualities")]
|
||||
@@ -43,7 +43,8 @@
|
||||
- type: Tool
|
||||
qualities:
|
||||
- Screwing
|
||||
useSoundCollection: Screwdriver
|
||||
useSound:
|
||||
collection: Screwdriver
|
||||
speed: 0.05
|
||||
|
||||
- type: entity
|
||||
|
||||
Reference in New Issue
Block a user