Custom transfer amount to hydroponic trays (#5833)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user