Lower data usage (#4005)

* Lower data usage

* Fix the problems at the root
This commit is contained in:
ShadowCommander
2021-05-16 13:37:58 -07:00
committed by GitHub
parent dc03f1f545
commit 483fbe6ea3
2 changed files with 12 additions and 5 deletions

View File

@@ -148,7 +148,7 @@ namespace Content.Shared.GameObjects.Components.Chemistry
/// <returns>If the solution could be added.</returns>
public bool TryAddSolution(Solution solution)
{
if (!CanAddSolution(solution))
if (!CanAddSolution(solution) || solution.TotalVolume == 0)
return false;
Solution.AddSolution(solution);

View File

@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
@@ -257,18 +257,25 @@ namespace Content.Shared.GameObjects.Components.Damage
finalDamage = Resistances.CalculateDamage(type, amount);
}
if (finalDamage == 0)
return false;
if (!_damageList.TryGetValue(type, out var current))
{
return false;
}
_damageList[type] = current + finalDamage;
if (_damageList[type] < 0)
if (current + finalDamage < 0)
{
if (current == 0)
return false;
_damageList[type] = 0;
finalDamage = -current;
}
else
{
_damageList[type] = current + finalDamage;
}
current = _damageList[type];