-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTwitchWorld.cs
61 lines (49 loc) · 1.64 KB
/
TwitchWorld.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
using System.Collections.Generic;
using Terraria;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
namespace TwitchChat
{
public class TwitchWorld : ModWorld
{
public bool FirstNight;
private bool statePrinted;
public List<string> UsedNicks = new List<string>();
public override void Load(TagCompound tag)
{
FirstNight = tag.GetBool("firstNigh");
//FirstNight = true;
UsedNicks = tag.ContainsKey("usedNicks") ? (List<string>) tag["usedNicks"] : new List<string>();
var inter = new List<string>();
for (var i = 0; i < Main.maxNPCs; i++)
if (Main.npc[i].active && Main.npc[i].townNPC && UsedNicks.Contains(Main.npc[i].GivenName))
inter.Add(Main.npc[i].GivenName);
UsedNicks = inter;
}
public override TagCompound Save()
{
return new TagCompound
{
["firstNight"] = FirstNight,
["usedNicks"] = UsedNicks
};
}
public override void Initialize()
{
base.Initialize();
statePrinted = false;
for (var i = 0; i < Main.npc.Length; i++) TwitchChat.ShadowNpc[i] = Main.npc[i].type;
}
public override void PostUpdate()
{
base.PostUpdate();
if (!statePrinted)
{
TwitchChat.Text(((TwitchChat) mod).LastStatus);
statePrinted = true;
}
if (TwitchChat.Instance.Fun &&Main.rand.Next(255) > 80)
TwitchBoss.ShatterBoss();
}
}
}