diff --git a/Content.Client/Construction/EntitySystems/AnchorableSystem.cs b/Content.Client/Construction/EntitySystems/AnchorableSystem.cs new file mode 100644 index 0000000000..731d5cec9f --- /dev/null +++ b/Content.Client/Construction/EntitySystems/AnchorableSystem.cs @@ -0,0 +1,5 @@ +using Content.Shared.Construction.EntitySystems; + +namespace Content.Client.Construction.EntitySystems; + +public sealed class AnchorableSystem : SharedAnchorableSystem { } diff --git a/Content.Client/Entry/IgnoredComponents.cs b/Content.Client/Entry/IgnoredComponents.cs index ce7f09805a..8d794f581a 100644 --- a/Content.Client/Entry/IgnoredComponents.cs +++ b/Content.Client/Entry/IgnoredComponents.cs @@ -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", diff --git a/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs b/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs index 127c6237dc..46629c1c2d 100644 --- a/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs +++ b/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs @@ -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; diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPortableSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPortableSystem.cs index e4f37906cb..f238a51dde 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPortableSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPortableSystem.cs @@ -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; diff --git a/Content.Server/Configurable/ConfigurationSystem.cs b/Content.Server/Configurable/ConfigurationSystem.cs index ff373c10d8..01dfc6a779 100644 --- a/Content.Server/Configurable/ConfigurationSystem.cs +++ b/Content.Server/Configurable/ConfigurationSystem.cs @@ -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; diff --git a/Content.Server/Construction/AnchorableSystem.cs b/Content.Server/Construction/AnchorableSystem.cs index ad17964798..2760a9db15 100644 --- a/Content.Server/Construction/AnchorableSystem.cs +++ b/Content.Server/Construction/AnchorableSystem.cs @@ -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(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); - } - /// /// Checks if a tool can change the anchored status. /// @@ -154,7 +134,7 @@ namespace Content.Server.Construction /// Tries to toggle the anchored status of this component's owner. /// /// true if toggled, false otherwise - public async Task TryToggleAnchor(EntityUid uid, EntityUid userUid, EntityUid usingUid, + public override async Task TryToggleAnchor(EntityUid uid, EntityUid userUid, EntityUid usingUid, AnchorableComponent? anchorable = null, TransformComponent? transform = null, SharedPullableComponent? pullable = null, diff --git a/Content.Server/Construction/Components/WelderRefinableComponent.cs b/Content.Server/Construction/Components/WelderRefinableComponent.cs index 7994d7a65c..ac758c2f05 100644 --- a/Content.Server/Construction/Components/WelderRefinableComponent.cs +++ b/Content.Server/Construction/Components/WelderRefinableComponent.cs @@ -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; diff --git a/Content.Server/Damage/Systems/DamageOnToolInteractSystem.cs b/Content.Server/Damage/Systems/DamageOnToolInteractSystem.cs index 551c58f44c..1a1a6888d6 100644 --- a/Content.Server/Damage/Systems/DamageOnToolInteractSystem.cs +++ b/Content.Server/Damage/Systems/DamageOnToolInteractSystem.cs @@ -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; diff --git a/Content.Server/Disease/DiseaseDiagnosisSystem.cs b/Content.Server/Disease/DiseaseDiagnosisSystem.cs index f156c926af..ccbe228902 100644 --- a/Content.Server/Disease/DiseaseDiagnosisSystem.cs +++ b/Content.Server/Disease/DiseaseDiagnosisSystem.cs @@ -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 { diff --git a/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs index 1358db6931..aa788ec7f0 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs @@ -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; diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs index 189abe76de..a3194e0f20 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs @@ -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; diff --git a/Content.Server/Doors/Systems/DoorSystem.cs b/Content.Server/Doors/Systems/DoorSystem.cs index 4a0a1d4cb2..6cc6018966 100644 --- a/Content.Server/Doors/Systems/DoorSystem.cs +++ b/Content.Server/Doors/Systems/DoorSystem.cs @@ -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; diff --git a/Content.Server/Nuke/NukeSystem.cs b/Content.Server/Nuke/NukeSystem.cs index 94a7201a2d..f50f845c9c 100644 --- a/Content.Server/Nuke/NukeSystem.cs +++ b/Content.Server/Nuke/NukeSystem.cs @@ -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; diff --git a/Content.Server/PneumaticCannon/PneumaticCannonSystem.cs b/Content.Server/PneumaticCannon/PneumaticCannonSystem.cs index 0c9b72d1e0..1a3e77d0aa 100644 --- a/Content.Server/PneumaticCannon/PneumaticCannonSystem.cs +++ b/Content.Server/PneumaticCannon/PneumaticCannonSystem.cs @@ -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; diff --git a/Content.Server/SubFloor/SubFloorHideSystem.cs b/Content.Server/SubFloor/SubFloorHideSystem.cs index 807607d241..6c6faeb133 100644 --- a/Content.Server/SubFloor/SubFloorHideSystem.cs +++ b/Content.Server/SubFloor/SubFloorHideSystem.cs @@ -1,4 +1,4 @@ -using Content.Server.Construction.Components; +using Content.Shared.Construction.Components; using Content.Shared.SubFloor; namespace Content.Server.SubFloor; diff --git a/Content.Server/Toilet/ToiletSystem.cs b/Content.Server/Toilet/ToiletSystem.cs index e97cad00e4..cc545a3d75 100644 --- a/Content.Server/Toilet/ToiletSystem.cs +++ b/Content.Server/Toilet/ToiletSystem.cs @@ -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; diff --git a/Content.Server/Tools/ToolSystem.TilePrying.cs b/Content.Server/Tools/ToolSystem.TilePrying.cs index 7240ac4ba9..4d94a47fff 100644 --- a/Content.Server/Tools/ToolSystem.TilePrying.cs +++ b/Content.Server/Tools/ToolSystem.TilePrying.cs @@ -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; diff --git a/Content.Server/Tools/ToolSystem.cs b/Content.Server/Tools/ToolSystem.cs index 6f1b3432a6..55b3e410b7 100644 --- a/Content.Server/Tools/ToolSystem.cs +++ b/Content.Server/Tools/ToolSystem.cs @@ -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. - /// + /// public bool UseTool(EntityUid tool, EntityUid user, EntityUid? target, float fuel, float doAfterDelay, string toolQualityNeeded, object doAfterCompleteEvent, object doAfterCancelledEvent, EntityUid? doAfterEventTarget = null, Func? doAfterCheck = null, ToolComponent? toolComponent = null) @@ -200,7 +201,7 @@ namespace Content.Server.Tools } // This is hilariously long. - /// + /// public Task UseTool(EntityUid tool, EntityUid user, EntityUid? target, float fuel, float doAfterDelay, string toolQualityNeeded, Func? doAfterCheck = null, ToolComponent? toolComponent = null) diff --git a/Content.Server/Weapon/Melee/EnergySword/EnergySwordSystem.cs b/Content.Server/Weapon/Melee/EnergySword/EnergySwordSystem.cs index f4b5562cd3..4dfdc4c0dd 100644 --- a/Content.Server/Weapon/Melee/EnergySword/EnergySwordSystem.cs +++ b/Content.Server/Weapon/Melee/EnergySword/EnergySwordSystem.cs @@ -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; diff --git a/Content.Server/WireHacking/WiresComponent.cs b/Content.Server/WireHacking/WiresComponent.cs index ac99a481f1..bb31992ee4 100644 --- a/Content.Server/WireHacking/WiresComponent.cs +++ b/Content.Server/WireHacking/WiresComponent.cs @@ -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; diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactElectricityTriggerSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactElectricityTriggerSystem.cs index ff5774716e..8cef4952fc 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactElectricityTriggerSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactElectricityTriggerSystem.cs @@ -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; diff --git a/Content.Server/Construction/Components/AnchorableComponent.cs b/Content.Shared/Construction/Components/AnchorableComponent.cs similarity index 90% rename from Content.Server/Construction/Components/AnchorableComponent.cs rename to Content.Shared/Construction/Components/AnchorableComponent.cs index ac6474f6f5..c4e2512147 100644 --- a/Content.Server/Construction/Components/AnchorableComponent.cs +++ b/Content.Shared/Construction/Components/AnchorableComponent.cs @@ -1,16 +1,13 @@ +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))] + [DataField("tool", customTypeSerializer: typeof(PrototypeIdSerializer))] public string Tool { get; private set; } = "Anchoring"; [DataField("snap")] diff --git a/Content.Shared/Construction/EntitySystems/SharedAnchorableSystem.cs b/Content.Shared/Construction/EntitySystems/SharedAnchorableSystem.cs new file mode 100644 index 0000000000..cb7d85ab2b --- /dev/null +++ b/Content.Shared/Construction/EntitySystems/SharedAnchorableSystem.cs @@ -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(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 TryToggleAnchor(EntityUid uid, EntityUid userUid, EntityUid usingUid, + AnchorableComponent? anchorable = null, + TransformComponent? transform = null, + SharedPullableComponent? pullable = null, + ToolComponent? usingTool = null) + { + // Thanks tool system. + return false; + } +} diff --git a/Content.Server/Tools/Components/ToolComponent.cs b/Content.Shared/Tools/Components/ToolComponent.cs similarity index 69% rename from Content.Server/Tools/Components/ToolComponent.cs rename to Content.Shared/Tools/Components/ToolComponent.cs index e597284dd2..eaf21009b3 100644 --- a/Content.Server/Tools/Components/ToolComponent.cs +++ b/Content.Shared/Tools/Components/ToolComponent.cs @@ -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")] diff --git a/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml b/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml index 6a48d2d098..70a4780199 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml @@ -43,7 +43,8 @@ - type: Tool qualities: - Screwing - useSoundCollection: Screwdriver + useSound: + collection: Screwdriver speed: 0.05 - type: entity