Make container draw disableble for mob-affecting Hyposprays (#30683)

* Seperate container draw from affects mobs

* Spaces

* More spaces

* Fix toggle

* Use better ands

* Reorder checks for Performance™️

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
This commit is contained in:
Verm
2025-05-07 15:43:47 -05:00
committed by GitHub
parent df10d75cf7
commit 47258651a3
4 changed files with 12 additions and 5 deletions

View File

@@ -44,7 +44,7 @@ public sealed class HyposprayStatusControl : Control
PrevMaxVolume = solution.MaxVolume;
PrevOnlyAffectsMobs = _parent.Comp.OnlyAffectsMobs;
var modeStringLocalized = Loc.GetString(_parent.Comp.OnlyAffectsMobs switch
var modeStringLocalized = Loc.GetString((_parent.Comp.OnlyAffectsMobs && _parent.Comp.CanContainerDraw) switch
{
false => "hypospray-all-mode-text",
true => "hypospray-mobs-only-mode-text",

View File

@@ -33,8 +33,9 @@ public sealed class HypospraySystem : SharedHypospraySystem
private bool TryUseHypospray(Entity<HyposprayComponent> entity, EntityUid target, EntityUid user)
{
// if target is ineligible but is a container, try to draw from the container
if (!EligibleEntity(target, EntityManager, entity)
// if target is ineligible but is a container, try to draw from the container if allowed
if (entity.Comp.CanContainerDraw
&& !EligibleEntity(target, EntityManager, entity)
&& _solutionContainers.TryGetDrawableSolution(target, out var drawableSolution, out _))
{
return TryDraw(entity, target, drawableSolution.Value, user);

View File

@@ -20,12 +20,18 @@ public sealed partial class HyposprayComponent : Component
/// <summary>
/// Decides whether you can inject everything or just mobs.
/// When you can only affect mobs, you're capable of drawing from beakers.
/// </summary>
[AutoNetworkedField]
[DataField(required: true)]
public bool OnlyAffectsMobs = false;
/// <summary>
/// If this can draw from containers in mob-only mode.
/// </summary>
[AutoNetworkedField]
[DataField]
public bool CanContainerDraw = true;
/// <summary>
/// Whether or not the hypospray is able to draw from containers or if it's a single use
/// device that can only inject.

View File

@@ -46,7 +46,7 @@ public abstract class SharedHypospraySystem : EntitySystem
private void ToggleMode(Entity<HyposprayComponent> entity, EntityUid user)
{
SetMode(entity, !entity.Comp.OnlyAffectsMobs);
string msg = entity.Comp.OnlyAffectsMobs ? "hypospray-verb-mode-inject-mobs-only" : "hypospray-verb-mode-inject-all";
string msg = (entity.Comp.OnlyAffectsMobs && entity.Comp.CanContainerDraw) ? "hypospray-verb-mode-inject-mobs-only" : "hypospray-verb-mode-inject-all";
_popup.PopupClient(Loc.GetString(msg), entity, user);
}