DamageSpecifier Total => GetTotal (#24160)
* DamageSpecifier [Obsolete] Total => GetTotal() * Remove obsolete Total member from DamageSpecifier.
This commit is contained in:
@@ -18,14 +18,14 @@ public sealed class WindowRepair : InteractionTest
|
|||||||
var comp = Comp<DamageableComponent>();
|
var comp = Comp<DamageableComponent>();
|
||||||
var damageType = Server.ResolveDependency<IPrototypeManager>().Index<DamageTypePrototype>("Blunt");
|
var damageType = Server.ResolveDependency<IPrototypeManager>().Index<DamageTypePrototype>("Blunt");
|
||||||
var damage = new DamageSpecifier(damageType, FixedPoint2.New(10));
|
var damage = new DamageSpecifier(damageType, FixedPoint2.New(10));
|
||||||
Assert.That(comp.Damage.Total, Is.EqualTo(FixedPoint2.Zero));
|
Assert.That(comp.Damage.GetTotal(), Is.EqualTo(FixedPoint2.Zero));
|
||||||
await Server.WaitPost(() => sys.TryChangeDamage(SEntMan.GetEntity(Target), damage, ignoreResistances: true));
|
await Server.WaitPost(() => sys.TryChangeDamage(SEntMan.GetEntity(Target), damage, ignoreResistances: true));
|
||||||
await RunTicks(5);
|
await RunTicks(5);
|
||||||
Assert.That(comp.Damage.Total, Is.GreaterThan(FixedPoint2.Zero));
|
Assert.That(comp.Damage.GetTotal(), Is.GreaterThan(FixedPoint2.Zero));
|
||||||
|
|
||||||
// Repair the entity
|
// Repair the entity
|
||||||
await Interact(Weld);
|
await Interact(Weld);
|
||||||
Assert.That(comp.Damage.Total, Is.EqualTo(FixedPoint2.Zero));
|
Assert.That(comp.Damage.GetTotal(), Is.EqualTo(FixedPoint2.Zero));
|
||||||
|
|
||||||
// Validate that we can still deconstruct the entity (i.e., that welding deconstruction is not blocked).
|
// Validate that we can still deconstruct the entity (i.e., that welding deconstruction is not blocked).
|
||||||
await Interact(
|
await Interact(
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ namespace Content.IntegrationTests.Tests
|
|||||||
Assert.That(damageResult, Is.Not.Null,
|
Assert.That(damageResult, Is.Not.Null,
|
||||||
"Received null damageResult when attempting to damage restock box.");
|
"Received null damageResult when attempting to damage restock box.");
|
||||||
|
|
||||||
Assert.That((int) damageResult!.Total, Is.GreaterThan(0),
|
Assert.That((int) damageResult!.GetTotal(), Is.GreaterThan(0),
|
||||||
"Box damage result was not greater than 0.");
|
"Box damage result was not greater than 0.");
|
||||||
#pragma warning restore NUnit2045
|
#pragma warning restore NUnit2045
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -80,14 +80,14 @@ namespace Content.Server.Bed.Sleep
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wake up if we take an instance of more than 2 damage.
|
/// Wake up on taking an instance of damage at least the value of WakeThreshold.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnDamageChanged(EntityUid uid, SleepingComponent component, DamageChangedEvent args)
|
private void OnDamageChanged(EntityUid uid, SleepingComponent component, DamageChangedEvent args)
|
||||||
{
|
{
|
||||||
if (!args.DamageIncreased || args.DamageDelta == null)
|
if (!args.DamageIncreased || args.DamageDelta == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (args.DamageDelta.Total >= component.WakeThreshold)
|
if (args.DamageDelta.GetTotal() >= component.WakeThreshold)
|
||||||
TryWaking(uid, component);
|
TryWaking(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ public sealed class BloodstreamSystem : EntitySystem
|
|||||||
|
|
||||||
// Does the calculation of how much bleed rate should be added/removed, then applies it
|
// Does the calculation of how much bleed rate should be added/removed, then applies it
|
||||||
var oldBleedAmount = component.BleedAmount;
|
var oldBleedAmount = component.BleedAmount;
|
||||||
var total = bloodloss.Total;
|
var total = bloodloss.GetTotal();
|
||||||
var totalFloat = total.Float();
|
var totalFloat = total.Float();
|
||||||
TryModifyBleedAmount(uid, totalFloat, component);
|
TryModifyBleedAmount(uid, totalFloat, component);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.Damage.ForceSay;
|
using Content.Shared.Damage.ForceSay;
|
||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
using Content.Shared.Mobs;
|
using Content.Shared.Mobs;
|
||||||
@@ -90,7 +90,7 @@ public sealed class DamageForceSaySystem : EntitySystem
|
|||||||
|
|
||||||
private void OnDamageChanged(EntityUid uid, DamageForceSayComponent component, DamageChangedEvent args)
|
private void OnDamageChanged(EntityUid uid, DamageForceSayComponent component, DamageChangedEvent args)
|
||||||
{
|
{
|
||||||
if (args.DamageDelta == null || !args.DamageIncreased || args.DamageDelta.Total < component.DamageThreshold)
|
if (args.DamageDelta == null || !args.DamageIncreased || args.DamageDelta.GetTotal() < component.DamageThreshold)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (component.ValidDamageGroups != null)
|
if (component.ValidDamageGroups != null)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace Content.Server.Damage.Systems
|
|||||||
|
|
||||||
// Log damage only for mobs. Useful for when people throw spears at each other, but also avoids log-spam when explosions send glass shards flying.
|
// Log damage only for mobs. Useful for when people throw spears at each other, but also avoids log-spam when explosions send glass shards flying.
|
||||||
if (dmg != null && HasComp<MobStateComponent>(args.Target))
|
if (dmg != null && HasComp<MobStateComponent>(args.Target))
|
||||||
_adminLogger.Add(LogType.ThrowHit, $"{ToPrettyString(args.Target):target} received {dmg.Total:damage} damage from collision");
|
_adminLogger.Add(LogType.ThrowHit, $"{ToPrettyString(args.Target):target} received {dmg.GetTotal():damage} damage from collision");
|
||||||
|
|
||||||
if (dmg is { Empty: false })
|
if (dmg is { Empty: false })
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public sealed class DamagePopupSystem : EntitySystem
|
|||||||
if (args.DamageDelta != null)
|
if (args.DamageDelta != null)
|
||||||
{
|
{
|
||||||
var damageTotal = args.Damageable.TotalDamage;
|
var damageTotal = args.Damageable.TotalDamage;
|
||||||
var damageDelta = args.DamageDelta.Total;
|
var damageDelta = args.DamageDelta.GetTotal();
|
||||||
|
|
||||||
var msg = component.Type switch
|
var msg = component.Type switch
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Content.Server.NPC.HTN;
|
using Content.Server.NPC.HTN;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
using Content.Shared.Mobs;
|
using Content.Shared.Mobs;
|
||||||
@@ -27,7 +27,7 @@ public sealed class KillTrackingSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
foreach (var key in component.LifetimeDamage.Keys)
|
foreach (var key in component.LifetimeDamage.Keys)
|
||||||
{
|
{
|
||||||
component.LifetimeDamage[key] -= args.DamageDelta.Total;
|
component.LifetimeDamage[key] -= args.DamageDelta.GetTotal();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -35,7 +35,7 @@ public sealed class KillTrackingSystem : EntitySystem
|
|||||||
|
|
||||||
var source = GetKillSource(args.Origin);
|
var source = GetKillSource(args.Origin);
|
||||||
var damage = component.LifetimeDamage.GetValueOrDefault(source);
|
var damage = component.LifetimeDamage.GetValueOrDefault(source);
|
||||||
component.LifetimeDamage[source] = damage + args.DamageDelta.Total;
|
component.LifetimeDamage[source] = damage + args.DamageDelta.GetTotal();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMobStateChanged(EntityUid uid, KillTrackerComponent component, MobStateChangedEvent args)
|
private void OnMobStateChanged(EntityUid uid, KillTrackerComponent component, MobStateChangedEvent args)
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
|
|
||||||
var burnMsg = Loc.GetString("powered-light-component-burn-hand");
|
var burnMsg = Loc.GetString("powered-light-component-burn-hand");
|
||||||
_popupSystem.PopupEntity(burnMsg, uid, userUid);
|
_popupSystem.PopupEntity(burnMsg, uid, userUid);
|
||||||
_adminLogger.Add(LogType.Damaged, $"{ToPrettyString(args.User):user} burned their hand on {ToPrettyString(args.Target):target} and received {damage.Total:damage} damage");
|
_adminLogger.Add(LogType.Damaged, $"{ToPrettyString(args.User):user} burned their hand on {ToPrettyString(args.Target):target} and received {damage.GetTotal():damage} damage");
|
||||||
_audio.PlayEntity(light.BurnHandSound, Filter.Pvs(uid), uid, true);
|
_audio.PlayEntity(light.BurnHandSound, Filter.Pvs(uid), uid, true);
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public sealed class HealingSystem : EntitySystem
|
|||||||
if (healed == null && healing.BloodlossModifier != 0)
|
if (healed == null && healing.BloodlossModifier != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var total = healed?.Total ?? FixedPoint2.Zero;
|
var total = healed?.GetTotal() ?? FixedPoint2.Zero;
|
||||||
|
|
||||||
// Re-verify that we can heal the damage.
|
// Re-verify that we can heal the damage.
|
||||||
|
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ public sealed class NPCUtilitySystem : EntitySystem
|
|||||||
{
|
{
|
||||||
if (TryComp<MeleeWeaponComponent>(targetUid, out var melee))
|
if (TryComp<MeleeWeaponComponent>(targetUid, out var melee))
|
||||||
{
|
{
|
||||||
return melee.Damage.Total.Float() * melee.AttackRate / 100f;
|
return melee.Damage.GetTotal().Float() * melee.AttackRate / 100f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0f;
|
return 0f;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public sealed class ProjectileSystem : SharedProjectileSystem
|
|||||||
|
|
||||||
_adminLogger.Add(LogType.BulletHit,
|
_adminLogger.Add(LogType.BulletHit,
|
||||||
HasComp<ActorComponent>(target) ? LogImpact.Extreme : LogImpact.High,
|
HasComp<ActorComponent>(target) ? LogImpact.Extreme : LogImpact.High,
|
||||||
$"Projectile {ToPrettyString(uid):projectile} shot by {ToPrettyString(component.Shooter!.Value):user} hit {otherName:target} and dealt {modifiedDamage.Total:damage} damage");
|
$"Projectile {ToPrettyString(uid):projectile} shot by {ToPrettyString(component.Shooter!.Value):user} hit {otherName:target} and dealt {modifiedDamage.GetTotal():damage} damage");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!deleted)
|
if (!deleted)
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public sealed partial class RevenantSystem : EntitySystem
|
|||||||
if (!HasComp<CorporealComponent>(uid) || args.DamageDelta == null)
|
if (!HasComp<CorporealComponent>(uid) || args.DamageDelta == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var essenceDamage = args.DamageDelta.Total.Float() * component.DamageToEssenceCoefficient * -1;
|
var essenceDamage = args.DamageDelta.GetTotal().Float() * component.DamageToEssenceCoefficient * -1;
|
||||||
ChangeEssenceAmount(uid, essenceDamage, component);
|
ChangeEssenceAmount(uid, essenceDamage, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -190,9 +190,9 @@ public sealed class StatValuesCommand : IConsoleCommand
|
|||||||
values.Add(new[]
|
values.Add(new[]
|
||||||
{
|
{
|
||||||
proto.ID,
|
proto.ID,
|
||||||
(comp.Damage.Total * comp.AttackRate).ToString(),
|
(comp.Damage.GetTotal() * comp.AttackRate).ToString(),
|
||||||
comp.AttackRate.ToString(CultureInfo.CurrentCulture),
|
comp.AttackRate.ToString(CultureInfo.CurrentCulture),
|
||||||
comp.Damage.Total.ToString(),
|
comp.Damage.GetTotal().ToString(),
|
||||||
comp.Range.ToString(CultureInfo.CurrentCulture),
|
comp.Range.ToString(CultureInfo.CurrentCulture),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ namespace Content.Server.VendingMachines
|
|||||||
component.DispenseOnHitChance == null || args.DamageDelta == null)
|
component.DispenseOnHitChance == null || args.DamageDelta == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (args.DamageIncreased && args.DamageDelta.Total >= component.DispenseOnHitThreshold &&
|
if (args.DamageIncreased && args.DamageDelta.GetTotal() >= component.DispenseOnHitThreshold &&
|
||||||
_random.Prob(component.DispenseOnHitChance.Value))
|
_random.Prob(component.DispenseOnHitChance.Value))
|
||||||
{
|
{
|
||||||
if (component.DispenseOnHitCooldown > 0f)
|
if (component.DispenseOnHitCooldown > 0f)
|
||||||
|
|||||||
@@ -274,12 +274,12 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
Logs.Add(LogType.HitScanHit,
|
Logs.Add(LogType.HitScanHit,
|
||||||
$"{ToPrettyString(user.Value):user} hit {hitName:target} using hitscan and dealt {dmg.Total:damage} damage");
|
$"{ToPrettyString(user.Value):user} hit {hitName:target} using hitscan and dealt {dmg.GetTotal():damage} damage");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logs.Add(LogType.HitScanHit,
|
Logs.Add(LogType.HitScanHit,
|
||||||
$"{hitName:target} hit by hitscan dealing {dmg.Total:damage} damage");
|
$"{hitName:target} hit by hitscan dealing {dmg.GetTotal():damage} damage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -371,7 +371,7 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
// 3. Nothing
|
// 3. Nothing
|
||||||
var playedSound = false;
|
var playedSound = false;
|
||||||
|
|
||||||
if (!forceWeaponSound && modifiedDamage != null && modifiedDamage.Total > 0 && TryComp<RangedDamageSoundComponent>(otherEntity, out var rangedSound))
|
if (!forceWeaponSound && modifiedDamage != null && modifiedDamage.GetTotal() > 0 && TryComp<RangedDamageSoundComponent>(otherEntity, out var rangedSound))
|
||||||
{
|
{
|
||||||
var type = SharedMeleeWeaponSystem.GetHighestDamageSound(modifiedDamage, ProtoManager);
|
var type = SharedMeleeWeaponSystem.GetHighestDamageSound(modifiedDamage, ProtoManager);
|
||||||
|
|
||||||
|
|||||||
@@ -38,10 +38,6 @@ namespace Content.Shared.Damage
|
|||||||
[IncludeDataField(customTypeSerializer: typeof(DamageSpecifierDictionarySerializer), readOnly: true)]
|
[IncludeDataField(customTypeSerializer: typeof(DamageSpecifierDictionarySerializer), readOnly: true)]
|
||||||
public Dictionary<string, FixedPoint2> DamageDict { get; set; } = new();
|
public Dictionary<string, FixedPoint2> DamageDict { get; set; } = new();
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
[Obsolete("Use GetTotal()")]
|
|
||||||
public FixedPoint2 Total => GetTotal();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a sum of the damage values.
|
/// Returns a sum of the damage values.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -516,12 +516,12 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
|||||||
if (meleeUid == user)
|
if (meleeUid == user)
|
||||||
{
|
{
|
||||||
AdminLogger.Add(LogType.MeleeHit, LogImpact.Medium,
|
AdminLogger.Add(LogType.MeleeHit, LogImpact.Medium,
|
||||||
$"{ToPrettyString(user):actor} melee attacked (light) {ToPrettyString(target.Value):subject} using their hands and dealt {damageResult.Total:damage} damage");
|
$"{ToPrettyString(user):actor} melee attacked (light) {ToPrettyString(target.Value):subject} using their hands and dealt {damageResult.GetTotal():damage} damage");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AdminLogger.Add(LogType.MeleeHit, LogImpact.Medium,
|
AdminLogger.Add(LogType.MeleeHit, LogImpact.Medium,
|
||||||
$"{ToPrettyString(user):actor} melee attacked (light) {ToPrettyString(target.Value):subject} using {ToPrettyString(meleeUid):tool} and dealt {damageResult.Total:damage} damage");
|
$"{ToPrettyString(user):actor} melee attacked (light) {ToPrettyString(target.Value):subject} using {ToPrettyString(meleeUid):tool} and dealt {damageResult.GetTotal():damage} damage");
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayHitSound(target.Value, user, GetHighestDamageSound(modifiedDamage, _protoManager), hitEvent.HitSoundOverride, component.HitSound);
|
PlayHitSound(target.Value, user, GetHighestDamageSound(modifiedDamage, _protoManager), hitEvent.HitSoundOverride, component.HitSound);
|
||||||
@@ -542,7 +542,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (damageResult?.Total > FixedPoint2.Zero)
|
if (damageResult?.GetTotal() > FixedPoint2.Zero)
|
||||||
{
|
{
|
||||||
DoDamageEffect(targets, user, targetXform);
|
DoDamageEffect(targets, user, targetXform);
|
||||||
}
|
}
|
||||||
@@ -670,7 +670,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
AdminLogger.Add(LogType.MeleeHit, LogImpact.Medium,
|
AdminLogger.Add(LogType.MeleeHit, LogImpact.Medium,
|
||||||
$"{ToPrettyString(user):actor} melee attacked (heavy) {ToPrettyString(entity):subject} using {ToPrettyString(meleeUid):tool} and dealt {damageResult.Total:damage} damage");
|
$"{ToPrettyString(user):actor} melee attacked (heavy) {ToPrettyString(entity):subject} using {ToPrettyString(meleeUid):tool} and dealt {damageResult.GetTotal():damage} damage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace Content.Tests.Shared
|
|||||||
|
|
||||||
// Check that it properly split up the groups into types
|
// Check that it properly split up the groups into types
|
||||||
FixedPoint2 damage;
|
FixedPoint2 damage;
|
||||||
Assert.That(damageSpec.Total, Is.EqualTo(FixedPoint2.New(8)));
|
Assert.That(damageSpec.GetTotal(), Is.EqualTo(FixedPoint2.New(8)));
|
||||||
Assert.That(damageSpec.DamageDict.TryGetValue("Blunt", out damage));
|
Assert.That(damageSpec.DamageDict.TryGetValue("Blunt", out damage));
|
||||||
Assert.That(damage, Is.EqualTo(FixedPoint2.New(2)));
|
Assert.That(damage, Is.EqualTo(FixedPoint2.New(2)));
|
||||||
Assert.That(damageSpec.DamageDict.TryGetValue("Piercing", out damage));
|
Assert.That(damageSpec.DamageDict.TryGetValue("Piercing", out damage));
|
||||||
@@ -73,7 +73,7 @@ namespace Content.Tests.Shared
|
|||||||
|
|
||||||
// check that integer multiplication works
|
// check that integer multiplication works
|
||||||
damageSpec = damageSpec * 2;
|
damageSpec = damageSpec * 2;
|
||||||
Assert.That(damageSpec.Total, Is.EqualTo(FixedPoint2.New(16)));
|
Assert.That(damageSpec.GetTotal(), Is.EqualTo(FixedPoint2.New(16)));
|
||||||
Assert.That(damageSpec.DamageDict.TryGetValue("Blunt", out damage));
|
Assert.That(damageSpec.DamageDict.TryGetValue("Blunt", out damage));
|
||||||
Assert.That(damage, Is.EqualTo(FixedPoint2.New(4)));
|
Assert.That(damage, Is.EqualTo(FixedPoint2.New(4)));
|
||||||
Assert.That(damageSpec.DamageDict.TryGetValue("Piercing", out damage));
|
Assert.That(damageSpec.DamageDict.TryGetValue("Piercing", out damage));
|
||||||
@@ -93,7 +93,7 @@ namespace Content.Tests.Shared
|
|||||||
Assert.That(damage, Is.EqualTo(FixedPoint2.New(4.4)));
|
Assert.That(damage, Is.EqualTo(FixedPoint2.New(4.4)));
|
||||||
Assert.That(damageSpec.DamageDict.TryGetValue("Radiation", out damage));
|
Assert.That(damageSpec.DamageDict.TryGetValue("Radiation", out damage));
|
||||||
Assert.That(damage, Is.EqualTo(FixedPoint2.New(13.2)));
|
Assert.That(damage, Is.EqualTo(FixedPoint2.New(13.2)));
|
||||||
Assert.That(damageSpec.Total, Is.EqualTo(FixedPoint2.New(8.8 + 8.8 + 4.4 + 13.2)));
|
Assert.That(damageSpec.GetTotal(), Is.EqualTo(FixedPoint2.New(8.8 + 8.8 + 4.4 + 13.2)));
|
||||||
|
|
||||||
// check that integer division works
|
// check that integer division works
|
||||||
damageSpec = damageSpec / 2;
|
damageSpec = damageSpec / 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user