-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathPetPlayer.cs
1018 lines (911 loc) · 39.4 KB
/
PetPlayer.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 AssortedCrazyThings.Base;
using AssortedCrazyThings.Items;
using AssortedCrazyThings.Items.PetAccessories;
using AssortedCrazyThings.Projectiles.Pets;
using AssortedCrazyThings.UI;
using System;
using System.Collections.Generic;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
namespace AssortedCrazyThings
{
public class PetPlayer : ModPlayer
{
/// <summary>
/// transition from 1.2.3 to 1.3.0 (reset cute slime vanity slots)
/// </summary>
private bool petAccessoryRework = false;
/// <summary>
/// transition from 1.3.0 to "CURRENT VERSION" (simplified pet type handling)
/// </summary>
private bool petVanityRework = false;
private bool enteredWorld = false;
//docile demon eye texture
public byte petEyeType = 0; //texture type, not ID
//mech frog texture
public byte mechFrogCrown = 0;
//cursed skull texture
public byte cursedSkullType = 0;
//young wyvern texture
public byte youngWyvernType = 0;
//young wyvern texture
public byte petFishronType = 0;
//moon pet texture
public byte petMoonType = 0;
//young harpy texture
public byte youngHarpyType = 0;
//abeeminiation texture
public byte abeeminationType = 0;
//lil wraps texture
public byte lilWrapsType = 0;
//vampire bat texture
public byte vampireBatType = 0;
//vampire bat texture
public byte pigronataType = 0;
//queen larva texture
public byte queenLarvaType = 0;
//ocean slime texture
public byte oceanSlimeType = 0;
//queen larva texture
public byte miniAntlionType = 0;
//pet goldfish texture
public byte petGoldfishType = 0;
//skeletron hand texture
public byte skeletronHandType = 0;
//skeletron prime hand texture
public byte skeletronPrimeHandType = 0;
//pet cultist texture
public byte petCultistType = 0;
//pet cultist texture
public byte animatedTomeType = 0;
//ALTERNATE
////name pet texture
//public byte classNameType = 0;
public bool DrumstickElemental = false;
public bool MiniAntlion = false;
public bool LilWraps = false;
public bool PetFishron = false;
public bool RainbowSlime = false;
public bool PrinceSlime = false;
public bool IlluminantSlime = false;
public bool ChunkySlime = false;
public bool FairySlime = false;
public bool HornedSlime = false;
public bool JoyousSlime = false;
public bool MeatballSlime = false;
public bool OceanSlime = false;
public bool StingSlimeBlack = false;
public bool StingSlimeOrange = false;
public bool TurtleSlime = false;
public bool Pigronata = false;
public bool Abeemination = false;
public bool CuteSlimeYellowNew = false;
public bool CuteSlimeXmasNew = false;
public bool CuteSlimeToxicNew = false;
public bool CuteSlimeSandNew = false;
public bool CuteSlimeRedNew = false;
public bool CuteSlimeRainbowNew = false;
public bool CuteSlimePurpleNew = false;
public bool CuteSlimePrincessNew = false;
public bool CuteSlimePinkNew = false;
public bool CuteSlimeLavaNew = false;
public bool CuteSlimeJungleNew = false;
public bool CuteSlimeIlluminantNew = false;
public bool CuteSlimeIceNew = false;
public bool CuteSlimeGreenNew = false;
public bool CuteSlimeDungeonNew = false;
public bool CuteSlimeCrimsonNew = false;
public bool CuteSlimeCorruptNew = false;
public bool CuteSlimeBlueNew = false;
public bool CuteSlimeBlackNew = false;
public bool OrigamiCrane = false;
public bool MiniMegalodon = false;
public bool SmallMegalodon = false;
public bool CuteSlimeXmas = false;
public bool YoungHarpy = false;
public bool CuteGastropod = false;
public bool YoungWyvern = false;
public bool BabyIchorSticker = false;
public bool LifelikeMechanicalFrog = false;
public bool CuteSlimeBlue = false;
public bool CuteSlimeGreen = false;
public bool CuteSlimePink = false;
public bool CuteSlimeBlack = false;
public bool CuteSlimePurple = false;
public bool CuteSlimeRed = false;
public bool CuteSlimeYellow = false;
public bool CuteSlimeRainbow = false;
public bool ChunkyandMeatball = false;
public bool DemonHeart = false;
public bool BrainofConfusion = false;
public bool AlienHornet = false;
public bool DetachedHungry = false;
public bool BabyOcram = false;
public bool CursedSkull = false;
public bool BabyCrimera = false;
public bool VampireBat = false;
public bool TorturedSoul = false;
public bool EnchantedSword = false;
public bool Goblet = false;
public bool SoulLightPet = false;
public bool SoulLightPet2 = false;
public bool DocileDemonEye = false;
public bool QueenLarva = false;
public bool PetSun = false;
public bool PetMoon = false;
public bool WallFragment = false;
public bool TinyTwins = false;
public bool ObservingEye = false;
public bool PetGoldfish = false;
public bool SkeletronHand = false;
public bool SkeletronPrimeHand = false;
public bool PetGolemHead = false;
public bool TrueObservingEye = false;
public bool PetCultist = false;
public bool PetPlantera = false;
public bool PetEaterofWorlds = false;
public bool PetDestroyer = false;
public bool AnimatedTome = false;
//ALTERNATE
//public bool ClassName = false;
public override void ResetEffects()
{
DrumstickElemental = false;
MiniAntlion = false;
LilWraps = false;
PetFishron = false;
RainbowSlime = false;
PrinceSlime = false;
IlluminantSlime = false;
ChunkySlime = false;
FairySlime = false;
HornedSlime = false;
JoyousSlime = false;
MeatballSlime = false;
OceanSlime = false;
StingSlimeBlack = false;
StingSlimeOrange = false;
TurtleSlime = false;
Pigronata = false;
Abeemination = false;
CuteSlimeYellowNew = false;
CuteSlimeXmasNew = false;
CuteSlimeToxicNew = false;
CuteSlimeSandNew = false;
CuteSlimeRedNew = false;
CuteSlimeRainbowNew = false;
CuteSlimePrincessNew = false;
CuteSlimePurpleNew = false;
CuteSlimePinkNew = false;
CuteSlimeLavaNew = false;
CuteSlimeJungleNew = false;
CuteSlimeIceNew = false;
CuteSlimeIlluminantNew = false;
CuteSlimeGreenNew = false;
CuteSlimeBlueNew = false;
CuteSlimeBlackNew = false;
CuteSlimeCrimsonNew = false;
CuteSlimeCorruptNew = false;
CuteSlimeDungeonNew = false;
OrigamiCrane = false;
MiniMegalodon = false;
SmallMegalodon = false;
CuteSlimeXmas = false;
YoungHarpy = false;
CuteGastropod = false;
YoungWyvern = false;
BabyIchorSticker = false;
LifelikeMechanicalFrog = false;
CuteSlimeBlue = false;
CuteSlimeGreen = false;
CuteSlimePink = false;
CuteSlimeBlack = false;
CuteSlimePurple = false;
CuteSlimeRed = false;
CuteSlimeYellow = false;
CuteSlimeRainbow = false;
ChunkyandMeatball = false;
DemonHeart = false;
BrainofConfusion = false;
AlienHornet = false;
DetachedHungry = false;
BabyOcram = false;
CursedSkull = false;
BabyCrimera = false;
VampireBat = false;
TorturedSoul = false;
EnchantedSword = false;
Goblet = false;
SoulLightPet = false;
SoulLightPet2 = false;
DocileDemonEye = false;
QueenLarva = false;
PetSun = false;
PetMoon = false;
WallFragment = false;
TinyTwins = false;
ObservingEye = false;
PetGoldfish = false;
SkeletronHand = false;
SkeletronPrimeHand = false;
PetGolemHead = false;
TrueObservingEye = false;
PetCultist = false;
PetPlantera = false;
PetEaterofWorlds = false;
PetDestroyer = false;
AnimatedTome = false;
//ALTERNATE
//ClassName = false;
}
/// <summary>
/// Returns true if this has been called the third time after two successful calls within 36 ticks
/// </summary>
public bool ThreeTimesUseTime()
{
if (Math.Abs(lastTime - Main.time) > 38.0) //(usetime + 1) x 3 + 1
{
//19
resetSlots = false;
lastTime = Main.time;
return false; //step one
}
//step two and three have to be done in 35 ticks
if (Math.Abs(lastTime - Main.time) <= 38.0)
{
if (!resetSlots)
{
//38
resetSlots = true;
return false; //step two
}
//if program gets to here, it is about to return true
if (resetSlots)
{
//57
resetSlots = false;
return true; //step three
}
}
//should never get here anyway
return false;
}
public override TagCompound Save()
{
TagCompound tag = new TagCompound {
{"slots", (int)slots},
{"color", (int)color},
{"petAccessoryRework", (bool)petAccessoryRework},
{"petVanityRework", (bool)petVanityRework}
};
var petTypes = new List<byte>(ClonedTypes);
tag.Add("petTypes", petTypes);
return tag;
}
public override void Load(TagCompound tag)
{
slots = (uint)tag.GetInt("slots");
color = (uint)tag.GetInt("color");
petAccessoryRework = tag.GetBool("petAccessoryRework");
petVanityRework = tag.GetBool("petVanityRework");
if (!petVanityRework) //transfer to new system
{
//DON'T TOUCH ANYTHING IN THIS SECTION
int index = -1;
ClonedTypes[++index] = mechFrogCrown = tag.GetByte("mechFrogCrown");
ClonedTypes[++index] = petEyeType = tag.GetByte("petEyeType");
ClonedTypes[++index] = cursedSkullType = tag.GetByte("cursedSkullType");
ClonedTypes[++index] = youngWyvernType = tag.GetByte("youngWyvernType");
ClonedTypes[++index] = petFishronType = tag.GetByte("petFishronType");
ClonedTypes[++index] = petMoonType = tag.GetByte("petMoonType");
ClonedTypes[++index] = youngHarpyType = tag.GetByte("youngHarpyType");
ClonedTypes[++index] = abeeminationType = tag.GetByte("abeeminationType");
ClonedTypes[++index] = lilWrapsType = tag.GetByte("lilWrapsType");
ClonedTypes[++index] = vampireBatType = tag.GetByte("vampireBatType");
ClonedTypes[++index] = pigronataType = tag.GetByte("pigronataType");
ClonedTypes[++index] = queenLarvaType = tag.GetByte("queenLarvaType");
ClonedTypes[++index] = oceanSlimeType = tag.GetByte("oceanSlimeType");
ClonedTypes[++index] = miniAntlionType = tag.GetByte("miniAntlionType");
ClonedTypes[++index] = petGoldfishType = tag.GetByte("petGoldfishType");
ClonedTypes[++index] = skeletronHandType = tag.GetByte("skeletronHandType");
ClonedTypes[++index] = skeletronPrimeHandType = tag.GetByte("skeletronPrimeHandType");
ClonedTypes[++index] = petCultistType = tag.GetByte("petCultistType");
//every other new type will be 0 (makes sense since this is when the player first updates to the new version)
//DON'T TOUCH ANYTHING IN THIS SECTION
}
else
{
var petTypeList = tag.GetList<byte>("petTypes");
int clonedTypesLength = ClonedTypes.Length;
ClonedTypes = new List<byte>(petTypeList).ToArray();
//in case new types got added (since this assignment overrides the old ClonedTypes length)
Array.Resize(ref ClonedTypes, clonedTypesLength);
}
}
public override void clientClone(ModPlayer clientClone)
{
PetPlayer clone = clientClone as PetPlayer;
clone.slots = slots;
clone.color = color;
Array.Copy(ClonedTypes, clone.ClonedTypes, ClonedTypes.Length);
}
public override void SendClientChanges(ModPlayer clientPlayer)
{
PetPlayer clone = clientPlayer as PetPlayer;
PetPlayerChanges changes = PetPlayerChanges.None;
int index = 255;
if (clone.slots != slots || clone.color != color)
{
changes = PetPlayerChanges.Slots;
}
else
{
for (int i = 0; i < ClonedTypes.Length; i++)
{
if (clone.ClonedTypes[i] != ClonedTypes[i])
{
changes = PetPlayerChanges.PetTypes;
index = i;
break;
}
}
}
if (changes != PetPlayerChanges.None) SendClientChangesPacket(changes, index);
}
public override void SyncPlayer(int toWho, int fromWho, bool newPlayer)
{
if (Main.netMode != NetmodeID.Server) return;
//from server to clients
ModPacket packet = mod.GetPacket();
packet.Write((byte)AssMessageType.SyncPlayerVanity);
packet.Write((byte)player.whoAmI);
//no "changes" packet
SendFieldValues(packet);
packet.Send(toWho, fromWho);
}
private void SendFieldValues(ModPacket packet)
{
packet.Write((uint)slots);
packet.Write((uint)color);
for (int i = 0; i < ClonedTypes.Length; i++)
{
packet.Write((byte)ClonedTypes[i]);
}
}
public void RecvSyncPlayerVanitySub(BinaryReader reader)
{
slots = reader.ReadUInt32();
color = reader.ReadUInt32();
for (int i = 0; i < ClonedTypes.Length; i++)
{
ClonedTypes[i] = reader.ReadByte();
}
GetFromClonedTypes();
}
/// <summary>
/// Reads from reader to assign the player fields (Called in Mod.HandlePacket())
/// </summary>
public void RecvClientChangesPacketSub(BinaryReader reader, byte changes, int index)
{
//AssUtils.Print("RecvClientChangesPacketSub " + changes + " index " + index + " from p " + player.whoAmI);
switch (changes)
{
case (byte)PetPlayerChanges.All:
RecvSyncPlayerVanitySub(reader);
break;
case (byte)PetPlayerChanges.Slots:
slots = reader.ReadUInt32();
color = reader.ReadUInt32();
break;
case (byte)PetPlayerChanges.PetTypes:
if (index >= 0 && index < ClonedTypes.Length) ClonedTypes[index] = reader.ReadByte();
break;
default: //shouldn't get there hopefully
mod.Logger.Debug("Received unspecified PetPlayerChanges Packet " + changes);
break;
}
GetFromClonedTypes();
}
/// <summary>
/// Sends the player fields either to clients or to the server. Called in OnEnterWorld (to the server), and in Mod.HandlePacket()
/// (forwarding data from the server to other players)
/// </summary>
public void SendClientChangesPacketSub(byte changes, int index, int toClient = -1, int ignoreClient = -1)
{
//AssUtils.Print("SendClientChangesPacketSub " + changes + " index " + index + " from p " + player.whoAmI + ((Main.netMode == NetmodeID.MultiplayerClient)? " client":" server"));
ModPacket packet = mod.GetPacket();
packet.Write((byte)AssMessageType.ClientChangesVanity);
packet.Write((byte)player.whoAmI);
packet.Write((byte)changes);
packet.Write((byte)index);
switch (changes)
{
case (byte)PetPlayerChanges.All:
SendFieldValues(packet);
break;
case (byte)PetPlayerChanges.Slots:
packet.Write((uint)slots);
packet.Write((uint)color);
break;
case (byte)PetPlayerChanges.PetTypes:
packet.Write((byte)ClonedTypes[index]);
break;
default: //shouldn't get there hopefully
mod.Logger.Debug("Sending unspecified PetPlayerChanges " + changes);
break;
}
packet.Send(toClient, ignoreClient);
}
/// <summary>
/// Cliendside method to send the chances specified to the server.
/// Called in OnEnterWorld() and in SendClientChanges()
/// </summary>
private void SendClientChangesPacket(PetPlayerChanges changes, int index = 255)
{
if (Main.netMode == NetmodeID.MultiplayerClient)
{
SendClientChangesPacketSub((byte)changes, index);
}
}
public override void OnEnterWorld(Player player)
{
enteredWorld = true;
if (!petAccessoryRework)
{
petAccessoryRework = true;
mod.Logger.Debug("Reset pet vanity slots during update from 1.2.3 to " + mod.Version);
slots = 0;
}
if (!petVanityRework)
{
petVanityRework = true;
}
else
{
//AssUtils.Print("onenterworld p " + player.whoAmI);
GetFromClonedTypes();
}
SendClientChangesPacket(PetPlayerChanges.All);
}
public override void PreUpdate()
{
if (Main.myPlayer == player.whoAmI) SetClonedTypes();
}
#region Slime Pet Vanity
public int slimePetIndex = -1;
public uint slotsLast = 0;
private bool resetSlots = false;
private double lastTime = 0.0;
private const uint mask = 255;//0000 0000|0000 0000|0000 0000|1111 1111
public uint slots = 0; //0000 0000|0000 0000|0000 0000|0000 0000
public uint color = 0; //0000 0000|0000 0000|0000 0000|0000 0000
//slot4 |slot3 |slot2 |slot1
/// <summary>
/// Adds the pet vanity accessory to the current pet
/// </summary>
public bool AddAccessory(PetAccessory petAccessory)
{
//id is between 0 and 255
byte slotNumber = (byte)(petAccessory.Slot - 1);
//returns false if accessory was already equipped //for slotNumber = 1:
uint setmask = mask << (slotNumber * 8); //0000 0000|0000 0000|1111 1111|0000 0000
uint clearmask = ~setmask; //setmask but inverted //1111 1111|1111 1111|0000 0000|1111 1111
uint id = (uint)petAccessory.ID << (slotNumber * 8);
uint col = (uint)petAccessory.Color << (slotNumber * 8);
uint tempslots = slots & setmask;
uint tempcolor = color & setmask;
if (id == tempslots && col == tempcolor) return false;
//if accessory not the same as the applied one: override/set
slots &= clearmask; //delete only current slot
slots |= id; //set current slot id
color &= clearmask; //delete only current slot
color |= col; //set current slot color
return true;
}
/// <summary>
/// Deletes the pet vanity accessory on the current pet
/// </summary>
public void DelAccessory(PetAccessory petAccessory)
{
byte slotNumber = (byte)(petAccessory.Slot - 1);
uint setmask = mask << (slotNumber * 8);
uint clearmask = ~setmask; //setmask but inverted
slots &= clearmask; //delete only current slot
color &= clearmask; //delete only current slot color
}
/// <summary>
/// Toggles the pet vanity acessory on the current pet
/// </summary>
public void ToggleAccessory(PetAccessory petAccessory)
{
if (petAccessory.Slot == SlotType.None) throw new Exception("Can't toggle accessory on reserved slot");
if (!AddAccessory(petAccessory)) DelAccessory(petAccessory);
}
/// <summary>
/// Returns the pet vanity accessory equipped in the specified SlotType of the current pet
/// </summary>
public PetAccessory GetAccessoryInSlot(byte slotNumber)
{
byte slot = slotNumber;
slotNumber -= 1;
byte id = (byte)((slots >> (slotNumber * 8)) & mask); //(byte) only takes the rightmost byte
byte col = (byte)((color >> (slotNumber * 8)) & mask);
if (id == 0) return null;
PetAccessory petAccessory = PetAccessory.GetAccessoryFromID((SlotType)slot, id);
petAccessory.Color = col;
return petAccessory;
}
#endregion
#region CircleUI
/// <summary>
/// Contains a list of CircleUIHandlers that are used in CircleUIStart/End in Mod
/// </summary>
public List<CircleUIHandler> CircleUIList;
/// <summary>
/// Contains a list of pet type fields (assigned during Load() and every tick in PreUpdate(),
/// and read from in OnEnterWorld(), and in Multiplayer whenever data is received).
/// Simplifies the saving/loading of tags
/// </summary>
public byte[] ClonedTypes;
public static CircleUIConf GetLifelikeMechanicalFrogConf()
{
List<string> textureNames = new List<string>() {
AssUtils.Instance.Name + "/Projectiles/Pets/LifelikeMechanicalFrog",
AssUtils.Instance.Name + "/Projectiles/Pets/LifelikeMechanicalFrogCrown" };
List<string> tooltips = new List<string>() { "Default", "Crowned" };
//no need for unlocked + toUnlock
return new CircleUIConf(
Main.projFrames[ModContent.ProjectileType<LifelikeMechanicalFrog>()],
ModContent.ProjectileType<LifelikeMechanicalFrog>(),
textureNames, null, tooltips, null);
}
public static CircleUIConf GetDocileDemonEyeConf()
{
List<string> tooltips = new List<string>() { "Red", "Green", "Purple",
"Red Fractured", "Green Fractured", "Purple Fractured",
"Red Mechanical", "Green Mechanical", "Purple Mechanical",
"Red Laser", "Green Laser", "Purple Laser" };
return CircleUIHandler.PetConf("DocileDemonEyeProj", tooltips);
}
public static CircleUIConf GetCursedSkullConf()
{
List<string> tooltips = new List<string>() { "Default", "Dragon" };
return CircleUIHandler.PetConf("CursedSkull", tooltips);
}
public static CircleUIConf GetYoungWyvernConf()
{
List<string> tooltips = new List<string>() { "Default", "Mythical", "Arch", "Arch (Legacy)" };
return CircleUIHandler.PetConf("YoungWyvern", tooltips);
}
public static CircleUIConf GetPetFishronConf()
{
List<string> tooltips = new List<string>() { "Default", "Sharkron", "Sharknado" };
return CircleUIHandler.PetConf("PetFishronProj", tooltips);
}
public static CircleUIConf GetPetMoonConf()
{
List<string> tooltips = new List<string>() { "Default", "Orange", "Green" }; //only 0, 1, 2 registered, 3 and 4 are event related
return CircleUIHandler.PetConf("PetMoonProj", tooltips);
}
public static CircleUIConf GetYoungHarpyConf()
{
List<string> tooltips = new List<string>() { "Default", "Eagle", "Raven", "Dove" };
return CircleUIHandler.PetConf("YoungHarpy", tooltips);
}
public static CircleUIConf GetAbeeminationConf()
{
List<string> tooltips = new List<string>() { "Default", "Snow Bee", "Oil Spill", "Missing Ingredients" };
return CircleUIHandler.PetConf("AbeeminationProj", tooltips);
}
public static CircleUIConf GetLilWrapsConf()
{
List<string> tooltips = new List<string>() { "Default", "Dark", "Light", "Shadow", "Spectral" };
return CircleUIHandler.PetConf("LilWrapsProj", tooltips);
}
public static CircleUIConf GetVampireBatConf()
{
List<string> tooltips = new List<string>() { "Default", "Werebat" };
return CircleUIHandler.PetConf("VampireBat", tooltips);
}
public static CircleUIConf GetPigronataConf()
{
List<string> tooltips = new List<string>() { "Default", "Winter", "Autumn", "Spring", "Summer", "Halloween", "Christmas" };
return CircleUIHandler.PetConf("Pigronata", tooltips);
}
public static CircleUIConf GetQueenLarvaConf()
{
List<string> tooltips = new List<string>() { "Default", "Prawn Larva", "Unexpected Seed", "Big Kid Larva", "Where's The Baby?" };
return CircleUIHandler.PetConf("QueenLarvaProj", tooltips);
}
public static CircleUIConf GetOceanSlimeConf()
{
List<string> tooltips = new List<string>() { "Default", "Stupid Hat", "Gnarly Grin", "Flipped Jelly" };
return CircleUIHandler.PetConf("OceanSlimeProj", tooltips);
}
public static CircleUIConf GetMiniAntlionConf()
{
List<string> tooltips = new List<string>() { "Default", "Albino" };
return CircleUIHandler.PetConf("MiniAntlionProj", tooltips);
}
public static CircleUIConf PetGoldfishConf()
{
List<string> tooltips = new List<string>() { "Default", "Crimson", "Corruption", "Bunny" };
return CircleUIHandler.PetConf("PetGoldfishProj", tooltips);
}
public static CircleUIConf GetSkeletronHandConf()
{
List<string> tooltips = new List<string>() { "Default", "OK-Hand", "Peace", "Rock It", "Fist" };
return CircleUIHandler.PetConf("SkeletronHandProj", tooltips);
}
public static CircleUIConf GetSkeletronPrimeHandConf()
{
List<string> tooltips = new List<string>() { "Cannon", "Saw", "Vice", "Laser" };
return CircleUIHandler.PetConf("SkeletronPrimeHandProj", tooltips);
}
public static CircleUIConf GetPetCultistConf()
{
List<string> tooltips = new List<string>() { "Lunar", "Solar" };
return CircleUIHandler.PetConf("PetCultistProj", tooltips);
}
public static CircleUIConf GetAnimatedTomeConf()
{
List<string> tooltips = new List<string>() { "Green", "Blue", "Purple", "Pink", "Yellow", "Spell" };
return CircleUIHandler.PetConf("AnimatedTomeProj", tooltips);
}
//ALTERNATE
//public static CircleUIConf GetClassNameConf()
//{
// List<string> tooltips = new List<string>() { "Default", "AltName1", "AltName2" };
// return CircleUIHandler.PetConf("ClassNameProj", tooltips);
//}
public override void Initialize()
{
//called before Load()
//needs to call new List() since Initialize() is called per player in the player select screen
CircleUIList = new List<CircleUIHandler>
{
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => LifelikeMechanicalFrog,
uiConf: GetLifelikeMechanicalFrogConf,
onUIStart: () => mechFrogCrown,
onUIEnd: () => mechFrogCrown = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => DocileDemonEye,
uiConf: GetDocileDemonEyeConf,
onUIStart: () => petEyeType,
onUIEnd: () => petEyeType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => CursedSkull,
uiConf: GetCursedSkullConf,
onUIStart: () => cursedSkullType,
onUIEnd: () => cursedSkullType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => YoungWyvern,
uiConf: GetYoungWyvernConf,
onUIStart: () => youngWyvernType,
onUIEnd: () => youngWyvernType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => PetFishron,
uiConf: GetPetFishronConf,
onUIStart: () => petFishronType,
onUIEnd: () => petFishronType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => PetMoon,
uiConf: GetPetMoonConf,
onUIStart: () => petMoonType,
onUIEnd: () => petMoonType = (byte)CircleUI.returned,
triggerLeft: false,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => YoungHarpy,
uiConf: GetYoungHarpyConf,
onUIStart: () => youngHarpyType,
onUIEnd: () => youngHarpyType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => Abeemination,
uiConf: GetAbeeminationConf,
onUIStart: () => abeeminationType,
onUIEnd: () => abeeminationType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => LilWraps,
uiConf: GetLilWrapsConf,
onUIStart: () => lilWrapsType,
onUIEnd: () => lilWrapsType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => VampireBat,
uiConf: GetVampireBatConf,
onUIStart: () => vampireBatType,
onUIEnd: () => vampireBatType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => Pigronata,
uiConf: GetPigronataConf,
onUIStart: () => pigronataType,
onUIEnd: () => pigronataType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => QueenLarva,
uiConf: GetQueenLarvaConf,
onUIStart: () => queenLarvaType,
onUIEnd: () => queenLarvaType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => OceanSlime,
uiConf: GetOceanSlimeConf,
onUIStart: () => oceanSlimeType,
onUIEnd: () => oceanSlimeType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => MiniAntlion,
uiConf: GetMiniAntlionConf,
onUIStart: () => miniAntlionType,
onUIEnd: () => miniAntlionType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => PetGoldfish,
uiConf: PetGoldfishConf,
onUIStart: () => petGoldfishType,
onUIEnd: () => petGoldfishType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => SkeletronHand,
uiConf: GetSkeletronHandConf,
onUIStart: () => skeletronHandType,
onUIEnd: () => skeletronHandType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => SkeletronPrimeHand,
uiConf: GetSkeletronPrimeHandConf,
onUIStart: () => skeletronPrimeHandType,
onUIEnd: () => skeletronPrimeHandType = (byte)CircleUI.returned,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => PetCultist,
uiConf: GetPetCultistConf,
onUIStart: () => petCultistType,
onUIEnd: () => petCultistType = (byte)CircleUI.returned,
triggerLeft: false,
needsSaving: true
),
new CircleUIHandler(
triggerItem: ModContent.ItemType<VanitySelector>(),
condition: () => AnimatedTome,
uiConf: GetAnimatedTomeConf,
onUIStart: () => animatedTomeType,
onUIEnd: () => animatedTomeType = (byte)CircleUI.returned,
needsSaving: true
),
//ALTERNATE
// new CircleUIHandler(
// triggerItem: ModContent.ItemType<VanitySelector>(),
// condition: () => ClassName,
// uiConf: GetClassNameConf,
// onUIStart: () => classNameType,
// onUIEnd: () => classNameType = (byte)CircleUI.returned,
// needsSaving: true
//),
};
// after filling the list, set the trigger list
for (int i = 0; i < CircleUIList.Count; i++)
{
CircleUIHandler.AddItemAsTrigger(CircleUIList[i].TriggerItem, CircleUIList[i].TriggerLeft);
}
//after filling the list, initialize the cloned list
int length = 0;
for (int i = 0; i < CircleUIList.Count; i++)
{
if (CircleUIList[i].NeedsSaving) length++;
}
ClonedTypes = new byte[length];
}
/// <summary>
/// Called whenever something is received (MP on reveive, or in Singleplayer/Local client in OnEnterWorld).
/// Sets the pet type of the corresponding entry of ClonedTypes
/// </summary>
public void GetFromClonedTypes()
{
//AssUtils.Print("set getfromclonedtypes p " + player.whoAmI + " " + mp);
int index = 0;
mechFrogCrown = ClonedTypes[index++];
petEyeType = ClonedTypes[index++];
cursedSkullType = ClonedTypes[index++];
youngWyvernType = ClonedTypes[index++];
petFishronType = ClonedTypes[index++];
petMoonType = ClonedTypes[index++];
youngHarpyType = ClonedTypes[index++];
abeeminationType = ClonedTypes[index++];
lilWrapsType = ClonedTypes[index++];
vampireBatType = ClonedTypes[index++];
pigronataType = ClonedTypes[index++];
queenLarvaType = ClonedTypes[index++];
oceanSlimeType = ClonedTypes[index++];
miniAntlionType = ClonedTypes[index++];
petGoldfishType = ClonedTypes[index++];
skeletronHandType = ClonedTypes[index++];
skeletronPrimeHandType = ClonedTypes[index++];
petCultistType = ClonedTypes[index++];
animatedTomeType = ClonedTypes[index++];
//ALTERNATE
//classNameType = ClonedTypes[index++];
}
/// <summary>
/// Called in PreUpdate (which runs before OnEnterWorld, hence the check).
/// Sets each entry of ClonedTypes to the corresponding pet type
/// </summary>
public void SetClonedTypes()
{
if (enteredWorld)
{
int index = -1;
ClonedTypes[++index] = mechFrogCrown;
ClonedTypes[++index] = petEyeType;
ClonedTypes[++index] = cursedSkullType;
ClonedTypes[++index] = youngWyvernType;
ClonedTypes[++index] = petFishronType;
ClonedTypes[++index] = petMoonType;
ClonedTypes[++index] = youngHarpyType;
ClonedTypes[++index] = abeeminationType;
ClonedTypes[++index] = lilWrapsType;