Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DrawAnimationVertical.cs
Go to the documentation of this file.
3
5
7{
8 public bool PingPong;
9
11
12 public DrawAnimationVertical(int ticksperframe, int frameCount, bool pingPong = false)
13 {
14 Frame = 0;
15 FrameCounter = 0;
16 FrameCount = frameCount;
17 TicksPerFrame = ticksperframe;
18 PingPong = pingPong;
19 }
20
21 public override void Update()
22 {
24 {
25 return;
26 }
27 FrameCounter = 0;
28 if (PingPong)
29 {
30 if (++Frame >= FrameCount * 2 - 2)
31 {
32 Frame = 0;
33 }
34 }
35 else if (++Frame >= FrameCount)
36 {
37 Frame = 0;
38 }
39 }
40
41 public override Rectangle GetFrame(Texture2D texture, int frameCounterOverride = -1)
42 {
43 if (frameCounterOverride != -1)
44 {
45 int num = frameCounterOverride / TicksPerFrame;
46 int num2 = FrameCount;
47 if (PingPong)
48 {
49 num2 = num2 * 2 - 1;
50 }
51 int num3 = num % num2;
52 if (PingPong && num3 >= FrameCount)
53 {
54 num3 = FrameCount * 2 - 2 - num3;
55 }
56 Rectangle result = texture.Frame(1, FrameCount, 0, num3);
57 result.Height -= 2;
58 return result;
59 }
60 int frameY = Frame;
61 if (PingPong && Frame >= FrameCount)
62 {
63 frameY = FrameCount * 2 - 2 - Frame;
64 }
65 Rectangle result2 = texture.Frame(1, FrameCount, 0, frameY);
66 result2.Height -= 2;
67 return result2;
68 }
69}
DrawAnimationVertical(int ticksperframe, int frameCount, bool pingPong=false)
override Rectangle GetFrame(Texture2D texture, int frameCounterOverride=-1)