Generalize ReagentUnit into FixedPoint2 and use it for damage calculations (#5151)
* Damage units * sum ext method
This commit is contained in:
@@ -10,6 +10,7 @@ using Content.Server.UserInterface;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Random.Helpers;
|
||||
@@ -184,7 +185,7 @@ namespace Content.Server.Chemistry.Components
|
||||
if (beaker is null || !beaker.TryGetComponent(out FitsInDispenserComponent? fits) ||
|
||||
!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(beaker.Uid, fits.Solution, out var beakerSolution))
|
||||
{
|
||||
return new ChemMasterBoundUserInterfaceState(Powered, false, ReagentUnit.New(0), ReagentUnit.New(0),
|
||||
return new ChemMasterBoundUserInterfaceState(Powered, false, FixedPoint2.New(0), FixedPoint2.New(0),
|
||||
"", Owner.Name, new List<Solution.ReagentQuantity>(), BufferSolution.Contents, _bufferModeTransfer,
|
||||
BufferSolution.TotalVolume);
|
||||
}
|
||||
@@ -225,7 +226,7 @@ namespace Content.Server.Chemistry.Components
|
||||
hands.PutInHand(item);
|
||||
}
|
||||
|
||||
private void TransferReagent(string id, ReagentUnit amount, bool isBuffer)
|
||||
private void TransferReagent(string id, FixedPoint2 amount, bool isBuffer)
|
||||
{
|
||||
if (!HasBeaker && _bufferModeTransfer) return;
|
||||
var beaker = BeakerContainer.ContainedEntity;
|
||||
@@ -240,16 +241,16 @@ namespace Content.Server.Chemistry.Components
|
||||
{
|
||||
if (reagent.ReagentId == id)
|
||||
{
|
||||
ReagentUnit actualAmount;
|
||||
FixedPoint2 actualAmount;
|
||||
if (
|
||||
amount == ReagentUnit
|
||||
.New(-1)) //amount is ReagentUnit.New(-1) when the client sends a message requesting to remove all solution from the container
|
||||
amount == FixedPoint2
|
||||
.New(-1)) //amount is FixedPoint2.New(-1) when the client sends a message requesting to remove all solution from the container
|
||||
{
|
||||
actualAmount = ReagentUnit.Min(reagent.Quantity, beakerSolution.AvailableVolume);
|
||||
actualAmount = FixedPoint2.Min(reagent.Quantity, beakerSolution.AvailableVolume);
|
||||
}
|
||||
else
|
||||
{
|
||||
actualAmount = ReagentUnit.Min(reagent.Quantity, amount, beakerSolution.AvailableVolume);
|
||||
actualAmount = FixedPoint2.Min(reagent.Quantity, amount, beakerSolution.AvailableVolume);
|
||||
}
|
||||
|
||||
|
||||
@@ -271,14 +272,14 @@ namespace Content.Server.Chemistry.Components
|
||||
{
|
||||
if (reagent.ReagentId == id)
|
||||
{
|
||||
ReagentUnit actualAmount;
|
||||
if (amount == ReagentUnit.New(-1))
|
||||
FixedPoint2 actualAmount;
|
||||
if (amount == FixedPoint2.New(-1))
|
||||
{
|
||||
actualAmount = reagent.Quantity;
|
||||
}
|
||||
else
|
||||
{
|
||||
actualAmount = ReagentUnit.Min(reagent.Quantity, amount);
|
||||
actualAmount = FixedPoint2.Min(reagent.Quantity, amount);
|
||||
}
|
||||
|
||||
EntitySystem.Get<SolutionContainerSystem>().TryRemoveReagent(beaker.Uid, beakerSolution, id, actualAmount);
|
||||
@@ -298,11 +299,11 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
if (action == UiAction.CreateBottles)
|
||||
{
|
||||
var individualVolume = BufferSolution.TotalVolume / ReagentUnit.New(bottleAmount);
|
||||
if (individualVolume < ReagentUnit.New(1))
|
||||
var individualVolume = BufferSolution.TotalVolume / FixedPoint2.New(bottleAmount);
|
||||
if (individualVolume < FixedPoint2.New(1))
|
||||
return;
|
||||
|
||||
var actualVolume = ReagentUnit.Min(individualVolume, ReagentUnit.New(30));
|
||||
var actualVolume = FixedPoint2.Min(individualVolume, FixedPoint2.New(30));
|
||||
for (int i = 0; i < bottleAmount; i++)
|
||||
{
|
||||
var bottle = Owner.EntityManager.SpawnEntity("ChemistryEmptyBottle01", Owner.Transform.Coordinates);
|
||||
@@ -331,11 +332,11 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
else //Pills
|
||||
{
|
||||
var individualVolume = BufferSolution.TotalVolume / ReagentUnit.New(pillAmount);
|
||||
if (individualVolume < ReagentUnit.New(1))
|
||||
var individualVolume = BufferSolution.TotalVolume / FixedPoint2.New(pillAmount);
|
||||
if (individualVolume < FixedPoint2.New(1))
|
||||
return;
|
||||
|
||||
var actualVolume = ReagentUnit.Min(individualVolume, ReagentUnit.New(50));
|
||||
var actualVolume = FixedPoint2.Min(individualVolume, FixedPoint2.New(50));
|
||||
for (int i = 0; i < pillAmount; i++)
|
||||
{
|
||||
var pill = Owner.EntityManager.SpawnEntity("pill", Owner.Transform.Coordinates);
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.Inventory.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Foam;
|
||||
using Content.Shared.Inventory;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -56,7 +57,7 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
|
||||
var cloneSolution = solution.Clone();
|
||||
var transferAmount = ReagentUnit.Min(cloneSolution.TotalVolume * solutionFraction * (1 - protection),
|
||||
var transferAmount = FixedPoint2.Min(cloneSolution.TotalVolume * solutionFraction * (1 - protection),
|
||||
bloodstream.EmptyVolume);
|
||||
var transferSolution = cloneSolution.SplitSolution(transferAmount);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Server.Interaction.Components;
|
||||
using Content.Server.Weapon.Melee;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Sound;
|
||||
@@ -27,7 +28,7 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
[DataField("TransferAmount")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public ReagentUnit TransferAmount { get; set; } = ReagentUnit.New(5);
|
||||
public FixedPoint2 TransferAmount { get; set; } = FixedPoint2.New(5);
|
||||
|
||||
[DataField("InjectSound")]
|
||||
private SoundSpecifier _injectSound = new SoundPathSpecifier("/Audio/Items/hypospray.ogg");
|
||||
@@ -85,7 +86,7 @@ namespace Content.Server.Chemistry.Components
|
||||
SoundSystem.Play(Filter.Pvs(user), _injectSound.GetSound(), user);
|
||||
|
||||
// Get transfer amount. May be smaller than _transferAmount if not enough room
|
||||
var realTransferAmount = ReagentUnit.Min(TransferAmount, targetSolution.AvailableVolume);
|
||||
var realTransferAmount = FixedPoint2.Min(TransferAmount, targetSolution.AvailableVolume);
|
||||
|
||||
if (realTransferAmount <= 0)
|
||||
{
|
||||
@@ -126,7 +127,7 @@ namespace Content.Server.Chemistry.Components
|
||||
var solutionSys = Owner.EntityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
|
||||
return solutionSys.TryGetSolution(Owner.Uid, SolutionName, out var solution)
|
||||
? new HyposprayComponentState(solution.CurrentVolume, solution.MaxVolume)
|
||||
: new HyposprayComponentState(ReagentUnit.Zero, ReagentUnit.Zero);
|
||||
: new HyposprayComponentState(FixedPoint2.Zero, FixedPoint2.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Shared.Body.Networks;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.Popups;
|
||||
@@ -41,14 +42,14 @@ namespace Content.Server.Chemistry.Components
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("transferAmount")]
|
||||
private ReagentUnit _transferAmount = ReagentUnit.New(5);
|
||||
private FixedPoint2 _transferAmount = FixedPoint2.New(5);
|
||||
|
||||
/// <summary>
|
||||
/// Initial storage volume of the injector
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("initialMaxVolume")]
|
||||
private ReagentUnit _initialMaxVolume = ReagentUnit.New(15);
|
||||
private FixedPoint2 _initialMaxVolume = FixedPoint2.New(15);
|
||||
|
||||
private InjectorToggleMode _toggleState;
|
||||
|
||||
@@ -180,7 +181,7 @@ namespace Content.Server.Chemistry.Components
|
||||
return;
|
||||
|
||||
// Get transfer amount. May be smaller than _transferAmount if not enough room
|
||||
var realTransferAmount = ReagentUnit.Min(_transferAmount, targetBloodstream.EmptyVolume);
|
||||
var realTransferAmount = FixedPoint2.Min(_transferAmount, targetBloodstream.EmptyVolume);
|
||||
|
||||
if (realTransferAmount <= 0)
|
||||
{
|
||||
@@ -223,7 +224,7 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
|
||||
// Get transfer amount. May be smaller than _transferAmount if not enough room
|
||||
var realTransferAmount = ReagentUnit.Min(_transferAmount, targetSolution.AvailableVolume);
|
||||
var realTransferAmount = FixedPoint2.Min(_transferAmount, targetSolution.AvailableVolume);
|
||||
|
||||
if (realTransferAmount <= 0)
|
||||
{
|
||||
@@ -285,7 +286,7 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
|
||||
// Get transfer amount. May be smaller than _transferAmount if not enough room
|
||||
var realTransferAmount = ReagentUnit.Min(_transferAmount, targetSolution.DrawAvailable);
|
||||
var realTransferAmount = FixedPoint2.Min(_transferAmount, targetSolution.DrawAvailable);
|
||||
|
||||
if (realTransferAmount <= 0)
|
||||
{
|
||||
@@ -317,8 +318,8 @@ namespace Content.Server.Chemistry.Components
|
||||
Owner.EntityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>()
|
||||
.TryGetSolution(Owner.Uid, SolutionName, out var solution);
|
||||
|
||||
var currentVolume = solution?.CurrentVolume ?? ReagentUnit.Zero;
|
||||
var maxVolume = solution?.MaxVolume ?? ReagentUnit.Zero;
|
||||
var currentVolume = solution?.CurrentVolume ?? FixedPoint2.Zero;
|
||||
var maxVolume = solution?.MaxVolume ?? FixedPoint2.Zero;
|
||||
|
||||
return new InjectorComponentState(currentVolume, maxVolume, ToggleState);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -13,7 +14,7 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("transferAmount")]
|
||||
public ReagentUnit TransferAmount { get; set; } = ReagentUnit.New(1);
|
||||
public FixedPoint2 TransferAmount { get; set; } = FixedPoint2.New(1);
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float TransferEfficiency { get => _transferEfficiency; set => _transferEfficiency = Math.Clamp(value, 0, 1); }
|
||||
|
||||
@@ -12,6 +12,7 @@ using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Dispenser;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Sound;
|
||||
@@ -53,7 +54,7 @@ namespace Content.Server.Chemistry.Components
|
||||
private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
|
||||
|
||||
[ViewVariables] public bool HasBeaker => BeakerContainer.ContainedEntity != null;
|
||||
[ViewVariables] private ReagentUnit _dispenseAmount = ReagentUnit.New(10);
|
||||
[ViewVariables] private FixedPoint2 _dispenseAmount = FixedPoint2.New(10);
|
||||
|
||||
[UsedImplicitly]
|
||||
[ViewVariables]
|
||||
@@ -163,31 +164,31 @@ namespace Content.Server.Chemistry.Components
|
||||
TryClear();
|
||||
break;
|
||||
case UiButton.SetDispenseAmount1:
|
||||
_dispenseAmount = ReagentUnit.New(1);
|
||||
_dispenseAmount = FixedPoint2.New(1);
|
||||
break;
|
||||
case UiButton.SetDispenseAmount5:
|
||||
_dispenseAmount = ReagentUnit.New(5);
|
||||
_dispenseAmount = FixedPoint2.New(5);
|
||||
break;
|
||||
case UiButton.SetDispenseAmount10:
|
||||
_dispenseAmount = ReagentUnit.New(10);
|
||||
_dispenseAmount = FixedPoint2.New(10);
|
||||
break;
|
||||
case UiButton.SetDispenseAmount15:
|
||||
_dispenseAmount = ReagentUnit.New(15);
|
||||
_dispenseAmount = FixedPoint2.New(15);
|
||||
break;
|
||||
case UiButton.SetDispenseAmount20:
|
||||
_dispenseAmount = ReagentUnit.New(20);
|
||||
_dispenseAmount = FixedPoint2.New(20);
|
||||
break;
|
||||
case UiButton.SetDispenseAmount25:
|
||||
_dispenseAmount = ReagentUnit.New(25);
|
||||
_dispenseAmount = FixedPoint2.New(25);
|
||||
break;
|
||||
case UiButton.SetDispenseAmount30:
|
||||
_dispenseAmount = ReagentUnit.New(30);
|
||||
_dispenseAmount = FixedPoint2.New(30);
|
||||
break;
|
||||
case UiButton.SetDispenseAmount50:
|
||||
_dispenseAmount = ReagentUnit.New(50);
|
||||
_dispenseAmount = FixedPoint2.New(50);
|
||||
break;
|
||||
case UiButton.SetDispenseAmount100:
|
||||
_dispenseAmount = ReagentUnit.New(100);
|
||||
_dispenseAmount = FixedPoint2.New(100);
|
||||
break;
|
||||
case UiButton.Dispense:
|
||||
if (HasBeaker)
|
||||
@@ -237,8 +238,8 @@ namespace Content.Server.Chemistry.Components
|
||||
if (beaker == null || !beaker.TryGetComponent(out FitsInDispenserComponent? fits) ||
|
||||
!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(beaker.Uid, fits.Solution, out var solution))
|
||||
{
|
||||
return new ReagentDispenserBoundUserInterfaceState(Powered, false, ReagentUnit.New(0),
|
||||
ReagentUnit.New(0),
|
||||
return new ReagentDispenserBoundUserInterfaceState(Powered, false, FixedPoint2.New(0),
|
||||
FixedPoint2.New(0),
|
||||
string.Empty, Inventory, Owner.Name, null, _dispenseAmount);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -13,7 +14,7 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
[DataField("transferAmount")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public ReagentUnit TransferAmount { get; set; } = ReagentUnit.New(10);
|
||||
public FixedPoint2 TransferAmount { get; set; } = FixedPoint2.New(10);
|
||||
|
||||
[DataField("tankType")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Server.Body.Respiratory;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Smoking;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -39,12 +40,12 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
var chemistry = EntitySystem.Get<ChemistrySystem>();
|
||||
var cloneSolution = solution.Clone();
|
||||
var transferAmount = ReagentUnit.Min(cloneSolution.TotalVolume * solutionFraction, bloodstream.EmptyVolume);
|
||||
var transferAmount = FixedPoint2.Min(cloneSolution.TotalVolume * solutionFraction, bloodstream.EmptyVolume);
|
||||
var transferSolution = cloneSolution.SplitSolution(transferAmount);
|
||||
|
||||
foreach (var reagentQuantity in transferSolution.Contents.ToArray())
|
||||
{
|
||||
if (reagentQuantity.Quantity == ReagentUnit.Zero) continue;
|
||||
if (reagentQuantity.Quantity == FixedPoint2.Zero) continue;
|
||||
chemistry.ReactionEntity(entity, ReactionMethod.Ingestion, reagentQuantity.ReagentId, reagentQuantity.Quantity, transferSolution);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using Content.Server.Coordinates.Helpers;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
@@ -133,7 +134,7 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
foreach (var reagentQuantity in solution.Contents)
|
||||
{
|
||||
if (reagentQuantity.Quantity == ReagentUnit.Zero) continue;
|
||||
if (reagentQuantity.Quantity == FixedPoint2.Zero) continue;
|
||||
var reagent = PrototypeManager.Index<ReagentPrototype>(reagentQuantity.ReagentId);
|
||||
|
||||
// React with the tile the effect is on
|
||||
@@ -164,7 +165,7 @@ namespace Content.Server.Chemistry.Components
|
||||
return;
|
||||
|
||||
var addSolution =
|
||||
solution.SplitSolution(ReagentUnit.Min(solution.TotalVolume, solutionArea.AvailableVolume));
|
||||
solution.SplitSolution(FixedPoint2.Min(solution.TotalVolume, solutionArea.AvailableVolume));
|
||||
|
||||
EntitySystem.Get<SolutionContainerSystem>().TryAddSolution(Owner.Uid, solutionArea, addSolution);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -16,7 +17,7 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("transferAmount")]
|
||||
public ReagentUnit TransferAmount { get; set; } = ReagentUnit.New(1);
|
||||
public FixedPoint2 TransferAmount { get; set; } = FixedPoint2.New(1);
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float TransferEfficiency { get => _transferEfficiency; set => _transferEfficiency = Math.Clamp(value, 0, 1); }
|
||||
|
||||
@@ -6,6 +6,7 @@ using Content.Server.UserInterface;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.Popups;
|
||||
@@ -35,21 +36,21 @@ namespace Content.Server.Chemistry.Components
|
||||
/// </summary>
|
||||
[DataField("transferAmount")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public ReagentUnit TransferAmount { get; set; } = ReagentUnit.New(5);
|
||||
public FixedPoint2 TransferAmount { get; set; } = FixedPoint2.New(5);
|
||||
|
||||
/// <summary>
|
||||
/// The minimum amount of solution that can be transferred at once from this solution.
|
||||
/// </summary>
|
||||
[DataField("minTransferAmount")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public ReagentUnit MinimumTransferAmount { get; set; } = ReagentUnit.New(5);
|
||||
public FixedPoint2 MinimumTransferAmount { get; set; } = FixedPoint2.New(5);
|
||||
|
||||
/// <summary>
|
||||
/// The maximum amount of solution that can be transferred at once from this solution.
|
||||
/// </summary>
|
||||
[DataField("maxTransferAmount")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public ReagentUnit MaximumTransferAmount { get; set; } = ReagentUnit.New(50);
|
||||
public FixedPoint2 MaximumTransferAmount { get; set; } = FixedPoint2.New(50);
|
||||
|
||||
/// <summary>
|
||||
/// Can this entity take reagent from reagent tanks?
|
||||
@@ -95,14 +96,14 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
serverMsg.Session.AttachedEntity?.PopupMessage(Loc.GetString("comp-solution-transfer-set-amount",
|
||||
("amount", amount)));
|
||||
SetTransferAmount(ReagentUnit.New(amount));
|
||||
SetTransferAmount(FixedPoint2.New(amount));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTransferAmount(ReagentUnit amount)
|
||||
public void SetTransferAmount(FixedPoint2 amount)
|
||||
{
|
||||
amount = ReagentUnit.New(Math.Clamp(amount.Int(), MinimumTransferAmount.Int(),
|
||||
amount = FixedPoint2.New(Math.Clamp(amount.Int(), MinimumTransferAmount.Int(),
|
||||
MaximumTransferAmount.Int()));
|
||||
TransferAmount = amount;
|
||||
}
|
||||
@@ -162,30 +163,30 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
|
||||
/// <returns>The actual amount transferred.</returns>
|
||||
private static ReagentUnit DoTransfer(IEntity user,
|
||||
private static FixedPoint2 DoTransfer(IEntity user,
|
||||
IEntity sourceEntity,
|
||||
Solution source,
|
||||
IEntity targetEntity,
|
||||
Solution target,
|
||||
ReagentUnit amount)
|
||||
FixedPoint2 amount)
|
||||
{
|
||||
|
||||
if (source.DrainAvailable == 0)
|
||||
{
|
||||
sourceEntity.PopupMessage(user,
|
||||
Loc.GetString("comp-solution-transfer-is-empty", ("target", sourceEntity)));
|
||||
return ReagentUnit.Zero;
|
||||
return FixedPoint2.Zero;
|
||||
}
|
||||
|
||||
if (target.AvailableVolume == 0)
|
||||
{
|
||||
targetEntity.PopupMessage(user,
|
||||
Loc.GetString("comp-solution-transfer-is-full", ("target", targetEntity)));
|
||||
return ReagentUnit.Zero;
|
||||
return FixedPoint2.Zero;
|
||||
}
|
||||
|
||||
var actualAmount =
|
||||
ReagentUnit.Min(amount, ReagentUnit.Min(source.DrainAvailable, target.AvailableVolume));
|
||||
FixedPoint2.Min(amount, FixedPoint2.Min(source.DrainAvailable, target.AvailableVolume));
|
||||
|
||||
var solution = EntitySystem.Get<SolutionContainerSystem>().Drain(sourceEntity.Uid, source, actualAmount);
|
||||
EntitySystem.Get<SolutionContainerSystem>().Refill(targetEntity.Uid, target, solution);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Vapor;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
@@ -12,7 +13,7 @@ namespace Content.Server.Chemistry.Components
|
||||
{
|
||||
[ViewVariables]
|
||||
[DataField("transferAmount")]
|
||||
internal ReagentUnit TransferAmount = ReagentUnit.New(0.5);
|
||||
internal FixedPoint2 TransferAmount = FixedPoint2.New(0.5);
|
||||
|
||||
internal bool Reached;
|
||||
internal float ReactTimer;
|
||||
|
||||
Reference in New Issue
Block a user