This repository has been archived by the owner on Sep 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
HookManager.cs
1037 lines (850 loc) · 25.6 KB
/
HookManager.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Text;
using System.Linq;
using System.Security.Cryptography;
using Terraria;
using System.IO;
namespace TerrariaApi.Server
{
public delegate void HookHandler<in ArgumentType>(ArgumentType args) where ArgumentType: EventArgs;
public class HookManager
{
#region Client Hooks
#region ClientChatReceived
private readonly HandlerCollection<ChatReceivedEventArgs> clientChatReceived =
new HandlerCollection<ChatReceivedEventArgs>("ClientChatReceived");
public HandlerCollection<ChatReceivedEventArgs> ClientChatReceived
{
get { return this.clientChatReceived; }
}
internal void InvokeClientChatReceived(byte playerID, Color color, string message)
{
ChatReceivedEventArgs args = new ChatReceivedEventArgs
{
PlayerID = playerID,
Color = color,
Message = message
};
this.ClientChatReceived.Invoke(args);
}
#endregion
#region ClientChat
private readonly HandlerCollection<ChatEventArgs> clientChat =
new HandlerCollection<ChatEventArgs>("ClientChat");
public HandlerCollection<ChatEventArgs> ClientChat
{
get { return this.clientChat; }
}
internal bool InvokeClientChat(ref string message)
{
ChatEventArgs args = new ChatEventArgs
{
Message = message
};
this.ClientChat.Invoke(args);
message = args.Message;
return args.Handled;
}
#endregion
#endregion
#region Game Hooks
#region GameUpdate
private readonly HandlerCollection<EventArgs> gameUpdate =
new HandlerCollection<EventArgs>("GameUpdate");
public HandlerCollection<EventArgs> GameUpdate
{
get { return this.gameUpdate; }
}
private bool currentGameMenuState;
internal void InvokeGameUpdate()
{
if (this.currentGameMenuState != Main.gameMenu)
{
this.currentGameMenuState = Main.gameMenu;
if (Main.gameMenu)
this.InvokeGameWorldDisconnect();
else
this.InvokeGameWorldConnect();
ServerApi.IsWorldRunning = !Main.gameMenu;
}
this.GameUpdate.Invoke(EventArgs.Empty);
}
#endregion
#region GamePostUpdate
private readonly HandlerCollection<EventArgs> gamePostUpdate =
new HandlerCollection<EventArgs>("GamePostUpdate");
public HandlerCollection<EventArgs> GamePostUpdate
{
get { return this.gamePostUpdate; }
}
internal void InvokeGamePostUpdate()
{
this.GamePostUpdate.Invoke(EventArgs.Empty);
}
#endregion
#region GameHardmodeTileUpdate
private readonly HandlerCollection<HardmodeTileUpdateEventArgs> gameHardmodeTileUpdate =
new HandlerCollection<HardmodeTileUpdateEventArgs>("GameHardmodeTileUpdate");
public HandlerCollection<HardmodeTileUpdateEventArgs> GameHardmodeTileUpdate
{
get { return this.gameHardmodeTileUpdate; }
}
internal bool InvokeGameHardmodeTileUpdate(int x, int y, int type)
{
HardmodeTileUpdateEventArgs args = new HardmodeTileUpdateEventArgs
{
X = x,
Y = y,
Type = type
};
this.GameHardmodeTileUpdate.Invoke(args);
return args.Handled;
}
#endregion
#region GameInitialize
private readonly HandlerCollection<EventArgs> gameInitialize =
new HandlerCollection<EventArgs>("GameInitialize");
public HandlerCollection<EventArgs> GameInitialize
{
get { return this.gameInitialize; }
}
internal void InvokeGameInitialize()
{
this.GameInitialize.Invoke(EventArgs.Empty);
}
#endregion
#region GamePostInitialize
private readonly HandlerCollection<EventArgs> gamePostInitialize =
new HandlerCollection<EventArgs>("GamePostInitialize");
public HandlerCollection<EventArgs> GamePostInitialize
{
get { return this.gamePostInitialize; }
}
internal void InvokeGamePostInitialize()
{
this.GamePostInitialize.Invoke(EventArgs.Empty);
}
#endregion
#region GameWorldConnect
private readonly HandlerCollection<EventArgs> gameWorldConnect =
new HandlerCollection<EventArgs>("GameWorldConnect");
public HandlerCollection<EventArgs> GameWorldConnect
{
get { return this.gameWorldConnect; }
}
internal void InvokeGameWorldConnect()
{
this.GameWorldConnect.Invoke(EventArgs.Empty);
}
#endregion
#region GameWorldDisconnect
private readonly HandlerCollection<EventArgs> gameWorldDisconnect =
new HandlerCollection<EventArgs>("GameWorldDisconnect");
public HandlerCollection<EventArgs> GameWorldDisconnect
{
get { return this.gameWorldDisconnect; }
}
internal void InvokeGameWorldDisconnect()
{
this.GameWorldDisconnect.Invoke(EventArgs.Empty);
}
#endregion
#region GameGetKeyState
private readonly HandlerCollection<HandledEventArgs> gameGetKeyState =
new HandlerCollection<HandledEventArgs>("GameGetKeyState");
public HandlerCollection<HandledEventArgs> GameGetKeyState
{
get { return this.gameGetKeyState; }
}
internal bool InvokeGameGetKeyState()
{
HandledEventArgs args = new HandledEventArgs();
this.GameGetKeyState.Invoke(args);
return args.Handled;
}
#endregion
#region GameStatueSpawn
private readonly HandlerCollection<StatueSpawnEventArgs> gameStatueSpawn =
new HandlerCollection<StatueSpawnEventArgs>("GameStatueSpawn");
public HandlerCollection<StatueSpawnEventArgs> GameStatueSpawn
{
get { return this.gameStatueSpawn; }
}
internal bool InvokeGameStatueSpawn(int within200, int within600, int worldWide, int x, int y, int type, bool npc)
{
StatueSpawnEventArgs args = new StatueSpawnEventArgs
{
Within200 = within200,
Within600 = within600,
WorldWide = worldWide,
X = x,
Y = y,
Type = type,
Npc = npc
};
this.GameStatueSpawn.Invoke(args);
return args.Handled;
}
#endregion
#endregion
#region Item Hooks
#region ItemSetDefaultsInt
private readonly HandlerCollection<SetDefaultsEventArgs<Item, int>> itemSetDefaultsInt =
new HandlerCollection<SetDefaultsEventArgs<Item, int>>("ItemSetDefaultsInt");
public HandlerCollection<SetDefaultsEventArgs<Item, int>> ItemSetDefaultsInt
{
get { return this.itemSetDefaultsInt; }
}
internal bool InvokeItemSetDefaultsInt(ref int itemType, Item item)
{
SetDefaultsEventArgs<Item, int> args = new SetDefaultsEventArgs<Item, int>
{
Info = itemType,
Object = item
};
this.ItemSetDefaultsInt.Invoke(args);
itemType = args.Info;
return args.Handled;
}
#endregion
#region ItemSetDefaultsString
private readonly HandlerCollection<SetDefaultsEventArgs<Item, string>> itemSetDefaultsString =
new HandlerCollection<SetDefaultsEventArgs<Item, string>>("ItemSetDefaultsString");
public HandlerCollection<SetDefaultsEventArgs<Item, string>> ItemSetDefaultsString
{
get { return this.itemSetDefaultsString; }
}
internal bool InvokeItemSetDefaultsString(ref string itemName, Item item)
{
SetDefaultsEventArgs<Item, string> args = new SetDefaultsEventArgs<Item, string>
{
Info = itemName,
Object = item
};
this.ItemSetDefaultsString.Invoke(args);
itemName = args.Info;
return args.Handled;
}
#endregion
#region ItemNetDefaults
private readonly HandlerCollection<SetDefaultsEventArgs<Item, int>> itemNetDefaults =
new HandlerCollection<SetDefaultsEventArgs<Item, int>>("ItemNetDefaults");
public HandlerCollection<SetDefaultsEventArgs<Item, int>> ItemNetDefaults
{
get { return this.itemNetDefaults; }
}
internal bool InvokeItemNetDefaults(ref int netType, Item item)
{
SetDefaultsEventArgs<Item, int> args = new SetDefaultsEventArgs<Item, int>
{
Info = netType,
Object = item
};
this.ItemNetDefaults.Invoke(args);
netType = args.Info;
return args.Handled;
}
#endregion
#endregion
#region Net Hooks
#region NetSendData
private readonly HandlerCollection<SendDataEventArgs> netSendData =
new HandlerCollection<SendDataEventArgs>("NetSendData");
public HandlerCollection<SendDataEventArgs> NetSendData
{
get { return this.netSendData; }
}
internal bool InvokeNetSendData(
ref int msgType, ref int remoteClient, ref int ignoreClient, ref string text,
ref int number, ref float number2, ref float number3, ref float number4, ref int number5)
{
if (Main.netMode != 2 && msgType == (int)PacketTypes.ChatText && this.InvokeClientChat(ref text))
return true;
SendDataEventArgs args = new SendDataEventArgs
{
MsgId = (PacketTypes)msgType,
remoteClient = remoteClient,
ignoreClient = ignoreClient,
text = text,
number = number,
number2 = number2,
number3 = number3,
number4 = number4,
number5 = number5
};
this.NetSendData.Invoke(args);
msgType = (int)args.MsgId;
remoteClient = args.remoteClient;
ignoreClient = args.ignoreClient;
text = args.text;
number = args.number;
number2 = args.number2;
number3 = args.number3;
number4 = args.number4;
number5 = args.number5;
return args.Handled;
}
#endregion
#region NetGetData
private readonly HandlerCollection<GetDataEventArgs> netGetData =
new HandlerCollection<GetDataEventArgs>("NetGetData");
public HandlerCollection<GetDataEventArgs> NetGetData
{
get { return this.netGetData; }
}
internal bool InvokeNetGetData(ref byte msgId, MessageBuffer buffer, ref int index, ref int length)
{
if (Main.netMode != 2 && msgId == (byte)PacketTypes.ChatText && length > 3)
{
byte playerID = buffer.readBuffer[index];
Color color = new Color(buffer.readBuffer[index + 1] << 16, buffer.readBuffer[index + 2] << 8, buffer.readBuffer[index + 3]);
string @string = Encoding.UTF8.GetString(buffer.readBuffer, index + 4, length - 5);
this.InvokeClientChatReceived(playerID, color, @string);
}
if (Main.netMode == 2)
{
switch ((PacketTypes) msgId)
{
case PacketTypes.ConnectRequest:
if (this.InvokeServerConnect(buffer.whoAmI))
{
Netplay.serverSock[buffer.whoAmI].kill = true;
return true;
}
break;
case PacketTypes.ContinueConnecting2:
if (this.InvokeServerJoin(buffer.whoAmI))
{
Netplay.serverSock[buffer.whoAmI].kill = true;
return true;
}
break;
case PacketTypes.ChatText:
var text = "";
using(var stream = new MemoryStream(buffer.readBuffer))
{
stream.Position = index;
using(var reader = new BinaryReader(stream))
{
reader.ReadByte();
reader.ReadRGB();
text = reader.ReadString();
}
}
if (this.InvokeServerChat(buffer, buffer.whoAmI, @text))
return true;
break;
case PacketTypes.ClientUUID:
byte[] uuid = new byte[length - 5];
Buffer.BlockCopy(buffer.readBuffer, index + 4, uuid, 0, length - 5);
SHA512 shaM = new SHA512Managed();
var result = shaM.ComputeHash(uuid);
Netplay.serverSock[buffer.whoAmI].clientUUID = result.Aggregate("", (s, b) => s + b.ToString("X2"));;
return true;
break;
}
}
GetDataEventArgs args = new GetDataEventArgs
{
MsgID = (PacketTypes)msgId,
Msg = buffer,
Index = index,
Length = length
};
this.NetGetData.Invoke(args);
msgId = (byte)args.MsgID;
index = args.Index;
length = args.Length;
return args.Handled;
}
#endregion
#region NetGreetPlayer
private readonly HandlerCollection<GreetPlayerEventArgs> netGreetPlayer =
new HandlerCollection<GreetPlayerEventArgs>("NetGreetPlayer");
public HandlerCollection<GreetPlayerEventArgs> NetGreetPlayer
{
get { return this.netGreetPlayer; }
}
internal bool InvokeNetGreetPlayer(int who)
{
GreetPlayerEventArgs args = new GreetPlayerEventArgs
{
Who = who
};
this.NetGreetPlayer.Invoke(args);
return args.Handled;
}
#endregion
#region NetSendBytes
private readonly HandlerCollection<SendBytesEventArgs> netSendBytes =
new HandlerCollection<SendBytesEventArgs>("NetSendBytes");
public HandlerCollection<SendBytesEventArgs> NetSendBytes
{
get { return this.netSendBytes; }
}
internal bool InvokeNetSendBytes(ServerSock socket, byte[] buffer, int offset, int count)
{
SendBytesEventArgs args = new SendBytesEventArgs
{
Socket = socket,
Buffer = buffer,
Offset = offset,
Count = count
};
this.NetSendBytes.Invoke(args);
return args.Handled;
}
#endregion
#region NetNameCollision
private readonly HandlerCollection<NameCollisionEventArgs> netNameCollision =
new HandlerCollection<NameCollisionEventArgs>("NetNameCollision");
public HandlerCollection<NameCollisionEventArgs> NetNameCollision
{
get { return this.netNameCollision; }
}
internal bool InvokeNetNameCollision(int who, string name)
{
NameCollisionEventArgs args = new NameCollisionEventArgs
{
Who = who,
Name = name
};
this.NetNameCollision.Invoke(args);
return args.Handled;
}
#endregion
#endregion
#region Npc Hooks
#region NpcSetDefaultsInt
private readonly HandlerCollection<SetDefaultsEventArgs<NPC, int>> npcSetDefaultsInt =
new HandlerCollection<SetDefaultsEventArgs<NPC, int>>("NpcSetDefaultsInt");
public HandlerCollection<SetDefaultsEventArgs<NPC, int>> NpcSetDefaultsInt
{
get { return this.npcSetDefaultsInt; }
}
internal bool InvokeNpcSetDefaultsInt(ref int npcType, NPC npc)
{
SetDefaultsEventArgs<NPC, int> args = new SetDefaultsEventArgs<NPC, int>
{
Object = npc,
Info = npcType
};
this.NpcSetDefaultsInt.Invoke(args);
npcType = args.Info;
return args.Handled;
}
#endregion
#region NpcSetDefaultsString
private readonly HandlerCollection<SetDefaultsEventArgs<NPC, string>> npcSetDefaultsString =
new HandlerCollection<SetDefaultsEventArgs<NPC, string>>("NpcSetDefaultsString");
public HandlerCollection<SetDefaultsEventArgs<NPC, string>> NpcSetDefaultsString
{
get { return this.npcSetDefaultsString; }
}
internal bool InvokeNpcSetDefaultsString(ref string npcName, NPC npc)
{
SetDefaultsEventArgs<NPC, string> args = new SetDefaultsEventArgs<NPC, string>
{
Object = npc,
Info = npcName
};
this.NpcSetDefaultsString.Invoke(args);
npcName = args.Info;
return args.Handled;
}
#endregion
#region NpcNetDefaults
private readonly HandlerCollection<SetDefaultsEventArgs<NPC, int>> npcNetDefaults =
new HandlerCollection<SetDefaultsEventArgs<NPC, int>>("NpcNetDefaults");
public HandlerCollection<SetDefaultsEventArgs<NPC, int>> NpcNetDefaults
{
get { return this.npcNetDefaults; }
}
internal bool InvokeNpcNetDefaults(ref int netType, NPC npc)
{
SetDefaultsEventArgs<NPC, int> args = new SetDefaultsEventArgs<NPC, int>
{
Object = npc,
Info = netType
};
this.NpcNetDefaults.Invoke(args);
netType = args.Info;
return args.Handled;
}
#endregion
#region NpcStrike
private readonly HandlerCollection<NpcStrikeEventArgs> npcStrike =
new HandlerCollection<NpcStrikeEventArgs>("NpcStrike");
public HandlerCollection<NpcStrikeEventArgs> NpcStrike
{
get { return this.npcStrike; }
}
internal bool InvokeNpcStrike(
NPC npc, ref int damage, ref float knockback, ref int hitDirection, ref bool crit, ref bool noEffect,
ref double returnDamage)
{
NpcStrikeEventArgs args = new NpcStrikeEventArgs
{
Npc = npc,
Damage = damage,
KnockBack = knockback,
HitDirection = hitDirection,
Critical = crit,
NoEffect = noEffect,
ReturnDamage = returnDamage
};
this.NpcStrike.Invoke(args);
damage = args.Damage;
knockback = args.KnockBack;
hitDirection = args.HitDirection;
crit = args.Critical;
noEffect = args.NoEffect;
returnDamage = args.ReturnDamage;
return args.Handled;
}
#endregion
#region NpcSpawn
private readonly HandlerCollection<NpcSpawnEventArgs> npcSpawn =
new HandlerCollection<NpcSpawnEventArgs>("NpcSpawn");
public HandlerCollection<NpcSpawnEventArgs> NpcSpawn
{
get { return this.npcSpawn; }
}
internal bool InvokeNpcSpawn(NPC npc)
{
NpcSpawnEventArgs args = new NpcSpawnEventArgs
{
Npc = npc
};
this.NpcSpawn.Invoke(args);
return args.Handled;
}
#endregion
#region NpcLootDrop
private readonly HandlerCollection<NpcLootDropEventArgs> npcLootDrop =
new HandlerCollection<NpcLootDropEventArgs>("NpcLootDrop");
public HandlerCollection<NpcLootDropEventArgs> NpcLootDrop
{
get { return this.npcLootDrop; }
}
internal bool InvokeNpcLootDrop(
ref int x, ref int y, ref int w, ref int h, ref int itemId, ref int stack, ref bool broadcast, ref int prefix,
int npcId, int npcArrayIndex, ref bool nodelay)
{
NpcLootDropEventArgs args = new NpcLootDropEventArgs
{
X = x,
Y = y,
Width = w,
Height = h,
ItemId = itemId,
Stack = stack,
Broadcast = broadcast,
Prefix = prefix,
NpcId = npcId,
NpcArrayIndex = npcArrayIndex,
NoGrabDelay = nodelay
};
this.NpcLootDrop.Invoke(args);
x = args.X;
y = args.Y;
w = args.Width;
h = args.Height;
itemId = args.ItemId;
stack = args.Stack;
broadcast = args.Broadcast;
prefix = args.Prefix;
nodelay = args.NoGrabDelay;
return args.Handled;
}
#endregion
#region NpcTriggerPressurePlate
private readonly HandlerCollection<TriggerPressurePlateEventArgs<NPC>> npcTriggerPressurePlate =
new HandlerCollection<TriggerPressurePlateEventArgs<NPC>>("NpcTriggerPressurePlate");
public HandlerCollection<TriggerPressurePlateEventArgs<NPC>> NpcTriggerPressurePlate
{
get { return this.npcTriggerPressurePlate; }
}
internal bool InvokeNpcTriggerPressurePlate(NPC npc, int tileX, int tileY)
{
TriggerPressurePlateEventArgs<NPC> args = new TriggerPressurePlateEventArgs<NPC>
{
Object = npc,
TileX = tileX,
TileY = tileY
};
this.NpcTriggerPressurePlate.Invoke(args);
return args.Handled;
}
#endregion
#endregion
#region Player Hooks
#region PlayerUpdatePhysics
private readonly HandlerCollection<UpdatePhysicsEventArgs> playerUpdatePhysics =
new HandlerCollection<UpdatePhysicsEventArgs>("PlayerUpdatePhysics");
public HandlerCollection<UpdatePhysicsEventArgs> PlayerUpdatePhysics
{
get { return this.playerUpdatePhysics; }
}
internal void InvokePlayerUpdatePhysics(Player player)
{
UpdatePhysicsEventArgs args = new UpdatePhysicsEventArgs
{
Player = player
};
this.PlayerUpdatePhysics.Invoke(args);
}
#endregion
#endregion
#region Projectile Hooks
#region ProjectileSetDefaults
private readonly HandlerCollection<SetDefaultsEventArgs<Projectile, int>> projectileSetDefaults =
new HandlerCollection<SetDefaultsEventArgs<Projectile, int>>("ProjectileSetDefaults");
public HandlerCollection<SetDefaultsEventArgs<Projectile, int>> ProjectileSetDefaults
{
get { return this.projectileSetDefaults; }
}
internal bool InvokeProjectileSetDefaults(ref int type, Projectile projectile)
{
SetDefaultsEventArgs<Projectile, int> args = new SetDefaultsEventArgs<Projectile, int>
{
Object = projectile,
Info = type
};
this.ProjectileSetDefaults.Invoke(args);
type = args.Info;
return args.Handled;
}
#endregion
#region ProjectileTriggerPressurePlate
private readonly HandlerCollection<TriggerPressurePlateEventArgs<Projectile>> projectileTriggerPressurePlate =
new HandlerCollection<TriggerPressurePlateEventArgs<Projectile>>("ProjectileTriggerPressurePlate");
public HandlerCollection<TriggerPressurePlateEventArgs<Projectile>> ProjectileTriggerPressurePlate
{
get { return this.projectileTriggerPressurePlate; }
}
internal bool InvokeProjectileTriggerPressurePlate(Projectile projectile, int tileX, int tileY)
{
TriggerPressurePlateEventArgs<Projectile> args = new TriggerPressurePlateEventArgs<Projectile>
{
Object = projectile,
TileX = tileX,
TileY = tileY
};
this.ProjectileTriggerPressurePlate.Invoke(args);
return args.Handled;
}
#endregion
#region ProjectileAIUpdate
private readonly HandlerCollection<ProjectileAiUpdateEventArgs> projectileAiUpdate =
new HandlerCollection<ProjectileAiUpdateEventArgs>("ProjectileAIUpdate");
public HandlerCollection<ProjectileAiUpdateEventArgs> ProjectileAIUpdate
{
get { return this.projectileAiUpdate; }
}
internal bool InvokeProjectileAIUpdate(Projectile projectile)
{
ProjectileAiUpdateEventArgs args = new ProjectileAiUpdateEventArgs
{
Projectile = projectile
};
this.ProjectileAIUpdate.Invoke(args);
return args.Handled;
}
#endregion
#endregion
#region Server Hooks
#region ServerCommand
private readonly HandlerCollection<CommandEventArgs> serverCommand =
new HandlerCollection<CommandEventArgs>("ServerCommand");
public HandlerCollection<CommandEventArgs> ServerCommand
{
get { return this.serverCommand; }
}
internal bool InvokeServerCommand(string command)
{
CommandEventArgs args = new CommandEventArgs
{
Command = command
};
this.ServerCommand.Invoke(args);
return args.Handled;
}
#endregion
#region ServerConnect
private readonly HandlerCollection<ConnectEventArgs> serverConnect =
new HandlerCollection<ConnectEventArgs>("ServerConnect");
public HandlerCollection<ConnectEventArgs> ServerConnect
{
get { return this.serverConnect; }
}
internal bool InvokeServerConnect(int who)
{
ConnectEventArgs args = new ConnectEventArgs
{
Who = who
};
this.ServerConnect.Invoke(args);
return args.Handled;
}
#endregion
#region ServerJoin
private readonly HandlerCollection<JoinEventArgs> serverJoin =
new HandlerCollection<JoinEventArgs>("ServerJoin");
public HandlerCollection<JoinEventArgs> ServerJoin
{
get { return this.serverJoin; }
}
internal bool InvokeServerJoin(int who)
{
JoinEventArgs args = new JoinEventArgs
{
Who = who
};
this.ServerJoin.Invoke(args);
return args.Handled;
}
#endregion
#region ServerLeave
private readonly HandlerCollection<LeaveEventArgs> serverLeave =
new HandlerCollection<LeaveEventArgs>("ServerLeave");
public HandlerCollection<LeaveEventArgs> ServerLeave
{
get { return this.serverLeave; }
}
internal void InvokeServerLeave(int who)
{
LeaveEventArgs args = new LeaveEventArgs
{
Who = who
};
this.ServerLeave.Invoke(args);
}
#endregion
#region ServerChat
private readonly HandlerCollection<ServerChatEventArgs> serverChat =
new HandlerCollection<ServerChatEventArgs>("ServerChat");
public HandlerCollection<ServerChatEventArgs> ServerChat
{
get { return this.serverChat; }
}
internal bool InvokeServerChat(MessageBuffer buffer, int who, string text)
{
ServerChatEventArgs args = new ServerChatEventArgs
{
Buffer = buffer,
Who = who,
Text = text
};
this.ServerChat.Invoke(args);
return args.Handled;
}
#endregion
#region ServerSocketReset
private readonly HandlerCollection<SocketResetEventArgs> serverSocketReset =
new HandlerCollection<SocketResetEventArgs>("ServerSocketReset");
public HandlerCollection<SocketResetEventArgs> ServerSocketReset
{
get { return this.serverSocketReset; }
}
internal void InvokeServerSocketReset(ServerSock socket)
{
SocketResetEventArgs args = new SocketResetEventArgs
{
Socket = socket
};
this.ServerSocketReset.Invoke(args);
}
#endregion
#endregion
#region World Hooks
#region WorldSave
private readonly HandlerCollection<WorldSaveEventArgs> worldSave =
new HandlerCollection<WorldSaveEventArgs>("WorldSave");
public HandlerCollection<WorldSaveEventArgs> WorldSave
{
get { return this.worldSave; }
}
internal bool InvokeWorldSave(bool resetTime)
{
WorldSaveEventArgs args = new WorldSaveEventArgs
{
ResetTime = resetTime
};
this.WorldSave.Invoke(args);
return args.Handled;
}
#endregion
#region WorldStartHardMode
private readonly HandlerCollection<HandledEventArgs> worldStartHardMode =
new HandlerCollection<HandledEventArgs>("WorldStartHardMode");
public HandlerCollection<HandledEventArgs> WorldStartHardMode
{
get { return this.worldStartHardMode; }
}
internal bool InvokeWorldStartHardMode()
{
HandledEventArgs args = new HandledEventArgs();
this.WorldStartHardMode.Invoke(args);
return args.Handled;
}
#endregion
#region WorldMeteorDrop
private readonly HandlerCollection<MeteorDropEventArgs> worldMeteorDrop =
new HandlerCollection<MeteorDropEventArgs>("WorldMeteorDrop");
public HandlerCollection<MeteorDropEventArgs> WorldMeteorDrop
{
get { return this.worldMeteorDrop; }
}
internal bool InvokeWorldMeteorDrop(int x, int y)
{
MeteorDropEventArgs args = new MeteorDropEventArgs
{
X = x,
Y = y
};
this.WorldMeteorDrop.Invoke(args);
return args.Handled;
}
#endregion
#region WorldChristmasCheck
private readonly HandlerCollection<ChristmasCheckEventArgs> worldChristmasCheck =
new HandlerCollection<ChristmasCheckEventArgs>("WorldChristmasCheck");
public HandlerCollection<ChristmasCheckEventArgs> WorldChristmasCheck
{
get { return this.worldChristmasCheck; }
}
internal bool InvokeWorldChristmasCheck(ref bool xmasCheck)