public static void SetNextMove(this Minecart cart, int yOffset, char currentRail) { // Now work out where it'll go next // We only care if it's on something that'll change it's direction... if (currentRail == '/' && (cart.NextMove == -1 || cart.NextMove == 1)) { // Coming to a left turn cart.TurnLeft(yOffset); } else if (currentRail == '/') { // Coming to a right turn cart.TurnRight(yOffset); } else if (currentRail == '\\' && (cart.NextMove == -1 || cart.NextMove == 1)) { // Coming to a right turn from the left cart.TurnRight(yOffset); } else if (currentRail == '\\') { // Coming to a left turn from the bottom cart.TurnLeft(yOffset); } else if (currentRail == '+') { switch (cart.NextIntersectionBehavior % 3) { case 0: cart.TurnLeft(yOffset); break; case 2: cart.TurnRight(yOffset); break; } cart.NextIntersectionBehavior++; } }
public static void TurnRight(this Minecart cart, int yOffset) { cart.TurnLeft(yOffset); cart.NextMove *= -1; }