Classes.cs 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Reflection;
  4. using System.IO;
  5. using UnityEngine;
  6. #if UNITY_EDITOR
  7. using UnityEditor;
  8. #endif
  9. namespace WorldComposer
  10. {
  11. #if UNITY_EDITOR
  12. [Serializable]
  13. public class area_class
  14. {
  15. public bool active;
  16. public bool foldout;
  17. public Rect area;
  18. public Rect area_old;
  19. public Rect area_max;
  20. public Vector2 center;
  21. public Vector2 image_offset;
  22. public Vector3 rotation;
  23. public bool rotation_active;
  24. public bool link_start;
  25. public bool link_end;
  26. public float resolution;
  27. public float custom_resolution;
  28. public Vector2 step;
  29. public Vector2 step_old;
  30. public Vector2 conversion_step;
  31. public resolution_mode_enum resolution_mode;
  32. public string resolution_mode_text;
  33. public string resolution_tooltip_text;
  34. public int tree_resolution;
  35. public int object_resolution;
  36. public int colormap_resolution;
  37. public bool tree_resolution_active;
  38. public bool object_resolution_active;
  39. public area_class()
  40. {
  41. active = true;
  42. link_start = true;
  43. link_end = true;
  44. resolution_mode = resolution_mode_enum.Automatic;
  45. tree_resolution = 128;
  46. object_resolution = 32;
  47. colormap_resolution = 2048;
  48. }
  49. public void max()
  50. {
  51. area = area_max;
  52. }
  53. public Rect round_area_to_step(Rect area1)
  54. {
  55. area1.xMin = Mathf.Round(area1.xMin / step.x) * step.x;
  56. area1.xMax = Mathf.Round(area1.xMax / step.x) * step.x;
  57. area1.yMin = Mathf.Round(area1.yMin / step.y) * step.y;
  58. area1.yMax = Mathf.Round(area1.yMax / step.y) * step.y;
  59. return area1;
  60. }
  61. public void set_resolution_mode_text()
  62. {
  63. if (area == area_max)
  64. {
  65. resolution_mode_text = "M";
  66. resolution_tooltip_text = "Maximum Area Selected";
  67. }
  68. else
  69. {
  70. resolution_mode_text = "C";
  71. resolution_tooltip_text = "Custum Area Selected";
  72. }
  73. if (resolution_mode == resolution_mode_enum.Automatic)
  74. {
  75. resolution_mode_text += "-> A";
  76. resolution_tooltip_text += "\n\nStep Mode is on Automatic";
  77. }
  78. else if (resolution_mode == resolution_mode_enum.Heightmap)
  79. {
  80. resolution_mode_text += "-> H";
  81. resolution_tooltip_text += "\n\nStep Mode is on Heightmap";
  82. }
  83. else if (resolution_mode == resolution_mode_enum.Splatmap)
  84. {
  85. resolution_mode_text += "-> S";
  86. resolution_tooltip_text += "\n\nStep Mode is on Splatmap";
  87. }
  88. else if (resolution_mode == resolution_mode_enum.Detailmap)
  89. {
  90. resolution_mode_text += "-> D";
  91. resolution_tooltip_text += "\n\nStep Mode is on Detailmap";
  92. }
  93. else if (resolution_mode == resolution_mode_enum.Tree)
  94. {
  95. resolution_mode_text += "-> T";
  96. resolution_tooltip_text += "\n\nStep Mode is on Tree";
  97. }
  98. else if (resolution_mode == resolution_mode_enum.Object)
  99. {
  100. resolution_mode_text += "-> O";
  101. resolution_tooltip_text += "\n\nStep Mode is on Object";
  102. }
  103. else if (resolution_mode == resolution_mode_enum.Units)
  104. {
  105. resolution_mode_text += "-> U";
  106. resolution_tooltip_text += "\n\nStep Mode is on Units";
  107. }
  108. else if (resolution_mode == resolution_mode_enum.Custom)
  109. {
  110. resolution_mode_text += "-> C";
  111. resolution_tooltip_text += "\n\nStep Mode is on Custom";
  112. }
  113. }
  114. }
  115. [Serializable]
  116. public class auto_search_class
  117. {
  118. public string path_full;
  119. public string path;
  120. public bool foldout;
  121. public bool custom;
  122. public int digits;
  123. public string format;
  124. public string filename;
  125. public string fullname;
  126. public string name;
  127. public string extension;
  128. public int start_x;
  129. public int start_y;
  130. public int start_n;
  131. public int count_x;
  132. public int count_y;
  133. public bool display;
  134. public int select_index;
  135. public Rect menu_rect;
  136. public string output_format;
  137. public auto_search_class()
  138. {
  139. path_full = string.Empty;
  140. path = string.Empty;
  141. digits = 1;
  142. format = "%n";
  143. filename = "tile";
  144. extension = ".raw";
  145. start_n = 1;
  146. count_x = 1;
  147. count_y = 1;
  148. select_index = -1;
  149. output_format = "1";
  150. }
  151. public void set_output_format()
  152. {
  153. if (digits < 1)
  154. {
  155. digits = 1;
  156. }
  157. string text = new string("0"[0], digits);
  158. output_format = format.Replace("%x", start_x.ToString(text));
  159. output_format = output_format.Replace("%y", start_y.ToString(text));
  160. output_format = output_format.Replace("%n", start_n.ToString(text));
  161. }
  162. public bool strip_file()
  163. {
  164. string text = new string("0"[0], digits);
  165. string text2 = format.Replace("%x", start_x.ToString(text));
  166. text2 = text2.Replace("%y", start_y.ToString(text));
  167. text2 = text2.Replace("%n", start_n.ToString(text));
  168. if (path_full.Length == 0) return false;
  169. path = Path.GetDirectoryName(path_full);
  170. filename = Path.GetFileNameWithoutExtension(path_full);
  171. filename = filename.Replace(text2, string.Empty);
  172. extension = Path.GetExtension(path_full);
  173. return true;
  174. }
  175. public void strip_name()
  176. {
  177. string text = new string("0"[0], digits);
  178. string text2 = format.Replace("%x", start_x.ToString(text));
  179. text2 = text2.Replace("%y", start_y.ToString(text));
  180. text2 = text2.Replace("%n", start_n.ToString(text));
  181. name = fullname;
  182. if (text2.Length > 0)
  183. {
  184. name = name.Replace(text2, string.Empty);
  185. }
  186. }
  187. public string get_file(int count_x, int count_y, int count_n)
  188. {
  189. string text = new string("0"[0], digits);
  190. string text2 = format.Replace("%x", (count_x + start_x).ToString(text));
  191. text2 = text2.Replace("%y", (count_y + start_y).ToString(text));
  192. text2 = text2.Replace("%n", (count_n + start_n).ToString(text));
  193. return path + "/" + filename + text2 + extension;
  194. }
  195. public string get_name(int count_x, int count_y, int count_n)
  196. {
  197. string text = new string("0"[0], digits);
  198. string text2 = format.Replace("%x", (count_x + start_x).ToString(text));
  199. text2 = text2.Replace("%y", (count_y + start_y).ToString(text));
  200. text2 = text2.Replace("%n", (count_n + start_n).ToString(text));
  201. return name + text2;
  202. }
  203. }
  204. [Serializable]
  205. public class BitmapData
  206. {
  207. public int height;
  208. public int width;
  209. private Color[] pixels;
  210. public BitmapData(Texture2D texture)
  211. {
  212. height = texture.height;
  213. width = texture.width;
  214. pixels = texture.GetPixels();
  215. }
  216. public Color getPixelColor(int x, int y)
  217. {
  218. if (x >= width)
  219. {
  220. x = width - 1;
  221. }
  222. if (y >= height)
  223. {
  224. y = height - 1;
  225. }
  226. if (x < 0)
  227. {
  228. x = 0;
  229. }
  230. if (y < 0)
  231. {
  232. y = 0;
  233. }
  234. return pixels[y * width + x];
  235. }
  236. }
  237. [Serializable]
  238. public class BitString
  239. {
  240. public int len;
  241. public int val;
  242. }
  243. [Serializable]
  244. public class buffer_class
  245. {
  246. public FileStream file;
  247. public Vector2 resolution;
  248. [NonSerialized] public byte[] bytes;
  249. public ulong length;
  250. public Vector2 size;
  251. public tile_class tiles;
  252. public ulong pos;
  253. public ulong row;
  254. public Rect innerRect;
  255. public Rect outerRect;
  256. public Vector2 offset;
  257. public int radius;
  258. public buffer_class()
  259. {
  260. tiles = new tile_class();
  261. }
  262. public void init()
  263. {
  264. tiles.x = (int)Mathf.Ceil(resolution.x / size.x);
  265. tiles.y = (int)Mathf.Ceil(resolution.x / size.y);
  266. row = (ulong)(resolution.x * 3);
  267. }
  268. public void getRects(tile_class tile)
  269. {
  270. int num = radius + 20;
  271. innerRect.x = tile.x * size.x - 5;
  272. innerRect.y = tile.y * size.y - 5;
  273. innerRect.width = size.x + 10;
  274. innerRect.height = size.y + 10;
  275. if (innerRect.xMin < 0)
  276. {
  277. innerRect.xMin = 0;
  278. }
  279. if (innerRect.yMin < 0)
  280. {
  281. innerRect.yMin = 0;
  282. }
  283. if (innerRect.xMax > resolution.x)
  284. {
  285. innerRect.xMax = resolution.x;
  286. }
  287. if (innerRect.yMax > resolution.y)
  288. {
  289. innerRect.yMax = resolution.y;
  290. }
  291. outerRect.xMin = innerRect.xMin - num;
  292. outerRect.yMin = innerRect.yMin - num;
  293. outerRect.xMax = innerRect.xMax + num;
  294. outerRect.yMax = innerRect.yMax + num;
  295. if (outerRect.xMin < 0)
  296. {
  297. outerRect.xMin = 0;
  298. }
  299. else if (outerRect.xMax > resolution.x)
  300. {
  301. outerRect.xMax = resolution.x;
  302. }
  303. if (outerRect.yMin < 0)
  304. {
  305. outerRect.yMin = 0;
  306. }
  307. else if (outerRect.yMax > resolution.y)
  308. {
  309. outerRect.yMax = resolution.y;
  310. }
  311. length = (ulong)(outerRect.width * outerRect.height * 3);
  312. offset.x = innerRect.x - outerRect.x;
  313. offset.y = innerRect.y - outerRect.y;
  314. if (bytes == null)
  315. {
  316. bytes = new byte[(int)length];
  317. }
  318. if (bytes.Length != (long)length)
  319. {
  320. bytes = new byte[(int)length];
  321. }
  322. }
  323. public void read()
  324. {
  325. int num = 0;
  326. while (num < outerRect.height)
  327. {
  328. pos = (ulong)(row * outerRect.y + ((long)row * num) + outerRect.x * 3);
  329. file.Seek((long)pos, 0);
  330. file.Read(bytes, (int)(outerRect.width * num * 3), (int)(outerRect.width * 3));
  331. num++;
  332. }
  333. }
  334. public void write()
  335. {
  336. int num = 0;
  337. while (num < innerRect.height)
  338. {
  339. pos = (ulong)(row * innerRect.y + ((long)row * num) + innerRect.x * 3);
  340. file.Seek((long)pos, 0);
  341. file.Write(bytes, (int)(outerRect.width * num * 3 + outerRect.width * 3 * offset.y + offset.x * 3), (int)(innerRect.width * 3));
  342. num++;
  343. }
  344. }
  345. public void copy_bytes(byte[] bytes1, byte[] bytes2)
  346. {
  347. ulong num = 0;
  348. while ((long)num < bytes1.Length)
  349. {
  350. bytes2[(int)num] = bytes1[(int)num];
  351. num = (ulong)((long)num + (long)((ulong)1));
  352. }
  353. }
  354. public void clear_bytes()
  355. {
  356. ulong num = 0;
  357. while ((long)num < bytes.Length)
  358. {
  359. bytes[(int)num] = 0;
  360. num = (ulong)((long)num + (long)((ulong)1));
  361. }
  362. }
  363. }
  364. [Serializable]
  365. public class ByteArray
  366. {
  367. private MemoryStream stream;
  368. private BinaryWriter writer;
  369. public ByteArray()
  370. {
  371. stream = new MemoryStream();
  372. writer = new BinaryWriter(stream);
  373. }
  374. public void writeByte(byte value)
  375. {
  376. writer.Write(value);
  377. }
  378. public byte[] GetAllBytes()
  379. {
  380. byte[] array = new byte[(int)stream.Length];
  381. stream.Position = 0L;
  382. stream.Read(array, 0, array.Length);
  383. return array;
  384. }
  385. }
  386. [Serializable]
  387. public class color_settings_class
  388. {
  389. public Color backgroundColor;
  390. public bool backgroundActive;
  391. public Color color_description;
  392. public Color color_layer;
  393. public Color color_filter;
  394. public Color color_subfilter;
  395. public Color color_colormap;
  396. public Color color_splat;
  397. public Color color_tree;
  398. public Color color_tree_precolor_range;
  399. public Color color_tree_filter;
  400. public Color color_tree_subfilter;
  401. public Color color_grass;
  402. public Color color_object;
  403. public Color color_terrain;
  404. public color_settings_class()
  405. {
  406. backgroundColor = new Color(0, 0, 0, 0.5f);
  407. color_description = new Color(1, 0.45f, 0);
  408. color_layer = Color.yellow;
  409. color_filter = Color.cyan;
  410. color_subfilter = Color.green;
  411. color_colormap = Color.white;
  412. color_splat = Color.white;
  413. color_tree = new Color(1, 0.7f, 0.4f);
  414. color_tree_precolor_range = new Color(1, 0.84f, 0.64f);
  415. color_tree_filter = new Color(0.5f, 1, 1);
  416. color_tree_subfilter = new Color(0.5f, 1, 0.5f);
  417. color_grass = Color.white;
  418. color_object = Color.white;
  419. color_terrain = Color.white;
  420. }
  421. }
  422. [Serializable]
  423. public enum condition_output_enum
  424. {
  425. add,
  426. subtract,
  427. change,
  428. multiply,
  429. divide,
  430. difference,
  431. average,
  432. max,
  433. min
  434. }
  435. [Serializable]
  436. public class detail_class
  437. {
  438. public int[,] detail;
  439. }
  440. [Serializable]
  441. public class detailPrototype_class
  442. {
  443. public bool foldout;
  444. public GameObject prototype;
  445. public Texture2D previewTexture;
  446. public Texture2D prototypeTexture;
  447. public float minWidth;
  448. public float maxWidth;
  449. public float minHeight;
  450. public float maxHeight;
  451. public float noiseSpread;
  452. public float bendFactor;
  453. public Color healthyColor;
  454. public Color dryColor;
  455. public DetailRenderMode renderMode;
  456. public bool usePrototypeMesh;
  457. public detailPrototype_class()
  458. {
  459. minWidth = 1;
  460. maxWidth = 2;
  461. minHeight = 1;
  462. maxHeight = 2;
  463. noiseSpread = 0.1f;
  464. healthyColor = Color.white;
  465. dryColor = new Color(0.8f, 0.76f, 0.53f);
  466. renderMode = DetailRenderMode.Grass;
  467. }
  468. }
  469. [Serializable]
  470. public class edit_class
  471. {
  472. public string text;
  473. public string default_text;
  474. public bool edit;
  475. public bool disable_edit;
  476. public Rect rect;
  477. public edit_class()
  478. {
  479. text = string.Empty;
  480. default_text = string.Empty;
  481. }
  482. }
  483. [Serializable]
  484. public class ext_class
  485. {
  486. public WebRequest pull = new WebRequest();
  487. public bool loaded;
  488. // public bool converted;
  489. public int error;
  490. public tile_class tile;
  491. public tile_class subtile;
  492. public latlong_area_class latlong_area;
  493. public latlong_class latlong_center;
  494. public string url;
  495. public Vector2 bres;
  496. public int zero_error;
  497. public int download_error;
  498. public float startTime;
  499. public int index;
  500. public ext_class(int index)
  501. {
  502. this.index = index;
  503. tile = new tile_class();
  504. subtile = new tile_class();
  505. latlong_area = new latlong_area_class();
  506. latlong_center = new latlong_class();
  507. }
  508. }
  509. [Serializable]
  510. public class global_settings_class
  511. {
  512. public bool disableLightmapping = true;
  513. public bool undo;
  514. public bool positionSeed;
  515. public color_settings_class color;
  516. public bool color_scheme_display;
  517. public bool color_scheme;
  518. public bool toggle_text_no;
  519. public bool toggle_text_short;
  520. public bool toggle_text_long;
  521. public bool tooltip_text_no;
  522. public bool tooltip_text_short;
  523. public bool tooltip_text_long;
  524. public bool mac_mode;
  525. public int tooltip_mode;
  526. public WebRequest myExt = new WebRequest();
  527. public WebRequest myExt2 = new WebRequest();
  528. public WebRequest myExt3 = new WebRequest();
  529. public WebRequest myExt4 = new WebRequest();
  530. public bool restrict_resolutions;
  531. public bool load_terrain_data;
  532. public bool rtp;
  533. public bool video_help;
  534. public bool view_only_output;
  535. public float save_global_timer;
  536. public int downloading;
  537. public bool download_foldout;
  538. public bool download_display;
  539. public int downloading2;
  540. public bool download_foldout2;
  541. public bool download_display2;
  542. public WebRequest wc_contents = new WebRequest();
  543. public int wc_loading;
  544. public float old_version;
  545. public float new_version;
  546. public bool update_display;
  547. public bool update_display2;
  548. public bool update_version;
  549. public bool update_version2;
  550. public string[] update;
  551. public float time_out;
  552. public bool button_export;
  553. public bool button_measure;
  554. public bool button_capture;
  555. public bool button_tools;
  556. public bool button_tiles;
  557. public bool button_node;
  558. public bool button_world;
  559. public bool example_display;
  560. public int example_resolution;
  561. public Vector2 exampleTerrainTiles;
  562. public int example_terrain;
  563. public int example_terrain_old1;
  564. public bool example_tree_active;
  565. public bool example_grass_active;
  566. public bool example_object_active;
  567. public int example_buttons;
  568. public global_settings_class()
  569. {
  570. positionSeed = true;
  571. color = new color_settings_class();
  572. color_scheme = true;
  573. toggle_text_short = true;
  574. tooltip_text_long = true;
  575. tooltip_mode = 2;
  576. restrict_resolutions = true;
  577. video_help = true;
  578. view_only_output = true;
  579. save_global_timer = 5;
  580. download_foldout = true;
  581. download_display = true;
  582. download_foldout2 = true;
  583. download_display2 = true;
  584. update = new string[]
  585. {
  586. "Don't check",
  587. "Notify",
  588. "Download and notify",
  589. "Download,import and notify",
  590. "Download and import automatically"
  591. };
  592. button_export = true;
  593. button_measure = true;
  594. button_capture = true;
  595. button_tools = true;
  596. button_tiles = true;
  597. button_node = true;
  598. button_world = true;
  599. example_display = true;
  600. example_resolution = 3;
  601. exampleTerrainTiles = new Vector2(2, 2);
  602. example_terrain_old1 = -1;
  603. example_tree_active = true;
  604. example_grass_active = true;
  605. example_object_active = true;
  606. example_buttons = 1;
  607. }
  608. }
  609. [Serializable]
  610. public class map_area_class
  611. {
  612. public string name;
  613. public latlong_class upper_left;
  614. public latlong_class lower_right;
  615. public latlong_class center;
  616. public int center_height;
  617. public map_pixel_class size;
  618. public bool normalizeHeightmap;
  619. public float normalizedHeight;
  620. public bool created;
  621. public bool resize;
  622. public bool resize_left;
  623. public bool resize_right;
  624. public bool resize_top;
  625. public bool resize_bottom;
  626. public bool resize_topLeft;
  627. public bool resize_topRight;
  628. public bool resize_bottomLeft;
  629. public bool resize_bottomRight;
  630. public bool resize_center;
  631. public bool manual_area;
  632. public Vector2 heightmap_offset;
  633. public Vector2 heightmap_offset_e;
  634. public Vector2 image_offset_e;
  635. public bool image_stop_one;
  636. public int select;
  637. public float smooth_strength = 1;
  638. public float width;
  639. public float height;
  640. public Vector2 heightmap_resolution;
  641. public double heightmap_scale;
  642. public int heightmap_zoom;
  643. public int elevation_zoom;
  644. public bool heightmap_manual;
  645. public double area_resolution;
  646. public int resolution;
  647. public int image_zoom;
  648. public bool image_changed;
  649. public bool start_tile_enabled;
  650. public tile_class start_tile;
  651. public tile_class tiles;
  652. public bool export_heightmap_active;
  653. public bool export_heightmap_call;
  654. public string export_heightmap_path;
  655. public string export_heightmap_filename;
  656. public bool export_heightmap_changed;
  657. public bool export_heightmap_not_fit;
  658. public Vector2 export_heightmap_bres;
  659. public bool export_image_active;
  660. public bool export_image_call;
  661. public string export_image_path;
  662. public string export_image_filename;
  663. public bool export_image_changed;
  664. public bool export_image_import_settings;
  665. public bool export_image_world_file;
  666. public string export_terrain_path;
  667. public bool export_terrain_changed;
  668. public bool export_to_terraincomposer;
  669. public string import_heightmap_path_full;
  670. public bool filter_perlin;
  671. public string converter_source_path_full;
  672. public string converter_destination_path_full;
  673. public Vector2 converter_resolution;
  674. public float converter_height;
  675. public bool converter_import_heightmap;
  676. public string terrain_asset_name;
  677. public string terrain_scene_name;
  678. public bool terrain_name_changed;
  679. public float terrain_scale;
  680. public AnimationCurve terrain_curve;
  681. public bool do_heightmap;
  682. public bool do_image;
  683. public int terrain_heightmap_resolution_select;
  684. public int terrain_heightmap_resolution;
  685. public bool terrain_heightmap_resolution_changed;
  686. public bool mipmapEnabled;
  687. public bool terrain_done;
  688. public FilterMode filterMode;
  689. public int anisoLevel;
  690. public int maxTextureSize;
  691. public int maxTextureSize_select;
  692. public bool maxTextureSize_changed;
  693. public bool auto_import_settings_apply;
  694. public bool preimage_export_active;
  695. public bool preimage_apply;
  696. public bool preimage_save_new;
  697. public string preimage_path;
  698. public bool preimage_path_changed;
  699. public string preimage_filename;
  700. public int preimage_count;
  701. public TextureImporterFormat textureFormat;
  702. public map_area_class(string name, int index)
  703. {
  704. this.name = name + (index + 1);
  705. upper_left = new latlong_class();
  706. lower_right = new latlong_class();
  707. center = new latlong_class();
  708. size = new map_pixel_class();
  709. normalizeHeightmap = true;
  710. heightmap_offset = new Vector2(0, 0);
  711. smooth_strength = 1;
  712. resolution = 2048;
  713. image_zoom = 18;
  714. start_tile = new tile_class();
  715. tiles = new tile_class();
  716. export_heightmap_path = string.Empty;
  717. export_heightmap_filename = string.Empty;
  718. export_image_path = string.Empty;
  719. export_image_filename = string.Empty;
  720. export_terrain_path = string.Empty;
  721. export_to_terraincomposer = true;
  722. converter_source_path_full = string.Empty;
  723. converter_destination_path_full = string.Empty;
  724. converter_height = 10000;
  725. terrain_asset_name = string.Empty;
  726. terrain_scene_name = string.Empty;
  727. terrain_scale = 1;
  728. do_heightmap = true;
  729. do_image = true;
  730. mipmapEnabled = true;
  731. filterMode = FilterMode.Trilinear;
  732. anisoLevel = 9;
  733. maxTextureSize_select = 6;
  734. auto_import_settings_apply = true;
  735. preimage_path = string.Empty;
  736. terrain_curve = AnimationCurve.Linear(0, 0, 1, 1);
  737. terrain_curve.AddKey(1, 0);
  738. terrain_curve = set_curve_linear(terrain_curve);
  739. #if UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4
  740. textureFormat = TextureImporterFormat.AutomaticCompressed;
  741. #endif
  742. }
  743. public map_area_class GetShallowCopy()
  744. {
  745. return (map_area_class)MemberwiseClone();
  746. }
  747. public void reset()
  748. {
  749. upper_left.reset();
  750. lower_right.reset();
  751. center.reset();
  752. size.reset();
  753. }
  754. public AnimationCurve set_curve_linear(AnimationCurve curve)
  755. {
  756. AnimationCurve animationCurve = new AnimationCurve();
  757. for (int i = 0; i < curve.length; i++)
  758. {
  759. float inTangent = 0;
  760. float outTangent = 0;
  761. bool flag = false;
  762. bool flag2 = false;
  763. Vector2 vector = new Vector2();
  764. Vector2 vector2 = new Vector2();
  765. Vector2 vector3 = new Vector2();
  766. Keyframe keyframe = curve[i];
  767. if (i == 0)
  768. {
  769. inTangent = 0;
  770. flag = true;
  771. }
  772. if (i == curve.length - 1)
  773. {
  774. outTangent = 0;
  775. flag2 = true;
  776. }
  777. if (!flag)
  778. {
  779. vector.x = curve[i - 1].time;
  780. vector.y = curve[i - 1].value;
  781. vector2.x = curve[i].time;
  782. vector2.y = curve[i].value;
  783. vector3 = vector2 - vector;
  784. inTangent = vector3.y / vector3.x;
  785. }
  786. if (!flag2)
  787. {
  788. vector.x = curve[i].time;
  789. vector.y = curve[i].value;
  790. vector2.x = curve[i + 1].time;
  791. vector2.y = curve[i + 1].value;
  792. vector3 = vector2 - vector;
  793. outTangent = vector3.y / vector3.x;
  794. }
  795. keyframe.inTangent = inTangent;
  796. keyframe.outTangent = outTangent;
  797. animationCurve.AddKey(keyframe);
  798. }
  799. return animationCurve;
  800. }
  801. }
  802. [Serializable]
  803. public class map_class
  804. {
  805. public map_type_enum type;
  806. public bool discordClicked;
  807. public int timeOut;
  808. public bool active;
  809. public bool button_parameters;
  810. public bool button_image_editor;
  811. public bool button_region;
  812. public bool button_image_export;
  813. public bool button_heightmap_export;
  814. public bool button_converter;
  815. public bool button_settings;
  816. public bool button_create_terrain;
  817. public bool button_help;
  818. public bool button_update;
  819. public float alpha;
  820. public Color backgroundColor;
  821. public Color titleColor;
  822. public Color errorColor;
  823. public bool region_popup_edit;
  824. public bool area_popup_edit;
  825. public bool disable_region_popup_edit;
  826. public bool disable_area_popup_edit;
  827. public List<map_region_class> region;
  828. public string[] region_popup;
  829. public int region_select;
  830. public bool manual_edit;
  831. public Rect region_rect;
  832. public Rect area_rect;
  833. public preimage_edit_class preimage_edit;
  834. public Color color_fault;
  835. public FileStream file_tex2;
  836. public FileStream file_tex3;
  837. public bool tex_swapped;
  838. public tile_class tex2_tile;
  839. public tile_class tex3_tile;
  840. public WebRequest elExt_check = new WebRequest();
  841. public bool elExt_check_loaded;
  842. public bool elExt_check_assign;
  843. [NonSerialized] public List<ext_class> elExt;
  844. [NonSerialized] public List<ext_class> texExt;
  845. public int export_texExt;
  846. public int export_elExt;
  847. public int mode;
  848. public bool export_tex3;
  849. public bool export_tex2;
  850. [NonSerialized] public latlong_area_class export_heightmap_area;
  851. [NonSerialized] public latlong_area_class export_image_area;
  852. public tile_class export_pullIndex;
  853. public int export_pulled;
  854. public bool export_image_active;
  855. public bool export_heightmap_active;
  856. public int export_heightmap_zoom;
  857. public float export_heightmap_timeStart;
  858. public float export_heightmap_timeEnd;
  859. public float export_heightmap_timePause;
  860. public bool export_heightmap_continue;
  861. [NonSerialized] public map_export_class export_heightmap;
  862. [NonSerialized] public map_export_class export_image;
  863. public int export_image_zoom;
  864. public float export_image_timeStart;
  865. public float export_image_timeEnd;
  866. public float export_image_timePause;
  867. public bool export_image_continue;
  868. public int export_jpg_quality;
  869. public bool export_jpg;
  870. public bool export_png;
  871. public bool export_raw;
  872. public Color color;
  873. public bool key_edit;
  874. public List<map_key_class> bingKey;
  875. public int bingKey_selected;
  876. public float mouse_sensivity;
  877. public bool path_display;
  878. public bool warnings;
  879. public bool track_tile;
  880. public bool snap;
  881. public float snapValue;
  882. public map_class()
  883. {
  884. timeOut = 4;
  885. active = true;
  886. button_parameters = true;
  887. button_image_editor = true;
  888. button_region = true;
  889. button_image_export = true;
  890. button_heightmap_export = true;
  891. button_settings = true;
  892. alpha = 0.65f;
  893. errorColor = new Color(0.498039216f, 0.498039216f, 0.498039216f);
  894. region = new List<map_region_class>();
  895. preimage_edit = new preimage_edit_class();
  896. tex2_tile = new tile_class();
  897. tex3_tile = new tile_class();
  898. elExt = new List<ext_class>();
  899. texExt = new List<ext_class>();
  900. export_texExt = 8;
  901. export_elExt = 16;
  902. export_heightmap_area = new latlong_area_class();
  903. export_image_area = new latlong_area_class();
  904. export_pullIndex = new tile_class();
  905. export_heightmap_continue = true;
  906. export_heightmap = new map_export_class();
  907. export_image = new map_export_class();
  908. export_image_continue = true;
  909. export_jpg_quality = 100;
  910. export_jpg = true;
  911. color = Color.red;
  912. bingKey = new List<map_key_class>();
  913. mouse_sensivity = 2;
  914. warnings = true;
  915. track_tile = true;
  916. snapValue = 0.1f;
  917. make_region_popup();
  918. }
  919. public void make_region_popup()
  920. {
  921. region_popup = new string[region.Count];
  922. for (int i = 0; i < region.Count; i++)
  923. {
  924. region_popup[i] = region[i].name;
  925. }
  926. }
  927. }
  928. [Serializable]
  929. public class map_export_class
  930. {
  931. public bool last_tile;
  932. public tile_class tiles;
  933. public tile_class tile;
  934. public tile_class subtiles;
  935. public tile_class subtile;
  936. public int subtiles_total;
  937. public int subtile_total;
  938. public int subtile2_total;
  939. public float progress;
  940. public map_export_class()
  941. {
  942. tiles = new tile_class();
  943. tile = new tile_class();
  944. subtiles = new tile_class();
  945. subtile = new tile_class();
  946. }
  947. }
  948. [Serializable]
  949. public class map_key_class
  950. {
  951. public int pulls_startDay;
  952. public int pulls_startHour;
  953. public int pulls_startMinute;
  954. public int pulls;
  955. public string key;
  956. public void reset()
  957. {
  958. pulls = 0;
  959. pulls_startDay = DateTime.Now.Day;
  960. pulls_startHour = DateTime.Now.Hour;
  961. pulls_startMinute = DateTime.Now.Minute;
  962. }
  963. }
  964. [Serializable]
  965. public class map_region_class
  966. {
  967. public string name;
  968. public List<map_area_class> area;
  969. public string[] area_popup;
  970. public int area_select;
  971. public latlong_class center;
  972. public map_region_class(int index)
  973. {
  974. name = "Untitled";
  975. area = new List<map_area_class>();
  976. center = new latlong_class();
  977. name += index.ToString();
  978. }
  979. public map_region_class GetShallowCopy()
  980. {
  981. map_region_class region = (map_region_class)MemberwiseClone();
  982. region.area = new List<map_area_class>(area.Count);
  983. for (int i = 0; i < area.Count; i++)
  984. {
  985. region.area.Add(area[i].GetShallowCopy());
  986. }
  987. return region;
  988. }
  989. public void make_area_popup()
  990. {
  991. area_popup = new string[area.Count];
  992. for (int i = 0; i < area.Count; i++)
  993. {
  994. area_popup[i] = area[i].name;
  995. }
  996. }
  997. }
  998. [Serializable]
  999. public enum map_type_enum
  1000. {
  1001. Aerial,
  1002. AerialWithLabels,
  1003. Road
  1004. }
  1005. [Serializable]
  1006. public class neighbor_class
  1007. {
  1008. public int left;
  1009. public int right;
  1010. public int top;
  1011. public int bottom;
  1012. public int top_left;
  1013. public int top_right;
  1014. public int bottom_left;
  1015. public int bottom_right;
  1016. public int self;
  1017. public neighbor_class()
  1018. {
  1019. left = -1;
  1020. right = -1;
  1021. top = -1;
  1022. bottom = -1;
  1023. top_left = -1;
  1024. top_right = -1;
  1025. bottom_left = -1;
  1026. bottom_right = -1;
  1027. }
  1028. }
  1029. [Serializable]
  1030. public class preimage_edit_class
  1031. {
  1032. public List<image_edit_class> edit_color;
  1033. public int y1, x1, x, y;
  1034. public float frames;
  1035. public float auto_speed_time;
  1036. private float target_frame;
  1037. public float time_start;
  1038. public float time;
  1039. public bool generate;
  1040. public bool loop;
  1041. public bool generate_call;
  1042. public bool active;
  1043. public bool loop_active;
  1044. public bool import_settings;
  1045. public bool regen;
  1046. public bool regenRaw;
  1047. public bool border;
  1048. public float progress;
  1049. public Vector2 resolution;
  1050. public Vector2 resolutionRaw;
  1051. public byte[] byte1;
  1052. public bool raw;
  1053. public int xx;
  1054. public Vector2 position;
  1055. public Vector2 position2;
  1056. public Vector2 direction;
  1057. public int dir;
  1058. public Vector2 pos_old;
  1059. public bool first;
  1060. public int count;
  1061. public buffer_class inputBuffer;
  1062. public buffer_class outputBuffer;
  1063. public int radius;
  1064. public int radiusSelect;
  1065. public int mode;
  1066. public tile_class tile;
  1067. public int repeat;
  1068. public int repeatAmount;
  1069. public bool content;
  1070. public preimage_edit_class()
  1071. {
  1072. edit_color = new List<image_edit_class>();
  1073. target_frame = 30;
  1074. active = true;
  1075. loop_active = true;
  1076. byte1 = new byte[3];
  1077. xx = 3;
  1078. position = new Vector2(x - 1, y - 1);
  1079. direction = new Vector2(1, 0);
  1080. dir = 1;
  1081. inputBuffer = new buffer_class();
  1082. outputBuffer = new buffer_class();
  1083. radius = 300;
  1084. radiusSelect = 300;
  1085. mode = 1;
  1086. tile = new tile_class();
  1087. repeatAmount = 3;
  1088. content = true;
  1089. }
  1090. public float calc_color_pos(Color color, Color color_start, Color color_end)
  1091. {
  1092. Color color_start2 = color_start;
  1093. Color color_range;
  1094. if (color_start.r > color_end.r) { color_start.r = color_end.r; color_end.r = color_start2.r; }
  1095. if (color_start.g > color_end.g) { color_start.g = color_end.g; color_end.g = color_start2.g; }
  1096. if (color_start.b > color_end.b) { color_start.b = color_end.b; color_end.b = color_start2.b; }
  1097. color_range = color_end - color_start;
  1098. color -= color_start;
  1099. if (color.r < 0 || color.g < 0 || color.b < 0) { return -1; }
  1100. if (color.r > color_range.r || color.g > color_range.g || color.b > color_range.b) { return -1; }
  1101. float color_range_total = (color_range.r + color_range.g + color_range.b);
  1102. float color_total = (color.r + color.g + color.b);
  1103. if (color_range_total != 0) { return (color_total / color_range_total); } else { return 1; }
  1104. }
  1105. public Color calc_color_from_pos(float pos, Color color_start, Color color_end)
  1106. {
  1107. Color color_start2 = color_start;
  1108. Color color_range;
  1109. if (color_start.r > color_end.r) { color_start.r = color_end.r; color_end.r = color_start2.r; }
  1110. if (color_start.g > color_end.g) { color_start.g = color_end.g; color_end.g = color_start2.g; }
  1111. if (color_start.b > color_end.b) { color_start.b = color_end.b; color_end.b = color_start2.b; }
  1112. color_range = color_end - color_start;
  1113. Color color = color_start + new Color(color_range.r * pos, color_range.g * pos, color_range.b * pos);
  1114. // if (color_range_total != 0){return (color_total/color_range_total);} else {return 1;}
  1115. return color;
  1116. }
  1117. public void swap_color(int color_index1, int color_index2)
  1118. {
  1119. image_edit_class image_edit_class = edit_color[color_index1];
  1120. edit_color[color_index1] = edit_color[color_index2];
  1121. edit_color[color_index2] = image_edit_class;
  1122. }
  1123. public void copy_color(int color_index1, int color_index2)
  1124. {
  1125. edit_color[color_index1].color1_start = edit_color[color_index2].color1_start;
  1126. edit_color[color_index1].color1_end = edit_color[color_index2].color1_end;
  1127. edit_color[color_index1].curve1 = edit_color[color_index2].curve1;
  1128. edit_color[color_index1].color2_start = edit_color[color_index2].color2_start;
  1129. edit_color[color_index1].color2_end = edit_color[color_index2].color2_end;
  1130. edit_color[color_index1].curve2 = edit_color[color_index2].curve2;
  1131. edit_color[color_index1].strength = edit_color[color_index2].strength;
  1132. edit_color[color_index1].output = edit_color[color_index2].output;
  1133. edit_color[color_index1].active = edit_color[color_index2].active;
  1134. edit_color[color_index1].solid_color = edit_color[color_index2].solid_color;
  1135. }
  1136. public void convert_texture_raw(bool multithread)
  1137. {
  1138. int count_color = 0;
  1139. Color color, color2, color3;
  1140. float color_pos1, color_pos2;
  1141. float strength;
  1142. // frames = 1/(Time.realtimeSinceStartup-auto_speed_time);
  1143. auto_speed_time = Time.realtimeSinceStartup;
  1144. pos_old.y = -100;
  1145. for (y = y1; y < (inputBuffer.innerRect.height + inputBuffer.offset.y); ++y)
  1146. {
  1147. xx = 3;
  1148. position = new Vector2(-1, y - 1);
  1149. direction = new Vector2(1, 0);
  1150. dir = 1;
  1151. count = 0;
  1152. for (x = (int)inputBuffer.offset.x + x1; x < (inputBuffer.innerRect.width + inputBuffer.offset.x); ++x)
  1153. {
  1154. color = GetPixelRaw(inputBuffer, x, y);
  1155. color3 = color;
  1156. for (count_color = 0; count_color < edit_color.Count; ++count_color)
  1157. {
  1158. if ((edit_color[count_color].active || edit_color[count_color].solid_color))
  1159. {
  1160. color_pos1 = calc_color_pos(color, edit_color[count_color].color1_start, edit_color[count_color].color1_end);
  1161. if (color_pos1 != -1)
  1162. {
  1163. color_pos1 = edit_color[count_color].curve1.Evaluate(color_pos1);
  1164. color_pos2 = edit_color[count_color].curve2.Evaluate(color_pos1);
  1165. color2 = calc_color_from_pos(color_pos2, edit_color[count_color].color2_start, edit_color[count_color].color2_end);
  1166. strength = edit_color[count_color].strength;
  1167. if (!edit_color[count_color].solid_color)
  1168. {
  1169. if (edit_color[count_color].output == image_output_enum.content)
  1170. {
  1171. if (x == pos_old.x + 1 && y == pos_old.y && xx > 3)
  1172. {
  1173. if (dir == 1)
  1174. {
  1175. if (count == 0)
  1176. {
  1177. position.x += 1;
  1178. xx -= 2;
  1179. }
  1180. else
  1181. {
  1182. --count;
  1183. }
  1184. }
  1185. else if (dir == 2)
  1186. {
  1187. xx -= 2;
  1188. }
  1189. else if (dir == 3 || dir == 4)
  1190. {
  1191. position.x = x + ((xx - 1) / 2);
  1192. position.y = y - ((xx - 1) / 2);
  1193. dir = 2;
  1194. count = 0;
  1195. direction = new Vector2(-1, 0);
  1196. }
  1197. color2 = content_fill_raw(x, y, edit_color[count_color].color1_start, edit_color[count_color].color1_end, edit_color[count_color].color2_start, false);
  1198. }
  1199. else
  1200. {
  1201. color2 = content_fill_raw(x, y, edit_color[count_color].color1_start, edit_color[count_color].color1_end, edit_color[count_color].color2_start, true);
  1202. }
  1203. pos_old = new Vector2(x, y);
  1204. color3 = color2;
  1205. }
  1206. switch (edit_color[count_color].output)
  1207. {
  1208. case image_output_enum.add:
  1209. color3.r += color2.r * strength;
  1210. color3.g += color2.g * strength;
  1211. color3.b += color2.b * strength;
  1212. break;
  1213. case image_output_enum.subtract:
  1214. color3.r -= color2.r * strength;
  1215. color3.g -= color2.g * strength;
  1216. color3.b -= color2.b * strength;
  1217. break;
  1218. case image_output_enum.change:
  1219. color3.r = (color.r * (1 - strength)) + color2.r * strength;
  1220. color3.g = (color.g * (1 - strength)) + color2.g * strength;
  1221. color3.b = (color.b * (1 - strength)) + color2.b * strength;
  1222. break;
  1223. case image_output_enum.multiply:
  1224. color3.r *= (color2.r * strength);
  1225. color3.g *= (color2.g * strength);
  1226. color3.b *= (color2.b * strength);
  1227. break;
  1228. case image_output_enum.divide:
  1229. if ((color2.r * strength) != 0)
  1230. {
  1231. color3.r = color.r / (color2.r * strength);
  1232. }
  1233. if ((color2.g * strength) != 0)
  1234. {
  1235. color3.g = color.g / (color2.g * strength);
  1236. }
  1237. if ((color2.b * strength) != 0)
  1238. {
  1239. color3.b = color.b / (color2.b * strength);
  1240. }
  1241. break;
  1242. case image_output_enum.difference:
  1243. color3.r = Mathf.Abs((color2.r * strength) - color.r);
  1244. color3.g = Mathf.Abs((color2.g * strength) - color.g);
  1245. color3.b = Mathf.Abs((color2.b * strength) - color.b);
  1246. break;
  1247. case image_output_enum.average:
  1248. color3.r = (color.r + (color2.r * strength)) / 2;
  1249. color3.g = (color.g + (color2.g * strength)) / 2;
  1250. color3.b = (color.b + (color2.b * strength)) / 2;
  1251. break;
  1252. case image_output_enum.max:
  1253. if (color2.r * strength > color.r) { color3.r = color2.r * strength; }
  1254. if (color2.g * strength > color.g) { color3.g = color2.g * strength; }
  1255. if (color2.b * strength > color.b) { color3.b = color2.b * strength; }
  1256. break;
  1257. case image_output_enum.min:
  1258. if (color2.r * strength < color.r) { color3.r = color2.r * strength; }
  1259. if (color2.g * strength < color.g) { color3.g = color2.g * strength; }
  1260. if (color2.b * strength < color.b) { color3.b = color2.b * strength; }
  1261. break;
  1262. }
  1263. }
  1264. else
  1265. {
  1266. color3.r += 1 - color_pos1;
  1267. color3.g += color_pos1;
  1268. color3.b += 1;
  1269. }
  1270. }
  1271. }
  1272. }
  1273. if (color3[0] > 1) { color3[0] = 1; }
  1274. else if (color3[0] < 0) { color3[0] = 0; }
  1275. if (color3[1] > 1) { color3[1] = 1; }
  1276. else if (color3[1] < 0) { color3[1] = 0; }
  1277. if (color3[2] > 1) { color3[2] = 1; }
  1278. else if (color3[2] < 0) { color3[2] = 0; }
  1279. SetPixelRaw(outputBuffer, x, y, color3);
  1280. if (Time.realtimeSinceStartup - auto_speed_time > (1.0 / target_frame) && multithread)
  1281. {
  1282. y1 = y;
  1283. x1 = (int)(x - inputBuffer.offset.x) + 1;
  1284. // Debug.Log(y1);
  1285. if (mode == 2) { time = Time.realtimeSinceStartup - time_start; }
  1286. // Debug.Log("mode: "+mode+", "+y1);
  1287. return;
  1288. }
  1289. }
  1290. x1 = 0;
  1291. }
  1292. generate = false;
  1293. }
  1294. public Color content_fill_raw(int _x, int _y, Color exclude_start, Color exclude_end, Color exclude2, bool reset)
  1295. {
  1296. Color color = new Color();
  1297. Color color2 = new Color();
  1298. Color color3 = new Color();
  1299. float num = 0;
  1300. float num2 = 360;
  1301. float num3 = 20;
  1302. Vector2 vector3 = new Vector2();
  1303. Vector2 vector4 = new Vector2();
  1304. float num4;
  1305. float num5;
  1306. bool flag = false;
  1307. bool flag2 = false;
  1308. if (reset)
  1309. {
  1310. xx = 3;
  1311. position = new Vector2(_x - 1, _y - 1);
  1312. direction = new Vector2(1, 0);
  1313. dir = 1;
  1314. count = 0;
  1315. }
  1316. do
  1317. {
  1318. color = GetPixelRaw(inputBuffer, (long)position.x, (long)position.y);
  1319. if (!color_in_range(exclude_start, exclude_end, color))
  1320. {
  1321. break;
  1322. }
  1323. count++;
  1324. if (count >= xx && dir == 1)
  1325. {
  1326. direction = new Vector2(0, 1);
  1327. count = 0;
  1328. dir = 2;
  1329. }
  1330. else if (count >= xx - 1 && dir == 2)
  1331. {
  1332. direction = new Vector2(-1, 0);
  1333. count = 0;
  1334. dir = 3;
  1335. }
  1336. else if (count >= xx - 1 && dir == 3)
  1337. {
  1338. direction = new Vector2(0, -1);
  1339. count = 0;
  1340. dir = 4;
  1341. }
  1342. else if (count >= xx - 2 && dir == 4)
  1343. {
  1344. direction = new Vector2(1, 0);
  1345. count = 0;
  1346. position += new Vector2(-1, -2);
  1347. dir = 1;
  1348. xx += 2;
  1349. continue;
  1350. }
  1351. position += direction;
  1352. }
  1353. while (!flag);
  1354. vector3.x = position.x - _x;
  1355. vector3.y = position.y - _y;
  1356. num4 = vector3.magnitude;
  1357. if (repeat < 1 && num4 > 4)
  1358. {
  1359. int num8 = (int)(position.y - 1);
  1360. while (num8 <= position.y + 1)
  1361. {
  1362. int num9 = (int)(position.x - 1);
  1363. while (num9 <= position.x + 1)
  1364. {
  1365. color2 = GetPixelRaw(inputBuffer, num9, num8);
  1366. if (color2[0] <= exclude2[0] && color2[1] <= exclude2[1] && color2[2] <= exclude2[2])
  1367. {
  1368. SetPixelRaw(outputBuffer, num9, num8, new Color(0, 0, 0));
  1369. }
  1370. num9++;
  1371. }
  1372. num8++;
  1373. }
  1374. }
  1375. if (repeat < repeatAmount - 1)
  1376. {
  1377. vector4 = vector3 / num4 * radius;
  1378. position2.x = _x + vector4.x;
  1379. position2.y = _y + vector4.y;
  1380. color = GetPixelRaw(inputBuffer, (long)position2.x, (long)position2.y);
  1381. if (color_in_range(exclude_start, exclude_end, color))
  1382. {
  1383. regen = true;
  1384. flag2 = true;
  1385. }
  1386. }
  1387. if (!flag2)
  1388. {
  1389. color2 = GetPixelRaw(outputBuffer, _x - 1, _y);
  1390. if (!color_in_range(exclude_start, exclude_end, color2))
  1391. {
  1392. num5 = color_difference(color2, color);
  1393. if (GetPixelRaw(inputBuffer, _x - 1, _y) == color2)
  1394. {
  1395. num5 *= 10;
  1396. }
  1397. if (num5 > num3)
  1398. {
  1399. color3 += color2 * (num5 / num2);
  1400. num += num5 / num2;
  1401. }
  1402. }
  1403. color2 = GetPixelRaw(outputBuffer, _x, _y - 1);
  1404. if (!color_in_range(exclude_start, exclude_end, color2))
  1405. {
  1406. num5 = color_difference(color2, color);
  1407. if (GetPixelRaw(inputBuffer, _x, _y - 1) == color2)
  1408. {
  1409. num5 *= 10;
  1410. }
  1411. if (num5 > num3)
  1412. {
  1413. color3 += color2 * (num5 / num2);
  1414. num += num5 / num2;
  1415. }
  1416. }
  1417. color2 = GetPixelRaw(outputBuffer, _x + 1, _y);
  1418. if (!color_in_range(exclude_start, exclude_end, color2))
  1419. {
  1420. num5 = color_difference(color2, color);
  1421. if (GetPixelRaw(inputBuffer, _x + 1, _y) == color2)
  1422. {
  1423. num5 *= 10;
  1424. }
  1425. if (num5 > num3)
  1426. {
  1427. color3 += color2 * (num5 / num2);
  1428. num += num5 / num2;
  1429. }
  1430. }
  1431. color2 = GetPixelRaw(outputBuffer, _x, _y + 1);
  1432. if (!color_in_range(exclude_start, exclude_end, color2))
  1433. {
  1434. num5 = color_difference(color2, color);
  1435. if (GetPixelRaw(inputBuffer, _x, _y + 1) == color2)
  1436. {
  1437. num5 *= 10;
  1438. }
  1439. if (num5 > num3)
  1440. {
  1441. color3 += color2 * (num5 / num2);
  1442. num += num5 / num2;
  1443. }
  1444. }
  1445. color += color3;
  1446. color /= 1 + num;
  1447. }
  1448. SetPixelRaw(outputBuffer, _x, _y, color);
  1449. return color;
  1450. }
  1451. public Color GetPixelRaw(buffer_class buffer, long x, long y)
  1452. {
  1453. if (mode == 1)
  1454. {
  1455. if (x < 0) { x = 0 - x; }
  1456. else if (x > buffer.outerRect.width - 1) { x = (int)(x - (x - (buffer.outerRect.width - 1))); }
  1457. if (y < 0) { y = 0 - y; }
  1458. else if (y > buffer.outerRect.height - 1) { y = (int)(y - (y - (buffer.outerRect.height - 1))); }
  1459. }
  1460. else
  1461. {
  1462. if (x < 0 || x > buffer.outerRect.width - 1 || y < 0 || y > buffer.outerRect.height - 1)
  1463. {
  1464. return GetPixelRaw2(buffer, x, y);
  1465. }
  1466. }
  1467. ulong pos = (ulong)((buffer.outerRect.width * 3 * y) + (x * 3));
  1468. // if (pos > buffer.bytes.Length-3) {pos = buffer.bytes.Length-3;}
  1469. // Debug.Log(file.length+" pos: "+pos+" x: "+x+" y: "+y);
  1470. return new Color((buffer.bytes[pos] * 1.0f) / 255, (buffer.bytes[pos + 1] * 1.0f) / 255, (buffer.bytes[pos + 2] * 1.0f) / 255);
  1471. }
  1472. public void SetPixelRaw(buffer_class buffer, long x, long y, Color color)
  1473. {
  1474. if (x < 0L)
  1475. {
  1476. x = 0L - x;
  1477. }
  1478. else if (x > buffer.outerRect.width - 1)
  1479. {
  1480. x = (long)(x - (x - (buffer.outerRect.width - 1)));
  1481. }
  1482. if (y < 0L)
  1483. {
  1484. y = 0L - y;
  1485. }
  1486. else if (y > buffer.outerRect.height - 1)
  1487. {
  1488. y = (long)(y - (y - (buffer.outerRect.height - 1)));
  1489. }
  1490. ulong num = (ulong)(buffer.outerRect.width * 3 * y + x * 3L);
  1491. buffer.bytes[(int)num] = (byte)(color[0] * 255);
  1492. buffer.bytes[(int)((long)num + (long)((ulong)1))] = (byte)(color[1] * 255);
  1493. buffer.bytes[(int)((long)num + (long)((ulong)2))] = (byte)(color[2] * 255);
  1494. }
  1495. public Color GetPixelRaw2(buffer_class buffer, long x, long y)
  1496. {
  1497. x = (long)(x + buffer.outerRect.x);
  1498. y = (long)(y + buffer.outerRect.y);
  1499. if (x < 0L)
  1500. {
  1501. x = -x;
  1502. }
  1503. else if (x > buffer.resolution.x - 1)
  1504. {
  1505. x = (long)(x - (x - buffer.resolution.x - 1));
  1506. }
  1507. if (y < 0L)
  1508. {
  1509. y = -y;
  1510. }
  1511. else if (y > buffer.resolution.y - 1)
  1512. {
  1513. y = (long)(y - (y - buffer.resolution.y - 1));
  1514. }
  1515. ulong num = (ulong)((long)buffer.row * y + x * 3L);
  1516. buffer.file.Seek((long)num, 0);
  1517. byte[] array = new byte[3];
  1518. buffer.file.Read(array, 0, 3);
  1519. return new Color(array[0] * 1f / 255, array[1] * 1f / 255, array[2] * 1f / 255);
  1520. }
  1521. public bool color_in_range(Color color_start, Color color_end, Color color)
  1522. {
  1523. return color[0] >= color_start[0] && color[0] <= color_end[0] && color[1] >= color_start[1] && color[1] <= color_end[1] && color[2] >= color_start[2] && color[2] <= color_end[2];
  1524. }
  1525. public int color_difference(Color color1, Color color2)
  1526. {
  1527. return (int)((Mathf.Abs(color1[0] - color2[0]) + Mathf.Abs(color1[1] - color2[1]) + Mathf.Abs(color1[2] - color2[1])) * 255);
  1528. }
  1529. }
  1530. [Serializable]
  1531. public class RawFile
  1532. {
  1533. public bool assigned;
  1534. public bool created;
  1535. public string file;
  1536. public string filename;
  1537. public raw_mode_enum mode;
  1538. public int length;
  1539. public Vector2 resolution;
  1540. public bool square;
  1541. public bool loaded;
  1542. public bool linked;
  1543. [NonSerialized] public byte[] bytes;
  1544. public float product1;
  1545. public float product2;
  1546. public void LoadRawFile(string path)
  1547. {
  1548. bytes = File.ReadAllBytes(path);
  1549. }
  1550. public RawFile()
  1551. {
  1552. created = true;
  1553. file = string.Empty;
  1554. filename = string.Empty;
  1555. mode = raw_mode_enum.Windows;
  1556. square = true;
  1557. linked = true;
  1558. }
  1559. public bool exists()
  1560. {
  1561. FileInfo fileInfo = new FileInfo(file);
  1562. return fileInfo.Exists;
  1563. }
  1564. }
  1565. [Serializable]
  1566. public enum raw_mode_enum
  1567. {
  1568. Windows,
  1569. Mac
  1570. }
  1571. [Serializable]
  1572. public class remarks_class
  1573. {
  1574. public bool textfield_foldout;
  1575. public int textfield_length;
  1576. public string textfield;
  1577. public remarks_class()
  1578. {
  1579. textfield_length = 1;
  1580. textfield = string.Empty;
  1581. }
  1582. }
  1583. [Serializable]
  1584. public enum resolution_mode_enum
  1585. {
  1586. Automatic,
  1587. Heightmap,
  1588. Splatmap,
  1589. Tree,
  1590. Detailmap,
  1591. Object,
  1592. Units,
  1593. Custom,
  1594. Colormap
  1595. }
  1596. [Serializable]
  1597. public class select_window_class
  1598. {
  1599. public bool active;
  1600. public bool button_colormap;
  1601. public bool button_node;
  1602. public bool button_terrain;
  1603. public bool button_heightmap;
  1604. public float terrain_zoom;
  1605. public float terrain_zoom2;
  1606. public Vector2 terrain_pos;
  1607. public float node_zoom;
  1608. public float node_zoom2;
  1609. public Vector2 node_pos;
  1610. public bool node_grid;
  1611. public bool node_grid_center;
  1612. public int mode;
  1613. public Vector2 terrain_offset;
  1614. public Vector2 node_offset;
  1615. public select_window_class()
  1616. {
  1617. button_heightmap = true;
  1618. terrain_zoom = 40;
  1619. terrain_zoom2 = 40;
  1620. terrain_pos = new Vector2(0, 0);
  1621. node_zoom = 40;
  1622. node_zoom2 = 40;
  1623. node_pos = new Vector2(0, 0);
  1624. node_grid = true;
  1625. node_grid_center = true;
  1626. terrain_offset = new Vector2(0, 0);
  1627. node_offset = new Vector2(0, 0);
  1628. }
  1629. public void select_colormap()
  1630. {
  1631. button_node = false;
  1632. button_colormap = true;
  1633. button_terrain = false;
  1634. }
  1635. public void select_terrain()
  1636. {
  1637. button_node = false;
  1638. button_colormap = false;
  1639. button_terrain = true;
  1640. }
  1641. public void select_node()
  1642. {
  1643. button_node = true;
  1644. button_colormap = false;
  1645. button_terrain = false;
  1646. }
  1647. }
  1648. [Serializable]
  1649. public class splatPrototype_class
  1650. {
  1651. public bool foldout;
  1652. public Texture2D texture;
  1653. public Vector2 tileSize;
  1654. public bool tileSize_link;
  1655. public Vector2 tileSize_old;
  1656. public Vector2 tileOffset;
  1657. public Vector2 normal_tileSize;
  1658. public float strength;
  1659. public float strength_splat;
  1660. public Texture2D normal_texture;
  1661. public Texture2D normalMap;
  1662. public Texture2D height_texture;
  1663. public Texture2D specular_texture;
  1664. public int import_max_size_list;
  1665. public splatPrototype_class()
  1666. {
  1667. tileSize = new Vector2(10, 10);
  1668. tileSize_link = true;
  1669. tileOffset = new Vector2(0, 0);
  1670. normal_tileSize = new Vector2(10, 10);
  1671. strength = 1;
  1672. strength_splat = 1;
  1673. }
  1674. }
  1675. public static class TC
  1676. {
  1677. public static Type[] GetAllSubTypes(Type aBaseClass)
  1678. {
  1679. List<Type> list = new List<Type>();
  1680. Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
  1681. int i = 0;
  1682. Assembly[] array = assemblies;
  1683. int length = array.Length;
  1684. while (i < length)
  1685. {
  1686. Type[] types = array[i].GetTypes();
  1687. int j = 0;
  1688. Type[] array2 = types;
  1689. int length2 = array2.Length;
  1690. while (j < length2)
  1691. {
  1692. if (array2[j].IsSubclassOf(aBaseClass))
  1693. {
  1694. list.Add(array2[j]);
  1695. }
  1696. j++;
  1697. }
  1698. i++;
  1699. }
  1700. return list.ToArray();
  1701. }
  1702. public static Type GetType(Type t, string typeName)
  1703. {
  1704. int i = 0;
  1705. Type[] allSubTypes = TC.GetAllSubTypes(t);
  1706. int length = allSubTypes.Length;
  1707. Type arg_3C_0;
  1708. while (i < length)
  1709. {
  1710. if (allSubTypes[i].Name == typeName)
  1711. {
  1712. arg_3C_0 = allSubTypes[i];
  1713. return arg_3C_0;
  1714. }
  1715. i++;
  1716. }
  1717. arg_3C_0 = null;
  1718. return arg_3C_0;
  1719. }
  1720. }
  1721. [Serializable]
  1722. public class terrain_area_class
  1723. {
  1724. public List<terrain_class2> terrains;
  1725. public int index;
  1726. public tile_class tiles;
  1727. public tile_class tiles_select;
  1728. public int tiles_total;
  1729. public int tiles_select_total;
  1730. public int tiles_assigned_total;
  1731. public bool tiles_select_link;
  1732. public Vector3 size;
  1733. public Vector3 center;
  1734. public bool edit;
  1735. public bool disable_edit;
  1736. public bool area_foldout;
  1737. public bool tiles_foldout;
  1738. public bool settings_foldout;
  1739. public bool center_synchronous;
  1740. public bool tile_synchronous;
  1741. public bool tile_position_synchronous;
  1742. public Rect rect;
  1743. public Rect rect1;
  1744. public string text;
  1745. public string text_edit;
  1746. public bool display_short;
  1747. public remarks_class remarks;
  1748. public bool copy_settings;
  1749. public int copy_terrain;
  1750. public bool foldout;
  1751. public bool terrains_active;
  1752. public bool terrains_scene_active;
  1753. public bool terrains_foldout;
  1754. public auto_search_class auto_search;
  1755. public auto_search_class auto_name;
  1756. public string path;
  1757. public Transform parent;
  1758. public string scene_name;
  1759. public string asset_name;
  1760. public bool resize;
  1761. public bool resize_left;
  1762. public bool resize_right;
  1763. public bool resize_top;
  1764. public bool resize_bottom;
  1765. public bool resize_topLeft;
  1766. public bool resize_topRight;
  1767. public bool resize_bottomLeft;
  1768. public bool resize_bottomRight;
  1769. public bool resize_center;
  1770. public terrain_area_class()
  1771. {
  1772. terrains = new List<terrain_class2>();
  1773. tiles = new tile_class();
  1774. tiles_select = new tile_class();
  1775. tiles_select_link = true;
  1776. center = new Vector3(0, 0, 0);
  1777. center_synchronous = true;
  1778. tile_synchronous = true;
  1779. tile_position_synchronous = true;
  1780. text_edit = string.Empty;
  1781. remarks = new remarks_class();
  1782. copy_settings = true;
  1783. foldout = true;
  1784. terrains_active = true;
  1785. terrains_scene_active = true;
  1786. terrains_foldout = true;
  1787. auto_search = new auto_search_class();
  1788. auto_name = new auto_search_class();
  1789. scene_name = "Terrain";
  1790. asset_name = "New Terrain";
  1791. set_terrain_text();
  1792. }
  1793. public void clear()
  1794. {
  1795. terrains.Clear();
  1796. set_terrain_text();
  1797. }
  1798. public void clear_to_one()
  1799. {
  1800. int count = terrains.Count;
  1801. for (int i = 1; i < count; i++)
  1802. {
  1803. terrains.RemoveAt(1);
  1804. }
  1805. set_terrain_text();
  1806. }
  1807. public void set_terrain_text()
  1808. {
  1809. if (text_edit.Length == 0)
  1810. {
  1811. if (terrains.Count > 1)
  1812. {
  1813. text = "Terrains";
  1814. }
  1815. else
  1816. {
  1817. text = "Terrain";
  1818. }
  1819. }
  1820. else
  1821. {
  1822. text = text_edit;
  1823. }
  1824. text += " (" + terrains.Count.ToString() + ")";
  1825. }
  1826. }
  1827. [Serializable]
  1828. public class terrain_class2
  1829. {
  1830. public bool active;
  1831. public bool foldout;
  1832. public int index;
  1833. public int index_old;
  1834. public bool on_row;
  1835. public Color color_terrain;
  1836. public Component rtp_script;
  1837. public Texture2D[] splat_alpha;
  1838. public Terrain terrain;
  1839. public Transform parent;
  1840. public string name;
  1841. public area_class prearea;
  1842. public float[,,] map;
  1843. public List<splatPrototype_class> splatPrototypes;
  1844. public splatPrototype_class colormap;
  1845. public bool splats_foldout;
  1846. public List<treePrototype_class> treePrototypes;
  1847. public bool trees_foldout;
  1848. public List<detailPrototype_class> detailPrototypes;
  1849. public bool details_foldout;
  1850. public List<TreeInstance> tree_instances;
  1851. public float[] splat;
  1852. public float[] splat_calc;
  1853. public float[] color;
  1854. public float[] splat_layer;
  1855. public float[] color_layer;
  1856. public float[] grass;
  1857. public int heightmap_resolution_list;
  1858. public int splatmap_resolution_list;
  1859. public int basemap_resolution_list;
  1860. public int detailmap_resolution_list;
  1861. public int detail_resolution_per_patch_list;
  1862. public Vector3 size;
  1863. public bool size_xz_link;
  1864. public int tile_x;
  1865. public int tile_z;
  1866. public Vector2 tiles;
  1867. public Rect rect;
  1868. public bool data_foldout;
  1869. public Vector3 scale;
  1870. public bool maps_foldout;
  1871. public bool settings_foldout;
  1872. public bool resolution_foldout;
  1873. public bool scripts_foldout;
  1874. public bool reset_foldout;
  1875. public bool size_foldout;
  1876. public int raw_file_index;
  1877. public RawFile raw_save_file;
  1878. public int heightmap_resolution;
  1879. public int splatmap_resolution;
  1880. public int detail_resolution;
  1881. public int detail_resolution_per_patch;
  1882. public int basemap_resolution;
  1883. public bool size_synchronous;
  1884. public bool resolutions_synchronous;
  1885. public bool splat_synchronous;
  1886. public bool tree_synchronous;
  1887. public bool detail_synchronous;
  1888. public Vector2 splatmap_conversion;
  1889. public Vector2 heightmap_conversion;
  1890. public Vector2 detailmap_conversion;
  1891. public bool splat_foldout;
  1892. public int splat_length;
  1893. public int color_length;
  1894. public bool tree_foldout;
  1895. public int tree_length;
  1896. public bool detail_foldout;
  1897. public float detail_scale;
  1898. public bool base_terrain_foldout;
  1899. public bool tree_detail_objects_foldout;
  1900. public bool wind_settings_foldout;
  1901. public bool settings_all_terrain;
  1902. public float heightmapPixelError;
  1903. public int heightmapMaximumLOD;
  1904. public bool castShadows;
  1905. public float basemapDistance;
  1906. public float treeDistance;
  1907. public float detailObjectDistance;
  1908. public float detailObjectDensity;
  1909. public int treeMaximumFullLODCount;
  1910. public float treeBillboardDistance;
  1911. public float treeCrossFadeLength;
  1912. public bool draw;
  1913. public bool editor_draw;
  1914. public TerrainDetail script_terrainDetail;
  1915. public bool settings_runtime;
  1916. public bool settings_editor;
  1917. public float wavingGrassSpeed;
  1918. public float wavingGrassAmount;
  1919. public float wavingGrassStrength;
  1920. public Color wavingGrassTint;
  1921. public neighbor_class neighbor;
  1922. public terrain_class2()
  1923. {
  1924. active = true;
  1925. color_terrain = new Color(2, 2, 2, 1);
  1926. prearea = new area_class();
  1927. splatPrototypes = new List<splatPrototype_class>();
  1928. colormap = new splatPrototype_class();
  1929. treePrototypes = new List<treePrototype_class>();
  1930. detailPrototypes = new List<detailPrototype_class>();
  1931. tree_instances = new List<TreeInstance>();
  1932. heightmap_resolution_list = 5;
  1933. splatmap_resolution_list = 4;
  1934. basemap_resolution_list = 4;
  1935. size = new Vector3(1000, 250, 1000);
  1936. size_xz_link = true;
  1937. tiles = new Vector2(1, 1);
  1938. data_foldout = true;
  1939. resolution_foldout = true;
  1940. raw_file_index = -1;
  1941. raw_save_file = new RawFile();
  1942. heightmap_resolution = 129;
  1943. splatmap_resolution = 128;
  1944. detail_resolution = 128;
  1945. detail_resolution_per_patch = 8;
  1946. basemap_resolution = 128;
  1947. size_synchronous = true;
  1948. resolutions_synchronous = true;
  1949. splat_synchronous = true;
  1950. tree_synchronous = true;
  1951. detail_synchronous = true;
  1952. detail_scale = 1;
  1953. base_terrain_foldout = true;
  1954. tree_detail_objects_foldout = true;
  1955. wind_settings_foldout = true;
  1956. settings_all_terrain = true;
  1957. heightmapPixelError = 5;
  1958. basemapDistance = 20000;
  1959. treeDistance = 20000;
  1960. detailObjectDistance = 250;
  1961. detailObjectDensity = 1;
  1962. treeMaximumFullLODCount = 50;
  1963. treeBillboardDistance = 250;
  1964. treeCrossFadeLength = 200;
  1965. draw = true;
  1966. editor_draw = true;
  1967. settings_editor = true;
  1968. wavingGrassSpeed = 0.5f;
  1969. wavingGrassAmount = 0.5f;
  1970. wavingGrassStrength = 0.5f;
  1971. wavingGrassTint = new Color(0.698f, 0.6f, 0.5f);
  1972. neighbor = new neighbor_class();
  1973. }
  1974. public void add_splatprototype(int splat_number)
  1975. {
  1976. splatPrototypes.Insert(splat_number, new splatPrototype_class());
  1977. }
  1978. public void erase_splatprototype(int splat_number)
  1979. {
  1980. if (splatPrototypes.Count > 0)
  1981. {
  1982. splatPrototypes.RemoveAt(splat_number);
  1983. }
  1984. }
  1985. public void clear_splatprototype()
  1986. {
  1987. splatPrototypes.Clear();
  1988. }
  1989. public void add_treeprototype(int tree_number)
  1990. {
  1991. treePrototypes.Insert(tree_number, new treePrototype_class());
  1992. }
  1993. public void erase_treeprototype(int tree_number)
  1994. {
  1995. if (treePrototypes.Count > 0)
  1996. {
  1997. treePrototypes.RemoveAt(tree_number);
  1998. }
  1999. }
  2000. public void clear_treeprototype()
  2001. {
  2002. treePrototypes.Clear();
  2003. }
  2004. public void add_detailprototype(int detail_number)
  2005. {
  2006. detailPrototypes.Insert(detail_number, new detailPrototype_class());
  2007. }
  2008. public void erase_detailprototype(int detail_number)
  2009. {
  2010. if (detailPrototypes.Count > 0)
  2011. {
  2012. detailPrototypes.RemoveAt(detail_number);
  2013. }
  2014. }
  2015. public void clear_detailprototype()
  2016. {
  2017. detailPrototypes.Clear();
  2018. }
  2019. }
  2020. [Serializable]
  2021. public class terrain_region_class
  2022. {
  2023. public bool active;
  2024. public bool foldout;
  2025. public string text;
  2026. public List<terrain_area_class> area;
  2027. public int area_select;
  2028. public int mode;
  2029. public Rect area_size;
  2030. public terrain_region_class()
  2031. {
  2032. active = true;
  2033. foldout = true;
  2034. text = "Terrain Area";
  2035. area = new List<terrain_area_class>();
  2036. area.Add(new terrain_area_class());
  2037. }
  2038. public void add_area(int index)
  2039. {
  2040. area.Insert(index, new terrain_area_class());
  2041. set_area_index();
  2042. set_area_text();
  2043. area[index].set_terrain_text();
  2044. area[index].path = Application.dataPath;
  2045. }
  2046. public void erase_area(int index)
  2047. {
  2048. area.RemoveAt(index);
  2049. set_area_index();
  2050. set_area_text();
  2051. }
  2052. public void set_area_index()
  2053. {
  2054. for (int i = 0; i < area.Count; i++)
  2055. {
  2056. area[i].index = i;
  2057. }
  2058. }
  2059. public void set_area_text()
  2060. {
  2061. if (area.Count > 1)
  2062. {
  2063. text = "Terrain Areas";
  2064. }
  2065. else
  2066. {
  2067. text = "Terrain Area";
  2068. }
  2069. }
  2070. }
  2071. [Serializable]
  2072. public class treePrototype_class
  2073. {
  2074. public GameObject prefab;
  2075. public Texture2D texture;
  2076. public float bendFactor;
  2077. public bool foldout;
  2078. public treePrototype_class()
  2079. {
  2080. bendFactor = 0.3f;
  2081. }
  2082. }
  2083. #endif
  2084. [Serializable]
  2085. public class tile_class
  2086. {
  2087. public int x;
  2088. public int y;
  2089. public tile_class() { }
  2090. public tile_class(int x1, int y2)
  2091. {
  2092. x = x1;
  2093. y = y2;
  2094. }
  2095. public void reset()
  2096. {
  2097. x = 0;
  2098. y = 0;
  2099. }
  2100. }
  2101. [Serializable]
  2102. public class map_pixel_class
  2103. {
  2104. public double x;
  2105. public double y;
  2106. public void reset()
  2107. {
  2108. x = 0;
  2109. y = 0;
  2110. }
  2111. }
  2112. }