Mathw.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace WorldComposer
  5. {
  6. static public class Mathw
  7. {
  8. const double minLatitude = -85.05113f;
  9. const double maxLatitude = 85.05113f;
  10. const double minLongitude = -180;
  11. const double maxLongitude = 180;
  12. static public void Swap<T>(ref T item1, ref T item2)
  13. {
  14. T temp = item1;
  15. item1 = item2;
  16. item2 = temp;
  17. }
  18. static public Vector2 calc_rect_allign(Rect rect, Vector2 size, int mode)
  19. {
  20. Vector2 result = new Vector2();
  21. if (mode == 1)
  22. {
  23. result.x = rect.x;
  24. result.y = rect.y;
  25. }
  26. else if (mode == 2)
  27. {
  28. result.x = rect.x + rect.width / 2 - size.x / 2;
  29. result.y = rect.yMax;
  30. }
  31. else if (mode == 3)
  32. {
  33. result.x = rect.x;
  34. result.y = rect.yMax;
  35. }
  36. else if (mode == 4)
  37. {
  38. result.x = rect.x + rect.width / 2 - size.x / 2;
  39. result.y = rect.y + rect.height / 2 - size.y / 2;
  40. }
  41. else if (mode == 5)
  42. {
  43. result.x = rect.xMax - size.x;
  44. result.y = rect.y;
  45. }
  46. else if (mode == 6)
  47. {
  48. result.x = rect.x + rect.width / 2 - size.x / 2;
  49. result.y = rect.y - size.y;
  50. }
  51. return result;
  52. }
  53. static public Vector2 calc_rotation_pixel(float x, float y, float xx, float yy, float rotation)
  54. {
  55. Vector2 result = new Vector2(x - xx, y - yy);
  56. float magnitude = result.magnitude;
  57. if (magnitude != 0)
  58. {
  59. result.x /= magnitude;
  60. result.y /= magnitude;
  61. }
  62. float num = Mathf.Acos(result.x);
  63. if (result.y < 0)
  64. {
  65. num = Mathf.PI * 2 - num;
  66. }
  67. num -= rotation * 0.0174532924f;
  68. result.x = Mathf.Cos(num) * magnitude + xx;
  69. result.y = Mathf.Sin(num) * magnitude + yy;
  70. return result;
  71. }
  72. static public double clip(double n, double minValue, double maxValue)
  73. {
  74. return calcMin(calcMax(n, minValue), maxValue);
  75. }
  76. static public latlong_class clip_latlong(latlong_class latlong)
  77. {
  78. if (latlong.latitude > maxLatitude)
  79. {
  80. latlong.latitude -= maxLatitude * 2;
  81. }
  82. else if (latlong.latitude < minLatitude)
  83. {
  84. latlong.latitude += maxLatitude * 2;
  85. }
  86. if (latlong.longitude > maxLongitude)
  87. {
  88. latlong.longitude -= 360;
  89. }
  90. else if (latlong.longitude < minLongitude)
  91. {
  92. latlong.longitude += 360;
  93. }
  94. return latlong;
  95. }
  96. static public map_pixel_class clip_pixel(map_pixel_class map_pixel, double zoom)
  97. {
  98. double num = 256 * Mathf.Pow(2, (float)zoom);
  99. if (map_pixel.x > num - 1)
  100. {
  101. map_pixel.x -= num - 1;
  102. }
  103. else if (map_pixel.x < 0)
  104. {
  105. map_pixel.x = num - 1 - map_pixel.x;
  106. }
  107. if (map_pixel.y > num - 1)
  108. {
  109. map_pixel.y -= num - 1;
  110. }
  111. else if (map_pixel.y < 0)
  112. {
  113. map_pixel.y = num - 1 - map_pixel.y;
  114. }
  115. return map_pixel;
  116. }
  117. static public double calcMin(double a, double b)
  118. {
  119. return (a >= b) ? b : a;
  120. }
  121. static public double calcMax(double a, double b)
  122. {
  123. return (a <= b) ? b : a;
  124. }
  125. static public int mapSize(int zoom)
  126. {
  127. return (int)(Mathf.Pow(2, zoom) * 256);
  128. }
  129. static public Vector2 latlong_to_pixel(latlong_class latlong, latlong_class latlong_center, double zoom, Vector2 screen_resolution)
  130. {
  131. latlong = clip_latlong(latlong);
  132. latlong_center = clip_latlong(latlong_center);
  133. double num = 3.14159274f;
  134. double num2 = (latlong.longitude + 180) / 360;
  135. double num3 = Mathf.Sin((float)(latlong.latitude * num / 180));
  136. double num4 = 0.5f - Mathf.Log((float)((1 + num3) / (1 - num3))) / (4 * num);
  137. Vector2 vector = new Vector2((float)num2, (float)num4);
  138. num2 = (latlong_center.longitude + 180) / 360;
  139. num3 = Mathf.Sin((float)(latlong_center.latitude * num / 180));
  140. num4 = 0.5f - Mathf.Log((float)((1 + num3) / (1 - num3))) / (4 * num);
  141. Vector2 vector2 = new Vector2((float)num2, (float)num4);
  142. Vector2 vector3 = vector - vector2;
  143. vector3 *= 256 * Mathf.Pow(2, (float)zoom);
  144. return vector3 + screen_resolution / 2;
  145. }
  146. static public map_pixel_class latlong_to_pixel2(latlong_class latlong, double zoom)
  147. {
  148. latlong = clip_latlong(latlong);
  149. double num = 3.14159274f;
  150. double num2 = (latlong.longitude + 180f) / 360f;
  151. double num3 = Mathf.Sin((float)(latlong.latitude * num / 180f));
  152. double num4 = 0.5f - Mathf.Log((float)((1f + num3) / (1f - num3))) / (4f * num);
  153. num2 *= 256f * Mathf.Pow(2f, (float)zoom);
  154. num4 *= 256f * Mathf.Pow(2f, (float)zoom);
  155. return new map_pixel_class
  156. {
  157. x = num2,
  158. y = num4
  159. };
  160. }
  161. static public latlong_class pixel_to_latlong2(map_pixel_class map_pixel, double zoom)
  162. {
  163. map_pixel = clip_pixel(map_pixel, zoom);
  164. double num = 3.14159274f;
  165. double num2 = 256f * Mathf.Pow(2f, (float)zoom);
  166. double num3 = map_pixel.x / num2 - 0.5f;
  167. double num4 = 0.5f - map_pixel.y / num2;
  168. return new latlong_class
  169. {
  170. latitude = 90f - 360f * Mathf.Atan(Mathf.Exp((float)(-(float)num4 * (double)2f * num))) / num,
  171. longitude = 360f * num3
  172. };
  173. }
  174. static public latlong_class pixel_to_latlong(Vector2 offset, latlong_class latlong_center, double zoom)
  175. {
  176. double num = 3.14159274f;
  177. double num2 = 256 * Mathf.Pow(2, (float)zoom);
  178. map_pixel_class map_pixel_class = latlong_to_pixel2(latlong_center, zoom);
  179. map_pixel_class map_pixel_class2 = new map_pixel_class();
  180. map_pixel_class2.x = map_pixel_class.x + offset.x;
  181. map_pixel_class2.y = map_pixel_class.y + offset.y;
  182. double num3 = map_pixel_class2.x / num2 - 0.5f;
  183. double num4 = 0.5f - map_pixel_class2.y / num2;
  184. return clip_latlong(new latlong_class
  185. {
  186. latitude = 90 - 360 * Mathf.Atan(Mathf.Exp((float)(-(float)num4 * (double)2 * num))) / num,
  187. longitude = 360 * num3
  188. });
  189. }
  190. static public map_pixel_class calc_latlong_area_size(latlong_class latlong1, latlong_class latlong2, latlong_class latlong_center)
  191. {
  192. double num = 3.14159274f;
  193. map_pixel_class map_pixel_class = latlong_to_pixel2(latlong1, 19);
  194. map_pixel_class map_pixel_class2 = latlong_to_pixel2(latlong2, 19);
  195. double num2 = 156543.047f * Mathf.Cos((float)(latlong_center.latitude * (num / 180))) / Mathf.Pow(2, 19);
  196. return new map_pixel_class
  197. {
  198. x = (map_pixel_class2.x - map_pixel_class.x) * num2,
  199. y = (map_pixel_class2.y - map_pixel_class.y) * num2
  200. };
  201. }
  202. static public double calc_latlong_area_resolution(latlong_class latlong, double zoom)
  203. {
  204. double num = 3.14159274f;
  205. return 156543.047f * Mathf.Cos((float)(latlong.latitude * (num / 180))) / Mathf.Pow(2, (float)zoom);
  206. }
  207. static public latlong_area_class calc_latlong_area_rounded(latlong_class latlong1, latlong_class latlong2, double zoom, int resolution, bool square, int mode)
  208. {
  209. map_pixel_class map_pixel_class = latlong_to_pixel2(latlong1, zoom);
  210. map_pixel_class map_pixel_class2 = latlong_to_pixel2(latlong2, zoom);
  211. map_pixel_class map_pixel_class3 = new map_pixel_class();
  212. map_pixel_class3.x = Mathf.Round((float)((map_pixel_class2.x - map_pixel_class.x) / resolution)) * resolution;
  213. if (square)
  214. {
  215. map_pixel_class3.y = map_pixel_class3.x;
  216. }
  217. else
  218. {
  219. map_pixel_class3.y = Mathf.Round((float)((map_pixel_class2.y - map_pixel_class.y) / resolution)) * resolution;
  220. }
  221. if (mode == 1)
  222. {
  223. if (map_pixel_class.x > map_pixel_class2.x - resolution)
  224. {
  225. map_pixel_class.x = map_pixel_class2.x - resolution;
  226. }
  227. else
  228. {
  229. map_pixel_class.x = map_pixel_class2.x - map_pixel_class3.x;
  230. }
  231. }
  232. else if (mode == 2)
  233. {
  234. if (map_pixel_class2.x < map_pixel_class.x + resolution)
  235. {
  236. map_pixel_class2.x = map_pixel_class.x + resolution;
  237. }
  238. else
  239. {
  240. map_pixel_class2.x = map_pixel_class.x + map_pixel_class3.x;
  241. }
  242. }
  243. else if (mode == 3)
  244. {
  245. if (map_pixel_class.y > map_pixel_class2.y - resolution)
  246. {
  247. map_pixel_class.y = map_pixel_class2.y - resolution;
  248. }
  249. else
  250. {
  251. map_pixel_class.y = map_pixel_class2.y - map_pixel_class3.y;
  252. }
  253. }
  254. else if (mode == 4)
  255. {
  256. if (map_pixel_class2.y < map_pixel_class.y + resolution)
  257. {
  258. map_pixel_class2.y = map_pixel_class.y + resolution;
  259. }
  260. else
  261. {
  262. map_pixel_class2.y = map_pixel_class.y + map_pixel_class3.y;
  263. }
  264. }
  265. else if (mode == 5)
  266. {
  267. if (map_pixel_class.x > map_pixel_class2.x - resolution)
  268. {
  269. map_pixel_class.x = map_pixel_class2.x - resolution;
  270. }
  271. else
  272. {
  273. map_pixel_class.x = map_pixel_class2.x - map_pixel_class3.x;
  274. }
  275. if (map_pixel_class.y > map_pixel_class2.y - resolution)
  276. {
  277. map_pixel_class.y = map_pixel_class2.y - resolution;
  278. }
  279. else
  280. {
  281. map_pixel_class.y = map_pixel_class2.y - map_pixel_class3.y;
  282. }
  283. }
  284. else if (mode == 6)
  285. {
  286. if (map_pixel_class2.x < map_pixel_class.x + resolution)
  287. {
  288. map_pixel_class2.x = map_pixel_class.x + resolution;
  289. }
  290. else
  291. {
  292. map_pixel_class2.x = map_pixel_class.x + map_pixel_class3.x;
  293. }
  294. if (map_pixel_class.y > map_pixel_class2.y - resolution)
  295. {
  296. map_pixel_class.y = map_pixel_class2.y - resolution;
  297. }
  298. else
  299. {
  300. map_pixel_class.y = map_pixel_class2.y - map_pixel_class3.y;
  301. }
  302. }
  303. else if (mode == 7)
  304. {
  305. if (map_pixel_class.x > map_pixel_class2.x - resolution)
  306. {
  307. map_pixel_class.x = map_pixel_class2.x - resolution;
  308. }
  309. else
  310. {
  311. map_pixel_class.x = map_pixel_class2.x - map_pixel_class3.x;
  312. }
  313. if (map_pixel_class2.y < map_pixel_class.y + resolution)
  314. {
  315. map_pixel_class2.y = map_pixel_class.y + resolution;
  316. }
  317. else
  318. {
  319. map_pixel_class2.y = map_pixel_class.y + map_pixel_class3.y;
  320. }
  321. }
  322. else if (mode == 8)
  323. {
  324. if (map_pixel_class2.x - resolution < map_pixel_class.x)
  325. {
  326. map_pixel_class2.x = map_pixel_class.x + resolution;
  327. }
  328. else
  329. {
  330. map_pixel_class2.x = map_pixel_class.x + map_pixel_class3.x;
  331. }
  332. if (map_pixel_class2.y - resolution < map_pixel_class.y)
  333. {
  334. map_pixel_class2.y = map_pixel_class.y + resolution;
  335. }
  336. else
  337. {
  338. map_pixel_class2.y = map_pixel_class.y + map_pixel_class3.y;
  339. }
  340. }
  341. return new latlong_area_class
  342. {
  343. latlong1 = pixel_to_latlong2(map_pixel_class, zoom),
  344. latlong2 = pixel_to_latlong2(map_pixel_class2, zoom)
  345. };
  346. }
  347. static public tile_class calc_latlong_area_tiles(latlong_class latlong1, latlong_class latlong2, double zoom, int resolution)
  348. {
  349. tile_class tile_class = new tile_class();
  350. map_pixel_class map_pixel_class = latlong_to_pixel2(latlong1, zoom);
  351. map_pixel_class map_pixel_class2 = latlong_to_pixel2(latlong2, zoom);
  352. tile_class.x = (int)Mathf.Round((float)((map_pixel_class2.x - map_pixel_class.x) / resolution));
  353. tile_class.y = (int)Mathf.Round((float)((map_pixel_class2.y - map_pixel_class.y) / resolution));
  354. return tile_class;
  355. }
  356. static public latlong_class calc_latlong_center(latlong_class latlong1, latlong_class latlong2, double zoom, Vector2 screen_resolution)
  357. {
  358. map_pixel_class map_pixel_class = latlong_to_pixel2(latlong1, zoom);
  359. map_pixel_class map_pixel_class2 = latlong_to_pixel2(latlong2, zoom);
  360. return pixel_to_latlong2(new map_pixel_class
  361. {
  362. x = (map_pixel_class.x + map_pixel_class2.x) / 2,
  363. y = (map_pixel_class.y + map_pixel_class2.y) / 2
  364. }, zoom);
  365. }
  366. #if UNITY_EDITOR
  367. static public void calc_latlong_area_from_center(map_area_class area, latlong_class center, double zoom, Vector2 resolution)
  368. {
  369. map_pixel_class map_pixel_class = latlong_to_pixel2(area.center, zoom);
  370. map_pixel_class map_pixel_class2 = latlong_to_pixel2(center, zoom);
  371. map_pixel_class map_pixel_class3 = latlong_to_pixel2(area.upper_left, zoom);
  372. map_pixel_class map_pixel_class4 = latlong_to_pixel2(area.lower_right, zoom);
  373. map_pixel_class map_pixel_class5 = new map_pixel_class();
  374. map_pixel_class5.x = map_pixel_class2.x - map_pixel_class.x;
  375. map_pixel_class5.y = map_pixel_class2.y - map_pixel_class.y;
  376. map_pixel_class3.x += map_pixel_class5.x;
  377. map_pixel_class3.y += map_pixel_class5.y;
  378. map_pixel_class4.x = map_pixel_class3.x + resolution.x;
  379. map_pixel_class4.y = map_pixel_class3.y + resolution.y;
  380. area.upper_left = pixel_to_latlong2(map_pixel_class3, zoom);
  381. area.lower_right = pixel_to_latlong2(map_pixel_class4, zoom);
  382. area.center = center;
  383. }
  384. static public void calc_latlong1_area_from_center(map_area_class area, latlong_class center, double zoom)
  385. {
  386. map_pixel_class map_pixel_class = latlong_to_pixel2(area.upper_left, zoom);
  387. map_pixel_class map_pixel_class2 = latlong_to_pixel2(center, zoom);
  388. map_pixel_class map_pixel_class3 = latlong_to_pixel2(area.center, zoom);
  389. map_pixel_class map_pixel_class4 = latlong_to_pixel2(area.lower_right, zoom);
  390. map_pixel_class map_pixel_class5 = new map_pixel_class();
  391. map_pixel_class5.x = map_pixel_class2.x - map_pixel_class.x;
  392. map_pixel_class5.y = map_pixel_class2.y - map_pixel_class.y;
  393. map_pixel_class3.x += map_pixel_class5.x;
  394. map_pixel_class3.y += map_pixel_class5.y;
  395. map_pixel_class4.x += map_pixel_class5.x;
  396. map_pixel_class4.y += map_pixel_class5.y;
  397. area.upper_left = center;
  398. area.center = pixel_to_latlong2(map_pixel_class3, zoom);
  399. area.lower_right = pixel_to_latlong2(map_pixel_class4, zoom);
  400. }
  401. static public void calc_latlong2_area_from_center(map_area_class area, latlong_class center, double zoom)
  402. {
  403. map_pixel_class map_pixel_class = latlong_to_pixel2(area.lower_right, zoom);
  404. map_pixel_class map_pixel_class2 = latlong_to_pixel2(center, zoom);
  405. map_pixel_class map_pixel_class3 = latlong_to_pixel2(area.center, zoom);
  406. map_pixel_class map_pixel_class4 = latlong_to_pixel2(area.upper_left, zoom);
  407. map_pixel_class map_pixel_class5 = new map_pixel_class();
  408. map_pixel_class5.x = map_pixel_class2.x - map_pixel_class.x;
  409. map_pixel_class5.y = map_pixel_class2.y - map_pixel_class.y;
  410. map_pixel_class3.x += map_pixel_class5.x;
  411. map_pixel_class3.y += map_pixel_class5.y;
  412. map_pixel_class4.x += map_pixel_class5.x;
  413. map_pixel_class4.y += map_pixel_class5.y;
  414. area.lower_right = center;
  415. area.center = pixel_to_latlong2(map_pixel_class3, zoom);
  416. area.upper_left = pixel_to_latlong2(map_pixel_class4, zoom);
  417. }
  418. #endif
  419. static public Vector2 calc_pixel_zoom(Vector2 pixel, double zoom, double current_zoom, Vector2 screen_resolution)
  420. {
  421. double num = Mathf.Pow(2, (float)(zoom - current_zoom));
  422. Vector2 vector = pixel - screen_resolution;
  423. vector *= (float)num;
  424. return vector + screen_resolution;
  425. }
  426. static public latlong_area_class calc_latlong_area_by_tile(latlong_class latlong, tile_class tile, double zoom, int resolution, Vector2 bresolution, Vector2 offset)
  427. {
  428. float num = Mathf.Pow(2, (float)(19 - zoom));
  429. zoom = 19;
  430. resolution = (int)(resolution * num);
  431. bresolution *= num;
  432. latlong_area_class latlong_area_class = new latlong_area_class();
  433. map_pixel_class map_pixel_class = latlong_to_pixel2(latlong, zoom);
  434. Vector2 vector = new Vector2(0, 0);
  435. map_pixel_class.x += tile.x * resolution + offset.x;
  436. map_pixel_class.y += tile.y * resolution + offset.y;
  437. if (tile.x > 0)
  438. {
  439. map_pixel_class.x += num;
  440. vector.x = num;
  441. }
  442. if (tile.y > 0)
  443. {
  444. map_pixel_class.y += num;
  445. vector.y = num;
  446. }
  447. latlong_class latlong_class = pixel_to_latlong2(map_pixel_class, zoom);
  448. latlong_area_class.latlong1 = latlong_class;
  449. map_pixel_class.x += bresolution.x - vector.x;
  450. map_pixel_class.y += bresolution.y - vector.y;
  451. latlong_class = pixel_to_latlong2(map_pixel_class, zoom);
  452. latlong_area_class.latlong2 = latlong_class;
  453. return latlong_area_class;
  454. }
  455. static public latlong_area_class calc_latlong_area_by_tile2(latlong_class latlong, tile_class tile, double zoom, int resolution, Vector2 bresolution)
  456. {
  457. latlong_area_class latlong_area_class = new latlong_area_class();
  458. map_pixel_class map_pixel_class = latlong_to_pixel2(latlong, zoom);
  459. map_pixel_class.x += tile.x * resolution;
  460. map_pixel_class.y += tile.y * resolution;
  461. latlong_class latlong_class = pixel_to_latlong2(map_pixel_class, zoom);
  462. latlong_area_class.latlong1 = latlong_class;
  463. map_pixel_class.x += bresolution.x;
  464. map_pixel_class.y += bresolution.y;
  465. latlong_class = pixel_to_latlong2(map_pixel_class, zoom);
  466. latlong_area_class.latlong2 = latlong_class;
  467. return latlong_area_class;
  468. }
  469. static public latlong_class calc_latlong_center_by_tile(latlong_class latlong, tile_class tile, tile_class subtile, tile_class subtiles, double zoom, int resolution, Vector2 offset)
  470. {
  471. float num = Mathf.Pow(2, (float)(19 - zoom));
  472. zoom = 19;
  473. resolution = (int)(resolution * num);
  474. map_pixel_class map_pixel_class = latlong_to_pixel2(latlong, zoom);
  475. map_pixel_class.x += tile.x * subtiles.x * resolution + subtile.x * resolution;
  476. map_pixel_class.y += tile.y * subtiles.y * resolution + subtile.y * resolution;
  477. map_pixel_class.x += resolution / 2 + offset.x;
  478. map_pixel_class.y += resolution / 2 + offset.y;
  479. return pixel_to_latlong2(map_pixel_class, zoom);
  480. }
  481. static public int calc_rest_value(float value1, float divide)
  482. {
  483. int num = (int)(value1 / divide);
  484. return (int)(value1 - num * divide);
  485. }
  486. static public map_pixel_class calc_latlong_to_mercator(latlong_class latlong)
  487. {
  488. map_pixel_class map_pixel_class = new map_pixel_class();
  489. map_pixel_class.x = latlong.latitude * 20037508f / 180;
  490. map_pixel_class.y = Mathf.Log(Mathf.Tan((float)((90 + latlong.longitude) * 3.14159274f / 360))) / 0.0174532924f;
  491. map_pixel_class.y = map_pixel_class.y * 20037508f / 180;
  492. return map_pixel_class;
  493. }
  494. static public latlong_class calc_mercator_to_latlong(map_pixel_class pixel)
  495. {
  496. latlong_class latlong_class = new latlong_class();
  497. latlong_class.longitude = pixel.x / 20037508f * 180;
  498. latlong_class.latitude = pixel.y / 20037508f * 180;
  499. latlong_class.latitude = 57.2957764f * (2 * Mathf.Atan(Mathf.Exp((float)(latlong_class.latitude * 3.14159274f / 180))) - 1.57079637f);
  500. return latlong_class;
  501. }
  502. static public tile_class calc_terrain_tile(int terrain_index, tile_class tiles)
  503. {
  504. tile_class tile_class = new tile_class();
  505. tile_class.y = terrain_index / tiles.x;
  506. tile_class.x = terrain_index - tile_class.y * tiles.x;
  507. return tile_class;
  508. }
  509. }
  510. }