-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTheLunaticMod.cs
105 lines (78 loc) · 2.61 KB
/
TheLunaticMod.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
using System.IO;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.ModLoader;
using TheLunatic.Tiles;
using Terraria.ID;
using System;
using TheLunatic.NetProtocol;
using HamstarHelpers.Helpers.Debug;
using HamstarHelpers.Helpers.TModLoader.Mods;
namespace TheLunatic {
partial class TheLunaticMod : Mod {
public static TheLunaticMod Instance { get; private set; }
////////////////
public LunaticConfig Config => ModContent.GetInstance<LunaticConfig>();
internal AnimatedSky Sky { get; private set; }
////////////////
public TheLunaticMod() {
TheLunaticMod.Instance = this;
}
////////////////
public override void Load() {
if( !Main.dedServ ) {
this.Sky = new AnimatedSky();
SkyManager.Instance["TheLunaticMod:AnimatedColorize"] = this.Sky;
}
}
public override void Unload() {
TheLunaticMod.Instance = null;
}
////////////////
public override void HandlePacket( BinaryReader reader, int playerWho ) {
try {
if( Main.netMode == 1 ) {
ClientPacketHandlers.HandlePacket( reader );
} else if( Main.netMode == 2 ) {
ServerPacketHandlers.HandlePacket( reader, playerWho );
}
} catch( Exception e ) {
LogHelpers.Log( "HandlePacket "+e.ToString() );
}
}
public override bool HijackGetData( ref byte messageType, ref BinaryReader reader, int playerNumber ) {
var myworld = ModContent.GetInstance<TheLunaticWorld>();
if( myworld != null && myworld.GameLogic != null ) {
// Let not a peep of town NPC suffering be heard when set to do so
if( myworld.GameLogic.KillSurfaceTownNPCs ) {
if( (int)messageType == MessageID.SyncNPCName ) {
//reader.ReadInt16();
//reader.ReadString();
return true;
}
}
}
return base.HijackGetData( ref messageType, ref reader, playerNumber );
}
////////////////
public override void PostDrawInterface( SpriteBatch sb ) {
if( this.Config == null || !this.Config.Enabled ) { return; }
var myworld = ModContent.GetInstance<TheLunaticWorld>();
if( myworld.GameLogic != null ) {
myworld.GameLogic.ReadyClient = true; // Ugh!
}
}
public override void UpdateMusic( ref int music, ref MusicPriority priority ) {
if( this.Config == null || !this.Config.Enabled ) { return; }
var myworld = ModContent.GetInstance<TheLunaticWorld>();
if( myworld != null && myworld.GameLogic != null ) {
myworld.GameLogic.UpdateMyMusic( ref music );
}
}
////////////////
public override object Call( params object[] args ) {
return ModBoilerplateHelpers.HandleModCall( typeof(TheLunaticAPI), args );
}
}
}