welder stuff (#17476)
This commit is contained in:
@@ -26,13 +26,6 @@ public sealed class WeldableComponent : SharedWeldableComponent
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool Weldable = true;
|
||||
|
||||
/// <summary>
|
||||
/// How much fuel does it take to weld/unweld entity.
|
||||
/// </summary>
|
||||
[DataField("fuel")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float FuelConsumption = 3f;
|
||||
|
||||
/// <summary>
|
||||
/// How much time does it take to weld/unweld entity.
|
||||
/// </summary>
|
||||
|
||||
@@ -13,25 +13,25 @@ namespace Content.Server.Tools.Components
|
||||
/// <summary>
|
||||
/// Solution on the entity that contains the fuel.
|
||||
/// </summary>
|
||||
[DataField("fuelSolution")]
|
||||
[DataField("fuelSolution"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public string FuelSolution { get; } = "Welder";
|
||||
|
||||
/// <summary>
|
||||
/// Reagent that will be used as fuel for welding.
|
||||
/// </summary>
|
||||
[DataField("fuelReagent", customTypeSerializer:typeof(PrototypeIdSerializer<ReagentPrototype>))]
|
||||
[DataField("fuelReagent", customTypeSerializer:typeof(PrototypeIdSerializer<ReagentPrototype>)), ViewVariables(VVAccess.ReadWrite)]
|
||||
public string FuelReagent { get; } = "WeldingFuel";
|
||||
|
||||
/// <summary>
|
||||
/// Fuel consumption per second, while the welder is active.
|
||||
/// </summary>
|
||||
[DataField("fuelConsumption")]
|
||||
public FixedPoint2 FuelConsumption { get; } = FixedPoint2.New(0.05f);
|
||||
[DataField("fuelConsumption"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public FixedPoint2 FuelConsumption { get; } = FixedPoint2.New(2.0f);
|
||||
|
||||
/// <summary>
|
||||
/// A fuel amount to be consumed when the welder goes from being unlit to being lit.
|
||||
/// </summary>
|
||||
[DataField("welderOnConsume")]
|
||||
[DataField("fuelLitCost"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public FixedPoint2 FuelLitCost { get; } = FixedPoint2.New(0.5f);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -68,7 +68,7 @@ public sealed class WeldableSystem : EntitySystem
|
||||
if (!CanWeld(uid, tool, user, component))
|
||||
return false;
|
||||
|
||||
if (!_toolSystem.UseTool(tool, user, uid, component.WeldingTime.Seconds, component.WeldingQuality, new WeldFinishedEvent(), fuel: component.FuelConsumption))
|
||||
if (!_toolSystem.UseTool(tool, user, uid, component.WeldingTime.Seconds, component.WeldingQuality, new WeldFinishedEvent()))
|
||||
return false;
|
||||
|
||||
// Log attempt
|
||||
|
||||
@@ -41,7 +41,6 @@ namespace Content.Server.Tools
|
||||
SubscribeLocalEvent<WelderComponent, ActivateInWorldEvent>(OnWelderActivate);
|
||||
SubscribeLocalEvent<WelderComponent, AfterInteractEvent>(OnWelderAfterInteract);
|
||||
SubscribeLocalEvent<WelderComponent, DoAfterAttemptEvent<ToolDoAfterEvent>>(OnWelderToolUseAttempt);
|
||||
SubscribeLocalEvent<WelderComponent, ToolDoAfterEvent>(OnWelderDoAfter);
|
||||
SubscribeLocalEvent<WelderComponent, ComponentShutdown>(OnWelderShutdown);
|
||||
SubscribeLocalEvent<WelderComponent, ComponentGetState>(OnWelderGetState);
|
||||
SubscribeLocalEvent<WelderComponent, GetMeleeDamageEvent>(OnGetMeleeDamage);
|
||||
@@ -266,7 +265,6 @@ namespace Content.Server.Tools
|
||||
|
||||
private void OnWelderToolUseAttempt(EntityUid uid, WelderComponent welder, DoAfterAttemptEvent<ToolDoAfterEvent> args)
|
||||
{
|
||||
DebugTools.Assert(args.Event.Fuel > 0);
|
||||
var user = args.DoAfter.Args.User;
|
||||
|
||||
if (!welder.Lit)
|
||||
@@ -275,26 +273,6 @@ namespace Content.Server.Tools
|
||||
args.Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
var (fuel, _) = GetWelderFuelAndCapacity(uid, welder);
|
||||
|
||||
if (FixedPoint2.New(args.Event.Fuel) > fuel)
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("welder-component-cannot-weld-message"), uid, user);
|
||||
args.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnWelderDoAfter(EntityUid uid, WelderComponent welder, ToolDoAfterEvent args)
|
||||
{
|
||||
if (args.Cancelled)
|
||||
return;
|
||||
|
||||
if (!_solutionContainerSystem.TryGetSolution(uid, welder.FuelSolution, out var solution))
|
||||
return;
|
||||
|
||||
solution.RemoveReagent(welder.FuelReagent, FixedPoint2.New(args.Fuel));
|
||||
_entityManager.Dirty(welder);
|
||||
}
|
||||
|
||||
private void OnWelderShutdown(EntityUid uid, WelderComponent welder, ComponentShutdown args)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Shared.Tools;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
@@ -32,5 +33,10 @@ namespace Content.Server.Tools
|
||||
|
||||
UpdateWelders(frameTime);
|
||||
}
|
||||
|
||||
protected override bool IsWelder(EntityUid uid)
|
||||
{
|
||||
return HasComp<WelderComponent>(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user