Makes tools and welders ECS, add ToolQualityPrototype. (#4741)
This commit is contained in:
committed by
GitHub
parent
f2760d0002
commit
365c7da4dc
@@ -2,13 +2,16 @@ using System;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Coordinates.Helpers;
|
||||
using Content.Server.Pulling;
|
||||
using Content.Server.Tools;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Tools;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Content.Shared.Tool;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Construction.Components
|
||||
@@ -20,8 +23,8 @@ namespace Content.Server.Construction.Components
|
||||
public override string Name => "Anchorable";
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("tool")]
|
||||
public ToolQuality Tool { get; private set; } = ToolQuality.Anchoring;
|
||||
[DataField("tool", customTypeSerializer:typeof(PrototypeIdSerializer<ToolQualityPrototype>))]
|
||||
public string Tool { get; private set; } = "Anchoring";
|
||||
|
||||
[ViewVariables]
|
||||
int IInteractUsing.Priority => 1;
|
||||
@@ -56,7 +59,7 @@ namespace Content.Server.Construction.Components
|
||||
if (attempt.Cancelled)
|
||||
return false;
|
||||
|
||||
return utilizing.TryGetComponent(out ToolComponent? tool) && await tool.UseTool(user, Owner, 0.5f + attempt.Delay, Tool);
|
||||
return await EntitySystem.Get<ToolSystem>().UseTool(utilizing.Uid, user.Uid, Owner.Uid, 0f, 0.5f + attempt.Delay, Tool);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -5,12 +5,13 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Stack;
|
||||
using Content.Server.Tools;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Shared.Construction;
|
||||
using Content.Shared.Construction.Prototypes;
|
||||
using Content.Shared.Construction.Steps;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Tool;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -227,19 +228,7 @@ namespace Content.Server.Construction.Components
|
||||
switch (step)
|
||||
{
|
||||
case ToolConstructionGraphStep toolStep:
|
||||
// Gotta take welder fuel into consideration.
|
||||
if (toolStep.Tool == ToolQuality.Welding)
|
||||
{
|
||||
if (eventArgs.Using.TryGetComponent(out WelderComponent? welder) &&
|
||||
await welder.UseTool(eventArgs.User, Owner, step.DoAfter, toolStep.Tool, toolStep.Fuel))
|
||||
{
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (eventArgs.Using.TryGetComponent(out ToolComponent? tool) &&
|
||||
await tool.UseTool(eventArgs.User, Owner, step.DoAfter, toolStep.Tool))
|
||||
if (await EntitySystem.Get<ToolSystem>().UseTool(eventArgs.Using.Uid, eventArgs.User.Uid, Owner.Uid, toolStep.Fuel, step.DoAfter, toolStep.Tool))
|
||||
{
|
||||
handled = true;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Stack;
|
||||
using Content.Server.Tools;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Stacks;
|
||||
using Content.Shared.Tool;
|
||||
using Content.Shared.Tools;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Construction.Components
|
||||
@@ -18,13 +21,18 @@ namespace Content.Server.Construction.Components
|
||||
[RegisterComponent]
|
||||
public class WelderRefinableComponent : Component, IInteractUsing
|
||||
{
|
||||
[ViewVariables]
|
||||
[DataField("refineResult")]
|
||||
private HashSet<string>? _refineResult = new() { };
|
||||
[ViewVariables]
|
||||
|
||||
[DataField("refineTime")]
|
||||
private float _refineTime = 2f;
|
||||
|
||||
[DataField("refineFuel")]
|
||||
private float _refineFuel = 0f;
|
||||
|
||||
[DataField("qualityNeeded", customTypeSerializer:typeof(PrototypeIdSerializer<ToolQualityPrototype>))]
|
||||
private string _qualityNeeded = "Welding";
|
||||
|
||||
private bool _beingWelded;
|
||||
|
||||
public override string Name => "WelderRefinable";
|
||||
@@ -38,9 +46,12 @@ namespace Content.Server.Construction.Components
|
||||
// check if someone is already welding object
|
||||
if (_beingWelded)
|
||||
return false;
|
||||
|
||||
_beingWelded = true;
|
||||
|
||||
if (!await tool.UseTool(eventArgs.User, Owner, _refineTime, ToolQuality.Welding))
|
||||
var toolSystem = EntitySystem.Get<ToolSystem>();
|
||||
|
||||
if (!await toolSystem.UseTool(eventArgs.Using.Uid, eventArgs.User.Uid, Owner.Uid, _refineFuel, _refineTime, _qualityNeeded))
|
||||
{
|
||||
// failed to veld - abort refine
|
||||
_beingWelded = false;
|
||||
|
||||
Reference in New Issue
Block a user