This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
forked from new-frontiers-14/frontier-station-14
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
104 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
Content.Server/Construction/Components/WelderRefinableComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Content.Shared.Tools; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.Construction.Components; | ||
|
||
/// <summary> | ||
/// Used for something that can be refined by welder. | ||
/// For example, glass shard can be refined to glass sheet. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class WelderRefinableComponent : Component | ||
{ | ||
[DataField] | ||
public HashSet<EntProtoId>? RefineResult = new(); | ||
|
||
[DataField] | ||
public float RefineTime = 2f; | ||
|
||
[DataField] | ||
public float RefineFuel; | ||
|
||
[DataField] | ||
public ProtoId<ToolQualityPrototype> QualityNeeded = "Welding"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Content.Server.Construction.Components; | ||
using Content.Server.Stack; | ||
using Content.Shared.Construction; | ||
using Content.Shared.Interaction; | ||
using Content.Shared.Stacks; | ||
using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem; | ||
|
||
namespace Content.Server.Construction | ||
{ | ||
public sealed class RefiningSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedToolSystem _toolSystem = default!; | ||
[Dependency] private readonly StackSystem _stackSystem = default!; | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<WelderRefinableComponent, InteractUsingEvent>(OnInteractUsing); | ||
SubscribeLocalEvent<WelderRefinableComponent, WelderRefineDoAfterEvent>(OnDoAfter); | ||
} | ||
|
||
private void OnInteractUsing(EntityUid uid, WelderRefinableComponent component, InteractUsingEvent args) | ||
{ | ||
if (args.Handled) | ||
return; | ||
|
||
args.Handled = _toolSystem.UseTool(args.Used, args.User, uid, component.RefineTime, component.QualityNeeded, new WelderRefineDoAfterEvent(), fuel: component.RefineFuel); | ||
} | ||
|
||
private void OnDoAfter(EntityUid uid, WelderRefinableComponent component, WelderRefineDoAfterEvent args) | ||
{ | ||
if (args.Cancelled) | ||
return; | ||
|
||
// get last owner coordinates and delete it | ||
var resultPosition = Transform(uid).Coordinates; | ||
EntityManager.DeleteEntity(uid); | ||
|
||
// spawn each result after refine | ||
foreach (var result in component.RefineResult!) | ||
{ | ||
var droppedEnt = Spawn(result, resultPosition); | ||
|
||
// TODO: If something has a stack... Just use a prototype with a single thing in the stack. | ||
// This is not a good way to do it. | ||
if (TryComp<StackComponent>(droppedEnt, out var stack)) | ||
_stackSystem.SetCount(droppedEnt, 1, stack); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters