-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathLevelPlus.cs
More file actions
46 lines (37 loc) · 1.2 KB
/
Copy pathLevelPlus.cs
File metadata and controls
46 lines (37 loc) · 1.2 KB
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
using System;
using System.IO;
using LevelPlus.Network;
using Terraria.ModLoader;
namespace LevelPlus;
public class LevelPlus : Mod
{
public bool IsCalamityLoaded { get; private set; }
public bool IsThoriumLoaded { get; private set; }
public override void Load()
{
IsCalamityLoaded = ModLoader.HasMod("CalamityMod");
IsThoriumLoaded = ModLoader.HasMod("ThoriumMod");
Logger.InfoFormat("{0}: Calamity = {1}", Name, IsCalamityLoaded);
Logger.InfoFormat("{0}: Thorium = {1}", Name, IsThoriumLoaded);
}
public override void Unload()
{
IsCalamityLoaded = false;
IsThoriumLoaded = false;
}
public override void HandlePacket(BinaryReader reader, int whoAmI)
{
var typeString = reader.ReadString();
if (Type.GetType(typeString) is not { } type)
{
Logger.WarnFormat("{0}: Packet of unknown type \"{1}\"", Name, typeString);
return;
}
if (Activator.CreateInstance(type) is not Packet packet)
{
Logger.WarnFormat("{0}: Failed to instantiate Packet of type \"{1}\"", Name, typeString);
return;
}
packet.Receive(reader, whoAmI);
}
}