-
Notifications
You must be signed in to change notification settings - Fork 3
/
biomehandler.cs
77 lines (70 loc) · 2.36 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
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;
namespace spritersguildwip
{
public class BiomeHandler : ModPlayer
{
public bool ZoneGlass= false;
public override void UpdateBiomes()
{
ZoneGlass = (LegendWorld.glassTiles > 50);
}
public override bool CustomBiomesMatch(Player other)
{
BiomeHandler modOther = other.GetModPlayer<BiomeHandler>(mod);
return ZoneGlass == modOther.ZoneGlass;
// If you have several Zones, you might find the &= operator or other logic operators useful:
// bool allMatch = true;
// allMatch &= ZoneGlass == modOther.ZoneGlass;
// allMatch &= ZoneModel == modOther.ZoneModel;
// return allMatch;
// Here is an example just using && chained together in one statemeny
// return ZoneGlass == modOther.ZoneGlass && ZoneModel == modOther.ZoneModel;
}
public override void CopyCustomBiomesTo(Player other)
{
BiomeHandler modOther = other.GetModPlayer<BiomeHandler>(mod);
modOther.ZoneGlass = ZoneGlass;
}
public override void SendCustomBiomes(BinaryWriter writer)
{
BitsByte flags = new BitsByte();
flags[0] = ZoneGlass;
writer.Write(flags);
}
public override void ReceiveCustomBiomes(BinaryReader reader)
{
BitsByte flags = reader.ReadByte();
ZoneGlass = flags[0];
}
public override Texture2D GetMapBackgroundImage()
{
if (ZoneGlass)
{
//return mod.GetTexture("ExampleBiomeMapBackground");
return null;
}
return null;
}
}
public partial class LegendWorld
{
public static int glassTiles;
public override void TileCountsAvailable(int[] tileCounts)
{
glassTiles = tileCounts[mod.TileType("SandGlass")] + tileCounts[mod.TileType("GlassCrystal")];
}
}
}