From 2446c6a37b95455049ecdf359ab7c955e0e06540 Mon Sep 17 00:00:00 2001 From: Vasilis Date: Thu, 7 Sep 2023 18:49:02 +0200 Subject: [PATCH] Hypo can inject solutions back into beakers (#19877) * Inject to beakers * Stop fighting in my pr * Review --- .../Chemistry/Components/HyposprayComponent.cs | 6 ++++++ .../EntitySystems/ChemistrySystemHypospray.cs | 14 ++++++++------ .../Objects/Specific/Medical/hypospray.yml | 3 +++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Content.Server/Chemistry/Components/HyposprayComponent.cs b/Content.Server/Chemistry/Components/HyposprayComponent.cs index cddbd17888..76bb0e8d41 100644 --- a/Content.Server/Chemistry/Components/HyposprayComponent.cs +++ b/Content.Server/Chemistry/Components/HyposprayComponent.cs @@ -19,5 +19,11 @@ namespace Content.Server.Chemistry.Components [DataField("injectSound")] public SoundSpecifier InjectSound = new SoundPathSpecifier("/Audio/Items/hypospray.ogg"); + + /// + /// Whether or not the hypo is able to inject only into mobs. On false you can inject into beakers/jugs + /// + [DataField("onlyMobs")] + public bool OnlyMobs = true; } } diff --git a/Content.Server/Chemistry/EntitySystems/ChemistrySystemHypospray.cs b/Content.Server/Chemistry/EntitySystems/ChemistrySystemHypospray.cs index d357e46f66..a352d51368 100644 --- a/Content.Server/Chemistry/EntitySystems/ChemistrySystemHypospray.cs +++ b/Content.Server/Chemistry/EntitySystems/ChemistrySystemHypospray.cs @@ -74,7 +74,7 @@ namespace Content.Server.Chemistry.EntitySystems if (!Resolve(uid, ref component)) return false; - if (!EligibleEntity(target, _entMan)) + if (!EligibleEntity(target, _entMan, component)) return false; if (TryComp(uid, out UseDelayComponent? delayComp) && _useDelay.ActiveDelay(uid, delayComp)) @@ -84,7 +84,7 @@ namespace Content.Server.Chemistry.EntitySystems if (target == user) msgFormat = "hypospray-component-inject-self-message"; - else if (EligibleEntity(user, _entMan) && _interaction.TryRollClumsy(user, component.ClumsyFailChance)) + else if (EligibleEntity(user, _entMan, component) && _interaction.TryRollClumsy(user, component.ClumsyFailChance)) { msgFormat = "hypospray-component-inject-self-clumsy-message"; target = user; @@ -143,13 +143,15 @@ namespace Content.Server.Chemistry.EntitySystems return true; } - static bool EligibleEntity([NotNullWhen(true)] EntityUid? entity, IEntityManager entMan) + static bool EligibleEntity([NotNullWhen(true)] EntityUid? entity, IEntityManager entMan, HyposprayComponent component) { // TODO: Does checking for BodyComponent make sense as a "can be hypospray'd" tag? // In SS13 the hypospray ONLY works on mobs, NOT beakers or anything else. - - return entMan.HasComponent(entity) - && entMan.HasComponent(entity); + // But this is 14, we dont do what SS13 does just because SS13 does it. + return component.OnlyMobs + ? entMan.HasComponent(entity) && + entMan.HasComponent(entity) + : entMan.HasComponent(entity); } } } diff --git a/Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml b/Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml index 2dc5555c03..fb234194f9 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml @@ -18,6 +18,7 @@ - type: ExaminableSolution solution: hypospray - type: Hypospray + onlyMobs: false - type: UseDelay delay: 0.5 - type: StaticPrice @@ -46,6 +47,7 @@ - type: ExaminableSolution solution: hypospray - type: Hypospray + onlyMobs: false - type: UseDelay delay: 0.5 @@ -330,6 +332,7 @@ - type: ExaminableSolution solution: hypospray - type: Hypospray + onlyMobs: false - type: UseDelay delay: 0.5 - type: StaticPrice # A new shitcurity meta -- 2.51.2