Some more int -> decimal conversions. Changed the use of the Solution constructor.
This commit is contained in:
@@ -28,13 +28,13 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
|
||||
public override string Name => "Pourable";
|
||||
|
||||
private int _transferAmount;
|
||||
private decimal _transferAmount;
|
||||
|
||||
/// <summary>
|
||||
/// The amount of solution to be transferred from this solution when clicking on other solutions with it.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public int TransferAmount
|
||||
public decimal TransferAmount
|
||||
{
|
||||
get => _transferAmount;
|
||||
set => _transferAmount = value;
|
||||
@@ -43,7 +43,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _transferAmount, "transferAmount", 5);
|
||||
serializer.DataField(ref _transferAmount, "transferAmount", 5.0M);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
[ViewVariables] private string _packPrototypeId;
|
||||
|
||||
[ViewVariables] private bool HasBeaker => _beakerContainer.ContainedEntity != null;
|
||||
[ViewVariables] private int DispenseAmount = 10;
|
||||
[ViewVariables] private decimal _dispenseAmount = 10;
|
||||
|
||||
[ViewVariables]
|
||||
private SolutionComponent Solution => _beakerContainer.ContainedEntity.GetComponent<SolutionComponent>();
|
||||
@@ -115,22 +115,22 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
TryClear();
|
||||
break;
|
||||
case UiButton.SetDispenseAmount1:
|
||||
DispenseAmount = 1;
|
||||
_dispenseAmount = 1;
|
||||
break;
|
||||
case UiButton.SetDispenseAmount5:
|
||||
DispenseAmount = 5;
|
||||
_dispenseAmount = 5;
|
||||
break;
|
||||
case UiButton.SetDispenseAmount10:
|
||||
DispenseAmount = 10;
|
||||
_dispenseAmount = 10;
|
||||
break;
|
||||
case UiButton.SetDispenseAmount25:
|
||||
DispenseAmount = 25;
|
||||
_dispenseAmount = 25;
|
||||
break;
|
||||
case UiButton.SetDispenseAmount50:
|
||||
DispenseAmount = 50;
|
||||
_dispenseAmount = 50;
|
||||
break;
|
||||
case UiButton.SetDispenseAmount100:
|
||||
DispenseAmount = 100;
|
||||
_dispenseAmount = 100;
|
||||
break;
|
||||
case UiButton.Dispense:
|
||||
if (HasBeaker)
|
||||
@@ -173,12 +173,12 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
if (beaker == null)
|
||||
{
|
||||
return new ReagentDispenserBoundUserInterfaceState(false, 0, 0,
|
||||
"", Inventory, Owner.Name, null, DispenseAmount);
|
||||
"", Inventory, Owner.Name, null, _dispenseAmount);
|
||||
}
|
||||
|
||||
var solution = beaker.GetComponent<SolutionComponent>();
|
||||
return new ReagentDispenserBoundUserInterfaceState(true, solution.CurrentVolume, solution.MaxVolume,
|
||||
beaker.Name, Inventory, Owner.Name, solution.ReagentList.ToList(), DispenseAmount);
|
||||
beaker.Name, Inventory, Owner.Name, solution.ReagentList.ToList(), _dispenseAmount);
|
||||
}
|
||||
|
||||
private void UpdateUserInterface()
|
||||
@@ -228,7 +228,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
if (!HasBeaker) return;
|
||||
|
||||
var solution = _beakerContainer.ContainedEntity.GetComponent<SolutionComponent>();
|
||||
solution.TryAddReagent(Inventory[dispenseIndex].ID, DispenseAmount, out _);
|
||||
solution.TryAddReagent(Inventory[dispenseIndex].ID, _dispenseAmount, out _);
|
||||
|
||||
UpdateUserInterface();
|
||||
}
|
||||
|
||||
@@ -37,8 +37,9 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
_reactions = _prototypeManager.EnumeratePrototypes<ReactionPrototype>();
|
||||
_audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>();
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
||||
}
|
||||
|
||||
//Add reagents ready for transfer to bloodstream to transferSolution
|
||||
var transferSolution = new Solution();
|
||||
var transferSolution = IoCManager.InjectDependencies(new Solution());
|
||||
foreach (var delta in _reagentDeltas.ToList()) //Use ToList here to remove entries while iterating
|
||||
{
|
||||
//Increment lifetime of reagents
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace Content.Shared.Chemistry
|
||||
public Solution SplitSolution(decimal quantity)
|
||||
{
|
||||
if (quantity <= 0)
|
||||
return new Solution();
|
||||
return IoCManager.InjectDependencies(new Solution());
|
||||
|
||||
Solution newSolution;
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace Content.Shared.Chemistry
|
||||
return newSolution;
|
||||
}
|
||||
|
||||
newSolution = new Solution();
|
||||
newSolution = IoCManager.InjectDependencies(new Solution());
|
||||
var newTotalVolume = 0M;
|
||||
var ratio = (TotalVolume - quantity) / TotalVolume;
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace Content.Shared.Chemistry
|
||||
public Solution Clone()
|
||||
{
|
||||
var volume = 0M;
|
||||
var newSolution = new Solution();
|
||||
var newSolution = IoCManager.InjectDependencies(new Solution());
|
||||
|
||||
for (var i = 0; i < _contents.Count; i++)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Content.Shared.GameObjects.Components.Chemistry
|
||||
#pragma warning restore 649
|
||||
|
||||
[ViewVariables]
|
||||
protected Solution ContainedSolution = new Solution();
|
||||
protected Solution ContainedSolution;
|
||||
private decimal _maxVolume;
|
||||
private SolutionCaps _capabilities;
|
||||
|
||||
@@ -95,10 +95,15 @@ namespace Content.Shared.GameObjects.Components.Chemistry
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref _maxVolume, "maxVol", 0M);
|
||||
serializer.DataField(ref ContainedSolution, "contents", ContainedSolution);
|
||||
serializer.DataField(ref ContainedSolution, "contents", IoCManager.InjectDependencies(new Solution()));
|
||||
serializer.DataField(ref _capabilities, "caps", SolutionCaps.None);
|
||||
}
|
||||
|
||||
public virtual void Init()
|
||||
{
|
||||
ContainedSolution = IoCManager.InjectDependencies(new Solution());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Startup()
|
||||
{
|
||||
@@ -113,7 +118,7 @@ namespace Content.Shared.GameObjects.Components.Chemistry
|
||||
base.Shutdown();
|
||||
|
||||
ContainedSolution.RemoveAllSolution();
|
||||
ContainedSolution = new Solution();
|
||||
ContainedSolution = IoCManager.InjectDependencies(new Solution());
|
||||
}
|
||||
|
||||
public void RemoveAllSolution()
|
||||
|
||||
Reference in New Issue
Block a user