-
Notifications
You must be signed in to change notification settings - Fork 5
/
Calculator.OverheatMultiplier.cs
40 lines (37 loc) · 1.45 KB
/
Calculator.OverheatMultiplier.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
using System;
using System.Text;
using BattleTech;
using UnityEngine;
namespace WeaponRealizer
{
static partial class Calculator
{
private static class OverheatMultiplier
{
public static bool IsApplicable(Weapon weapon)
{
return Core.ModSettings.OverheatModifier &&
Mathf.Abs(weapon.weaponDef.OverheatedDamageMultiplier) > Epsilon;
}
public static float Calculate(AbstractActor attacker, ICombatant target, Weapon weapon, float rawDamage)
{
var rawMultiplier = weapon.weaponDef.OverheatedDamageMultiplier;
var effectActor = rawMultiplier < 0 ? attacker : target;
var multiplier = Mathf.Abs(rawMultiplier);
var damage = rawDamage;
if (effectActor is Mech mech && mech.IsOverheated)
{
damage = rawDamage * multiplier;
}
var sb = new StringBuilder();
sb.AppendLine($"rawMultiplier: {rawMultiplier}");
sb.AppendLine(String.Format("effectActor: {0}", rawMultiplier < 0 ? "attacker" : "target"));
sb.AppendLine($"multiplier: {multiplier}");
sb.AppendLine($"rawDamage: {rawDamage}");
sb.AppendLine($"damage: {damage}");
Logger.Debug(sb.ToString());
return damage;
}
}
}
}