-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPillarAdder.cs
69 lines (60 loc) · 2.5 KB
/
PillarAdder.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
using DarknessUnbound.NPCs;
using Microsoft.Xna.Framework;
using System.Linq;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace DarknessUnbound
{
public class PillarAdder : ModWorld
{
public static bool lastLunarApocalypse;
public override void PreUpdate()
{
if (!lastLunarApocalypse && NPC.LunarApocalypseIsUp)
{
MovePillars();
}
lastLunarApocalypse = NPC.LunarApocalypseIsUp;
}
private void MovePillars()
{
Main.NewText("Moving...");
float counter = 1;
float quotient = Main.maxTilesX * 16f / 6f;
foreach (NPC npc in from NPC n in Main.npc where n.IsAPillar() select n)
{
int num = Main.maxTilesX / 5;
int num2 = (int)Main.worldSurface;
for (int j = 0; j < 4; j++)
{
int num3 = num * (1 + j);
bool flag = false;
for (int k = 0; k < 30; k++)
{
int num4 = Main.rand.Next(-100, 101);
for (int num5 = num2; num5 > 100; num5--)
{
if (!Collision.SolidTiles(num3 + num4 - 10, num3 + num4 + 10, num5 - 20, num5 + 15) && !WorldGen.PlayerLOS(num3 + num4 - 10, num5) && !WorldGen.PlayerLOS(num3 + num4 + 10, num5) && !WorldGen.PlayerLOS(num3 + num4 - 10, num5 - 20) && !WorldGen.PlayerLOS(num3 + num4 + 10, num5 - 20))
{
npc.position = new Vector2(quotient * counter, num5 * 16);
if (Main.netMode == 2 && npc.whoAmI < 200)
NetMessage.SendData(23, -1, -1, null, npc.whoAmI);
flag = true;
break;
}
}
}
}
//npc.position.X = quotient * counter;
counter++;
}
NPC.NewNPC((int)(quotient * counter), (int)Main.worldSurface * 16, ModContent.NPCType<TerrenceTheFatDragon>());
Main.NewText("Moved.");
}
}
public static class PillarUtils
{
public static bool IsAPillar(this NPC npc) => npc.type == NPCID.LunarTowerSolar || npc.type == NPCID.LunarTowerNebula || npc.type == NPCID.LunarTowerVortex || npc.type == NPCID.LunarTowerStardust;
}
}