2020-08-22 22:29:20 +02:00
|
|
|
using System;
|
2021-12-07 19:19:26 +13:00
|
|
|
using System.Threading;
|
2020-12-17 10:45:04 +03:00
|
|
|
using System.Threading.Tasks;
|
2021-12-05 00:33:21 +13:00
|
|
|
using Content.Server.Administration.Logs;
|
2021-11-11 16:10:57 -07:00
|
|
|
using Content.Server.Body.Components;
|
2021-11-30 16:47:21 -07:00
|
|
|
using Content.Server.Body.Systems;
|
2021-10-29 13:40:15 +01:00
|
|
|
using Content.Server.Chemistry.Components.SolutionManager;
|
|
|
|
|
using Content.Server.Chemistry.EntitySystems;
|
2021-12-05 00:33:21 +13:00
|
|
|
using Content.Server.CombatMode;
|
|
|
|
|
using Content.Server.DoAfter;
|
|
|
|
|
using Content.Shared.ActionBlocker;
|
2021-11-11 16:10:57 -07:00
|
|
|
using Content.Shared.Body.Components;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Chemistry.Components;
|
|
|
|
|
using Content.Shared.Chemistry.Reagent;
|
2021-12-05 00:33:21 +13:00
|
|
|
using Content.Shared.Database;
|
2021-11-03 16:48:03 -07:00
|
|
|
using Content.Shared.FixedPoint;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Interaction;
|
|
|
|
|
using Content.Shared.Interaction.Helpers;
|
2021-12-05 00:33:21 +13:00
|
|
|
using Content.Shared.MobState.Components;
|
2021-09-26 15:18:45 +02:00
|
|
|
using Content.Shared.Popups;
|
2020-02-23 19:47:33 -05:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 11:11:52 +01:00
|
|
|
using Robust.Shared.IoC;
|
2020-02-23 19:47:33 -05:00
|
|
|
using Robust.Shared.Localization;
|
2021-12-05 00:33:21 +13:00
|
|
|
using Robust.Shared.Player;
|
2021-02-18 09:09:07 +01:00
|
|
|
using Robust.Shared.Players;
|
2021-03-05 01:08:38 +01:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2020-02-23 19:47:33 -05:00
|
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Chemistry.Components
|
2020-02-23 19:47:33 -05:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Server behavior for reagent injectors and syringes. Can optionally support both
|
|
|
|
|
/// injection and drawing or just injection. Can inject/draw reagents from solution
|
|
|
|
|
/// containers, and can directly inject into a mobs bloodstream.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[RegisterComponent]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class InjectorComponent : SharedInjectorComponent
|
2020-02-23 19:47:33 -05:00
|
|
|
{
|
2021-09-06 15:49:44 +02:00
|
|
|
public const string SolutionName = "injector";
|
|
|
|
|
|
2020-02-23 19:47:33 -05:00
|
|
|
/// <summary>
|
|
|
|
|
/// Whether or not the injector is able to draw from containers or if it's a single use
|
|
|
|
|
/// device that can only inject.
|
|
|
|
|
/// </summary>
|
2021-03-05 01:08:38 +01:00
|
|
|
[ViewVariables]
|
|
|
|
|
[DataField("injectOnly")]
|
2022-02-07 00:34:13 +11:00
|
|
|
public bool InjectOnly;
|
2020-02-23 19:47:33 -05:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Amount to inject or draw on each usage. If the injector is inject only, it will
|
|
|
|
|
/// attempt to inject it's entire contents upon use.
|
|
|
|
|
/// </summary>
|
2021-12-05 00:33:21 +13:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("transferAmount")]
|
2022-02-07 00:34:13 +11:00
|
|
|
public FixedPoint2 TransferAmount = FixedPoint2.New(5);
|
2020-02-23 19:47:33 -05:00
|
|
|
|
|
|
|
|
/// <summary>
|
2021-12-05 00:33:21 +13:00
|
|
|
/// Injection delay (seconds) when the target is a mob.
|
2020-02-23 19:47:33 -05:00
|
|
|
/// </summary>
|
2021-12-05 00:33:21 +13:00
|
|
|
/// <remarks>
|
|
|
|
|
/// The base delay has a minimum of 1 second, but this will still be modified if the target is incapacitated or
|
|
|
|
|
/// in combat mode.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
[DataField("delay")]
|
|
|
|
|
public float Delay = 5;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2021-12-07 19:19:26 +13:00
|
|
|
/// Token for interrupting a do-after action (e.g., injection another player). If not null, implies
|
|
|
|
|
/// component is currently "in use".
|
2021-12-05 00:33:21 +13:00
|
|
|
/// </summary>
|
2021-12-07 19:19:26 +13:00
|
|
|
public CancellationTokenSource? CancelToken;
|
2020-02-23 19:47:33 -05:00
|
|
|
|
2021-01-25 02:10:23 +01:00
|
|
|
private InjectorToggleMode _toggleState;
|
|
|
|
|
|
2020-02-23 19:47:33 -05:00
|
|
|
/// <summary>
|
|
|
|
|
/// The state of the injector. Determines it's attack behavior. Containers must have the
|
|
|
|
|
/// right SolutionCaps to support injection/drawing. For InjectOnly injectors this should
|
|
|
|
|
/// only ever be set to Inject
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2021-01-25 02:10:23 +01:00
|
|
|
public InjectorToggleMode ToggleState
|
|
|
|
|
{
|
|
|
|
|
get => _toggleState;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_toggleState = value;
|
|
|
|
|
Dirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-02-23 19:47:33 -05:00
|
|
|
}
|
|
|
|
|
}
|