-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMultiPathPlusPlus.cs
More file actions
45 lines (37 loc) · 1.33 KB
/
MultiPathPlusPlus.cs
File metadata and controls
45 lines (37 loc) · 1.33 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using BTD_Mod_Helper.Api;
using Il2CppAssets.Scripts.Simulation.Towers;
namespace PathsPlusPlus;
/// <summary>
/// A PathPlusPlus class that can apply to multiple base towers
/// </summary>
public abstract class MultiPathPlusPlus : PathPlusPlus
{
/// <inheritdoc />
public override string Name => base.Name + "-" + Tower;
private string tower = null!;
/// <inheritdoc />
public sealed override string Tower =>
tower ?? throw new ArgumentException($"Tower was null for MultiPathPlusPlus {Name}");
/// <summary>
/// The multiple towers that this will be added as a path for
/// </summary>
public abstract IEnumerable<string> Towers { get; }
/// <summary>
/// The generated MultiPathPlusPlus instances for each tower
/// </summary>
public readonly Dictionary<string, MultiPathPlusPlus> PathsByTower = new();
/// <inheritdoc />
public override IEnumerable<ModContent> Load() => Towers.Select(t =>
{
var path = (MultiPathPlusPlus) Activator.CreateInstance(GetType())!;
path.tower = t;
PathsByTower[t] = path;
return path;
});
/// <inheritdoc />
public override int GetTier(Tower t) =>
!PathsByTower.TryGetValue(t.towerModel.baseId, out var path) ? 0 : path.GetTier(t);
}