-
Notifications
You must be signed in to change notification settings - Fork 0
/
TPUnchained.cs
60 lines (51 loc) · 1.58 KB
/
TPUnchained.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
using System.IO;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;
using TPUnchained.Tiles;
using TPUnchained.Tracking;
namespace TPUnchained
{
public class TPUnchained : Mod
{
public enum ModMessageID { RequestLock, RequestUnlock, RequestPush, ShareTeleporterData }
public TPUnchained()
{
Properties = new ModProperties()
{
Autoload = true
};
}
public override void HandlePacket(BinaryReader reader, int whoAmI)
{
ModMessageID msg = (ModMessageID)reader.ReadByte();
int id = reader.ReadInt32();
TileEntity TE;
if (!TileEntity.ByID.TryGetValue(id, out TE))
{
GetModWorld<TPTrackerWorld>().teleporters.RemoveAll(x => x.ID == id);
return;
}
TEWirelessTeleporter TEw = (TEWirelessTeleporter)TE;
if (Main.netMode == 2)
{
switch (msg)
{
case ModMessageID.RequestLock:
TEw.Connect();
break;
case ModMessageID.RequestUnlock:
TEw.Disconnect();
break;
case ModMessageID.RequestPush:
TEw.PushDown();
break;
}
}
else if (Main.netMode == 1 && msg == ModMessageID.ShareTeleporterData)
{
TEw.NetReceive(reader, false);
}
}
}
}