Hyposprays Draw from Jugs (#25544)
* Hyposprays Draw from Jugs * Fix last onlyMobs usage in yml * Some Suggested Changes * Remove unnecessary datafield name declarations * Remove unnecessary dirtying of component * Same line parentheses * Added client-side HypospraySystem * Cache UI values and only updates if values change * empty line * Update label * Label change * Reimplement ReactionMixerSystem * Remove DataField from Hypospray Toggle Mode * Change ToggleMode from enum to Bool OnlyAffectsMobs * Add DataField required back since it's required for replays...? * update EligibleEntity and uses of it * Add user argument back * Adds newline Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Guard for dirty entity * Adds summary tag --------- Co-authored-by: Plykiya <plykiya@protonmail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
33
Content.Shared/Chemistry/Components/HyposprayComponent.cs
Normal file
33
Content.Shared/Chemistry/Components/HyposprayComponent.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Shared.Chemistry.Components;
|
||||
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class HyposprayComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public string SolutionName = "hypospray";
|
||||
|
||||
// TODO: This should be on clumsycomponent.
|
||||
[DataField]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float ClumsyFailChance = 0.5f;
|
||||
|
||||
[DataField]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public FixedPoint2 TransferAmount = FixedPoint2.New(5);
|
||||
|
||||
[DataField]
|
||||
public SoundSpecifier InjectSound = new SoundPathSpecifier("/Audio/Items/hypospray.ogg");
|
||||
|
||||
/// <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;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Chemistry.Components;
|
||||
|
||||
[NetworkedComponent()]
|
||||
public abstract partial class SharedHyposprayComponent : Component
|
||||
{
|
||||
[DataField("solutionName")]
|
||||
public string SolutionName = "hypospray";
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class HyposprayComponentState : ComponentState
|
||||
{
|
||||
public FixedPoint2 CurVolume { get; }
|
||||
public FixedPoint2 MaxVolume { get; }
|
||||
|
||||
public HyposprayComponentState(FixedPoint2 curVolume, FixedPoint2 maxVolume)
|
||||
{
|
||||
CurVolume = curVolume;
|
||||
MaxVolume = maxVolume;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Timing;
|
||||
using Content.Shared.Verbs;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.Player;
|
||||
using Content.Shared.Administration.Logs;
|
||||
|
||||
namespace Content.Shared.Chemistry.EntitySystems;
|
||||
|
||||
public abstract class SharedHypospraySystem : EntitySystem
|
||||
{
|
||||
[Dependency] protected readonly UseDelaySystem _useDelay = default!;
|
||||
[Dependency] protected readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] protected readonly SharedSolutionContainerSystem _solutionContainers = default!;
|
||||
[Dependency] protected readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] protected readonly ReactiveSystem _reactiveSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<HyposprayComponent, GetVerbsEvent<AlternativeVerb>>(AddToggleModeVerb);
|
||||
}
|
||||
|
||||
// <summary>
|
||||
// Uses the OnlyMobs field as a check to implement the ability
|
||||
// to draw from jugs and containers with the hypospray
|
||||
// Toggleable to allow people to inject containers if they prefer it over drawing
|
||||
// </summary>
|
||||
private void AddToggleModeVerb(Entity<HyposprayComponent> entity, ref GetVerbsEvent<AlternativeVerb> args)
|
||||
{
|
||||
if (!args.CanAccess || !args.CanInteract || args.Hands == null)
|
||||
return;
|
||||
|
||||
var (_, component) = entity;
|
||||
var user = args.User;
|
||||
var verb = new AlternativeVerb
|
||||
{
|
||||
Text = Loc.GetString("hypospray-verb-mode-label"),
|
||||
Act = () =>
|
||||
{
|
||||
ToggleMode(entity, user);
|
||||
}
|
||||
};
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
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";
|
||||
_popup.PopupClient(Loc.GetString(msg), entity, user);
|
||||
}
|
||||
|
||||
public void SetMode(Entity<HyposprayComponent> entity, bool onlyAffectsMobs)
|
||||
{
|
||||
if (entity.Comp.OnlyAffectsMobs == onlyAffectsMobs)
|
||||
return;
|
||||
|
||||
entity.Comp.OnlyAffectsMobs = onlyAffectsMobs;
|
||||
Dirty(entity);
|
||||
}
|
||||
}
|
||||
@@ -37,10 +37,7 @@ public abstract class SharedInjectorSystem : EntitySystem
|
||||
if (!args.CanAccess || !args.CanInteract || args.Hands == null)
|
||||
return;
|
||||
|
||||
if (!HasComp<ActorComponent>(args.User))
|
||||
return;
|
||||
var user = args.User;
|
||||
|
||||
var (_, component) = entity;
|
||||
|
||||
var min = component.MinimumTransferAmount;
|
||||
|
||||
Reference in New Issue
Block a user