Merge remote-tracking branch 'upstream/master' into ed-17-09-2024-upstream2
# Conflicts: # Content.Server/GameTicking/GameTicker.Spawning.cs
This commit is contained in:
@@ -330,8 +330,23 @@ public sealed class InjectorSystem : SharedInjectorSystem
|
||||
return false;
|
||||
}
|
||||
|
||||
var applicableTargetSolution = targetSolution.Comp.Solution;
|
||||
// If a whitelist exists, remove all non-whitelisted reagents from the target solution temporarily
|
||||
var temporarilyRemovedSolution = new Solution();
|
||||
if (injector.Comp.ReagentWhitelist is { } reagentWhitelist)
|
||||
{
|
||||
string[] reagentPrototypeWhitelistArray = new string[reagentWhitelist.Count];
|
||||
var i = 0;
|
||||
foreach (var reagent in reagentWhitelist)
|
||||
{
|
||||
reagentPrototypeWhitelistArray[i] = reagent;
|
||||
++i;
|
||||
}
|
||||
temporarilyRemovedSolution = applicableTargetSolution.SplitSolutionWithout(applicableTargetSolution.Volume, reagentPrototypeWhitelistArray);
|
||||
}
|
||||
|
||||
// Get transfer amount. May be smaller than _transferAmount if not enough room, also make sure there's room in the injector
|
||||
var realTransferAmount = FixedPoint2.Min(injector.Comp.TransferAmount, targetSolution.Comp.Solution.Volume,
|
||||
var realTransferAmount = FixedPoint2.Min(injector.Comp.TransferAmount, applicableTargetSolution.Volume,
|
||||
solution.AvailableVolume);
|
||||
|
||||
if (realTransferAmount <= 0)
|
||||
@@ -353,6 +368,9 @@ public sealed class InjectorSystem : SharedInjectorSystem
|
||||
// Move units from attackSolution to targetSolution
|
||||
var removedSolution = SolutionContainers.Draw(target.Owner, targetSolution, realTransferAmount);
|
||||
|
||||
// Add back non-whitelisted reagents to the target solution
|
||||
applicableTargetSolution.AddSolution(temporarilyRemovedSolution, null);
|
||||
|
||||
if (!SolutionContainers.TryAddSolution(soln.Value, removedSolution))
|
||||
{
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user