25 {
26 Vector2 position = entity.position;
27 Vector2 velocity = entity.velocity;
29 float num = entityAngularVelocity;
30 float num2 = size.X * 0.5f;
31 num *= physicsProperties.Drag;
32 velocity *= physicsProperties.Drag;
33 float num3 = velocity.
Length();
34 if (num3 > 1000f)
35 {
37 num3 = 1000f;
38 }
40 float num5 = 1f / (float)num4;
41 velocity *= num5;
42 num *= num5;
43 float num6 = physicsProperties.Gravity / (float)(num4 * num4);
44 bool flag = false;
45 for (
int i = 0;
i < num4;
i++)
46 {
47 velocity.Y += num6;
49 {
50 if (
type ==
BallPassThroughType.Tile && Main.tileSolid[contactTile.type] && !Main.tileSolidTop[contactTile.type])
51 {
52 velocity *= 0f;
53 num *= 0f;
54 flag = true;
55 }
56 else
57 {
58 BallPassThroughEvent passThrough =
new BallPassThroughEvent(num5, contactTile, entity,
type);
59 listener.OnPassThrough(physicsProperties, ref position, ref velocity, ref num, ref passThrough);
60 }
61 }
62 position += velocity;
64 {
65 return BallStepResult.OutOfBounds();
66 }
68 {
70 position = collisionPoint + vector * (num2 + 0.0001f) - size * 0.5f;
71 BallCollisionEvent collision = new BallCollisionEvent(num5, vector, collisionPoint, contactTile, entity);
72 flag = true;
74 listener.OnCollision(physicsProperties, ref position, ref velocity, ref collision);
75 num = (collision.Normal.X * velocity.Y - collision.Normal.Y * velocity.X) / num2;
76 }
77 }
78 velocity /= num5;
79 num /= num5;
80 BallStepResult result = BallStepResult.Moving();
81 if (flag && velocity.
X > -0.01f && velocity.
X < 0.01f && velocity.
Y <= 0f && velocity.
Y > 0f - physicsProperties.Gravity)
82 {
83 result = BallStepResult.Resting();
84 }
85 entity.position = position;
86 entity.velocity = velocity;
87 entityAngularVelocity = num;
88 return result;
89 }
static double Ceiling(double a)
static byte Max(byte val1, byte val2)
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)
static Vector2 Reflect(Vector2 vector, Vector2 normal)