diff --git a/Content.Server/GameObjects/Components/Damage/DamageOnToolInteractComponent.cs b/Content.Server/GameObjects/Components/Damage/DamageOnToolInteractComponent.cs new file mode 100644 index 0000000000..4f66b92807 --- /dev/null +++ b/Content.Server/GameObjects/Components/Damage/DamageOnToolInteractComponent.cs @@ -0,0 +1,67 @@ +using Content.Server.GameObjects.Components.Interactable; +using Content.Server.GameObjects.EntitySystems; +using Content.Shared.GameObjects.Components.Interactable; +using Robust.Shared.GameObjects; +using Robust.Shared.Serialization; +using System.Collections.Generic; + +namespace Content.Server.GameObjects.Components.Damage +{ + [RegisterComponent] + class DamageOnToolInteractComponent : Component, IInteractUsing + { + public override string Name => "DamageOnToolInteract"; + + /* Set in YAML */ + protected int Damage; + private List _tools = new List(); + + public override void ExposeData(ObjectSerializer serializer) + { + base.ExposeData(serializer); + + serializer.DataField(ref Damage, "damage", 0); + + serializer.DataField(ref _tools, "tools", new List()); + } + + public override void Initialize() + { + base.Initialize(); + Owner.EnsureComponent(); + } + + public bool InteractUsing(InteractUsingEventArgs eventArgs) + { + if (eventArgs.Using.TryGetComponent(out var tool)) + { + foreach (var toolQuality in _tools) + { + if (tool.HasQuality(ToolQuality.Welding) && toolQuality == ToolQuality.Welding) + { + if (eventArgs.Using.TryGetComponent(out WelderComponent welder)) + { + if (welder.WelderLit) return CallDamage(eventArgs, tool); + } + break; //If the tool quality is welding and its not lit or its not actually a welder that can be lit then its pointless to continue. + } + + if (tool.HasQuality(toolQuality)) return CallDamage(eventArgs, tool); + } + } + return false; + } + + protected bool CallDamage(InteractUsingEventArgs eventArgs, ToolComponent tool) + { + if (eventArgs.Target.TryGetComponent(out var damageable)) + { + if(tool.HasQuality(ToolQuality.Welding)) damageable.TakeDamage(Shared.GameObjects.DamageType.Heat, Damage, eventArgs.Using, eventArgs.User); + else + damageable.TakeDamage(Shared.GameObjects.DamageType.Brute, Damage, eventArgs.Using, eventArgs.User); + return true; + } + return false; + } + } +} diff --git a/Resources/Prototypes/Entities/Buildings/Storage/StorageTanks/fuel_tank.yml b/Resources/Prototypes/Entities/Buildings/Storage/StorageTanks/fuel_tank.yml index 0f032dcf45..55a315154b 100644 --- a/Resources/Prototypes/Entities/Buildings/Storage/StorageTanks/fuel_tank.yml +++ b/Resources/Prototypes/Entities/Buildings/Storage/StorageTanks/fuel_tank.yml @@ -18,3 +18,8 @@ reagents: - ReagentId: chem.WeldingFuel Quantity: 1500 + - type: DamageOnToolInteract + damage: 200 + tools: + - Welding +