forked from zoroarkcity/Not-BTFA-Source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TGEMWorld.cs
221 lines (206 loc) · 6.29 KB
/
TGEMWorld.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
using System.IO;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.World.Generation;
using Microsoft.Xna.Framework;
using Terraria.GameContent.Generation;
using Terraria.ModLoader.IO;
using ForgottenMemories.Tiles;
namespace ForgottenMemories
{
public class TGEMWorld : ModWorld
{
public static readonly Mod mod = ModLoader.GetMod("ForgottenMemories");
public static bool Cryotine = false;
public static bool Gelatine = false;
public static bool Blight = false;
public static bool downedGhastlyEnt = false;
public static bool downedArterius = false;
public static bool downedTitanRock = false;
public static bool forestInvasionUp = false;
public static bool downedAcheron = false;
public static bool downedMag = false;
public static bool downedForestInvasion = false;
public static bool spawnedGems = false;
public static int TremorTime;
public static bool Cosmirock = false;
public override void Initialize()
{
Gelatine = false;
Blight = false;
downedArterius = false;
Cryotine = false;
downedGhastlyEnt = false;
TremorTime = 0;
downedTitanRock = false;
Main.invasionSize = 0;
downedAcheron = false;
forestInvasionUp = false;
downedForestInvasion = false;
downedMag = false;
spawnedGems = false;
Cosmirock = false;
}
public override TagCompound Save()
{
var downed = new List<string>();
var ore = new List<string>();
if (Gelatine) ore.Add("Gelatine");
if (Cryotine) ore.Add("Cryotine");
if (Blight) ore.Add("Blight");
if (downedGhastlyEnt) downed.Add("GhastlyEnt");
if (downedTitanRock) downed.Add("TitanRock");
if (downedArterius) downed.Add("acheron");
if (downedArterius) downed.Add("Arterius");
if (downedForestInvasion) downed.Add("forestInvasion");
if (spawnedGems) ore.Add("Gems");
if (downedMag) downed.Add("Mag");
if (Cosmirock) ore.Add ("Cosmirock");
return new TagCompound {
{"downed", downed},
{"ore", ore}
};;
}
public override void Load(TagCompound tag)
{
var downed = tag.GetList<string>("downed");
var ore = tag.GetList<string>("ore");
downedGhastlyEnt = downed.Contains("GhastlyEnt");
downedTitanRock = downed.Contains("TitanRock");
downedArterius = downed.Contains("Arterius");
Gelatine = ore.Contains("Gelatine");
Cryotine = ore.Contains("Cryotine");
Blight = ore.Contains("Blight");
spawnedGems = ore.Contains("Gems");
downedMag = downed.Contains("Mag");
downedForestInvasion = downed.Contains("forestInvasion");
Cosmirock = ore.Contains("Cosmirock");
downedAcheron = downed.Contains("acheron");
}
public override void NetSend(BinaryWriter writer)
{
BitsByte flags = new BitsByte();
flags[0] = Gelatine;
flags[1] = Cryotine;
flags[2] = downedGhastlyEnt;
flags[3] = downedTitanRock;
flags[4] = Blight;
flags[5] = downedArterius;
flags[6] = downedForestInvasion;
flags[7] = downedAcheron;
flags[9] = spawnedGems;
flags[8] = downedMag;
flags[10] = Cosmirock;
writer.Write(flags);
}
public override void NetReceive(BinaryReader reader)
{
BitsByte flags = reader.ReadByte();
Gelatine = flags[0];
Cryotine = flags[1];
downedGhastlyEnt = flags[2];
downedTitanRock = flags[3];
Blight = flags[4];
downedArterius = flags[5];
downedForestInvasion = flags[6];
downedForestInvasion = flags[8];
downedAcheron = flags[7];
spawnedGems = flags[9];
Cosmirock = flags[10];
}
public override void PostUpdate()
{
if(forestInvasionUp)
{
if(Main.invasionX == (double)Main.spawnTileX)
{
CustomInvasion.CheckCustomInvasionProgress();
}
CustomInvasion.UpdateCustomInvasion();
}
if(!spawnedGems)
{
for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 15E-04); k++)
{
int i = WorldGen.genRand.Next(10, Main.maxTilesX - 10);
int j = WorldGen.genRand.Next((int) Main.worldSurface - 1, Main.maxTilesY - 10);
Tile tile = Main.tile[i, j];
if ((tile.type == 368) && tile.active())
{
WorldGen.TileRunner(i, j, (double)WorldGen.genRand.Next(2, 6), WorldGen.genRand.Next(2, 6), mod.TileType<TourmalineOre>());
}
if ((tile.type == 367) && tile.active())
{
WorldGen.TileRunner(i, j, (double)WorldGen.genRand.Next(2, 6), WorldGen.genRand.Next(2, 6), mod.TileType<CitrineOre>());
}
}
for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 15E-04); k++)
{
int i = WorldGen.genRand.Next(10, Main.maxTilesX - 10);
int j = WorldGen.genRand.Next((int) Main.worldSurface - 1, Main.maxTilesY - 10);
Tile tile = Main.tile[i, j];
if ((tile.type == 57) && tile.active())
{
WorldGen.TileRunner(i, j, (double)WorldGen.genRand.Next(2, 6), WorldGen.genRand.Next(2, 6), mod.TileType<SpinelOre>());
}
}
spawnedGems = true;
}
}
public static void TryForBossMask(Vector2 center, int type)
{
if (Main.rand.Next(7) == 0 && !Main.expertMode)
{
int maskType = 0;
if (type == mod.NPCType("TitanRock"))
{
maskType = mod.ItemType("TitanMask");
}
if (type == mod.NPCType("FaceOfInsanity"))
{
maskType = mod.ItemType("ArteryMask");
}
if (type == mod.NPCType("GhastlyEnt"))
{
maskType = mod.ItemType("GhastlyMask");
}
if (type == mod.NPCType("Acheron"))
{
maskType = mod.ItemType("picklerick");
}
if (type == mod.NPCType("MagnoliacSecondStage"))
{
maskType = mod.ItemType("birdman");
}
Item mask = Main.item[Item.NewItem((int)center.X, (int)center.Y, 0, 0, maskType, 1)];
}
if (Main.rand.Next(10) == 0)
{
int trophyType = 0;
if (type == mod.NPCType("TitanRock"))
{
trophyType = mod.ItemType("TitanRockTrophy");
}
if (type == mod.NPCType("FaceOfInsanity"))
{
trophyType = mod.ItemType("ArteriusTrophy");
}
if (type == mod.NPCType("GhastlyEnt"))
{
trophyType = mod.ItemType("GhastlyEntTrophy");
}
if (type == mod.NPCType("Acheron"))
{
trophyType = mod.ItemType("AcheronTrophy");
}
if (type == mod.NPCType("MagnoliacSecondStage"))
{
trophyType = mod.ItemType("MagnoliacTrophy");
}
Item trophy = Main.item[Item.NewItem((int)center.X, (int)center.Y, 0, 0, trophyType, 1)];
}
}
}
}