forked from space-wizards/space-station-14
-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'space-wizards/master' into upstream-merge
- Loading branch information
Showing
161 changed files
with
40,778 additions
and
24,188 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
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
31 changes: 31 additions & 0 deletions
31
Content.Server/Materials/Components/ProduceMaterialExtractorComponent.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,31 @@ | ||
using Content.Shared.Chemistry.Reagent; | ||
using Content.Shared.Materials; | ||
using Robust.Shared.Audio; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.Materials.Components; | ||
|
||
/// <summary> | ||
/// This is used for a machine that turns produce into a specified material. | ||
/// </summary> | ||
[RegisterComponent, Access(typeof(ProduceMaterialExtractorSystem))] | ||
public sealed partial class ProduceMaterialExtractorComponent : Component | ||
{ | ||
/// <summary> | ||
/// The material that produce is converted into | ||
/// </summary> | ||
[DataField] | ||
public ProtoId<MaterialPrototype> ExtractedMaterial = "Biomass"; | ||
|
||
/// <summary> | ||
/// List of reagents that determines how much material is yielded from a produce. | ||
/// </summary> | ||
[DataField] | ||
public List<ProtoId<ReagentPrototype>> ExtractionReagents = new() | ||
{ | ||
"Nutriment" | ||
}; | ||
|
||
[DataField] | ||
public SoundSpecifier? ExtractSound = new SoundPathSpecifier("/Audio/Effects/waterswirl.ogg"); | ||
} |
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
48 changes: 48 additions & 0 deletions
48
Content.Server/Materials/ProduceMaterialExtractorSystem.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,48 @@ | ||
using System.Linq; | ||
using Content.Server.Botany.Components; | ||
using Content.Server.Materials.Components; | ||
using Content.Server.Power.EntitySystems; | ||
using Content.Shared.Chemistry.EntitySystems; | ||
using Content.Shared.Interaction; | ||
using Robust.Server.Audio; | ||
|
||
namespace Content.Server.Materials; | ||
|
||
public sealed class ProduceMaterialExtractorSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly AudioSystem _audio = default!; | ||
[Dependency] private readonly MaterialStorageSystem _materialStorage = default!; | ||
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!; | ||
|
||
/// <inheritdoc/> | ||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<ProduceMaterialExtractorComponent, AfterInteractUsingEvent>(OnInteractUsing); | ||
} | ||
|
||
private void OnInteractUsing(Entity<ProduceMaterialExtractorComponent> ent, ref AfterInteractUsingEvent args) | ||
{ | ||
if (args.Handled) | ||
return; | ||
|
||
if (!this.IsPowered(ent, EntityManager)) | ||
return; | ||
|
||
if (!TryComp<ProduceComponent>(args.Used, out var produce)) | ||
return; | ||
|
||
if (!_solutionContainer.TryGetSolution(args.Used, produce.SolutionName, out var solution)) | ||
return; | ||
|
||
// Can produce even have fractional amounts? Does it matter if they do? | ||
// Questions man was never meant to answer. | ||
var matAmount = solution.Value.Comp.Solution.Contents | ||
.Where(r => ent.Comp.ExtractionReagents.Contains(r.Reagent.Prototype)) | ||
.Sum(r => r.Quantity.Float()); | ||
_materialStorage.TryChangeMaterialAmount(ent, ent.Comp.ExtractedMaterial, (int) matAmount); | ||
|
||
_audio.PlayPvs(ent.Comp.ExtractSound, ent); | ||
QueueDel(args.Used); | ||
args.Handled = true; | ||
} | ||
} |
Oops, something went wrong.