Skip to content

Commit

Permalink
Autoinjectors220 (SerbiaStrong-220#881)
Browse files Browse the repository at this point in the history
* хуйхухйхуйхухйхуй

* le mew

* oopsfix

* lefix

* lefix

* cultcultmybeloved

* NUKETIMEEEEE

* Merge branch 'Codemew' of https://github.com/Gnomeev/space-station-14 into Codemew

* Revert "NUKETIMEEEEE"

This reverts commit 66da1a8.

* Revert "cultcultmybeloved"

This reverts commit ba303e7.

* some :gagaga:

* (hope)done

* well well well

* quickfix

---------

Co-authored-by: Malutka Gnomeev <[email protected]>
  • Loading branch information
Gnomeev and Gnomeev authored May 15, 2024
1 parent c249c65 commit c553b5a
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Content.Server/Chemistry/EntitySystems/HypospraySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Robust.Server.Audio;
using Content.Shared.Chemistry;

namespace Content.Server.Chemistry.EntitySystems;

Expand Down Expand Up @@ -144,6 +145,10 @@ public bool TryDoInject(Entity<HyposprayComponent> entity, EntityUid target, Ent

var ev = new TransferDnaEvent { Donor = target, Recipient = uid };
RaiseLocalEvent(target, ref ev);
//220 autoinjector update begin
var hypoev = new AfterHypoEvent(entity, target, user);
RaiseLocalEvent(entity, ref hypoev);
//220 autoinjector update end

// same LogType as syringes...
_adminLogger.Add(LogType.ForceFeed, $"{EntityManager.ToPrettyString(user):user} injected {EntityManager.ToPrettyString(target):target} with a solution {SolutionContainerSystem.ToPrettyString(removedSolution):removedSolution} using a {EntityManager.ToPrettyString(uid):using}");
Expand Down
13 changes: 13 additions & 0 deletions Content.Server/SS220/Autoinjector/AutoinjectorComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Content.Server.Chemistry.Components
{
[RegisterComponent]
public sealed partial class AutoinjectorComponent : Component
{
[DataField]
public string OnUseMessage = "loc-autoinjector-after-use";
[DataField]
public string OnExaminedMessage = "loc-autoinjector-examined-message";
[DataField, ViewVariables(VVAccess.ReadOnly)]
public bool Used = false;
}
}
40 changes: 40 additions & 0 deletions Content.Server/SS220/Autoinjector/AutoinjectorSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Content.Server.Chemistry.Components;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Components;
using Content.Server.Popups;
using Content.Shared.Examine;

namespace Content.Server.SS220.Autoinjector
{
public sealed partial class AutoinjectorSystem : EntitySystem
{
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly PopupSystem _popup = default!;
public override void Initialize()
{
SubscribeLocalEvent<AutoinjectorComponent, AfterHypoEvent>(OnAfterHypo);
SubscribeLocalEvent<AutoinjectorComponent, ExaminedEvent>(OnExamined);
}

private void OnExamined(Entity<AutoinjectorComponent> entity, ref ExaminedEvent ev)
{
if (entity.Comp.Used)
ev.PushMarkup(Loc.GetString(entity.Comp.OnExaminedMessage));
}

private void OnAfterHypo(Entity<AutoinjectorComponent> entity, ref AfterHypoEvent ev)
{
if (!TryComp<HyposprayComponent>(entity, out var hypoComp)
|| !_solutionContainerSystem.TryGetSolution(entity.Owner, hypoComp.SolutionName, out _, out _))
return;

RemComp<RefillableSolutionComponent>(entity);
entity.Comp.Used = true;

var message = Loc.GetString(entity.Comp.OnUseMessage);
_popup.PopupEntity(message, ev.Target, ev.User);
}
}
}

17 changes: 17 additions & 0 deletions Content.Shared/Chemistry/SharedAfterHypoEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Content.Shared.Chemistry
{
[ByRefEvent]
public readonly struct AfterHypoEvent
{
public readonly EntityUid Hypo;
public readonly EntityUid Target;
public readonly EntityUid User;

public AfterHypoEvent(EntityUid hypo, EntityUid target, EntityUid user)
{
Hypo = hypo;
Target = target;
User = user;
}
}
}
2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/ss220/autoinjector/autoinjector.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
loc-autoinjector-after-use = Вы использовали одноразовый автоинъектор
loc-autoinjector-examined-message = [color=#C41E3A] Инъектор уже был использован. [/color]
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@
- Saw
- Hemostat
- ClothingEyesGlassesChemical
- MedAutoinjector #ss220 Autoinjecors update
dynamicRecipes:
- ChemicalPayload
- CryostasisBeaker
Expand Down
9 changes: 9 additions & 0 deletions Resources/Prototypes/Recipes/Lathes/medical.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,12 @@
Steel: 600
Plastic: 300

- type: latheRecipe # ss220 autoinjectors update
id: MedAutoinjector
result: MedAutoinjector
completetime: 2
materials:
Glass: 100
Plastic: 200
Steel: 25

46 changes: 46 additions & 0 deletions Resources/Prototypes/SS220/Chemistry/autoinjectors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
- type: entity
name: Автоинжектор
parent: BaseItem
description: уээээ
id: BaseAutoinjectorss220
abstract: true
components:
- type: Sprite
sprite: SS220/Objects/Misc/autoinjectors.rsi
state: autoinjector
- type: Item
sprite: SS220/Objects/Misc/autoinjectors.rsi
size: Tiny
- type: SolutionContainerManager
solutions:
pen:
maxVol: 15
- type: ExaminableSolution
solution: pen
- type: Hypospray
solutionName: pen
onlyAffectsMobs: false
injectOnly: true
transferAmount: 15
- type: RefillableSolution
solution: pen
- type: Autoinjector

- type: entity
name: Медицинский автоинжектор
parent: BaseAutoinjectorss220
description: Одноразовый медицинский автоинжектор, предназначеный для быстрой доставки веществ в организм. Внимание! После первого использование повторно пополнить инжектор будет невозможно. Использовать с умом.
id: MedAutoinjector
components:
- type: SolutionContainerManager
solutions:
pen:
maxVol: 10
- type: ExaminableSolution
solution: pen
- type: Hypospray
solutionName: pen
onlyAffectsMobs: false
injectOnly: true
transferAmount: 10
- type: Autoinjector
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Resources/Textures/SS220/Objects/Misc/autoinjectors.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Sprites made by okroshka59 for SS220.",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "autoinjector"
}
]

}

0 comments on commit c553b5a

Please sign in to comment.