forked from TehCheat/PassiveSkillTreePlanter
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSkillNode.cs
More file actions
78 lines (63 loc) · 2.33 KB
/
SkillNode.cs
File metadata and controls
78 lines (63 loc) · 2.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
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
using System;
using System.Collections.Generic;
using System.Numerics;
using PassiveSkillTreePlanter.SkillTreeJson;
namespace PassiveSkillTreePlanter;
public class SkillNode
{
public Constants Constants { private get; init; }
public List<int> OrbitRadii => Constants.OrbitRadii;
public List<int> SkillsPerOrbit => Constants.SkillsPerOrbit;
public bool bJevel;
public bool bKeyStone;
public bool bMastery;
public bool bMult;
public bool bNotable;
public Vector2 DrawPosition;
//Cached for drawing
public float DrawSize = 100;
public ushort Id; // "id": -28194677,
public List<ushort> linkedNodes = new List<ushort>();
public string Name; //"dn": "Block Recovery",
public int Orbit; // "o": 1,
public long OrbitIndex; // "oidx": 3,
public SkillNodeGroup SkillNodeGroup;
public Vector2 Position => GetPositionAtAngle(Arc);
public Vector2 GetPositionAtAngle(float angle)
{
if (SkillNodeGroup == null) return new Vector2();
return SkillNodeGroup.Position + OrbitRadius * GetAngleVector(angle);
}
public int OrbitRadius => OrbitRadii[Orbit];
public float Arc => GetOrbitAngle(OrbitIndex, SkillsPerOrbit[Orbit]);
public void Init()
{
DrawPosition = Position;
if (bJevel)
DrawSize = 160;
if (bNotable)
DrawSize = 170;
if (bKeyStone)
DrawSize = 250;
}
private static readonly int[] Angles16 = { 0, 30, 45, 60, 90, 120, 135, 150, 180, 210, 225, 240, 270, 300, 315, 330 };
private static readonly int[] Angles40 = { 0, 10, 20, 30, 40, 45, 50, 60, 70, 80, 90, 100, 110, 120, 130, 135, 140, 150, 160, 170, 180, 190, 200, 210, 220, 225, 230, 240, 250, 260, 270, 280, 290, 300, 310, 315, 320, 330, 340, 350 };
private static float GetOrbitAngle(long orbitIndex, long maxNodePositions)
{
return maxNodePositions switch
{
16 => Angles16[orbitIndex] * MathF.PI / 180,
40 => Angles40[orbitIndex] * MathF.PI / 180,
_ => 2 * MathF.PI * orbitIndex / maxNodePositions
};
}
public static Vector2 GetAngleVector(float angle)
{
return new Vector2(MathF.Sin(angle), -MathF.Cos(angle));
}
}
public class SkillNodeGroup
{
public List<SkillNode> Nodes = new List<SkillNode>();
public Vector2 Position;
}