Custom transfer amount to hydroponic trays (#5833)
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Plants;
|
||||
@@ -727,23 +728,20 @@ namespace Content.Server.Botany.Components
|
||||
|
||||
var solutionSystem = EntitySystem.Get<SolutionContainerSystem>();
|
||||
if (solutionSystem.TryGetDrainableSolution(usingItem, out var solution)
|
||||
&& solutionSystem.TryGetSolution(Owner, SoilSolutionName, out var targetSolution))
|
||||
&& solutionSystem.TryGetSolution(Owner, SoilSolutionName, out var targetSolution) && _entMan.TryGetComponent(usingItem, out SprayComponent? spray))
|
||||
{
|
||||
var amount = FixedPoint2.New(5);
|
||||
var sprayed = false;
|
||||
var amount = FixedPoint2.New(1);
|
||||
|
||||
var targetEntity = Owner;
|
||||
var solutionEntity = usingItem;
|
||||
|
||||
if (_entMan.TryGetComponent(usingItem, out SprayComponent? spray))
|
||||
{
|
||||
sprayed = true;
|
||||
amount = FixedPoint2.New(1);
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound.GetSound(), usingItem,
|
||||
AudioHelpers.WithVariation(0.125f));
|
||||
}
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound.GetSound(), usingItem,
|
||||
AudioHelpers.WithVariation(0.125f));
|
||||
|
||||
|
||||
var split = solutionSystem.Drain(solutionEntity, solution, amount);
|
||||
|
||||
if (split.TotalVolume == 0)
|
||||
{
|
||||
user.PopupMessageCursor(Loc.GetString("plant-holder-component-empty-message",
|
||||
@@ -751,8 +749,7 @@ namespace Content.Server.Botany.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
user.PopupMessageCursor(Loc.GetString(
|
||||
sprayed ? "plant-holder-component-spray-message" : "plant-holder-component-transfer-message",
|
||||
user.PopupMessageCursor(Loc.GetString("plant-holder-component-spray-message",
|
||||
("owner", Owner),
|
||||
("amount", split.TotalVolume)));
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Content.Shared.FixedPoint;
|
||||
|
||||
namespace Content.Server.Chemistry.Components.SolutionManager
|
||||
{
|
||||
@@ -21,5 +22,13 @@ namespace Content.Server.Chemistry.Components.SolutionManager
|
||||
[DataField("solution")]
|
||||
public string Solution { get; set; } = "default";
|
||||
|
||||
/// <summary>
|
||||
/// The maximum amount that can be transferred to the solution at once
|
||||
/// </summary>
|
||||
[DataField("maxRefill")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public FixedPoint2? MaxRefill { get; set; } = null;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,14 @@ namespace Content.Server.Chemistry.Components
|
||||
&& solutionsSys.TryGetRefillableSolution(Owner, out var ownerRefill)
|
||||
&& solutionsSys.TryGetDrainableSolution(target, out var targetDrain))
|
||||
{
|
||||
var transferred = DoTransfer(eventArgs.User, target, targetDrain, Owner, ownerRefill, tank.TransferAmount);
|
||||
var tankTransferAmount = tank.TransferAmount;
|
||||
|
||||
if (_entities.TryGetComponent(Owner, out RefillableSolutionComponent? refill) && refill.MaxRefill != null)
|
||||
{
|
||||
tankTransferAmount = FixedPoint2.Min(tankTransferAmount, (FixedPoint2) refill.MaxRefill);
|
||||
}
|
||||
|
||||
var transferred = DoTransfer(eventArgs.User, target, targetDrain, Owner, ownerRefill, tankTransferAmount);
|
||||
if (transferred > 0)
|
||||
{
|
||||
var toTheBrim = ownerRefill.AvailableVolume == 0;
|
||||
@@ -151,7 +158,14 @@ namespace Content.Server.Chemistry.Components
|
||||
if (CanSend && solutionsSys.TryGetRefillableSolution(target, out var targetRefill)
|
||||
&& solutionsSys.TryGetDrainableSolution(Owner, out var ownerDrain))
|
||||
{
|
||||
var transferred = DoTransfer(eventArgs.User, Owner, ownerDrain, target, targetRefill, TransferAmount);
|
||||
var transferAmount = TransferAmount;
|
||||
|
||||
if (_entities.TryGetComponent(target, out RefillableSolutionComponent? refill) && refill.MaxRefill != null)
|
||||
{
|
||||
transferAmount = FixedPoint2.Min(transferAmount, (FixedPoint2) refill.MaxRefill);
|
||||
}
|
||||
|
||||
var transferred = DoTransfer(eventArgs.User, Owner, ownerDrain, target, targetRefill, transferAmount);
|
||||
|
||||
if (transferred > 0)
|
||||
{
|
||||
@@ -190,8 +204,7 @@ namespace Content.Server.Chemistry.Components
|
||||
return FixedPoint2.Zero;
|
||||
}
|
||||
|
||||
var actualAmount =
|
||||
FixedPoint2.Min(amount, FixedPoint2.Min(source.DrainAvailable, target.AvailableVolume));
|
||||
var actualAmount = FixedPoint2.Min(amount, FixedPoint2.Min(source.DrainAvailable, target.AvailableVolume));
|
||||
|
||||
var solution = EntitySystem.Get<SolutionContainerSystem>().Drain(sourceEntity, source, actualAmount);
|
||||
EntitySystem.Get<SolutionContainerSystem>().Refill(targetEntity, target, solution);
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
maxVol: 200
|
||||
- type: RefillableSolution
|
||||
solution: soil
|
||||
maxRefill: 50
|
||||
- type: Transform
|
||||
anchored: true
|
||||
- type: Reactive
|
||||
|
||||
Reference in New Issue
Block a user