Minor damage opt (#7322)
This commit is contained in:
@@ -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
|
/// 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.
|
/// group is not included in the resulting dictionary.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public Dictionary<string, FixedPoint2> GetDamagePerGroup()
|
public Dictionary<string, FixedPoint2> GetDamagePerGroup(IPrototypeManager? protoManager = null)
|
||||||
{
|
{
|
||||||
|
IoCManager.Resolve(ref protoManager);
|
||||||
var damageGroupDict = new Dictionary<string, FixedPoint2>();
|
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))
|
if (TryGetDamageInGroup(group, out var value))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace Content.Shared.Damage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
component.DamagePerGroup = component.Damage.GetDamagePerGroup();
|
component.DamagePerGroup = component.Damage.GetDamagePerGroup(_prototypeManager);
|
||||||
component.TotalDamage = component.Damage.Total;
|
component.TotalDamage = component.Damage.Total;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,13 +82,13 @@ namespace Content.Shared.Damage
|
|||||||
public void DamageChanged(DamageableComponent component, DamageSpecifier? damageDelta = null,
|
public void DamageChanged(DamageableComponent component, DamageSpecifier? damageDelta = null,
|
||||||
bool interruptsDoAfters = true)
|
bool interruptsDoAfters = true)
|
||||||
{
|
{
|
||||||
component.DamagePerGroup = component.Damage.GetDamagePerGroup();
|
component.DamagePerGroup = component.Damage.GetDamagePerGroup(_prototypeManager);
|
||||||
component.TotalDamage = component.Damage.Total;
|
component.TotalDamage = component.Damage.Total;
|
||||||
Dirty(component);
|
Dirty(component);
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent<AppearanceComponent>(component.Owner, out var appearance) && damageDelta != null)
|
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);
|
appearance.SetData(DamageVisualizerKeys.DamageUpdateGroups, data);
|
||||||
}
|
}
|
||||||
RaiseLocalEvent(component.Owner, new DamageChangedEvent(component, damageDelta, interruptsDoAfters), false);
|
RaiseLocalEvent(component.Owner, new DamageChangedEvent(component, damageDelta, interruptsDoAfters), false);
|
||||||
|
|||||||
Reference in New Issue
Block a user