Minor damage opt (#7322)

This commit is contained in:
metalgearsloth
2022-03-29 00:26:39 +11:00
committed by GitHub
parent 8705e2ae57
commit 2f9f626ea9
2 changed files with 6 additions and 5 deletions

View File

@@ -312,10 +312,11 @@ namespace Content.Shared.Damage
/// total of each group. If no members of a group are present in this <see cref="DamageSpecifier"/>, the
/// group is not included in the resulting dictionary.
/// </remarks>
public Dictionary<string, FixedPoint2> GetDamagePerGroup()
public Dictionary<string, FixedPoint2> GetDamagePerGroup(IPrototypeManager? protoManager = null)
{
IoCManager.Resolve(ref protoManager);
var damageGroupDict = new Dictionary<string, FixedPoint2>();
foreach (var group in IoCManager.Resolve<IPrototypeManager>().EnumeratePrototypes<DamageGroupPrototype>())
foreach (var group in protoManager.EnumeratePrototypes<DamageGroupPrototype>())
{
if (TryGetDamageInGroup(group, out var value))
{

View File

@@ -55,7 +55,7 @@ namespace Content.Shared.Damage
}
}
component.DamagePerGroup = component.Damage.GetDamagePerGroup();
component.DamagePerGroup = component.Damage.GetDamagePerGroup(_prototypeManager);
component.TotalDamage = component.Damage.Total;
}
@@ -82,13 +82,13 @@ namespace Content.Shared.Damage
public void DamageChanged(DamageableComponent component, DamageSpecifier? damageDelta = null,
bool interruptsDoAfters = true)
{
component.DamagePerGroup = component.Damage.GetDamagePerGroup();
component.DamagePerGroup = component.Damage.GetDamagePerGroup(_prototypeManager);
component.TotalDamage = component.Damage.Total;
Dirty(component);
if (EntityManager.TryGetComponent<AppearanceComponent>(component.Owner, out var appearance) && damageDelta != null)
{
var data = new DamageVisualizerGroupData(damageDelta.GetDamagePerGroup().Keys.ToList());
var data = new DamageVisualizerGroupData(damageDelta.GetDamagePerGroup(_prototypeManager).Keys.ToList());
appearance.SetData(DamageVisualizerKeys.DamageUpdateGroups, data);
}
RaiseLocalEvent(component.Owner, new DamageChangedEvent(component, damageDelta, interruptsDoAfters), false);