From 1e425f3c286dd49fb5ef111a66912f9fca9e2c30 Mon Sep 17 00:00:00 2001 From: DamianX Date: Wed, 6 Nov 2019 17:22:55 +0100 Subject: [PATCH] Basic wrenchable component (#418) --- Content.Client/EntryPoint.cs | 1 + .../GameObjects/Components/Wrenchable.cs | 41 +++++++++++++++++++ .../Entities/buildings/computers.yml | 5 +++ .../Entities/buildings/vending_machines.yml | 1 + 4 files changed, 48 insertions(+) create mode 100644 Content.Server/GameObjects/Components/Wrenchable.cs diff --git a/Content.Client/EntryPoint.cs b/Content.Client/EntryPoint.cs index 3acda3a4fb..c7175ceddc 100644 --- a/Content.Client/EntryPoint.cs +++ b/Content.Client/EntryPoint.cs @@ -44,6 +44,7 @@ namespace Content.Client var registerIgnore = new[] { + "Wrenchable", "AmmoBox", "Breakable", "Pickaxe", diff --git a/Content.Server/GameObjects/Components/Wrenchable.cs b/Content.Server/GameObjects/Components/Wrenchable.cs new file mode 100644 index 0000000000..a3994cf4b0 --- /dev/null +++ b/Content.Server/GameObjects/Components/Wrenchable.cs @@ -0,0 +1,41 @@ +using Content.Server.GameObjects.Components.Interactable.Tools; +using Content.Server.GameObjects.EntitySystems; +using Robust.Server.GameObjects; +using Robust.Server.GameObjects.EntitySystems; +using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.IoC; + +namespace Content.Server.GameObjects.Components +{ + [RegisterComponent] + public class Wrenchable : Component, IAttackBy + { + public override string Name => "Wrenchable"; + private AudioSystem _audioSystem; + + public override void Initialize() + { + base.Initialize(); + _audioSystem = IoCManager.Resolve().GetEntitySystem(); + } + + public bool AttackBy(AttackByEventArgs eventArgs) + { + if (!eventArgs.AttackWith.HasComponent()) + { + return false; + } + + if (!Owner.TryGetComponent(out PhysicsComponent physics)) + { + return false; + } + + physics.Anchored = !physics.Anchored; + _audioSystem.Play("/Audio/items/ratchet.ogg", Owner); + + return true; + } + } +} diff --git a/Resources/Prototypes/Entities/buildings/computers.yml b/Resources/Prototypes/Entities/buildings/computers.yml index c9297c8e08..8e2222d0b2 100644 --- a/Resources/Prototypes/Entities/buildings/computers.yml +++ b/Resources/Prototypes/Entities/buildings/computers.yml @@ -2,8 +2,12 @@ id: computerBase name: Computer components: + - type: Physics + mass: 25 + Anchored: true - type: Clickable - type: Collidable + IsScrapingFloor: true shapes: - !type:PhysShapeAabb bounds: "-0.5,-0.25,0.5,0.25" @@ -15,6 +19,7 @@ - type: Computer - type: PowerDevice priority: High + - type: Wrenchable - type: Sprite sprite: Buildings/computer.rsi diff --git a/Resources/Prototypes/Entities/buildings/vending_machines.yml b/Resources/Prototypes/Entities/buildings/vending_machines.yml index 7fdeef1614..5c43cb24f3 100644 --- a/Resources/Prototypes/Entities/buildings/vending_machines.yml +++ b/Resources/Prototypes/Entities/buildings/vending_machines.yml @@ -39,6 +39,7 @@ - type: PowerDevice priority: Low - type: Wires + - type: Wrenchable - type: entity parent: VendingMachine