forked from Chinzilla00/AncientsAwakened
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDownedBools.cs
72 lines (59 loc) · 1.87 KB
/
DownedBools.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
using Terraria;
using System.Collections.Generic;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
using System.IO;
namespace AAMod
{
public class DownedBools : ModWorld
{
public static bool downedGobSummoner = false;
public static bool downedOgre = false;
public static bool downedBetsy = false;
public static bool downedMoth = false;
public override void Initialize()
{
downedGobSummoner = false;
downedOgre = false;
downedBetsy = false;
downedMoth = false;
}
public override TagCompound Save()
{
var downed = new List<string>();
if (downedGobSummoner) downed.Add("GS");
if (downedOgre) downed.Add("O");
if (downedBetsy) downed.Add("B");
if (downedMoth) downed.Add("M");
return new TagCompound
{
{"downed", downed}
};
}
public override void Load(TagCompound tag)
{
var downed = tag.GetList<string>("downed");
downedGobSummoner = downed.Contains("GS");
downedOgre = downed.Contains("O");
downedBetsy = downed.Contains("B");
downedMoth = downed.Contains("M");
}
public override void NetSend(BinaryWriter writer)
{
BitsByte killed = new BitsByte();
killed[0] = downedGobSummoner;
killed[1] = downedOgre;
killed[2] = downedBetsy;
killed[3] = downedMoth;
writer.Write(killed);
}
public override void NetReceive(BinaryReader reader)
{
BitsByte killed = reader.ReadByte();
downedGobSummoner = killed[0];
downedOgre = killed[1];
downedBetsy = killed[2];
downedMoth = killed[3];
}
}
}