-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial implementation of combat hypospray mechanics
- Loading branch information
1 parent
1a2fda6
commit e15ca6b
Showing
12 changed files
with
237 additions
and
1 deletion.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
Content.Shared/_DV/Chemistry/Components/SolutionCartridgeReceiverComponent.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,25 @@ | ||
using Content.Shared.Containers.ItemSlots; | ||
using Content.Shared.Tag; | ||
using Robust.Shared.Audio; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Shared._DV.Chemistry.SolutionCartridge; | ||
|
||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class SolutionCartridgeReceiverComponent : Component | ||
{ | ||
public const string CartridgeSlotId = "cartridge-slot"; | ||
|
||
[DataField("cartridgeSlot")] | ||
public ItemSlot CartridgeSlot = new(); | ||
|
||
[DataField] | ||
public string HypospraySolution = "hypospray"; | ||
|
||
[DataField] | ||
public string CartridgeSolution = "cartridge"; | ||
|
||
[DataField] | ||
public SoundSpecifier InsertSound = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/revolver_magin.ogg"); | ||
} |
94 changes: 94 additions & 0 deletions
94
Content.Shared/_DV/Chemistry/Systems/SolutionCartridgeReceiverSystem.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,94 @@ | ||
using Content.Shared.Chemistry.Components.SolutionManager; | ||
using Content.Shared.Chemistry.EntitySystems; | ||
using Content.Shared.Containers.ItemSlots; | ||
using Robust.Shared.Containers; | ||
|
||
namespace Content.Shared._DV.Chemistry.SolutionCartridge; | ||
|
||
public sealed class SolutionCartridgeReceiverSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedSolutionContainerSystem _container = default!; | ||
|
||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; // TODO: Use this | ||
|
||
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<SolutionCartridgeReceiverComponent, ComponentInit>(OnComponentInit); | ||
SubscribeLocalEvent<SolutionCartridgeReceiverComponent, ComponentRemove>(OnComponentRemove); | ||
|
||
SubscribeLocalEvent<SolutionCartridgeReceiverComponent, EntInsertedIntoContainerMessage>(OnItemInserted); | ||
SubscribeLocalEvent<SolutionCartridgeReceiverComponent, EntRemovedFromContainerMessage>(OnItemRemoved); | ||
} | ||
|
||
private void OnComponentInit(EntityUid uid, SolutionCartridgeReceiverComponent receiver, ComponentInit args) | ||
{ | ||
_itemSlots.AddItemSlot(uid, SolutionCartridgeReceiverComponent.CartridgeSlotId, receiver.CartridgeSlot); | ||
} | ||
|
||
private void OnComponentRemove(EntityUid uid, SolutionCartridgeReceiverComponent receiver, ComponentRemove args) | ||
{ | ||
_itemSlots.RemoveItemSlot(uid, receiver.CartridgeSlot); | ||
} | ||
|
||
private bool DrainInto(EntityUid fromEnt, string fromName, EntityUid toEnt, string toName) | ||
{ | ||
if (!TryComp(fromEnt, out SolutionContainerManagerComponent? fromManager)) | ||
return false; | ||
|
||
if (!_container.TryGetSolution((fromEnt, fromManager), | ||
fromName, | ||
out var _, | ||
out var fromSolution)) | ||
return false; | ||
|
||
// Get the solution from our hypospray | ||
if (!TryComp(toEnt, out SolutionContainerManagerComponent? toManager)) | ||
return false; | ||
|
||
if (!_container.TryGetSolution((toEnt, toManager), | ||
toName, | ||
out var toSolutionEnt, | ||
out var _)) | ||
return false; | ||
|
||
if (!_container.TryAddSolution(toSolutionEnt.Value, fromSolution)) | ||
return false; | ||
|
||
// Drain the solution completely | ||
fromSolution.RemoveAllSolution(); | ||
|
||
return true; | ||
} | ||
|
||
private void OnItemInserted(Entity<SolutionCartridgeReceiverComponent> entity, ref EntInsertedIntoContainerMessage args) | ||
{ | ||
var (uid, receiver) = entity; | ||
|
||
// Drain the newly inserted cartridge into the hypospray | ||
if (!DrainInto(args.Entity, receiver.CartridgeSolution, | ||
uid, receiver.HypospraySolution)) | ||
{ | ||
return; | ||
} | ||
|
||
// TODO: Update appearance | ||
} | ||
|
||
private void OnItemRemoved(Entity<SolutionCartridgeReceiverComponent> entity, ref EntRemovedFromContainerMessage args) | ||
{ | ||
var (uid, receiver) = entity; | ||
|
||
// Drain the hypospray into the cartridge that's been removed | ||
if (!DrainInto(uid, receiver.HypospraySolution, | ||
args.Entity, receiver.CartridgeSolution)) | ||
{ | ||
return; | ||
} | ||
|
||
// TODO: Update appearance | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
Resources/Prototypes/_DV/Entities/Objects/Specific/Medical/hypospray.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,79 @@ | ||
- type: entity | ||
id: CombatHypospray | ||
name: combat hypospray | ||
parent: [BaseItem, BaseRestrictedContraband] | ||
description: A small hypospray intended for combat and rapid response teams, uses pre-built cartridges | ||
components: | ||
- type: Sprite | ||
sprite: _DV/Objects/Specific/Medical/combathypo.rsi | ||
state: hypo | ||
- type: Item | ||
sprite: _DV/Objects/Specific/Medical/combathypo.rsi | ||
- type: SolutionContainerManager | ||
solutions: | ||
hypospray: | ||
maxVol: 30 | ||
reagents: [] | ||
- type: ExaminableSolution | ||
solution: hypospray | ||
- type: Hypospray | ||
solutionName: hypospray | ||
transferAmount: 5 | ||
onlyAffectsMobs: false | ||
injectOnly: true | ||
- type: HyposprayBlockNonMobInjection | ||
- type: UseDelay | ||
delay: 0.5 | ||
- type: SolutionCartridgeReceiver | ||
cartridgeSlot: | ||
whitelist: | ||
tags: | ||
- HyposprayCartridge | ||
- type: ContainerContainer | ||
containers: | ||
cartridge-slot: !type:ContainerSlot {} | ||
|
||
- type: entity | ||
id: BaseEmptyHypoCartridge | ||
name: hypo cartridge | ||
parent: [BaseItem, BaseRestrictedContraband] | ||
components: | ||
- type: SolutionContainerManager | ||
solutions: | ||
cartridge: | ||
maxVol: 30 | ||
reagents: [] | ||
- type: Tag | ||
tags: | ||
- HyposprayCartridge | ||
- type: Sprite | ||
sprite: Objects/Specific/Chemistry/bottle.rsi | ||
layers: | ||
- state: bottle-1 | ||
- state: bottle-1-1 | ||
map: ["enum.SolutionContainerLayers.Fill"] | ||
visible: false | ||
- type: ExaminableSolution | ||
solution: cartridge | ||
- type: SolutionItemStatus | ||
solution: cartridge | ||
- type: SolutionContainerVisuals | ||
maxFillLevels: 6 | ||
fillBaseName: bottle-1- | ||
- type: Item | ||
size: Tiny | ||
sprite: Objects/Specific/Chemistry/bottle.rsi | ||
|
||
- type: entity | ||
id: BicaridineHypoCartridge | ||
name: Bicaridine hypo cartridge | ||
parent: BaseEmptyHypoCartridge | ||
components: | ||
- type: SolutionContainerManager | ||
solutions: | ||
cartridge: | ||
maxVol: 30 | ||
reagents: | ||
- ReagentId: Bicaridine | ||
Quantity: 30 | ||
|
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
Binary file added
BIN
+602 Bytes
Resources/Textures/_DV/Objects/Specific/Medical/combathypo.rsi/borghypo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+517 Bytes
Resources/Textures/_DV/Objects/Specific/Medical/combathypo.rsi/borghypo_s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+665 Bytes
Resources/Textures/_DV/Objects/Specific/Medical/combathypo.rsi/combat_hypo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+293 Bytes
Resources/Textures/_DV/Objects/Specific/Medical/combathypo.rsi/equipped-BELT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+429 Bytes
Resources/Textures/_DV/Objects/Specific/Medical/combathypo.rsi/hypo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+319 Bytes
Resources/Textures/_DV/Objects/Specific/Medical/combathypo.rsi/inhand-left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+319 Bytes
Resources/Textures/_DV/Objects/Specific/Medical/combathypo.rsi/inhand-right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions
35
Resources/Textures/_DV/Objects/Specific/Medical/combathypo.rsi/meta.json
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,35 @@ | ||
{ | ||
"version": 1, | ||
"license": "CC-BY-SA-3.0", | ||
"copyright": "Taken from vgstation at commit https://github.com/vgstation-coders/vgstation13/commit/1cdfb0230cc96d0ba751fa002d04f8aa2f25ad7d", | ||
"size": { | ||
"x": 32, | ||
"y": 32 | ||
}, | ||
"states": [ | ||
{ | ||
"name": "borghypo" | ||
}, | ||
{ | ||
"name": "borghypo_s" | ||
}, | ||
{ | ||
"name": "combat_hypo" | ||
}, | ||
{ | ||
"name": "hypo" | ||
}, | ||
{ | ||
"name": "inhand-left", | ||
"directions": 4 | ||
}, | ||
{ | ||
"name": "inhand-right", | ||
"directions": 4 | ||
}, | ||
{ | ||
"name": "equipped-BELT", | ||
"directions": 4 | ||
} | ||
] | ||
} |