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;
|
||||||
using Content.Server.Atmos.EntitySystems;
|
using Content.Server.Atmos.EntitySystems;
|
||||||
using Content.Server.Chemistry.EntitySystems;
|
using Content.Server.Chemistry.EntitySystems;
|
||||||
|
using Content.Server.Chemistry.Components;
|
||||||
using Content.Server.Fluids.Components;
|
using Content.Server.Fluids.Components;
|
||||||
using Content.Server.Hands.Components;
|
using Content.Server.Hands.Components;
|
||||||
using Content.Server.Plants;
|
using Content.Server.Plants;
|
||||||
@@ -727,23 +728,20 @@ namespace Content.Server.Botany.Components
|
|||||||
|
|
||||||
var solutionSystem = EntitySystem.Get<SolutionContainerSystem>();
|
var solutionSystem = EntitySystem.Get<SolutionContainerSystem>();
|
||||||
if (solutionSystem.TryGetDrainableSolution(usingItem, out var solution)
|
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 amount = FixedPoint2.New(1);
|
||||||
var sprayed = false;
|
|
||||||
var targetEntity = Owner;
|
var targetEntity = Owner;
|
||||||
var solutionEntity = usingItem;
|
var solutionEntity = usingItem;
|
||||||
|
|
||||||
if (_entMan.TryGetComponent(usingItem, out SprayComponent? spray))
|
|
||||||
{
|
SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound.GetSound(), usingItem,
|
||||||
sprayed = true;
|
AudioHelpers.WithVariation(0.125f));
|
||||||
amount = FixedPoint2.New(1);
|
|
||||||
|
|
||||||
SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound.GetSound(), usingItem,
|
|
||||||
AudioHelpers.WithVariation(0.125f));
|
|
||||||
}
|
|
||||||
|
|
||||||
var split = solutionSystem.Drain(solutionEntity, solution, amount);
|
var split = solutionSystem.Drain(solutionEntity, solution, amount);
|
||||||
|
|
||||||
if (split.TotalVolume == 0)
|
if (split.TotalVolume == 0)
|
||||||
{
|
{
|
||||||
user.PopupMessageCursor(Loc.GetString("plant-holder-component-empty-message",
|
user.PopupMessageCursor(Loc.GetString("plant-holder-component-empty-message",
|
||||||
@@ -751,8 +749,7 @@ namespace Content.Server.Botany.Components
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.PopupMessageCursor(Loc.GetString(
|
user.PopupMessageCursor(Loc.GetString("plant-holder-component-spray-message",
|
||||||
sprayed ? "plant-holder-component-spray-message" : "plant-holder-component-transfer-message",
|
|
||||||
("owner", Owner),
|
("owner", Owner),
|
||||||
("amount", split.TotalVolume)));
|
("amount", split.TotalVolume)));
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
using Content.Shared.FixedPoint;
|
||||||
|
|
||||||
namespace Content.Server.Chemistry.Components.SolutionManager
|
namespace Content.Server.Chemistry.Components.SolutionManager
|
||||||
{
|
{
|
||||||
@@ -21,5 +22,13 @@ namespace Content.Server.Chemistry.Components.SolutionManager
|
|||||||
[DataField("solution")]
|
[DataField("solution")]
|
||||||
public string Solution { get; set; } = "default";
|
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.TryGetRefillableSolution(Owner, out var ownerRefill)
|
||||||
&& solutionsSys.TryGetDrainableSolution(target, out var targetDrain))
|
&& 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)
|
if (transferred > 0)
|
||||||
{
|
{
|
||||||
var toTheBrim = ownerRefill.AvailableVolume == 0;
|
var toTheBrim = ownerRefill.AvailableVolume == 0;
|
||||||
@@ -151,7 +158,14 @@ namespace Content.Server.Chemistry.Components
|
|||||||
if (CanSend && solutionsSys.TryGetRefillableSolution(target, out var targetRefill)
|
if (CanSend && solutionsSys.TryGetRefillableSolution(target, out var targetRefill)
|
||||||
&& solutionsSys.TryGetDrainableSolution(Owner, out var ownerDrain))
|
&& 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)
|
if (transferred > 0)
|
||||||
{
|
{
|
||||||
@@ -190,8 +204,7 @@ namespace Content.Server.Chemistry.Components
|
|||||||
return FixedPoint2.Zero;
|
return FixedPoint2.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
var actualAmount =
|
var actualAmount = FixedPoint2.Min(amount, FixedPoint2.Min(source.DrainAvailable, target.AvailableVolume));
|
||||||
FixedPoint2.Min(amount, FixedPoint2.Min(source.DrainAvailable, target.AvailableVolume));
|
|
||||||
|
|
||||||
var solution = EntitySystem.Get<SolutionContainerSystem>().Drain(sourceEntity, source, actualAmount);
|
var solution = EntitySystem.Get<SolutionContainerSystem>().Drain(sourceEntity, source, actualAmount);
|
||||||
EntitySystem.Get<SolutionContainerSystem>().Refill(targetEntity, target, solution);
|
EntitySystem.Get<SolutionContainerSystem>().Refill(targetEntity, target, solution);
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
maxVol: 200
|
maxVol: 200
|
||||||
- type: RefillableSolution
|
- type: RefillableSolution
|
||||||
solution: soil
|
solution: soil
|
||||||
|
maxRefill: 50
|
||||||
- type: Transform
|
- type: Transform
|
||||||
anchored: true
|
anchored: true
|
||||||
- type: Reactive
|
- type: Reactive
|
||||||
|
|||||||
Reference in New Issue
Block a user