-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathAscendedSpeed.cs
58 lines (51 loc) · 2.48 KB
/
AscendedSpeed.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
53
54
55
56
57
58
using System;
using BTD_Mod_Helper.Api;
using BTD_Mod_Helper.Api.Display;
using BTD_Mod_Helper.Extensions;
using HarmonyLib;
using Il2CppAssets.Scripts.Models;
using Il2CppAssets.Scripts.Models.Towers.Behaviors;
using Il2CppAssets.Scripts.Models.Towers.Behaviors.Abilities.Behaviors;
using Il2CppAssets.Scripts.Models.Towers.Weapons.Behaviors;
using Il2CppAssets.Scripts.Simulation.Objects;
namespace AscendedUpgrades;
public class AscendedSpeed : AscendedUpgrade<AscendedSpeedIcon>
{
public override string Description =>
"Infinitely Repeatable: Improved attack speed, production speed, and attack speed buffs.";
public override int Path => 1;
protected override BehaviorMutator CreateMutator(int stacks) => new RateSupportModel.RateSupportMutator(false, Id,
1 / (1 + GetFactor(stacks)), stacks, BuffIndicatorModel);
}
public class AscendedSpeedIcon : ModBuffIcon
{
public override string Icon => nameof(AscendedSpeed);
public override int MaxStackSize => 999;
protected override int Order => 1;
}
[HarmonyPatch(typeof(RateSupportModel.RateSupportMutator), nameof(RateSupportModel.RateSupportMutator.Mutate))]
internal static class RateMutator_Mutate
{
[HarmonyPrefix]
private static bool Prefix(RateSupportModel.RateSupportMutator __instance, Model model)
{
if (__instance.id == ModContent.GetInstance<AscendedSpeed>().Id)
{
model.GetDescendants<EmissionsPerRoundFilterModel>()
.ForEach(filter => filter.count = (int) Math.Ceiling(filter.count / __instance.multiplier));
model.GetDescendants<RateSupportModel>()
.ForEach(supportModel => supportModel.multiplier *= __instance.multiplier);
model.GetDescendants<ActivateRateSupportZoneModel>()
.ForEach(zoneModel => zoneModel.rateModifier *= __instance.multiplier);
model.GetDescendants<CallToArmsModel>()
.ForEach(zoneModel => zoneModel.multiplier *= (float) Math.Sqrt(1 / __instance.multiplier));
model.GetDescendants<PoplustSupportModel>()
.ForEach(supportModel => supportModel.ratePercentIncrease /= __instance.multiplier);
model.GetDescendants<OverclockModel>()
.ForEach(overclockModel => overclockModel.rateModifier *= __instance.multiplier);
model.GetDescendants<OverclockPermanentModel>()
.ForEach(permanentModel => permanentModel.rateModifier *= __instance.multiplier);
}
return true;
}
}