-
Notifications
You must be signed in to change notification settings - Fork 5
/
Calculator.cs
52 lines (42 loc) · 1.76 KB
/
Calculator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using BattleTech;
namespace WeaponRealizer
{
static partial class Calculator
{
internal const float Epsilon = 0.0001f;
internal static float ApplyDamageModifiers(AbstractActor attacker, ICombatant target, Weapon weapon, float rawDamage)
{
return ApplyAllDamageModifiers(attacker, target, weapon, rawDamage, true);
}
internal static float ApplyAllDamageModifiers(AbstractActor attacker, ICombatant target, Weapon weapon, float rawDamage, bool calculateRandomComponent)
{
var damage = rawDamage;
if (calculateRandomComponent && SimpleVariance.IsApplicable(weapon))
{
damage = SimpleVariance.Calculate(weapon, rawDamage);
}
if (DistanceBasedVariance.IsApplicable(weapon))
{
damage = DistanceBasedVariance.Calculate(attacker, target, weapon, damage, rawDamage);
}
if (ReverseDistanceBasedVariance.IsApplicable(weapon))
{
damage = ReverseDistanceBasedVariance.Calculate(attacker, target, weapon, damage, rawDamage);
}
if (OverheatMultiplier.IsApplicable(weapon))
{
damage = OverheatMultiplier.Calculate(attacker, target, weapon, damage);
}
if (HeatDamageModifier.IsApplicable(weapon))
{
// TODO: this can't work becuse the values don't get ingested from weapondef
// damage = HeatDamageModifier.Calculate(weapon, damage);
}
if (HeatAsNormalDamage.IsApplicable(weapon))
{
damage = HeatAsNormalDamage.Calculate(target, weapon, damage, rawDamage);
}
return damage;
}
}
}