-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMisc.cs
3769 lines (3687 loc) · 144 KB
/
Misc.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 Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.ModLoader;
using Terraria.ID;
using System.Runtime.CompilerServices;
using System.Reflection;
using Terraria.Utilities;
using System.Collections;
using Terraria.ModLoader.IO;
using Tyfyter.Utils;
using Origins.Tiles;
using ReLogic.Content;
using Terraria.GameContent.ItemDropRules;
using Terraria.ModLoader.Exceptions;
using ReLogic.Reflection;
using Terraria.Localization;
using ReLogic.Graphics;
using System.Reflection.Emit;
using Terraria.GameContent.Personalities;
using Terraria.Map;
using Origins.Reflection;
using Terraria.GameContent.Bestiary;
using System.Diagnostics.CodeAnalysis;
using AltLibrary.Common.AltBiomes;
using Origins.Walls;
using Terraria.GameContent.Drawing;
using Origins.Items.Weapons.Ammo.Canisters;
using Origins.Tiles.Banners;
using Terraria.ObjectData;
using PegasusLib;
using PegasusLib.Graphics;
using Terraria.GameInput;
using Terraria.UI;
namespace Origins {
#region classes
public class LinkedQueue<T> : ICollection<T> {
public int Count {
get { return _items.Count; }
}
public void Enqueue(T item) {
_items.AddLast(item);
}
public T Dequeue() {
if (_items.First is null)
throw new InvalidOperationException("Queue empty.");
var item = _items.First.Value;
_items.RemoveFirst();
return item;
}
//convenient shorthand that's incompatible with the vs debugger
/*# region shorthand
/// <summary>
/// shorthand for Dequeue
/// </summary>
public T DQ => Dequeue();
/// <summary>
/// shorthand for Enqueue
/// </summary>
public void NQ(T value) => Enqueue(value);
/// <summary>
/// shorthand for Dequeue/Enqueue
/// </summary>
public T Q {
get => Dequeue();
set => Enqueue(value);
}
# endregion*/
public bool Remove(T item) {
return _items.Remove(item);
}
public void RemoveAt(int index) {
_items.Remove(GetNodeEnumerator().Skip(index).First());
}
public IEnumerable<T> GetEnumerator() {
while (Count > 0) yield return Dequeue();
}
public IEnumerable<LinkedListNode<T>> GetNodeEnumerator() {
IEnumerator<LinkedListNode<T>> enumerator = new LLNodeEnumerator<T>(_items);
yield return enumerator.Current;
while (enumerator.MoveNext()) yield return enumerator.Current;
}
public T[] ToArray() {
return [.. _items];
}
#region ICollection implementation
[Obsolete("Use Enqueue")]
public void Add(T item) {
Enqueue(item);
}
public void Clear() {
_items.Clear();
}
public bool Contains(T item) {
return _items.Contains(item);
}
public void CopyTo(T[] array, int arrayIndex) {
_items.CopyTo(array, arrayIndex);
}
[Obsolete]
IEnumerator<T> IEnumerable<T>.GetEnumerator() {
throw new NotImplementedException();
}
[Obsolete]
IEnumerator IEnumerable.GetEnumerator() {
throw new NotImplementedException();
}
public bool IsReadOnly => false;
#endregion
private readonly LinkedList<T> _items = new();
}
public struct LLNodeEnumerator<T>(LinkedList<T> list) : IEnumerator<LinkedListNode<T>> {
internal static FieldInfo LLVersion;
private readonly LinkedList<T> list = list;
private LinkedListNode<T> current = list.First;
private readonly int version = list.GetVersion();
public readonly LinkedListNode<T> Current => current;
readonly object IEnumerator.Current => current;
public readonly void Dispose() { }
public bool MoveNext() {
VersionCheck();
current = current.Next;
return current is not null;
}
public void Reset() {
VersionCheck();
current = list.First;
}
readonly void VersionCheck() {
if (version != list.GetVersion()) {
throw new InvalidOperationException("Collection has been modified");
}
}
}
/// <summary>
/// Because it's a little more convenient than an extension method for every number type
/// </summary>
public struct Fraction(int numerator, int denominator) {
public static Fraction Half => new(1, 2);
public static Fraction Third => new(1, 3);
public static Fraction Quarter => new(1, 4);
public static Fraction Fifth => new(1, 5);
public static Fraction Sixth => new(1, 6);
public int numerator = numerator;
public int denominator = denominator;
public int N { readonly get => numerator; set => numerator = value; }
public int D { readonly get => denominator; set => denominator = value; }
public static Fraction operator +(Fraction f1, Fraction f2) {
return new Fraction((f1.N * f2.D) + (f2.N * f1.D), f1.D * f2.D);
}
public static Fraction operator -(Fraction f1, Fraction f2) {
return new Fraction((f1.N * f2.D) - (f2.N * f1.D), f1.D * f2.D);
}
public static Fraction operator *(Fraction f1, Fraction f2) {
return new Fraction(f1.N * f2.N, f1.D * f2.D);
}
public static Fraction operator /(Fraction f1, Fraction f2) {
return new Fraction(f1.N * f2.D, f1.D * f2.N);
}
public static Fraction operator *(Fraction frac, int i) {
return new Fraction(frac.N * i, frac.D);
}
public static int operator *(int i, Fraction frac) {
return (i * frac.N) / frac.D;
}
public static Fraction operator /(Fraction frac, int i) {
return new Fraction(frac.N, frac.D * i);
}
public static int operator /(int i, Fraction frac) {
return (i * frac.D) / frac.N;
}
public static explicit operator float(Fraction frac) {
return frac.N / (float)frac.D;
}
public static explicit operator double(Fraction frac) {
return frac.N / (double)frac.D;
}
public override readonly string ToString() {
return N + "/" + D;
}
}
public class DrawAnimationManual : DrawAnimation {
public DrawAnimationManual(int frameCount) {
Frame = 0;
FrameCounter = 0;
FrameCount = frameCount;
TicksPerFrame = -1;
}
public override void Update() { }
public override Rectangle GetFrame(Texture2D texture, int frameCounterOverride = -1) {
if (TicksPerFrame == -1) FrameCounter = 0;
if (frameCounterOverride != -1) {
return texture.Frame(FrameCount, 1, (frameCounterOverride / TicksPerFrame) % FrameCount, 0);
}
return texture.Frame(FrameCount, 1, Frame, 0);
}
}
public class DrawAnimationDelegated : DrawAnimation {
Func<Texture2D, Rectangle> frame;
public DrawAnimationDelegated(Func<Texture2D, Rectangle> frameMethod) {
Frame = 0;
FrameCounter = 0;
FrameCount = 1;
TicksPerFrame = -1;
frame = frameMethod;
}
public override void Update() { }
public override Rectangle GetFrame(Texture2D texture, int frameCounterOverride = -1) {
if (TicksPerFrame == -1) FrameCounter = 0;
return frame(texture);
}
}
public readonly struct AutoCastingAsset<T> where T : class {
public bool IsLoaded => asset?.IsLoaded ?? false;
public T Value => asset?.Value;
public readonly Asset<T> asset;
AutoCastingAsset(Asset<T> asset) {
this.asset = asset;
}
public static implicit operator AutoCastingAsset<T>(Asset<T> asset) => new(asset);
public static implicit operator T(AutoCastingAsset<T> asset) => asset.Value;
}
public struct AutoLoadingAsset<T> : IUnloadable where T : class {
public readonly bool IsLoaded => asset.Value?.IsLoaded ?? false;
public T Value {
get {
LoadAsset();
return asset.Value?.Value;
}
}
public bool Exists {
get {
LoadAsset();
return exists;
}
}
bool exists;
bool triedLoading;
string assetPath;
Ref<Asset<T>> asset;
AutoLoadingAsset(Asset<T> asset) {
triedLoading = false;
assetPath = "";
this.asset = new(asset);
exists = false;
this.RegisterForUnload();
}
AutoLoadingAsset(string asset) {
triedLoading = false;
assetPath = asset;
this.asset = new(null);
exists = false;
this.RegisterForUnload();
}
public void Unload() {
assetPath = null;
asset = null;
}
public void LoadAsset() {
if (!triedLoading) {
triedLoading = true;
if (assetPath is null) {
asset.Value = Asset<T>.Empty;
} else {
if (!Main.dedServ) {
exists = ModContent.RequestIfExists(assetPath, out Asset<T> foundAsset);
asset.Value = exists ? foundAsset : Asset<T>.Empty;
} else {
asset.Value = Asset<T>.Empty;
}
}
}
}
public static implicit operator AutoLoadingAsset<T>(Asset<T> asset) => new(asset);
public static implicit operator AutoLoadingAsset<T>(string asset) => new(asset);
public static implicit operator T(AutoLoadingAsset<T> asset) => asset.Value;
public static implicit operator AutoCastingAsset<T>(AutoLoadingAsset<T> asset) {
asset.LoadAsset();
return asset.asset.Value;
}
public static implicit operator Asset<T>(AutoLoadingAsset<T> asset) {
asset.LoadAsset();
return asset.asset.Value;
}
}
public readonly struct UnorderedTuple<T>(T a, T b) : IEquatable<UnorderedTuple<T>> {
readonly T a = a;
readonly T b = b;
public bool Equals(UnorderedTuple<T> other) {
return other == this;
}
public override bool Equals(object obj) {
return obj is UnorderedTuple<T> other && Equals(other);
}
public static bool operator ==(UnorderedTuple<T> a, UnorderedTuple<T> b) {
return (EqualityComparer<T>.Default.Equals(a.a, b.a) && EqualityComparer<T>.Default.Equals(a.b, b.b))
|| (EqualityComparer<T>.Default.Equals(a.a, b.b) && EqualityComparer<T>.Default.Equals(a.b, b.a));
}
public static bool operator !=(UnorderedTuple<T> a, UnorderedTuple<T> b) {
return (!EqualityComparer<T>.Default.Equals(a.a, b.a) || !EqualityComparer<T>.Default.Equals(a.b, b.b))
&& (!EqualityComparer<T>.Default.Equals(a.a, b.b) || !EqualityComparer<T>.Default.Equals(a.b, b.a));
}
public static implicit operator UnorderedTuple<T>((T a, T b) v) => new(v.a, v.b);
public override int GetHashCode() {
return a.GetHashCode() + b.GetHashCode();
}
}
public class KeyedPlayerDeathReason : PlayerDeathReason {
public string Key { get => SourceCustomReason; set => SourceCustomReason = value; }
}
public struct PlayerShaderSet {
public int cHead;
public int cBody;
public int cLegs;
public int cHandOn;
public int cHandOff;
public int cBack;
public int cFront;
public int cShoe;
public int cWaist;
public int cShield;
public int cNeck;
public int cFace;
public int cFaceHead;
public int cFaceFlower;
public int cBalloon;
public int cWings;
public int cBalloonFront;
public int cCarpet;
public int cFloatingTube;
public int cBackpack;
public int cTail;
public int cShieldFallback;
public int cGrapple;
public int cMount;
public int cMinecart;
public int cPet;
public int cLight;
public int cYorai;
public int cPortableStool;
public int cUnicornHorn;
public int cAngelHalo;
public int cBeard;
public int cMinion;
public int cLeinShampoo;
public PlayerShaderSet(Player player) {
cHead = player.cHead;
cBody = player.cBody;
cLegs = player.cLegs;
cHandOn = player.cHandOn;
cHandOff = player.cHandOff;
cBack = player.cBack;
cFront = player.cFront;
cShoe = player.cShoe;
cWaist = player.cWaist;
cShield = player.cShield;
cNeck = player.cNeck;
cFace = player.cFace;
cFaceHead = player.cFaceHead;
cFaceFlower = player.cFaceFlower;
cBalloon = player.cBalloon;
cWings = player.cWings;
cBalloonFront = player.cBalloonFront;
cCarpet = player.cCarpet;
cFloatingTube = player.cFloatingTube;
cBackpack = player.cBackpack;
cTail = player.cTail;
cShieldFallback = player.cShieldFallback;
cGrapple = player.cGrapple;
cMount = player.cMount;
cMinecart = player.cMinecart;
cPet = player.cPet;
cLight = player.cLight;
cYorai = player.cYorai;
cPortableStool = player.cPortableStool;
cUnicornHorn = player.cUnicornHorn;
cAngelHalo = player.cAngelHalo;
cBeard = player.cBeard;
cMinion = player.cMinion;
cLeinShampoo = player.cLeinShampoo;
}
public PlayerShaderSet(int shader) {
cHead = shader;
cBody = shader;
cLegs = shader;
cHandOn = shader;
cHandOff = shader;
cBack = shader;
cFront = shader;
cShoe = shader;
cWaist = shader;
cShield = shader;
cNeck = shader;
cFace = shader;
cFaceHead = shader;
cFaceFlower = shader;
cBalloon = shader;
cWings = shader;
cBalloonFront = shader;
cCarpet = shader;
cFloatingTube = shader;
cBackpack = shader;
cTail = shader;
cShieldFallback = shader;
cGrapple = shader;
cMount = shader;
cMinecart = shader;
cPet = shader;
cLight = shader;
cYorai = shader;
cPortableStool = shader;
cUnicornHorn = shader;
cAngelHalo = shader;
cBeard = shader;
cMinion = shader;
cLeinShampoo = shader;
}
public void Apply(Player player) {
player.cHead = cHead;
player.cBody = cBody;
player.cLegs = cLegs;
player.cHandOn = cHandOn;
player.cHandOff = cHandOff;
player.cBack = cBack;
player.cFront = cFront;
player.cShoe = cShoe;
player.cWaist = cWaist;
player.cShield = cShield;
player.cNeck = cNeck;
player.cFace = cFace;
player.cFaceHead = cFaceHead;
player.cFaceFlower = cFaceFlower;
player.cBalloon = cBalloon;
player.cWings = cWings;
player.cBalloonFront = cBalloonFront;
player.cCarpet = cCarpet;
player.cFloatingTube = cFloatingTube;
player.cBackpack = cBackpack;
player.cTail = cTail;
player.cShieldFallback = cShieldFallback;
player.cGrapple = cGrapple;
player.cMount = cMount;
player.cMinecart = cMinecart;
player.cPet = cPet;
player.cLight = cLight;
player.cYorai = cYorai;
player.cPortableStool = cPortableStool;
player.cUnicornHorn = cUnicornHorn;
player.cAngelHalo = cAngelHalo;
player.cBeard = cBeard;
player.cMinion = cMinion;
player.cLeinShampoo = cLeinShampoo;
}
}
public struct ItemSlotSet {
public int headSlot;
public int bodySlot;
public int legSlot;
public int beardSlot;
public int backSlot;
public int faceSlot;
public int neckSlot;
public int shieldSlot;
public int wingSlot;
public int waistSlot;
public int shoeSlot;
public int frontSlot;
public int handOffSlot;
public int handOnSlot;
public int balloonSlot;
public ItemSlotSet(Item item) {
headSlot = item.headSlot;
bodySlot = item.bodySlot;
legSlot = item.legSlot;
beardSlot = item.beardSlot;
backSlot = item.backSlot;
faceSlot = item.faceSlot;
neckSlot = item.neckSlot;
shieldSlot = item.shieldSlot;
wingSlot = item.wingSlot;
waistSlot = item.waistSlot;
shoeSlot = item.shoeSlot;
frontSlot = item.frontSlot;
handOffSlot = item.handOffSlot;
handOnSlot = item.handOnSlot;
balloonSlot = item.balloonSlot;
}
public void Apply(Item item) {
item.headSlot = headSlot;
item.bodySlot = bodySlot;
item.legSlot = legSlot;
item.beardSlot = beardSlot;
item.backSlot = backSlot;
item.faceSlot = faceSlot;
item.neckSlot = neckSlot;
item.shieldSlot = shieldSlot;
item.wingSlot = wingSlot;
item.waistSlot = waistSlot;
item.shoeSlot = shoeSlot;
item.frontSlot = frontSlot;
item.handOffSlot = handOffSlot;
item.handOnSlot = handOnSlot;
item.balloonSlot = balloonSlot;
}
public ItemSlotSet(Player player) {
headSlot = player.head;
bodySlot = player.body;
legSlot = player.legs;
beardSlot = player.beard;
backSlot = player.back;
faceSlot = player.face;
neckSlot = player.neck;
shieldSlot = player.shield;
wingSlot = player.wings;
waistSlot = player.waist;
shoeSlot = player.shoe;
frontSlot = player.front;
handOffSlot = player.handoff;
handOnSlot = player.handon;
balloonSlot = player.balloon;
}
public void Apply(Player player) {
player.head = headSlot;
player.body = bodySlot;
player.legs = legSlot;
player.beard = beardSlot;
player.back = backSlot;
player.face = faceSlot;
player.neck = neckSlot;
player.shield = shieldSlot;
player.wings = wingSlot;
player.waist = waistSlot;
player.shoe = shoeSlot;
player.front = frontSlot;
player.handoff = handOffSlot;
player.handon = handOnSlot;
player.balloon = balloonSlot;
}
}
public class GeneratorCache<TKey, TValue>(Func<TKey, TValue> generator) : IReadOnlyDictionary<TKey, TValue> {
readonly Dictionary<TKey, TValue> cache = new();
readonly Func<TKey, TValue> generator = generator;
public GeneratorCache(Func<TKey, TValue> generator, params TKey[] pregenerate) : this(generator) {
for (int i = 0; i < pregenerate.Length; i++) {
_ = this[pregenerate[i]];
}
}
public TValue this[TKey key] {
get {
if (!cache.TryGetValue(key, out TValue value)) {
value = generator(key);
cache.Add(key, value);
}
return value;
}
}
public IEnumerable<TKey> Keys => cache.Keys;
public IEnumerable<TValue> Values => cache.Values;
public int Count => cache.Count;
public bool ContainsKey(TKey key) {
return cache.ContainsKey(key);
}
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() {
return cache.GetEnumerator();
}
public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) {
return cache.TryGetValue(key, out value);
}
IEnumerator IEnumerable.GetEnumerator() {
return cache.GetEnumerator();
}
}
public abstract class AnimatedModItem : ModItem {
public abstract DrawAnimation Animation { get; }
public virtual Color? GetGlowmaskTint(Player player) => null;
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) {
Texture2D texture = TextureAssets.Item[Item.type].Value;
spriteBatch.Draw(texture, Item.position - Main.screenPosition, Animation.GetFrame(texture), lightColor, 0f, default, scale, SpriteEffects.None, 0f);
return false;
}
}
public interface ICustomDrawItem {
void DrawInHand(Texture2D itemTexture, ref PlayerDrawSet drawInfo, Vector2 itemCenter, Color lightColor, Vector2 drawOrigin);
bool DrawOverHand => false;
bool BackHand => false;
}
public interface IAltTileCollideNPC {
int CollisionType { get; }
}
public interface ICustomCollisionNPC {
bool IsSandshark => false;
void PreUpdateCollision();
void PostUpdateCollision();
}
public interface IMeleeCollisionDataNPC {
void GetMeleeCollisionData(Rectangle victimHitbox, int enemyIndex, ref int specialHitSetter, ref float damageMultiplier, ref Rectangle npcRect, ref float knockbackMult);
}
public interface IWhipProjectile {
void GetWhipSettings(out float timeToFlyOut, out int segments, out float rangeMultiplier);
}
public static class MeleeCollisionNPCData {
public static float knockbackMult = 1f;
}
public interface IElementalItem {
ushort Element { get; }
}
public interface IElementalProjectile {
ushort Element { get; }
}
public interface IGlowingWaterStyle {
public void AddLight(ref Vector3 color, byte liquidAmount);
}
public interface IShadedProjectile {
public int Shader { get; }
}
interface IIsExplodingProjectile {
void Explode(int delay = 0) {
if (this is ModProjectile modProjectile) {
if (modProjectile.Projectile.timeLeft > delay) modProjectile.Projectile.timeLeft = delay;
}
}
bool IsExploding();
}
interface ISelfDamageEffectProjectile {
void OnSelfDamage(Player player, Player.HurtInfo info, double damageDealt);
}
interface ICustomRespawnArtifact {
void Respawn();
}
public interface ICustomCanPlaceTile {
public void CanPlace(Player self, Tile targetTile, Item sItem, ref int tileToCreate, ref int previewPlaceStyle, ref bool? overrideCanPlace, ref int? forcedRandom);
}
interface ILoadExtraTextures {
void LoadTextures();
}
interface IItemObtainabilityProvider {
IEnumerable<int> ProvideItemObtainability();
}
public interface IDrawOverArmProjectile {
DrawData GetDrawData();
}
public interface IUnloadable {
void Unload();
}
public static class Elements {
public const ushort Fire = 1;
public const ushort Earth = 2;
public const ushort Acid = 4;
public const ushort Ice = 8;
public const ushort Fiberglass = 16;
}
public static class SlopeID {
public const byte None = 0;
public const byte BottomLeft = 1;
public const byte BottomRight = 2;
public const byte TopLeft = 3;
public const byte TopRight = 4;
}
public static class NPCAIStyleID {
///<summary>
///Doesn't move.
///</summary>
public const int ActuallyNone = -1;
///<summary>
///Doesn't move.
///</summary>
public const int None = 0;
///<summary>
/// Hops in one direction, slides on slopes, floats in water, follows player if damaged or it's nighttime. Grasshoppers, on the other hand, flees from nearby players.
///</summary>
public const int Slime = 1;
///<summary>
/// Flies, follows player, bounces off walls in an arc.
///</summary>
public const int Demon_Eye = 2;
///<summary>
/// Will walk, jump over holes, follow player. It will try to line up vertically first. If it fails to reach its target, it will back up a bit, then re-attempt. It is the most common AI in Terraria.
///</summary>
public const int Fighter = 3;
///<summary>
/// Alternates between trying to stay above the player and summoning Servants of Cthulhu, and charging at the player occasionally. Spins when at low health, and begins exclusively charging at the player. Always looks at player.
///</summary>
public const int Eye_of_Cthulhu = 4;
///<summary>
/// Flies, looks at player, follows player.
///</summary>
public const int Flying = 5;
///<summary>
/// Burrows in ground (and/or air), passes through blocks, follows player. Truffle Worm instead flees from players.
///</summary>
public const int Worm = 6;
///<summary>
/// "Walks semi-randomly, jumps over holes. As of the 1.3 update, all Town NPCs talk to each other and the player, and each Town NPC has a different weapon to defend themselves when an enemy is nearby."
///</summary>
public const int Passive = 7;
///<summary>
/// Casts spells at player, stays stationary, warps after three casts, warps if falling. It stops casting spells if damaged, then warps if left alone.
///</summary>
public const int Caster = 8;
///<summary>
/// Travels in a direct line towards player, going through blocks. Used by casters.
///</summary>
public const int Spell = 9;
///<summary>
/// Tries to drift towards or around player, often stays a little bit out of reach once having touched the player.
///</summary>
public const int Cursed_Skull = 10;
///<summary>
/// Tries to stay above player, spins and moves towards player occasionally, enrages during the daytime.
///</summary>
public const int Head = 11;
///<summary>
/// Follows the Skeletron head, flails, waves, and attempts to damage player.
///</summary>
public const int Skeletron_Hand = 12;
///<summary>
/// Extends on a vine towards player, looks at player. Dies if not rooted to a block.
///</summary>
public const int Plant = 13;
///<summary>
/// Spasmodically flies towards player.
///</summary>
public const int Bat = 14;
///<summary>
/// Hops towards the player and releases Blue Slimes when damaged. Teleports to the player when the player is out of reach; releases Spiked Slimes when damaged in Expert Mode.
///</summary>
public const int King_Slime = 15;
///<summary>
/// Swims back and forth and moves towards the player if they are in water, except for Goldfish, Gold Goldfish and Pupfish.
///</summary>
public const int Swimming = 16;
///<summary>
/// Stands still until player gets within five blocks of AI or it is damaged. AI then acts similarly to the Flying AI.
///</summary>
public const int Vulture = 17;
///<summary>
/// Floats back and forth, swims towards player in small bursts if player is in water.
///</summary>
public const int Jellyfish = 18;
///<summary>
/// Looks at player, climbs overlapping blocks, shoots falling sand at nearby players.
///</summary>
public const int Antlion = 19;
///<summary>
/// Swings in a circle from a pivot point on a chain.
///</summary>
public const int Spike_Ball = 20;
///<summary>
/// Moves along walls, floors and closed doors.
///</summary>
public const int Blazing_Wheel = 21;
///<summary>
/// Similar to the Fighter AI, floats over the ground instead of jumping.
///</summary>
public const int Hovering = 22;
///<summary>
/// Doesn't adhere to gravity or tile collisions. Spins several times, then heads straight towards the player. Any damage cancels its attack and forces it to spin again.
///</summary>
public const int Flying_Weapon = 23;
///<summary>
/// Stands still until player gets nearby, then flies away. Avoids walls and obstacles and changes direction if one is in the way.
///</summary>
public const int Bird = 24;
///<summary>
/// Stands still until player approaches or attacks, then leaps towards them with varying heights.
///</summary>
public const int Mimic = 25;
///<summary>
/// Slowly gains speed while moving, jumps over obstacles.
///</summary>
public const int Unicorn = 26;
///<summary>
/// Wall of Flesh Mouth with Wall image attached. Traverses the world horizontally. Also spawns with two Wall of Flesh Eyes which share its health.
///</summary>
public const int Wall_of_Flesh = 27;
///<summary>
/// Bound to an entity, watches player, and shoots projectiles. The more damaged it is, the more it shoots.
///</summary>
public const int Wall_of_Flesh_Eye = 28;
///<summary>
/// Similar to the Plant AI, but attached to an entity.
///</summary>
public const int The_Hungry = 29;
///<summary>
/// Alternates between attempting to stay diagonally above player while shooting projectiles slowly, and attempting to stay beside player and shooting projectiles very rapidly.
///</summary>
public const int Retinazer = 30;
///<summary>
/// Alternates between shooting projectiles and staying beside player, and charging toward player.
///</summary>
public const int Spazmatism = 31;
///<summary>
/// Same as Head AI.
///</summary>
public const int Skeletron_Prime_Head = 32;
///<summary>
/// Occasionally charges at the player, heads directly towards player when enraged.
///</summary>
public const int Prime_Saw = 33;
///<summary>
/// Occasionally charges at the player, rapidly charges when enraged.
///</summary>
public const int Prime_Vice = 34;
///<summary>
/// Fires bombs upwards, aims directly at player when enraged.
///</summary>
public const int Prime_Cannon = 35;
///<summary>
/// Fires projectiles at player, shoots very rapidly when enraged.
///</summary>
public const int Prime_Laser = 36;
///<summary>
/// Similar to Worm AI except it will shoot projectiles from the body and tail and is unable to "fly" in air. It will also release Probes.
///</summary>
public const int The_Destroyer = 37;
///<summary>
/// Jumps and runs towards the player, similar to Fighter AI.
///</summary>
public const int Snowman = 38;
///<summary>
/// Crawls a bit, then leaps towards player. Will indefinitely leap towards the player in water.
///</summary>
public const int Tortoise = 39;
///<summary>
/// Capable of climbing background walls as well as through platforms. Used only when crawling on a wall. Without a wall listed enemies seamlessly transform into their walking variants, which use Fighter AI.
///</summary>
public const int Spider = 40;
///<summary>
/// Jumps high and attempts to land on the player. It can strafe to the sides in midair.
///</summary>
public const int Herpling = 41;
///<summary>
/// Turns into a Nymph when a player gets too close.
///</summary>
public const int Lost_Girl = 42;
///<summary>
/// Alternates between attempting to stay above player while firing projectiles downwards or spawning bees, and charging back and forth very rapidly.
///</summary>
public const int Queen_Bee = 43;
///<summary>
/// Flies straight towards player.
///</summary>
public const int Flying_Fish = 44;
///<summary>
/// Jumps towards player every few seconds, shoots lasers.
///</summary>
public const int Golem_Body = 45;
///<summary>
/// Bound to an entity.
///</summary>
public const int Golem_Head = 46;
///<summary>
/// Flies towards player, returns when hit.
///</summary>
public const int Golem_Fist = 47;
///<summary>
/// Attempts to fly back and forth, shoots projectiles at player.
///</summary>
public const int Free_Golem_Head = 48;
///<summary>
/// Attempts to stay directly above the player, and fires projectiles downwards.
///</summary>
public const int Angry_Nimbus = 49;
///<summary>
/// Drifts downwards while following player, destroyed on contact.
///</summary>
public const int Spore = 50;
///<summary>
/// Clings to nearby blocks, chases player, fires projectiles and spiky balls that bounce around.
///</summary>
public const int Plantera = 51;
///<summary>
/// Moves forward briefly before latching onto a block.
///</summary>
public const int Plantera_Hook = 52;
///<summary>
/// Acts very similar to the Plant AI, only bound to a certain entity.
///</summary>
public const int Plantera_Tentacle = 53;
///<summary>
/// Doesn't adhere to gravity or tile collisions, and teleports occasionally in first form. Once all Creepers are killed, it will begin rapidly teleporting and moving towards the player.
///</summary>
public const int Brain_of_Cthulhu = 54;
///<summary>
/// Circles around an entity, charging at player.
///</summary>
public const int Creeper = 55;
///<summary>
/// Moves directly towards player, gaining momentum. Emits blueish particles.
///</summary>
public const int Dungeon_Spirit = 56;
///<summary>
/// Moves towards player, stops, and fires projectiles straight at the player.
///</summary>
public const int Mourning_Wood = 57;
///<summary>
/// Very similar to the Head AI. Spawns with two Pumpking Scythes.
///</summary>
public const int Pumpking = 58;
///<summary>
/// Very similar to the Skeletron Hand AI.
///</summary>
public const int Pumpking_Scythe = 59;
///<summary>
/// Flies around, shooting a barrage of ice-based projectiles.
///</summary>
public const int Ice_Queen = 60;
///<summary>
/// Moves across the ground, stops moving, and launches many different types of projectiles.
///</summary>
public const int Santank = 61;
///<summary>
/// Attempts to fly around the player, shooting bullets rapidly if they are in sight.
///</summary>
public const int Elf_Copter = 62;
///<summary>
/// Flies towards the player at high speed.
///</summary>
public const int Flocko = 63;
///<summary>
/// Flies slowly in any direction and occasionally glows.
///</summary>
public const int Firefly = 64;
///<summary>
/// Flies slowly in any direction.
///</summary>
public const int Butterfly = 65;
///<summary>
/// Moves along the ground, pause for a bit, then continue moving. Will avoid walls and moves in the other direction if it has hit one.
///</summary>
public const int Passive_Worm = 66;
///<summary>
/// Acts similarly to the Passive Worm AI, but climbs up walls instead of moving away.
///</summary>
public const int Snail = 67;
///<summary>
/// Swims on water and walks on land. Will fly away when a player is nearby, but only while swimming. Lands after flying for a while.
///</summary>
public const int Duck = 68;
///<summary>
/// Rams player multiple times before summoning entities. In second form, it flies in circles and summons entities.
///</summary>
public const int Duke_Fishron = 69;
///<summary>
/// Flies through the air, chases player, and disappears after a period of time. Explodes and deals damage if it succeeds in reaching player.
///</summary>
public const int Detonating_Bubble = 70;
///<summary>
/// Follows an arcing path, dies when it touches a wall or player.
///</summary>
public const int Sharkron = 71;
///<summary>
/// Created by the Martian Officer, absorbs all damage dealt to the officer.
///</summary>
public const int Bubble_Shield = 72;
///<summary>
/// Built by Martian Engineers on the ground.
///</summary>
public const int Tesla_Turret = 73;
///<summary>
/// Travels through blocks, charges at the player.
///</summary>
public const int Corite = 74;
///<summary>
/// Has a Rider and a corresponding mount, if one is destroyed the other keeps attacking.
///</summary>
public const int Rider = 75;