Makes tools and welders ECS, add ToolQualityPrototype. (#4741)

This commit is contained in:
Vera Aguilera Puerto
2021-10-07 13:01:27 +02:00
committed by GitHub
parent f2760d0002
commit 365c7da4dc
44 changed files with 1144 additions and 863 deletions

View File

@@ -1,16 +1,18 @@
using Content.Server.Tools;
using Content.Server.Tools.Components;
using Content.Shared.Damage;
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Content.Shared.Tool;
using Content.Shared.Tools.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Content.Server.Repairable
{
public class ReairableSystem : EntitySystem
public class RepairableSystem : EntitySystem
{
[Dependency] private readonly ToolSystem _toolSystem = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
public override void Initialize()
@@ -20,16 +22,12 @@ namespace Content.Server.Repairable
public async void Repair(EntityUid uid, RepairableComponent component, InteractUsingEvent args)
{
// Only repair if you are using a lit welder
if (!args.Used.TryGetComponent(out WelderComponent? welder) || !welder.WelderLit)
return;
// Only try repair the target if it is damaged
if (!component.Owner.TryGetComponent(out DamageableComponent? damageable) || damageable.TotalDamage == 0)
return;
// Can the welder actually repair this, does it have enough fuel?
if (!await welder.UseTool(args.User, component.Owner, component.DoAfterDelay, ToolQuality.Welding, component.FuelCost))
// Can the tool actually repair this, does it have enough fuel?
if (!await _toolSystem.UseTool(args.Used.Uid, args.User.Uid, uid, component.FuelCost, component.DoAfterDelay, component.QualityNeeded))
return;
// Repair all damage
@@ -38,7 +36,7 @@ namespace Content.Server.Repairable
component.Owner.PopupMessage(args.User,
Loc.GetString("comp-repairable-repair",
("target", component.Owner),
("welder", args.Used)));
("tool", args.Used)));
args.Handled = true;
}