-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBossRoundSet.cs
95 lines (80 loc) · 2.95 KB
/
BossRoundSet.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System;
using System.Collections.Generic;
using System.Linq;
using BTD_Mod_Helper.Api;
using BTD_Mod_Helper.Api.Bloons;
using BTD_Mod_Helper.Api.Enums;
using BTD_Mod_Helper.Extensions;
using Il2CppAssets.Scripts.Data.Boss;
using Il2CppAssets.Scripts.Models.Rounds;
using Il2CppAssets.Scripts.Models.ServerEvents;
using Il2CppAssets.Scripts.Unity;
namespace BossRounds;
/// <summary>
/// Round set for enabling a specific boss. Automatically loads from the different values of <see cref="BossType" />
/// </summary>
public class BossRoundSet : ModRoundSet
{
public static readonly Dictionary<string, BossRoundSet> Cache = new();
public static readonly Dictionary<BossType, BossRoundSet> NormalCache = new();
public static readonly Dictionary<BossType, BossRoundSet> EliteCache = new();
public readonly BossType bossType;
public readonly bool elite;
// ReSharper disable once UnusedMember.Global gotta have empty constructor for any ModContent
public BossRoundSet()
{
}
public BossRoundSet(BossType bossType, bool elite)
{
this.bossType = bossType;
this.elite = elite;
}
public override string BaseRoundSet => RoundSetType.Default;
public override int DefinedRounds => BaseRounds.Count;
public override string Name => (elite ? "Elite" : "") + bossType;
public override string Icon =>
VanillaSprites.ByName.TryGetValue(bossType + "Btn" + (elite ? "Elite" : ""), out var icon)
? icon
: VanillaSprites.WoodenRoundButton;
/// <summary>
/// Load a BossRoundSet for each boss type / eliteness
/// </summary>
/// <returns></returns>
public override IEnumerable<ModContent> Load()
{
foreach (var boss in Enum.GetValues(typeof(BossType)).Cast<BossType>())
{
yield return new BossRoundSet(boss, false);
yield return new BossRoundSet(boss, true);
}
}
private readonly Dictionary<int, RoundInfo> roundInfos = new();
public override void Register()
{
foreach (var round in SkuSettings.instance.gameEvents.roundSets[bossType.ToString().ToLower()].rounds)
{
roundInfos[round.roundNumber] = round;
}
base.Register();
Cache[Id] = this;
var cache = elite ? EliteCache : NormalCache;
cache[bossType] = this;
}
public override void ModifyRoundModels(RoundModel roundModel, int round)
{
if (!roundInfos.TryGetValue(round + 1, out var roundInfo)) return;
var groups = roundInfo.GetRoundDef(1f).groups;
if (roundInfo.addToRound)
{
roundModel.groups = roundModel.groups.Concat(groups).ToArray();
roundModel.AddChildDependants(groups);
}
else
{
roundModel.RemoveChildDependants(roundModel.groups);
roundModel.groups = groups;
roundModel.AddChildDependants(groups);
}
roundModel.emissions_ = null;
}
}