-
Notifications
You must be signed in to change notification settings - Fork 5
/
TGEMWorld.cs
289 lines (277 loc) · 8.57 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
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;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using Terraria.DataStructures;
using Terraria.Enums;
using Terraria.GameContent;
using Terraria.GameContent.Achievements;
using Terraria.GameContent.Biomes;
using Terraria.GameContent.Events;
using Terraria.GameContent.Generation;
using Terraria.GameContent.Tile_Entities;
using Terraria.Graphics.Capture;
using Terraria.ID;
using Terraria.IO;
using Terraria.Localization;
using Terraria.Map;
using Terraria.ObjectData;
using Terraria.Utilities;
using Terraria.World.Generation;
using System.IO;
using Terraria;
using Terraria.ModLoader;
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 MagnoliacBool = false;
public static bool GentBool = 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;
MagnoliacBool = false;
GentBool = 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 (downedAcheron) 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;
flags[11] = GentBool;
flags[12] = MagnoliacBool;
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];
downedMag = flags[8];
downedAcheron = flags[7];
spawnedGems = flags[9];
Cosmirock = flags[10];
GentBool = flags[11];
MagnoliacBool = flags[12];
}
public override void PostUpdate()
{
if(forestInvasionUp)
{
if(Main.invasionX == (double)Main.spawnTileX)
{
CustomInvasion.CheckCustomInvasionProgress();
}
CustomInvasion.UpdateCustomInvasion();
}
}
public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
{
int genIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Final Cleanup"));
tasks.Insert(genIndex + 1, new PassLegacy("BTFA Gems", delegate (GenerationProgress progress)
{
int spinelGen = 0;
while (spinelGen <= 200) //this allows us to have X ore veins increase or decrease it at your will
{
int spinelX = Main.rand.Next(Main.maxTilesX);
double spinelNum = (int) (Main.rockLayer + Main.rockLayer + (double) Main.maxTilesY) / 3.0;
int spinelY = Main.rand.Next(Main.maxTilesY);
if (spinelX >= Main.maxTilesX - 50)
{
spinelX = spinelX - 50;
}
if (spinelX <= 50)
{
spinelX = spinelX + 50;
}
if ((Main.tile[spinelX, spinelY].type == 57))
{
spinelGen++;
WorldGen.TileRunner(spinelX, spinelY, (double) WorldGen.genRand.Next(2, 6), WorldGen.genRand.Next(3, 7), mod.TileType<SpinelOre>(), false, 0.0f, 0.0f, false, true);
}
}
int tourmalineGen = 0;
while (tourmalineGen <= 900) //this allows us to have X ore veins increase or decrease it at your will
{
int tourmalineX = Main.rand.Next(Main.maxTilesX);
double spinelNum = (int) (Main.rockLayer + Main.rockLayer + (double) Main.maxTilesY) / 3.0;
int tourmalineY = Main.rand.Next(Main.maxTilesY);
if (tourmalineX >= Main.maxTilesX - 50)
{
tourmalineX = tourmalineX - 50;
}
if (tourmalineX <= 50)
{
tourmalineX = tourmalineX + 50;
}
if ((Main.tile[tourmalineX, tourmalineY].type == 368))
{
tourmalineGen++;
WorldGen.TileRunner(tourmalineX, tourmalineY, (double) WorldGen.genRand.Next(2, 6), WorldGen.genRand.Next(3, 7), mod.TileType<TourmalineOre>(), false, 0.0f, 0.0f, false, true);
}
}
int citrineGen = 0;
while (citrineGen <= 900) //this allows us to have X ore veins increase or decrease it at your will
{
int citrineX = Main.rand.Next(Main.maxTilesX);
double spinelNum = (int) (Main.rockLayer + Main.rockLayer + (double) Main.maxTilesY) / 3.0;
int citrineY = Main.rand.Next(Main.maxTilesY);
if (citrineX >= Main.maxTilesX - 50)
{
citrineX = citrineX - 50;
}
if (citrineX <= 50)
{
citrineX = citrineX + 50;
}
if ((Main.tile[citrineX, citrineY].type == 367))
{
citrineGen++;
WorldGen.TileRunner(citrineX, citrineY, (double) WorldGen.genRand.Next(2, 6), WorldGen.genRand.Next(3, 7), mod.TileType<CitrineOre>(), false, 0.0f, 0.0f, false, 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("Ghastly_Ent"))
{
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("Ghastly_Ent"))
{
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)];
}
}
}
}