-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDataManager.cs
137 lines (116 loc) · 4.73 KB
/
DataManager.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ModLoader.IO;
namespace BossAssist
{
public class BossRecord : TagSerializable
{
internal string bossName;
internal string modName;
internal BossStats stat = new BossStats();
public static Func<TagCompound, BossRecord> DESERIALIZER = tag => new BossRecord(tag);
private BossRecord(TagCompound tag)
{
modName = tag.Get<string>(nameof(modName));
bossName = tag.Get<string>(nameof(bossName));
stat = tag.Get<BossStats>(nameof(stat));
}
public BossRecord(string mod, string boss)
{
modName = mod;
bossName = boss;
}
public TagCompound SerializeData()
{
return new TagCompound
{
{ nameof(bossName), bossName },
{ nameof(modName), modName },
{ nameof(stat), stat }
};
}
}
public class BossStats : TagSerializable
{
public int kills; // How many times the player has killed the boss
public int deaths; // How many times the player has died during a participated boss fight
public int fightTime; // Quickest time a player has defeated a boss
public int fightTime2; // Slowest time a player has defeated a boss
public int fightTimeL = -1;
public int dodgeTime; // Most time that a player has not been damaged during a boss fight
public int totalDodges; // Least amount of times the player has been damaged
public int totalDodges2; // Most amount of times the player has been damaged
public int dodgeTimeL = -1;
public int totalDodgesL = -1;
public int brink; // Least amount of health a player has had during a boss fight
public int brinkPercent; // The above stat in %
public int brink2; // "Highest" lowest amount of health a player has had during a boss fight
public int brinkPercent2; // The above stat in %
public int brinkL = -1;
public int brinkPercentL = -1;
public static Func<TagCompound, BossStats> DESERIALIZER = tag => new BossStats(tag);
public BossStats() { }
private BossStats(TagCompound tag)
{
kills = tag.Get<int>(nameof(kills));
deaths = tag.Get<int>(nameof(deaths));
fightTime = tag.Get<int>(nameof(fightTime));
fightTime2 = tag.Get<int>(nameof(fightTime2));
dodgeTime = tag.Get<int>(nameof(dodgeTime));
totalDodges = tag.Get<int>(nameof(totalDodges));
totalDodges2 = tag.Get<int>(nameof(totalDodges2));
brink = tag.Get<int>(nameof(brink));
brinkPercent = tag.Get<int>(nameof(brinkPercent));
brink2 = tag.Get<int>(nameof(brink2));
brinkPercent2 = tag.Get<int>(nameof(brinkPercent2));
}
public TagCompound SerializeData()
{
return new TagCompound
{
{ nameof(kills), kills },
{ nameof(deaths), deaths },
{ nameof(fightTime), fightTime },
{ nameof(fightTime2), fightTime2 },
{ nameof(dodgeTime), dodgeTime },
{ nameof(totalDodges), totalDodges },
{ nameof(totalDodges2), totalDodges2 },
{ nameof(brink), brink },
{ nameof(brinkPercent), brinkPercent },
{ nameof(brink2), brink2 },
{ nameof(brinkPercent2), brinkPercent2 }
};
}
}
public class BossCollection : TagSerializable
{
internal string modName;
internal string bossName;
internal List<Item> loot;
internal List<Item> collectibles;
public static Func<TagCompound, BossCollection> DESERIALIZER = tag => new BossCollection(tag);
private BossCollection(TagCompound tag)
{
modName = tag.Get<string>(nameof(modName));
bossName = tag.Get<string>(nameof(bossName));
loot = tag.Get<List<Item>>(nameof(loot));
collectibles = tag.Get<List<Item>>(nameof(collectibles));
}
public BossCollection(string mod, string boss)
{
modName = mod;
bossName = boss;
}
public TagCompound SerializeData()
{
return new TagCompound
{
{ nameof(modName), modName },
{ nameof(bossName), bossName },
{ nameof(loot), loot },
{ nameof(collectibles), collectibles },
};
}
}
}