95 throw new Exception(
"Be sure to update Minecart.textureWidth to match the actual texture size of " + 50f +
".");
103 for (
int i = 0; i < 36; i++)
105 int[]
array =
new int[8];
106 for (
int j = 0; j <
array.Length; j++)
125 for (
int k = 0; k < 4; k++)
133 for (
int l = 4; l < 8; l++)
177 for (
int m = 0; m < 8; m++)
185 for (
int n = 0; n < 8; n++)
195 for (
int num2 = 2; num2 < 8; num2++)
205 for (
int num3 = 0; num3 < 6; num3++)
216 for (
int num4 = 3; num4 < 8; num4++)
227 for (
int num5 = 0; num5 < 5; num5++)
245 for (
int num6 = 0; num6 < 6; num6++)
257 for (
int num7 = 2; num7 < 8; num7++)
265 for (
int num8 = 0; num8 < 6; num8++)
277 for (
int num9 = 2; num9 < 8; num9++)
309 for (
int num10 = 0; num10 < 6; num10++)
317 for (
int num11 = 2; num11 < 8; num11++)
327 for (
int num12 = 2; num12 < 8; num12++)
337 for (
int num13 = 0; num13 < 6; num13++)
348 for (
int num14 = 3; num14 < 8; num14++)
359 for (
int num15 = 0; num15 < 5; num15++)
379 for (
int num16 = 0; num16 < 8; num16++)
389 for (
int num17 = 0; num17 < 8; num17++)
399 for (
int num18 = 0; num18 < 8; num18++)
409 for (
int num19 = 0; num19 < 8; num19++)
425 for (
int num21 = 0; num21 <
_tileHeight.Length; num21++)
428 for (
int num22 = 0; num22 < array2.Length; num22++)
430 if (array2[num22] >= 0)
432 array2[num22] = (8 - array2[num22]) * 2;
436 int[] array3 =
new int[36];
438 for (
int num23 = 0; num23 < 64; num23++)
441 for (
int num25 = 1; num25 < 256; num25 <<= 1)
443 if ((num23 & num25) == num25)
449 for (
int num27 = 0; num27 < 36; num27++)
484 else if (num28 == 0 || (num23 & num28) != num28)
488 array3[num27] = num27;
495 int[] array4 =
new int[num26];
497 for (
int num30 = 0; num30 < 36; num30++)
499 if (array3[num30] != -1)
501 array4[num29] = array3[num30];
510 for (
int num31 = 0; num31 <
_trackType.Length; num31++)
550 public static BitsByte TrackCollision(
Player Player, ref
Vector2 Position, ref
Vector2 Velocity, ref
Vector2 lastBoost,
int Width,
int Height,
bool followDown,
bool followUp,
int fallStart,
bool trackOnly,
Mount.
MountDelegatesData delegatesData)
552 if (followDown && followUp)
557 Vector2 vector =
new Vector2((
float)(Width / 2) - 25f, Height / 2);
560 float num = vector3.
Length();
579 int num5 = (int)(vector4.
X / 16f);
580 int num6 = (int)(vector4.
Y / 16f);
581 int num7 = (int)vector4.
X % 16 / 2;
586 bool flag7 = num7 != num4;
589 int num8 = ((trackState !=
TrackState.OnBack) ? tile.FrontTrack() : tile.BackTrack());
604 if (num5 != num2 || num6 != num3)
620 flag = ((tile.
nactive() && tile.type == 314) ?
true :
false);
625 int num9 = tile.FrontTrack();
626 int num10 = tile.BackTrack();
671 float num14 = (float)(num5 * 16 + (num7 + 1) * 2) - vector4.
X;
673 num += num14 / vector3.
X;
675 vector3.X = 0f - vector3.
X;
684 vector5.X = Velocity.X;
691 float num12 = num6 * 16 + num11;
692 if (num5 != num2 && trackState ==
TrackState.NoTrack && vector4.
Y > num12 && vector4.
Y - num12 < 2f)
697 TrackState trackState4 = ((!(vector4.Y < num12)) ? ((!(vector4.Y > num12)) ? TrackState.OnTrack :
TrackState.BelowTrack) :
TrackState.AboveTrack);
700 float num13 = num6 * 16 +
_tileHeight[num10][num7];
701 trackState3 = ((!(vector4.Y < num13)) ? ((!(vector4.Y > num13)) ? TrackState.OnTrack :
TrackState.BelowTrack) :
TrackState.AboveTrack);
709 trackState2 = trackState3
switch
712 TrackState.BelowTrack =>
TrackState.AboveFront,
713 TrackState.AboveTrack =>
TrackState.AboveTrack,
718 trackState2 = trackState3
switch
721 TrackState.AboveTrack =>
TrackState.AboveBack,
722 TrackState.BelowTrack =>
TrackState.BelowTrack,
733 if (trackState != trackState2)
736 if (flag7 || vector3.
Y > 0f)
788 num17 = tile.FrontTrack();
791 num17 = tile.BackTrack();
798 int num18 = (int)(
Position.Y / 16f);
799 if (fallStart < num18 - 1)
801 delegatesData.MinecartLandingSound(
Player,
Position, Width, Height);
817 if (flag &&
_trackType[tile.FrontTrack()] == 1)
825 int num19 = tile.FrontTrack();
826 if (
_trackType[num19] == 2 && lastBoost.X == 0f && lastBoost.Y == 0f)
828 lastBoost =
new Vector2(num5, num6);
840 trackState = trackState2;
845 float num20 = vector4.X % 2f;
846 float num21 = vector4.Y % 2f;
851 num22 = num20 + 0.125f;
853 else if (vector3.
X > 0f)
859 num23 = num21 + 0.125f;
861 else if (vector3.
Y > 0f)
865 if (num22 == 3f && num23 == 3f)
869 float num24 =
Math.
Abs(num22 / vector3.
X);
870 float num25 =
Math.
Abs(num23 / vector3.
Y);
871 float num26 = ((num24 < num25) ? num24 : num25);
874 vector6 = vector3 * num;
879 vector6 = vector3 * num26;
885 if (lastBoost.X != (
float)num2 || lastBoost.Y != (float)num3)
897 Velocity.X = vector4.X - vector2.
X;
907 Velocity.X = 0f - Velocity.
X;
908 Position.X = vector4.X - _trackMagnetOffset.X - vector.X - Velocity.X;
918 Velocity.X = vector4.X - vector2.
X;
925 Position.Y += vector4.Y - vector2.Y - Velocity.Y;
927 if (trackState ==
TrackState.OnTrack || (uint)(trackState - 5) <= 1u)
934 public static bool FrameTrack(
int i,
int j,
bool pound,
bool mute =
false)
946 if (mute && tile.
type != 314)
951 int num = tile.FrontTrack();
952 int num2 = tile.BackTrack();
972 for (
int k = 0; k <
array.Length; k++)
975 if (num2 ==
array[k])
1010 if (num4 == -1 || flag)
1033 for (
int l = 0; l <
array.Length; l++)
1035 if (num ==
array[l])
1039 if (num2 ==
array[l])
1046 for (
int m = 0; m <
array.Length; m++)
1060 if (num9 < 2 && num10 < 2)
1064 bool flag2 = num9 == 0;
1071 if (num5 >=
array.Length)
1087 if (num4 >=
array.Length)
1111 if (tile.FrontTrack() != 0)
1117 if (tile.FrontTrack() !=
array[num4])
1125 if (tile.BackTrack() != -1)
1130 else if (tile.BackTrack() !=
array[num5])
1143 tile.FrontTrack((
short)
array[num4]);
1152 tile.BackTrack((
short)
array[num5]);
1154 if (pound && flag4 && !mute)
1164 if (
Main.
tile[i - 1, j - 1] !=
null &&
Main.
tile[i - 1, j - 1].type == 314)
1172 if (
Main.
tile[i - 1, j + 1] !=
null &&
Main.
tile[i - 1, j + 1].type == 314)
1176 if (
Main.
tile[i + 1, j - 1] !=
null &&
Main.
tile[i + 1, j - 1].type == 314)
1184 if (
Main.
tile[i + 1, j + 1] !=
null &&
Main.
tile[i + 1, j + 1].type == 314)
1194 if (tile.
type != 314)
1198 Vector2 vector =
new Vector2((
float)(Width / 2) - 25f, Height / 2);
1200 int num = (int)vector2.
X % 16 / 2;
1203 for (
int i = num; i < 8; i++)
1214 for (
int num4 = num - 1; num4 >= 0; num4--)
1228 vector2.X = tileX * 16 + num2 * 2;
1229 vector2.Y = tileY * 16 + num3;
1239 int num = (int)(vector.
X / 16f);
1240 int num2 = (int)(vector.
Y / 16f);
1245 return Main.
tile[num, num2].type == 314;
1250 GetWheelsPositions(player,
Position, Width, Height, followDown, followUp, delegatesData, out var leftWheel, out var rightWheel);
1251 float num = rightWheel.Y - leftWheel.Y;
1252 float num2 = rightWheel.X - leftWheel.X;
1253 float num3 = num / num2;
1254 float num4 = leftWheel.Y + (Position.X - leftWheel.X) * num3;
1255 float num5 = (Position.X - (float)(
int)
Position.X) * num3;
1256 rotation = (float)
Math.
Atan2(num, num2);
1257 return num4 - Position.Y + num5;
1266 TrackCollision(player, ref leftWheel, ref Velocity, ref lastBoost, Width, Height, followDown, followUp, 0, trackOnly:
true, delegatesData);
1267 leftWheel += Velocity;
1268 Velocity =
new Vector2(12f, 0f);
1269 TrackCollision(player, ref rightWheel, ref Velocity, ref lastBoost, Width, Height, followDown, followUp, 0, trackOnly:
true, delegatesData);
1270 rightWheel += Velocity;
1276 int num = (int)(magnetPosition.
X / 16f);
1277 int num2 = (int)(magnetPosition.
Y / 16f);
1284 new Vector2((
float)(Width / 2) - 25f, Height / 2);
1291 short num = tileTrack.FrontTrack();
1299 if (tileTrack.BackTrack() != -1)
1301 tileTrack.FrontTrack(tileTrack.BackTrack());
1302 tileTrack.BackTrack(num);
1313 public static void TrackColors(
int i,
int j,
Tile trackTile, out
int frontColor, out
int backColor)
1315 if (trackTile.
type == 314)
1317 frontColor = trackTile.
color();
1318 backColor = frontColor;
1319 if (trackTile.
frameY == -1)
1331 for (
int k = 0; k < 4; k++)
1333 int num9 = (k
switch
1347 int num10 = ((tile !=
null && tile.
active() && tile.type == 314) ? tile.
color() : 0);
1413 frontColor = ((num2 <= num) ? num6 : num5);
1424 backColor = ((num4 <= num3) ? num8 : num7);
1436 if (frameID < 0 || frameID >= 36)
1445 if (frameID < 0 || frameID >= 36)
1454 if (frameID < 0 || frameID >= 36)
1467 if (frameID < 0 || frameID >= 36)
1480 trackCache.
active(active:
true);
1481 trackCache.type = 314;
1482 trackCache.frameY = -1;
1486 trackCache.frameX = -1;
1513 if (frameID < 0 || frameID >= 40)
1519 if (frameID < 36 &&
_trackType[frameID] == 2)
1521 result.Y += 18 * animationFrame;
1529 if (expectedYOffsetForLeft.HasValue)
1531 short num = tileTrack.FrontTrack();
1538 if (expectedYOffsetForRight.HasValue)
1540 short num3 = tileTrack.FrontTrack();
1559 int num =
_trackType[tileSafely.FrontTrack()];
1561 foreach (
int num3
in array)
1566 if (expectedYOffsetForLeft.HasValue)
1574 if (expectedYOffsetForRight.HasValue)
1590 tileSafely.FrontTrack((
short)num2.Value);
1597 return offsetY
switch
1607 return trackConnectionValue
switch
1617 Vector2 vector =
new Vector2((
float)(Width / 2) - 25f, Height / 2);
1619 for (
int i = 0; i < sparkCount; i++)
1632 tileTrack.frameX = trackID;
1642 tileTrack.frameY = trackID;
static double Atan2(double y, double x)
static decimal Round(decimal d)
static double Abs(double value)
static Tile GetTileSafely(Vector2 position)
static Asset< Texture2D > MinecartMount
static bool FrameTrack(int i, int j, bool pound, bool mute=false)
const int LeftDownDecoration
const int Flag_BouncyBumper
const int RightDownDecoration
static int[] _leftSideConnection
static void FrontTrack(this Tile tileTrack, short trackID)
static int[][] _trackSwitchOptions
static int ConvertOffsetYToTrackConnectionValue(int offsetY)
static BitsByte TrackCollision(Player Player, ref Vector2 Position, ref Vector2 Velocity, ref Vector2 lastBoost, int Width, int Height, bool followDown, bool followUp, int fallStart, bool trackOnly, Mount.MountDelegatesData delegatesData)
static void TryFittingTileOrientation(Point tileCoords, int? expectedYOffsetForLeft, int? expectedYOffsetForRight)
static short FrontTrack(this Tile tileTrack)
static bool DrawBouncyBumper(int frameID)
static short _firstPressureFrame
static void PlaceTrack(Tile trackCache, int style)
const int BottomConnection
static Vector2 GetMagnetPosition(Vector2 Position, int Width, int Height)
static bool DrawRightDecoration(int frameID)
static bool DrawBumper(int frameID)
static bool GetOnTrack(int tileX, int tileY, ref Vector2 Position, int Width, int Height)
static short _firstRightBoostFrame
static Rectangle GetSourceRect(int frameID, int animationFrame=0)
static void FlipSwitchTrack(int i, int j)
static bool OnTrack(Vector2 Position, int Width, int Height)
static Vector2[] _texturePosition
const int MiddleConnection
static void TrackColors(int i, int j, Tile trackTile, out int frontColor, out int backColor)
static short _firstLeftBoostFrame
static void GetWheelsPositions(Player player, Vector2 Position, int Width, int Height, bool followDown, bool followUp, Mount.MountDelegatesData delegatesData, out Vector2 leftWheel, out Vector2 rightWheel)
static bool IsPressurePlate(Tile tile)
static void WheelSparks(Action< Vector2 > DustAction, Vector2 Position, int Width, int Height, int sparkCount)
static bool DrawLeftDecoration(int frameID)
static float TrackRotation(Player player, ref float rotation, Vector2 Position, int Width, int Height, bool followDown, bool followUp, Mount.MountDelegatesData delegatesData)
static int GetTrackItem(Tile trackCache)
const int BouncyBumperDecoration
static short BackTrack(this Tile tileTrack)
const float MinecartTextureWidth
static int[] _rightSideConnection
static Vector2 _trackMagnetOffset
static int GetNearbyTilesSetLookupIndex(int i, int j)
static void BackTrack(this Tile tileTrack, short trackID)
static int[][] _tileHeight
static void HitTrackSwitch(Vector2 Position, int Width, int Height)
static int ConvertTrackConnectionValueToOffsetY(int trackConnectionValue)
static bool GetAreExpectationsForSidesMet(Point tileCoords, int? expectedYOffsetForLeft, int? expectedYOffsetForRight)
const int Flag_BoostRight
const int RegularBumperDecoration
static void SendData(int msgType, int remoteClient=-1, int ignoreClient=-1, NetworkText text=null, int number=0, float number2=0f, float number3=0f, float number4=0f, int number5=0, int number6=0, int number7=0)
static void SendTileSquare(int whoAmi, int tileX, int tileY, int xSize, int ySize, TileChangeType changeType=TileChangeType.None)
static float defaultGravity
static void HitSwitch(int i, int j)
static void KillTile(int i, int j, bool fail=false, bool effectOnly=false, bool noItem=false)
static Matrix CreateRotationZ(float radians)
static Vector2 Transform(Vector2 position, Matrix matrix)