forked from GabeHasWon/spritersguildwip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbiomehandler.cs
134 lines (125 loc) · 4.48 KB
/
biomehandler.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
using System.IO;
using System.Collections.Generic;
using System.Linq;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.World.Generation;
using Microsoft.Xna.Framework;
using Terraria.GameContent.Generation;
using Terraria.ModLoader.IO;
using Terraria.DataStructures;
using Microsoft.Xna.Framework.Graphics;
using System;
using StarlightRiver.GUI;
using StarlightRiver.Abilities;
namespace StarlightRiver
{
public class BiomeHandler : ModPlayer
{
public bool ZoneGlass = false;
public bool ZoneVoidPre = false;
public bool ZoneJungleCorrupt = false;
public bool ZoneJungleBloody = false;
public bool ZoneJungleHoly = false;
public override void UpdateBiomes()
{
ZoneGlass = (LegendWorld.glassTiles > 50);
ZoneVoidPre = (LegendWorld.voidTiles > 50);
ZoneJungleCorrupt = (LegendWorld.evilJungleTiles > 50);
ZoneJungleBloody = (LegendWorld.bloodJungleTiles > 50);
ZoneJungleHoly = (LegendWorld.holyJungleTiles > 50);
}
public override bool CustomBiomesMatch(Player other)
{
BiomeHandler modOther = other.GetModPlayer<BiomeHandler>();
bool allMatch = true;
allMatch &= ZoneGlass == modOther.ZoneGlass;
allMatch &= ZoneVoidPre == modOther.ZoneVoidPre;
allMatch &= ZoneJungleCorrupt == modOther.ZoneJungleCorrupt;
allMatch &= ZoneJungleBloody == modOther.ZoneJungleBloody;
allMatch &= ZoneJungleHoly == modOther.ZoneJungleHoly;
return allMatch;
}
public override void CopyCustomBiomesTo(Player other)
{
BiomeHandler modOther = other.GetModPlayer<BiomeHandler>();
modOther.ZoneGlass = ZoneGlass;
modOther.ZoneVoidPre = ZoneVoidPre;
modOther.ZoneJungleCorrupt = ZoneJungleCorrupt;
modOther.ZoneJungleBloody = ZoneJungleBloody;
modOther.ZoneJungleHoly = ZoneJungleHoly;
}
public override void SendCustomBiomes(BinaryWriter writer)
{
BitsByte flags = new BitsByte();
flags[0] = ZoneGlass;
flags[1] = ZoneVoidPre;
flags[2] = ZoneJungleCorrupt;
flags[3] = ZoneJungleBloody;
flags[4] = ZoneJungleHoly;
writer.Write(flags);
}
public override void ReceiveCustomBiomes(BinaryReader reader)
{
BitsByte flags = reader.ReadByte();
ZoneGlass = flags[0];
ZoneVoidPre = flags[1];
ZoneJungleCorrupt = flags[2];
ZoneJungleBloody = flags[3];
ZoneJungleHoly = flags[4];
}
public override void PreUpdate()
{
if (ZoneVoidPre)
{
Overlay.visible = true;
Overlay.state = 1;
if(player.GetModPlayer<AbilityHandler>().unlock[2] == 0)
{
player.AddBuff(mod.BuffType("DarkSlow"), 5);
}
}
else if (ZoneJungleCorrupt)
{
Overlay.visible = true;
Overlay.state = 2;
}
else if (ZoneJungleBloody)
{
Overlay.visible = true;
Overlay.state = 3;
}
else if (ZoneJungleHoly)
{
Overlay.visible = true;
Overlay.state = 4;
}
else
{
Overlay.visible = false;
}
}
public override void UpdateBiomeVisuals()
{
//player.ManageSpecialBiomeVisuals("StarlightRiver:", ZoneJungleCorrupt);
}
}
public partial class LegendWorld
{
public static int glassTiles;
public static int voidTiles;
public static int evilJungleTiles;
public static int bloodJungleTiles;
public static int holyJungleTiles;
public override void TileCountsAvailable(int[] tileCounts)
{
glassTiles = tileCounts[mod.TileType("VitricSand")] + tileCounts[mod.TileType("VitricGlassCrystal")];
voidTiles = tileCounts[mod.TileType("Void1")] + tileCounts[mod.TileType("Void2")];
evilJungleTiles = tileCounts[mod.TileType("GrassJungleCorrupt")];
bloodJungleTiles = tileCounts[mod.TileType("GrassJungleBloody")];
holyJungleTiles = tileCounts[mod.TileType("GrassJungleHoly")];
}
}
}