Adds missing reactions to chemical stuff.
- Adds ingestion reaction for food, drinks, and pills. - Adds injection reaction for syringes.
This commit is contained in:
@@ -11,6 +11,8 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -21,6 +23,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
public class PillComponent : FoodComponent, IUse, IAfterInteract
|
||||
{
|
||||
[Dependency] private readonly IEntitySystemManager _entitySystem = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public override string Name => "Pill";
|
||||
|
||||
@@ -45,8 +48,11 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_contents = Owner.GetComponent<SolutionContainerComponent>();
|
||||
|
||||
if (!Owner.EnsureComponent(out _contents))
|
||||
{
|
||||
Logger.Error($"Prototype {Owner.Prototype?.ID} had a {nameof(PillComponent)} without a {nameof(SolutionContainerComponent)}!");
|
||||
}
|
||||
}
|
||||
|
||||
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
|
||||
@@ -86,13 +92,24 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
|
||||
var transferAmount = ReagentUnit.Min(_transferAmount, _contents.CurrentVolume);
|
||||
var split = _contents.SplitSolution(transferAmount);
|
||||
if (!stomach.TryTransferSolution(split))
|
||||
|
||||
if (!stomach.CanTransferSolution(split))
|
||||
{
|
||||
_contents.TryAddSolution(split);
|
||||
trueTarget.PopupMessage(user, Loc.GetString("You can't eat any more!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Account for partial transfer.
|
||||
|
||||
foreach (var (reagentId, quantity) in split.Contents)
|
||||
{
|
||||
if (!_prototypeManager.TryIndex(reagentId, out ReagentPrototype reagent)) continue;
|
||||
split.RemoveReagent(reagentId, reagent.ReactionEntity(trueTarget, ReactionMethod.Ingestion, quantity));
|
||||
}
|
||||
|
||||
stomach.TryTransferSolution(split);
|
||||
|
||||
if (_useSound != null)
|
||||
{
|
||||
_entitySystem.GetEntitySystem<AudioSystem>()
|
||||
|
||||
Reference in New Issue
Block a user