-
Notifications
You must be signed in to change notification settings - Fork 401
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
1 parent
a9d799b
commit f5c299d
Showing
4 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
Content.Server/_DV/Chemistry/Components/CartridgeFabricatorComponent.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,13 @@ | ||
using Content.Shared.Tag; | ||
|
||
namespace Content.Server._DV.Chemistry.Components; | ||
|
||
[RegisterComponent] | ||
public sealed partial class CartridgeFabricatorComponent : Component | ||
{ | ||
[DataField] | ||
public string InputSolution = "drink"; | ||
|
||
[DataField] | ||
public string OutputSolution = "cartridge"; | ||
} |
68 changes: 68 additions & 0 deletions
68
Content.Server/_DV/Chemistry/EntitySystems/CartridgeFabricatorSystem.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,68 @@ | ||
using Content.Server._DV.Chemistry.Components; | ||
using Content.Server.Popups; | ||
using Content.Server.Power.EntitySystems; | ||
using Content.Shared.Chemistry.Components; | ||
using Content.Shared.Chemistry.Components.SolutionManager; | ||
using Content.Shared.Chemistry.EntitySystems; | ||
using Content.Shared.Interaction; | ||
using Content.Shared.Popups; | ||
using Content.Shared.Tag; | ||
using Robust.Shared.Prototypes; | ||
using YamlDotNet.Core.Tokens; | ||
|
||
namespace Content.Server._DV.Chemistry.Systems; | ||
|
||
public sealed class CartridgeFabricatorSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedSolutionContainerSystem _container = default!; | ||
[Dependency] private readonly PopupSystem _popupSystem = default!; | ||
[Dependency] private readonly TagSystem _tags = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
|
||
private static readonly ProtoId<TagPrototype>[] BottleTags = {"Bottle"}; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<CartridgeFabricatorComponent, InteractUsingEvent>(OnInteractUsing); | ||
} | ||
|
||
private void OnInteractUsing(Entity<CartridgeFabricatorComponent> entity, ref InteractUsingEvent args) | ||
{ | ||
if (!this.IsPowered(entity.Owner, EntityManager)) | ||
return; | ||
|
||
if (!TryComp(args.Used, out SolutionContainerManagerComponent? manager)) | ||
return; | ||
|
||
if (!_tags.HasAnyTag(args.Used, BottleTags)) | ||
return; | ||
|
||
if (!_container.TryGetSolution((args.Used, manager), | ||
entity.Comp.InputSolution, | ||
out var _, | ||
out var fromSolution)) | ||
return; | ||
|
||
// Success, this is a bottle with an amount of _something_ in it. | ||
args.Handled = true; | ||
|
||
_popupSystem.PopupCursor("You made a thing!", args.User, PopupType.Medium); | ||
|
||
var coords = Transform(entity.Owner).Coordinates; | ||
var cartridge = Spawn("BaseEmptyHypoCartridge", coords); | ||
|
||
var cartridgeManager = EnsureComp<SolutionContainerManagerComponent>(cartridge); | ||
if (!_container.TryGetSolution((cartridge, cartridgeManager), | ||
entity.Comp.OutputSolution, | ||
out var cartridgeSolutionEnt, | ||
out var _)) | ||
return; // Something very wrong here? | ||
|
||
if (!_container.TryAddSolution(cartridgeSolutionEnt.Value, fromSolution)) | ||
return; | ||
|
||
QueueDel(args.Used); // Ensure the old one is gone | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Resources/Prototypes/_DV/Entities/Objects/Devices/CircuitBoards/Machine/production.yml
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,17 @@ | ||
|
||
- type: entity | ||
id: CartridgeFabricatorMachineCircuitboard | ||
parent: BaseMachineCircuitboard | ||
name: cartridge fabricator machine board | ||
description: A machine printed circuit board for a cartridge fabricator | ||
components: | ||
- type: Sprite | ||
state: service | ||
- type: MachineBoard | ||
prototype: CartridgeFabricator | ||
stackRequirements: | ||
Manipulator: 2 | ||
Capacitor: 1 | ||
# replacing the console screen | ||
Glass: 1 | ||
Cable: 2 |
38 changes: 38 additions & 0 deletions
38
Resources/Prototypes/_DV/Structures/Machines/cartridge_fabricator.yml
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,38 @@ | ||
- type: entity | ||
id: CartridgeFabricator | ||
name: cartridge fabricator | ||
parent: [ BaseMachinePowered, ConstructibleMachine ] | ||
description: Converts bottles of chemicals into hypospray cartridges | ||
components: | ||
# TODO: Make this not the seed extractor | ||
- type: Sprite | ||
sprite: Structures/Machines/seed_extractor.rsi | ||
snapCardinals: true | ||
layers: | ||
- state: seedextractor-off | ||
- state: seedextractor-unlit | ||
shader: unshaded | ||
map: ["enum.PowerDeviceVisualLayers.Powered"] | ||
- type: Physics | ||
bodyType: Static | ||
- type: Fixtures | ||
fixtures: | ||
fix1: | ||
shape: | ||
!type:PhysShapeAabb | ||
bounds: "-0.25,-0.4,0.25,0.4" | ||
density: 190 | ||
mask: | ||
- MachineMask | ||
layer: | ||
- MachineLayer | ||
- type: Appearance | ||
- type: GenericVisualizer | ||
visuals: | ||
enum.PowerDeviceVisuals.Powered: | ||
enum.PowerDeviceVisualLayers.Powered: | ||
True: { visible: true } | ||
False: { visible: false } | ||
- type: CartridgeFabricator | ||
- type: Machine | ||
board: CartridgeFabricatorMachineCircuitboard |