TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ Step()

static BallStepResult Terraria.Physics.BallCollision.Step ( PhysicsProperties physicsProperties,
Entity entity,
ref float entityAngularVelocity,
IBallContactListener listener )
inlinestatic

Definition at line 24 of file BallCollision.cs.

25 {
26 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
27 //IL_0006: Unknown result type (might be due to invalid IL or missing references)
28 //IL_0008: Unknown result type (might be due to invalid IL or missing references)
29 //IL_000d: Unknown result type (might be due to invalid IL or missing references)
30 //IL_000f: Unknown result type (might be due to invalid IL or missing references)
31 //IL_0014: Unknown result type (might be due to invalid IL or missing references)
32 //IL_0018: Unknown result type (might be due to invalid IL or missing references)
33 //IL_002f: Unknown result type (might be due to invalid IL or missing references)
34 //IL_0036: Unknown result type (might be due to invalid IL or missing references)
35 //IL_003b: Unknown result type (might be due to invalid IL or missing references)
36 //IL_0088: Unknown result type (might be due to invalid IL or missing references)
37 //IL_008b: Unknown result type (might be due to invalid IL or missing references)
38 //IL_0090: Unknown result type (might be due to invalid IL or missing references)
39 //IL_0053: Unknown result type (might be due to invalid IL or missing references)
40 //IL_0054: Unknown result type (might be due to invalid IL or missing references)
41 //IL_0059: Unknown result type (might be due to invalid IL or missing references)
42 //IL_005e: Unknown result type (might be due to invalid IL or missing references)
43 //IL_00bd: Unknown result type (might be due to invalid IL or missing references)
44 //IL_00be: Unknown result type (might be due to invalid IL or missing references)
45 //IL_00c4: Unknown result type (might be due to invalid IL or missing references)
46 //IL_00c9: Unknown result type (might be due to invalid IL or missing references)
47 //IL_020a: Unknown result type (might be due to invalid IL or missing references)
48 //IL_020d: Unknown result type (might be due to invalid IL or missing references)
49 //IL_0212: Unknown result type (might be due to invalid IL or missing references)
50 //IL_0134: Unknown result type (might be due to invalid IL or missing references)
51 //IL_0135: Unknown result type (might be due to invalid IL or missing references)
52 //IL_0136: Unknown result type (might be due to invalid IL or missing references)
53 //IL_013b: Unknown result type (might be due to invalid IL or missing references)
54 //IL_013c: Unknown result type (might be due to invalid IL or missing references)
55 //IL_013d: Unknown result type (might be due to invalid IL or missing references)
56 //IL_0266: Unknown result type (might be due to invalid IL or missing references)
57 //IL_0267: Unknown result type (might be due to invalid IL or missing references)
58 //IL_026d: Unknown result type (might be due to invalid IL or missing references)
59 //IL_026e: Unknown result type (might be due to invalid IL or missing references)
60 //IL_0223: Unknown result type (might be due to invalid IL or missing references)
61 //IL_014b: Unknown result type (might be due to invalid IL or missing references)
62 //IL_014c: Unknown result type (might be due to invalid IL or missing references)
63 //IL_014d: Unknown result type (might be due to invalid IL or missing references)
64 //IL_0230: Unknown result type (might be due to invalid IL or missing references)
65 //IL_015c: Unknown result type (might be due to invalid IL or missing references)
66 //IL_015d: Unknown result type (might be due to invalid IL or missing references)
67 //IL_0163: Unknown result type (might be due to invalid IL or missing references)
68 //IL_0168: Unknown result type (might be due to invalid IL or missing references)
69 //IL_016d: Unknown result type (might be due to invalid IL or missing references)
70 //IL_016f: Unknown result type (might be due to invalid IL or missing references)
71 //IL_0174: Unknown result type (might be due to invalid IL or missing references)
72 //IL_0179: Unknown result type (might be due to invalid IL or missing references)
73 //IL_017b: Unknown result type (might be due to invalid IL or missing references)
74 //IL_017d: Unknown result type (might be due to invalid IL or missing references)
75 //IL_0187: Unknown result type (might be due to invalid IL or missing references)
76 //IL_018c: Unknown result type (might be due to invalid IL or missing references)
77 //IL_0191: Unknown result type (might be due to invalid IL or missing references)
78 //IL_0197: Unknown result type (might be due to invalid IL or missing references)
79 //IL_019c: Unknown result type (might be due to invalid IL or missing references)
80 //IL_01a1: Unknown result type (might be due to invalid IL or missing references)
81 //IL_01a6: Unknown result type (might be due to invalid IL or missing references)
82 //IL_01a8: Unknown result type (might be due to invalid IL or missing references)
83 //IL_01b5: Unknown result type (might be due to invalid IL or missing references)
84 //IL_01b8: Unknown result type (might be due to invalid IL or missing references)
85 //IL_01bd: Unknown result type (might be due to invalid IL or missing references)
86 //IL_01c2: Unknown result type (might be due to invalid IL or missing references)
87 //IL_01d2: Unknown result type (might be due to invalid IL or missing references)
88 //IL_01dc: Unknown result type (might be due to invalid IL or missing references)
89 //IL_01e5: Unknown result type (might be due to invalid IL or missing references)
90 //IL_01ef: Unknown result type (might be due to invalid IL or missing references)
91 //IL_023d: Unknown result type (might be due to invalid IL or missing references)
92 //IL_00fe: Unknown result type (might be due to invalid IL or missing references)
93 //IL_0104: Unknown result type (might be due to invalid IL or missing references)
94 //IL_0109: Unknown result type (might be due to invalid IL or missing references)
95 //IL_024a: Unknown result type (might be due to invalid IL or missing references)
96 Vector2 position = entity.position;
97 Vector2 velocity = entity.velocity;
98 Vector2 size = entity.Size;
100 float num2 = size.X * 0.5f;
101 num *= physicsProperties.Drag;
102 velocity *= physicsProperties.Drag;
103 float num3 = ((Vector2)(ref velocity)).Length();
104 if (num3 > 1000f)
105 {
106 velocity = 1000f * Vector2.Normalize(velocity);
107 num3 = 1000f;
108 }
109 int num4 = Math.Max(1, (int)Math.Ceiling(num3 / 2f));
110 float num5 = 1f / (float)num4;
111 velocity *= num5;
112 num *= num5;
113 float num6 = physicsProperties.Gravity / (float)(num4 * num4);
114 bool flag = false;
115 for (int i = 0; i < num4; i++)
116 {
117 velocity.Y += num6;
118 if (CheckForPassThrough(position + size * 0.5f, out var type, out var contactTile))
119 {
120 if (type == BallPassThroughType.Tile && Main.tileSolid[contactTile.type] && !Main.tileSolidTop[contactTile.type])
121 {
122 velocity *= 0f;
123 num *= 0f;
124 flag = true;
125 }
126 else
127 {
128 BallPassThroughEvent passThrough = new BallPassThroughEvent(num5, contactTile, entity, type);
129 listener.OnPassThrough(physicsProperties, ref position, ref velocity, ref num, ref passThrough);
130 }
131 }
132 position += velocity;
133 if (!IsBallInWorld(position, size))
134 {
135 return BallStepResult.OutOfBounds();
136 }
137 if (GetClosestEdgeToCircle(position, size, velocity, out var collisionPoint, out contactTile))
138 {
139 Vector2 vector = Vector2.Normalize(position + size * 0.5f - collisionPoint);
140 position = collisionPoint + vector * (num2 + 0.0001f) - size * 0.5f;
141 BallCollisionEvent collision = new BallCollisionEvent(num5, vector, collisionPoint, contactTile, entity);
142 flag = true;
143 velocity = Vector2.Reflect(velocity, collision.Normal);
144 listener.OnCollision(physicsProperties, ref position, ref velocity, ref collision);
145 num = (collision.Normal.X * velocity.Y - collision.Normal.Y * velocity.X) / num2;
146 }
147 }
148 velocity /= num5;
149 num /= num5;
150 BallStepResult result = BallStepResult.Moving();
151 if (flag && velocity.X > -0.01f && velocity.X < 0.01f && velocity.Y <= 0f && velocity.Y > 0f - physicsProperties.Gravity)
152 {
153 result = BallStepResult.Resting();
154 }
155 entity.position = position;
156 entity.velocity = velocity;
158 return result;
159 }
static bool IsBallInWorld(Vector2 position, Vector2 size)
static bool CheckForPassThrough(Vector2 center, out BallPassThroughType type, out Tile contactTile)
static bool GetClosestEdgeToCircle(Vector2 position, Vector2 size, Vector2 velocity, out Vector2 collisionPoint, out Tile collisionTile)

References Terraria.Physics.BallCollision.CheckForPassThrough(), Terraria.Physics.BallCollision.GetClosestEdgeToCircle(), Terraria.Physics.BallCollision.IsBallInWorld(), Terraria.Physics.BallStepResult.Moving(), Terraria.Physics.BallStepResult.OutOfBounds(), Terraria.Entity.position, Terraria.Physics.BallStepResult.Resting(), Terraria.Entity.Size, Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, and Terraria.Entity.velocity.

Referenced by Terraria.GameContent.Golf.GolfHelper.StepGolfBall().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: