welder stuff (#17476)
This commit is contained in:
@@ -16,9 +16,6 @@ namespace Content.Server.Construction.Components
|
||||
[DataField("refineTime")]
|
||||
public float RefineTime = 2f;
|
||||
|
||||
[DataField("refineFuel")]
|
||||
public float RefineFuel = 0f;
|
||||
|
||||
[DataField("qualityNeeded", customTypeSerializer:typeof(PrototypeIdSerializer<ToolQualityPrototype>))]
|
||||
public string QualityNeeded = "Welding";
|
||||
}
|
||||
|
||||
@@ -347,7 +347,6 @@ namespace Content.Server.Construction
|
||||
if (validation)
|
||||
{
|
||||
// Then we only really need to check whether the tool entity has that quality or not.
|
||||
// TODO fuel consumption?
|
||||
return _toolSystem.HasQuality(interactUsing.Used, toolInsertStep.Tool)
|
||||
? HandleResult.Validated
|
||||
: HandleResult.False;
|
||||
@@ -364,8 +363,7 @@ namespace Content.Server.Construction
|
||||
TimeSpan.FromSeconds(toolInsertStep.DoAfter),
|
||||
new [] { toolInsertStep.Tool },
|
||||
new ConstructionInteractDoAfterEvent(interactUsing),
|
||||
out var doAfter,
|
||||
fuel: toolInsertStep.Fuel);
|
||||
out var doAfter);
|
||||
|
||||
return result && doAfter != null ? HandleResult.DoAfter : HandleResult.False;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Content.Server.Construction
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
args.Handled = _toolSystem.UseTool(args.Used, args.User, uid, component.RefineTime, component.QualityNeeded, new WelderRefineDoAfterEvent(), component.RefineFuel);
|
||||
args.Handled = _toolSystem.UseTool(args.Used, args.User, uid, component.RefineTime, component.QualityNeeded, new WelderRefineDoAfterEvent());
|
||||
}
|
||||
|
||||
private void OnDoAfter(EntityUid uid, WelderRefinableComponent component, WelderRefineDoAfterEvent args)
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Content.Server.Repairable
|
||||
return;
|
||||
|
||||
// Only try repair the target if it is damaged
|
||||
if (!EntityManager.TryGetComponent(uid, out DamageableComponent? damageable) || damageable.TotalDamage == 0)
|
||||
if (!TryComp<DamageableComponent>(uid, out var damageable) || damageable.TotalDamage == 0)
|
||||
return;
|
||||
|
||||
float delay = component.DoAfterDelay;
|
||||
@@ -64,8 +64,8 @@ namespace Content.Server.Repairable
|
||||
if (args.User == args.Target)
|
||||
delay *= component.SelfRepairPenalty;
|
||||
|
||||
// Can the tool actually repair this, does it have enough fuel?
|
||||
args.Handled = _toolSystem.UseTool(args.Used, args.User, uid, delay, component.QualityNeeded, new RepairFinishedEvent(), component.FuelCost);
|
||||
// Run the repairing doafter
|
||||
args.Handled = _toolSystem.UseTool(args.Used, args.User, uid, delay, component.QualityNeeded, new RepairFinishedEvent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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