-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathClientHandle.cs
More file actions
1695 lines (1578 loc) · 65 KB
/
Copy pathClientHandle.cs
File metadata and controls
1695 lines (1578 loc) · 65 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
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 UnityEngine;
using System.Reflection;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Net;
using System.Net.Sockets;
using MelonLoader;
using Harmony;
using UnhollowerRuntimeLib;
using UnhollowerBaseLib;
using GameServer;
using Il2CppSystem.Reflection;
using System.Diagnostics;
using static SkyCoop.Shared;
using static Utils;
using static SkyCoop.DataStr;
namespace SkyCoop
{
public class ClientHandle
{
public static void Welcome(Packet _packet)
{
MyMod.RemovePleaseWait();
MyMod.DiscardRepeatPacket();
int _myId = _packet.ReadInt();
int _MaxPlayers = _packet.ReadInt();
List<string> ModsWhiteList = _packet.ReadStringList();
MyMod.MaxPlayers = _MaxPlayers;
Shared.InitAllPlayers();
MelonLogger.Msg("Welcome to server!");
ClientUser.myId = _myId;
MelonLogger.Msg("Host registered me as client "+ _myId);
MyMod.sendMyPosition = true;
ClientUser.LastConnectedIp = ClientUser.PendingConnectionIp;
MyMod.NoHostResponceSeconds = 0;
MyMod.NeedTryReconnect = false;
MyMod.TryingReconnect = false;
WelcomeReceived(ModsWhiteList);
}
public static void WelcomeReceived(List<string> ModsWhiteList)
{
MyMod.RemovePleaseWait();
MyMod.DiscardRepeatPacket();
using (Packet _packet = new Packet((int)ClientPackets.welcomeReceived))
{
_packet.Write(ClientUser.myId);
_packet.Write(MyMod.MyChatName);
_packet.Write(MyMod.BuildInfo.Version);
_packet.Write(Supporters.MyID);
_packet.Write(Supporters.ConfiguratedBenefits);
_packet.Write(ModsValidation.GetModsHash(true, ModsWhiteList).m_Hash);
MyMod.SendUDPData(_packet);
}
if (MyMod.level_name != "Empty" && MyMod.level_name != "Boot" && MyMod.level_name != "MainMenu")
{
MyMod.SendSpawnData();
}
}
public static void XYZ(Packet _packet)
{
Vector3 maboi = _packet.ReadVector3();
int from = _packet.ReadInt();
if (MyMod.playersData.Count > 0 && MyMod.playersData[from] != null)
{
MyMod.playersData[from].m_Position = maboi;
if(MyMod.players[from] != null && MyMod.players[from].GetComponent<Comps.MultiplayerPlayer>() != null)
{
MyMod.LongActionCancleCauseMoved(MyMod.players[from].GetComponent<Comps.MultiplayerPlayer>());
}
}
}
public static void XYZDW(Packet _packet)
{
}
public static void XYZW(Packet _packet)
{
Quaternion maboi = _packet.ReadQuaternion();
int from = _packet.ReadInt();
if (MyMod.playersData[from] != null)
{
MyMod.playersData[from].m_Rotation = maboi;
}
}
public static void BLOCK(Packet _packet)
{
Vector3 maboi = _packet.ReadVector3();
int from = _packet.ReadInt();
if (MyMod.playersData.Count > 0 && MyMod.playersData[from] != null)
{
if (MyMod.playersData[from].m_Levelid == MyMod.levelid)
{
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.position = maboi;
}
}
}
public static void LEVELID(Packet _packet)
{
int lel = _packet.ReadInt();
int from = _packet.ReadInt();
if (MyMod.playersData.Count > 0 && MyMod.playersData[from] != null)
{
if(MyMod.playersData[from].m_Levelid != lel)
{
MyMod.playersData[from].m_Levelid = lel;
MelonLogger.Msg("Player " + from + " transition to level " + lel);
}
}
}
public static void LEVELGUID(Packet _packet)
{
string lel = _packet.ReadString();
int from = _packet.ReadInt();
if (MyMod.playersData[from] != null)
{
if(MyMod.playersData[from].m_LevelGuid != lel)
{
MyMod.playersData[from].m_LevelGuid = lel;
//MelonLogger.Msg("Player " + from + " transition to level with GUID " + lel);
}
}
}
public static void GOTITEM(Packet _packet)
{
DataStr.GearItemDataPacket got = _packet.ReadGearData();
//MelonLogger.Msg(ConsoleColor.Blue, "Someone gave item to" + got.m_SendedTo);
//MelonLogger.Msg(ConsoleColor.Blue, "Got gear with name [" + got.m_GearName + "] DATA: " + got.m_DataProxy);
if(got.m_SendedTo == ClientUser.myId)
{
//MelonLogger.Msg(ConsoleColor.Blue, "This is item for me");
}
MyMod.GiveRecivedItem(got);
}
public static void GAMETIME(Packet _packet)
{
MyMod.OveridedTime = _packet.ReadString();
MyMod.MinutesFromStartServer = _packet.ReadInt();
MyMod.NeedSyncTime = true;
//MelonLogger.Msg("Time: " + OveridedTime);
}
public static void LIGHTSOURCENAME(Packet _packet)
{
string item = _packet.ReadString();
int from = _packet.ReadInt();
if (MyMod.playersData.Count > 0 && MyMod.playersData[from] != null)
{
MyMod.playersData[from].m_PlayerEquipmentData.m_HoldingItem = item;
}
}
public static void LIGHTSOURCE(Packet _packet)
{
bool itemToggle = _packet.ReadBool();
int from = _packet.ReadInt();
if (MyMod.playersData.Count > 0 && MyMod.playersData[from] != null)
{
MyMod.playersData[from].m_PlayerEquipmentData.m_LightSourceOn = itemToggle;
}
}
public static void MAKEFIRE(Packet _packet)
{
}
public static void ANIMSTATE(Packet _packet)
{
string _anim = _packet.ReadString();
int from = _packet.ReadInt();
//MelonLogger.Msg("Other player changed animation: " + AnimState);
if (MyMod.playersData.Count > 0 && MyMod.playersData[from] != null)
{
MyMod.playersData[from].m_AnimState = _anim;
}
}
public static void EQUIPMENT(Packet _packet)
{
DataStr.PlayerEquipmentData item = _packet.ReadEQ();
int from = _packet.ReadInt();
if (MyMod.playersData.Count > 0 && MyMod.playersData[from] != null)
{
MyMod.playersData[from].m_PlayerEquipmentData.m_Arrows = item.m_Arrows;
MyMod.playersData[from].m_PlayerEquipmentData.m_HasAxe = item.m_HasAxe;
MyMod.playersData[from].m_PlayerEquipmentData.m_HasMedkit = item.m_HasMedkit;
MyMod.playersData[from].m_PlayerEquipmentData.m_HasRevolver = item.m_HasRevolver;
MyMod.playersData[from].m_PlayerEquipmentData.m_HasRifle = item.m_HasRifle;
MyMod.playersData[from].m_PlayerEquipmentData.m_Flares = item.m_Flares;
MyMod.playersData[from].m_PlayerEquipmentData.m_BlueFlares = item.m_BlueFlares;
}
}
public static void SLEEPHOURS(Packet _packet)
{
int sleep = _packet.ReadInt();
int from = _packet.ReadInt();
if (MyMod.playersData.Count > 0 && MyMod.playersData[from] != null)
{
MyMod.playersData[from].m_SleepHours = sleep;
}
}
public static void SYNCWEATHER(Packet _packet)
{
}
public static void REVIVE(Packet _packet)
{
MyMod.SimRevive();
if (MyMod.sendMyPosition == true)
{
using (Packet __packet = new Packet((int)ClientPackets.REVIVEDONE))
{
__packet.Write(true);
MyMod.SendUDPData(__packet);
}
}
}
public static void ANIMALROLE(Packet _packet)
{
bool New = _packet.ReadBool();
if (MyMod.AnimalsController != New)
{
MyMod.AnimalsController = New;
MyMod.DisableOriginalAnimalSpawns();
if(MyMod.AnimalsController)
{
MyMod.SwitchToAnimalController();
}
MelonLogger.Msg("Got new animal controller role: " + MyMod.AnimalsController);
}
}
public static void ALIGNANIMAL(Packet _packet)
{
}
public static void ASKFORANIMALPROXY(Packet _packet)
{
}
public static void ANIMALDELETE(Packet _packet)
{
string AnimalGuid = _packet.ReadString();
MyMod.DeleteAnimal(AnimalGuid);
}
public static void KEEPITALIVE(Packet _packet)
{
MyMod.LastResponceTime = Time.time;
MyMod.NoHostResponceSeconds = 0;
}
public static void RQRECONNECT(Packet _packet)
{
MyMod.Disconnect();
ClientUser.DoConnectToIp(ClientUser.LastConnectedIp);
}
public static void CHAT(Packet _packet)
{
DataStr.MultiplayerChatMessage message = _packet.ReadChat();
int from = _packet.ReadInt();
Shared.SendMessageToChat(message, false);
}
public static void PLAYERSSTATUS(Packet _packet)
{
int howmany = _packet.ReadInt();
if (howmany > MyMod.MaxPlayers)
{
return;
}
for (int i = 0; i < MyMod.MaxPlayers; i++)
{
if (MyMod.playersData[i] != null)
{
MyMod.playersData[i].m_Used = false;
}
}
List<DataStr.MultiPlayerClientStatus> MPStatus = new List<DataStr.MultiPlayerClientStatus>();
int Sleepers = 0;
int Deads = 0;
for (int i = 1; i <= howmany; i++)
{
DataStr.MultiPlayerClientStatus client = _packet.ReadClientStatus();
MPStatus.Add(client);
if (MyMod.playersData[client.m_ID] != null)
{
MyMod.playersData[client.m_ID].m_Used = true;
MyMod.playersData[client.m_ID].m_Name = client.m_Name;
MyMod.playersData[client.m_ID].m_IsLoading = client.m_IsLoading;
if (client.m_Dead || client.m_Sleep)
{
Sleepers = Sleepers + 1;
}
if (client.m_Dead)
{
Deads = Deads + 1;
}
if (client.m_Sleep == true)
{
MyMod.playersData[client.m_ID].m_SleepHours = 1;
}else{
MyMod.playersData[client.m_ID].m_SleepHours = 0;
}
MyMod.playersData[client.m_ID].m_Dead = client.m_Dead;
}
}
Shared.ProcessSleep(Sleepers, howmany, Deads, 0);
MyMod.UpdatePlayerStatusMenu(MPStatus);
}
public static void ANIMALTEST(Packet _packet)
{
DataStr.AnimalCompactData dat = _packet.ReadAnimalCompactData();
DataStr.AnimalAnimsSync anim = _packet.ReadAnimalAnim();
int from = _packet.ReadInt();
MyMod.DoAnimalSync(dat, anim);
}
public static void ANIMALSYNCTRIGG(Packet _packet)
{
if (MyMod.level_name == "Boot" || MyMod.level_name == "Empty")
{
return;
}
DataStr.AnimalTrigger obj = _packet.ReadAnimalTrigger();
MyMod.SetAnimalTriggers(obj);
}
public static void REVIVEDONE(Packet _packet)
{
GameManager.GetInventoryComponent().RemoveGearFromInventory("GEAR_MedicalSupplies_hangar", 1);
}
public static void DARKWALKERREADY(Packet _packet)
{
}
public static void HOSTISDARKWALKER(Packet _packet)
{
}
public static void WARDISACTIVE(Packet _packet)
{
}
public static void DWCOUNTDOWN(Packet _packet)
{
}
public static void SHOOTSYNC(Packet _packet)
{
DataStr.ShootSync shoot = _packet.ReadShoot();
int from = _packet.ReadInt();
//MelonLogger.Msg("Client " + from + " shoot!");
MyMod.DoShootSync(shoot, from);
}
public static void PIMPSKILL(Packet _packet)
{
int SkillTypeId = _packet.ReadInt();
if (SkillTypeId == 1)
{
GameManager.GetSkillsManager().IncrementPointsAndNotify(SkillType.Rifle, 1, SkillsManager.PointAssignmentMode.AssignOnlyInSandbox);
MelonLogger.Msg("Got remote skill upgrade Rifle");
}
else if (SkillTypeId == 2)
{
GameManager.GetSkillsManager().IncrementPointsAndNotify(SkillType.Revolver, 1, SkillsManager.PointAssignmentMode.AssignOnlyInSandbox);
MelonLogger.Msg("Got remote skill upgrade Revolver");
}
}
public static void HARVESTINGANIMAL(Packet _packet)
{
string GUID = _packet.ReadString();
int FromWho = _packet.ReadInt();
if (MyMod.playersData[FromWho] != null)
{
MyMod.playersData[FromWho].m_HarvestingAnimal = GUID;
}
}
public static void BULLETDAMAGE(Packet _packet)
{
float damage = _packet.ReadFloat();
int BodyPart = _packet.ReadInt();
int from = _packet.ReadInt();
bool Melee = _packet.ReadBool();
string MeleeWeapon = "";
if (Melee)
{
MeleeWeapon = _packet.ReadString();
}
MyMod.DamageByBullet(damage, from, BodyPart, Melee, MeleeWeapon);
}
public static void MULTISOUND(Packet _packet)
{
string sound = _packet.ReadString();
int from = _packet.ReadInt();
MyMod.PlayMultiplayer3dAduio(sound, from);
}
public static void CONTAINEROPEN(Packet _packet)
{
DataStr.ContainerOpenSync sync = _packet.ReadContainer();
MyMod.DoSyncContainer(sync);
}
public static void LUREPLACEMENT(Packet _packet)
{
}
public static void LUREISACTIVE(Packet _packet)
{
}
public static void SAVEDATA(Packet _packet)
{
DataStr.SaveSlotSync SaveData = _packet.ReadSaveSlot();
MyMod.RemoveWaitForConnect();
MyMod.ApplyOtherCampfires = true;
if (MyMod.level_name != "MainMenu")
{
return;
}
MyMod.PendingSave = SaveData;
MyMod.CheckHaveSaveFileToJoin(SaveData);
}
public static void VERIFYSAVE(Packet _packet)
{
MyMod.RemoveWaitForConnect();
MyMod.RemovePleaseWait();
MyMod.MyUGUID = _packet.ReadString();
bool IsValid = _packet.ReadBool();
if (MyMod.level_name != "MainMenu")
{
return;
}
MyMod.VerifiedSave(IsValid);
}
public static void CARRYBODY(Packet _packet)
{
}
public static void BODYWARP(Packet _packet)
{
}
public static void CHANGENAME(Packet _packet)
{
string newName = _packet.ReadString();
int from = _packet.ReadInt();
MyMod.playersData[from].m_Name = newName;
}
public static void CLOTH(Packet _packet)
{
DataStr.PlayerClothingData ClotchData = _packet.ReadClothingData();
int from = _packet.ReadInt();
MyMod.playersData[from].m_PlayerClothingData = ClotchData;
//MelonLogger.Msg("[Clothing] Client "+ from + " Hat " + MyMod.playersData[from].m_PlayerClothingData.m_Hat);
//MelonLogger.Msg("[Clothing] Client " + from + " Torso "+ MyMod.playersData[from].m_PlayerClothingData.m_Top);
//MelonLogger.Msg("[Clothing] Client " + from + " Legs "+ MyMod.playersData[from].m_PlayerClothingData.m_Bottom);
//MelonLogger.Msg("[Clothing] Client " + from + " Feets "+ MyMod.playersData[from].m_PlayerClothingData.m_Boots);
}
public static void ASKSPAWNDATA(Packet _packet)
{
int lvl = _packet.ReadInt();
int from = _packet.ReadInt();
if(lvl == MyMod.levelid)
{
MyMod.SendSpawnData(false);
}
}
public static void FURNBROKEN(Packet _packet)
{
DataStr.BrokenFurnitureSync furn = _packet.ReadFurn();
if(furn.m_LevelGUID == MyMod.level_guid)
{
if (furn.m_Broken)
{
if (MyMod.DelayedGearsPickup)
{
MyMod.BrokenFurnsBackup.Add(furn);
} else
{
MyMod.RemoveBrokenFurniture(furn.m_Guid, furn.m_ParentGuid);
}
} else
{
MyMod.RepairBrokenFurniture(furn.m_Guid, furn.m_ParentGuid);
}
}
}
public static void FURNBROKENLIST(Packet _packet)
{
}
public static void FURNBREAKINGGUID(Packet _packet)
{
DataStr.BrokenFurnitureSync furn = _packet.ReadFurn();
int from = _packet.ReadInt();
if (MyMod.playersData[from] != null)
{
MyMod.playersData[from].m_BrakingObject = furn;
if (MyMod.playersData[from].m_LevelGuid == MyMod.level_guid)
{
MyMod.playersData[from].m_BrakingSounds = MyMod.GetBreakDownSound(furn);
}
}
}
public static void FURNBREAKINSTOP(Packet _packet)
{
bool broken = _packet.ReadBool();
int from = _packet.ReadInt();
if (MyMod.playersData[from] != null)
{
MyMod.playersData[from].m_BrakingObject = new DataStr.BrokenFurnitureSync();
MyMod.playersData[from].m_BrakingSounds = "";
}
}
public static void ProcessDeleyedGearsPickcup()
{
MyMod.DelayedGearsPickup = false;
foreach (DataStr.PickedGearSync gear in MyMod.PickedGearsBackup)
{
Shared.AddPickedGear(gear.m_Spawn, gear.m_LevelID, gear.m_LevelGUID, -1, gear.m_MyInstanceID, gear.m_GearName, false);
}
MyMod.FoundSomethingToBreak = false;
foreach (DataStr.BrokenFurnitureSync furn in MyMod.BrokenFurnsBackup)
{
MyMod.RemoveBrokenFurniture(furn.m_Guid, furn.m_ParentGuid, false);
}
MyMod.BakePreSpawnedGearsList();
if (MyMod.FoundSomethingToBreak)
{
MyMod.RemoveAttachedGears = 2;
} else{
MyMod.PickedGearsBackup.Clear();
}
MyMod.BrokenFurnsBackup.Clear();
}
public static void GEARPICKUP(Packet _packet)
{
DataStr.PickedGearSync gear = _packet.ReadPickedGear();
int from = _packet.ReadInt();
if(from != -1)
{
if (MyMod.playersData[from] != null && MyMod.playersData[from].m_LevelGuid == MyMod.level_guid)
{
if (MyMod.players[from] != null && MyMod.players[from].GetComponent<Comps.MultiplayerPlayerAnimator>() != null)
{
MyMod.players[from].GetComponent<Comps.MultiplayerPlayerAnimator>().Pickup();
}
}
}
if (MyMod.DelayedGearsPickup)
{
MyMod.PickedGearsBackup.Add(gear);
} else
{
Shared.AddPickedGear(gear.m_Spawn, gear.m_LevelID, gear.m_LevelGUID, from, gear.m_MyInstanceID, gear.m_GearName, false);
}
}
public static void GEARPICKUPLIST(Packet _packet)
{
}
public static void ROPE(Packet _packet)
{
DataStr.ClimbingRopeSync rope = _packet.ReadRope();
Shared.AddDeployedRopes(rope.m_Position, rope.m_Deployed, rope.m_Snapped, rope.m_LevelID, rope.m_LevelGUID, false);
}
public static void ROPELIST(Packet _packet)
{
int howmany = _packet.ReadInt();
for (int i = 1; i <= howmany; i++)
{
DataStr.ClimbingRopeSync rope = _packet.ReadRope();
if (MyMod.DeployedRopes.Contains(rope) == false)
{
Shared.AddDeployedRopes(rope.m_Position, rope.m_Deployed, rope.m_Snapped, rope.m_LevelID, rope.m_LevelGUID, false);
}
}
}
public static void CONSUME(Packet _packet)
{
bool IsDrink = _packet.ReadBool();
int from = _packet.ReadInt();
if (MyMod.playersData[from] != null && MyMod.playersData[from].m_Levelid == MyMod.levelid && MyMod.playersData[from].m_LevelGuid == MyMod.level_guid)
{
if (MyMod.players[from] != null && MyMod.players[from].GetComponent<Comps.MultiplayerPlayerAnimator>() != null)
{
MyMod.players[from].GetComponent<Comps.MultiplayerPlayerAnimator>().m_IsDrink = IsDrink;
MyMod.players[from].GetComponent<Comps.MultiplayerPlayerAnimator>().Consumption();
}
}
}
public static void SERVERCFG(Packet _packet)
{
DataStr.ServerConfigData cfg = _packet.ReadServerCFG();
MyMod.ServerConfig = cfg;
MyMod.ShowCFGData();
}
public static void STOPCONSUME(Packet _packet)
{
string LastAnim = _packet.ReadString();
int from = _packet.ReadInt();
if (MyMod.playersData[from] != null)
{
if(MyMod.playersData[from].m_Levelid == MyMod.levelid && MyMod.playersData[from].m_LevelGuid == MyMod.level_guid)
{
if (MyMod.players[from] != null && MyMod.players[from].GetComponent<Comps.MultiplayerPlayerAnimator>() != null)
{
MyMod.players[from].GetComponent<Comps.MultiplayerPlayerAnimator>().StopConsumption();
}
}
MyMod.playersData[from].m_AnimState = LastAnim;
}
}
public static void HEAVYBREATH(Packet _packet)
{
bool IsHeavyBreath = _packet.ReadBool();
int from = _packet.ReadInt();
if (MyMod.playersData[from] != null)
{
MyMod.playersData[from].m_HeavyBreath = IsHeavyBreath;
}
}
public static void BLOODLOSTS(Packet _packet)
{
int BloodCount = _packet.ReadInt();
int from = _packet.ReadInt();
if (MyMod.playersData[from] != null)
{
MyMod.playersData[from].m_BloodLosts = BloodCount;
}
}
public static void APPLYACTIONONPLAYER(Packet _packet)
{
string ActionType = _packet.ReadString();
int from = _packet.ReadInt();
MyMod.OtherPlayerApplyActionOnMe(ActionType, from);
}
public static void DONTMOVEWARNING(Packet _packet)
{
bool ok = _packet.ReadBool();
int from = _packet.ReadInt();
if(MyMod.playersData[from] != null)
{
HUDMessage.AddMessage("PLEASE DON'T MOVE, "+MyMod.playersData[from].m_Name+" IS TENDING YOU");
GameManager.GetVpFPSPlayer().Controller.Stop();
}
}
public static void INFECTIONSRISK(Packet _packet)
{
bool InfRisk = _packet.ReadBool();
int from = _packet.ReadInt();
if (MyMod.playersData[from] != null)
{
MyMod.playersData[from].m_NeedAntiseptic = InfRisk;
}
}
public static void CANCLEPICKUP(Packet _packet)
{
DataStr.PickedGearSync gear = _packet.ReadPickedGear();
int from = _packet.ReadInt();
MelonLogger.Msg(ConsoleColor.Blue, "Other shokal has pickup item before me! I need to delete my picked gear Item InstanceID "+ gear.m_MyInstanceID);
int _IID = gear.m_MyInstanceID;
Il2CppSystem.Collections.Generic.List<GearItemObject> invItems = GameManager.GetInventoryComponent().m_Items;
for (int i = 0; i < invItems.Count; i++)
{
GearItemObject currGear = invItems[i];
if (currGear != null)
{
if(currGear.m_GearItem.m_InstanceID == _IID)
{
HUDMessage.AddMessage("THIS ALREADY PICKED!");
GameAudioManager.PlayGUIError();
GameManager.GetInventoryComponent().DestroyGear(currGear.m_GearItem.gameObject);
return;
}
}
}
for (int i = 0; i < GearManager.m_Gear.Count; i++)
{
GearItem currentGear = GearManager.m_Gear[i];
if (currentGear.m_InstanceID == _IID)
{
currentGear.gameObject.SetActive(false);
UnityEngine.Object.Destroy(currentGear.gameObject);
HUDMessage.AddMessage("THIS ALREADY PICKED!");
GameAudioManager.PlayGUIError();
return;
}
}
}
public static void CONTAINERINTERACT(Packet _packet)
{
DataStr.ContainerOpenSync box = _packet.ReadContainer();
int from = _packet.ReadInt();
if (MyMod.playersData[from] != null)
{
if (box.m_Guid == "NULL")
{
MyMod.playersData[from].m_Container = null;
}else{
MyMod.playersData[from].m_Container = box;
}
}
}
public static void LOOTEDCONTAINER(Packet _packet)
{
DataStr.ContainerOpenSync box = _packet.ReadContainer();
int from = _packet.ReadInt();
int State = _packet.ReadInt();
Shared.AddLootedContainer(box, false, from, State);
}
public static void LOOTEDCONTAINERLIST(Packet _packet)
{
}
public static void HARVESTPLANT(Packet _packet)
{
DataStr.HarvestableSyncData harveData = _packet.ReadHarvestablePlant();
int from = _packet.ReadInt();
if (MyMod.playersData[from] != null)
{
if(harveData.m_State == "Start")
{
MyMod.playersData[from].m_Plant = harveData.m_Guid;
}else{
MyMod.playersData[from].m_Plant = "";
}
}
}
public static void LOOTEDHARVESTABLE(Packet _packet)
{
string plantGUID = _packet.ReadString();
string Scene = _packet.ReadString();
int HarvestTime = _packet.ReadInt();
if(Scene == MyMod.level_guid)
{
if(HarvestTime == -1)
{
MyMod.AddHarvastedPlant(plantGUID);
} else
{
MyMod.RemoveHarvastedPlant(plantGUID);
}
}
}
public static void LOOTEDHARVESTABLEALL(Packet _packet)
{
}
public static void SELECTEDCHARACTER(Packet _packet)
{
int character = _packet.ReadInt();
int from = _packet.ReadInt();
if (MyMod.playersData[from] != null)
{
MyMod.playersData[from].m_Character = character;
if(character == 0)
{
MyMod.playersData[from].m_Female = false;
}
if (character == 1)
{
MyMod.playersData[from].m_Female = true;
}
}
}
public static void ADDSHELTER(Packet _packet)
{
MelonLogger.Msg("Someone created shelter!");
DataStr.ShowShelterByOther shelter = _packet.ReadShelter();
int from = _packet.ReadInt();
Shared.ShelterCreated(shelter.m_Position, shelter.m_Rotation, shelter.m_LevelID, shelter.m_LevelGUID, false);
}
public static void REMOVESHELTER(Packet _packet)
{
MelonLogger.Msg("Someone removed shelter!");
DataStr.ShowShelterByOther shelter = _packet.ReadShelter();
int from = _packet.ReadInt();
Shared.ShelterRemoved(shelter.m_Position, shelter.m_LevelID, shelter.m_LevelGUID, false);
}
public static void ALLSHELTERS(Packet _packet)
{
int howmany = _packet.ReadInt();
for (int i = 1; i <= howmany; i++)
{
DataStr.ShowShelterByOther shelter = _packet.ReadShelter();
if (MyMod.ShowSheltersBuilded.Contains(shelter) == false)
{
Shared.ShelterCreated(shelter.m_Position, shelter.m_Rotation, shelter.m_LevelID, shelter.m_LevelGUID, false);
}
}
}
public static void USESHELTER(Packet _packet)
{
DataStr.ShowShelterByOther shelter = _packet.ReadShelter();
int from = _packet.ReadInt();
if (MyMod.playersData[from] != null)
{
if(shelter.m_Position == new Vector3(0, 0, 0))
{
MyMod.playersData[from].m_Shelter = null;
}else{
MyMod.playersData[from].m_Shelter = shelter;
}
}
}
public static void FIRE(Packet _packet)
{
DataStr.FireSourcesSync FireSource = _packet.ReadFire();
int from = _packet.ReadInt();
MyMod.MayAddFireSources(FireSource);
}
public static void FIREFUEL(Packet _packet)
{
DataStr.FireSourcesSync FireSource = _packet.ReadFire();
if(FireSource.m_LevelId != MyMod.levelid || FireSource.m_LevelGUID != MyMod.level_guid)
{
return;
}
int from = _packet.ReadInt();
MyMod.AddOtherFuel(FireSource, FireSource.m_FuelName);
}
public static void CUSTOM(Packet _packet)
{
API.CustomEventCallback(_packet, -1);
}
public static void KICKMESSAGE(Packet _packet)
{
string kickMessage = _packet.ReadString();
MyMod.DoKickMessage(kickMessage);
}
public static void PrintModsList(string RawString)
{
MelonLogger.Msg(ConsoleColor.Red,"SERVER MODS:\n"+RawString.Replace(@"M\", @"Mods\").Replace(@"A\", @"Mods\").Replace(@"P\", @"Plugins\"));
}
public static void MODSLIST(Packet _packet)
{
string CompressedString = _packet.ReadString();
string DecompressedString = Shared.DecompressString(CompressedString);
PrintModsList(DecompressedString);
}
public static void GOTITEMSLICE(Packet _packet)
{
DataStr.SlicedJsonData got = _packet.ReadSlicedGear();
MyMod.AddSlicedJsonData(got);
}
public static void VOICECHAT(Packet _packet)
{
int BytesWritten = _packet.ReadInt();
int ReadLength = _packet.ReadInt();
byte[] CompressedData = _packet.ReadBytes(ReadLength);
float RecordTime = _packet.ReadFloat();
float RadioF = _packet.ReadFloat();
RadioF = Mathf.Round(RadioF * 10.0f) * 0.1f;
int from = _packet.ReadInt(); // Play from
int Sender = _packet.ReadInt(); // Play whos voice
if (MyMod.playersData[from] != null && MyMod.playersData[from].m_LevelGuid == MyMod.level_guid)
{
bool IsRadio = false;
if(from != Sender)
{
IsRadio = true;
}
if (!MyMod.DedicatedServerAppMode)
{
MyMod.ProcessVoiceChatData(from, CompressedData, uint.Parse(BytesWritten.ToString()), RecordTime, IsRadio);
}
}
if(MyMod.RadioFrequency == RadioF && MyMod.playersData[from].m_PlayerEquipmentData.m_HoldingItem == "GEAR_HandheldShortwave" && !MyMod.DoingRecord)
{
MyMod.ProcessRadioChatData(CompressedData, uint.Parse(BytesWritten.ToString()), RecordTime);
MyMod.SendMyRadioAudio(CompressedData, BytesWritten, RecordTime, Sender);
}
}
public static void SLICEDBYTES(Packet _packet)
{
}
public static void ANIMALDAMAGE(Packet _packet)
{
string guid = _packet.ReadString();
float damage = _packet.ReadFloat();
MyMod.DoAnimalDamage(guid, damage);
}
public static void DROPITEM(Packet _packet)
{
DataStr.DroppedGearItemDataPacket GearData = _packet.ReadDroppedGearData();
Shared.FakeDropItem(GearData);
}
public static void PICKDROPPEDGEAR(Packet _packet)
{
int ItemHash = _packet.ReadInt();
int from = _packet.ReadInt();
MyMod.PickDroppedItem(ItemHash, from);
}
public static void GETREQUESTEDITEMSLICE(Packet _packet)
{
DataStr.SlicedJsonData got = _packet.ReadSlicedGear();
MyMod.AddSlicedJsonDataForPicker(got, false);
}
public static void GETREQUESTEDFORPLACESLICE(Packet _packet)
{
DataStr.SlicedJsonData got = _packet.ReadSlicedGear();
MyMod.AddSlicedJsonDataForPicker(got, true);
}
public static void GOTCONTAINERSLICE(Packet _packet)
{
}
public static void OPENEMPTYCONTAINER(Packet _packet)
{
MelonLogger.Msg("Host sent that this container is empty!");
MyMod.DiscardRepeatPacket();
MyMod.FinishOpeningFakeContainer("");
}
public static void MARKSEARCHEDCONTAINERS(Packet _packet)
{
string _GUID = _packet.ReadString();
GameObject box = ObjectGuidManager.Lookup(_GUID);
if (box != null)
{
GameObject reference = MyMod.GetGearItemObject("GEAR_SoftWood");
GameObject newGear = UnityEngine.Object.Instantiate<GameObject>(reference, box.transform.position, box.transform.rotation);
box.GetComponent<Container>().AddGear(newGear.GetComponent<GearItem>());
}
}
public static void READYSENDNEXTSLICE(Packet _packet)
{
}