14 public static string PathTemp
18 return CorePath.MapPieceSave +
"_temp.mp";
24 public bool altDirPosition
38 return new FileInfo(this.path).Name.Replace(
".mp",
"");
51 this.localOffsetX = (this.localOffsetZ = 0);
55 public void ClearMarkedCells()
57 foreach (
Cell cell
in this.cellsMarked)
59 cell.skipRender =
false;
61 this.cellsMarked.Clear();
68 CS$<>8__locals1.<>4__this =
this;
69 byte height = _point.cell.height;
70 int num = _point.cell.IsFloorWater ? this.baseHeightWater : this.baseHeight;
72 point.x += this.localOffsetX;
73 point.z += this.localOffsetZ;
74 if (this.altDirPosition)
79 point.z += this.w - 1;
82 point.x += this.w - 1;
83 point.z += this.h - 1;
86 point.x += this.h - 1;
92 CS$<>8__locals1.p =
new Point();
95 this.ClearMarkedCells();
103 CS$<>8__locals1.minX = point.x;
104 CS$<>8__locals1.minZ = point.z;
105 CS$<>8__locals1.maxX = point.x + this.w;
106 CS$<>8__locals1.maxZ = point.z + this.h;
110 CS$<>8__locals1.minX = point.x;
111 CS$<>8__locals1.maxX = point.x + this.h;
112 CS$<>8__locals1.minZ = point.z - this.w + 1;
113 CS$<>8__locals1.maxZ = point.z + 1;
116 CS$<>8__locals1.minX = point.x - this.w + 1;
117 CS$<>8__locals1.maxX = point.x + 1;
118 CS$<>8__locals1.minZ = point.z - this.h + 1;
119 CS$<>8__locals1.maxZ = point.z + 1;
122 CS$<>8__locals1.minX = point.x - this.h + 1;
123 CS$<>8__locals1.maxX = point.x + 1;
124 CS$<>8__locals1.minZ = point.z;
125 CS$<>8__locals1.maxZ = point.z + this.w;
128 EClass.pc.GetCurrency(
"money");
131 this.result.ruined.Clear();
132 for (
int i = 0; i < this.w; i++)
134 for (
int j = 0; j < this.h; j++)
136 Cell cell = this.map.cells[i, j];
137 CS$<>8__locals1.p.Set(point.x + num2, point.z + num3);
138 if (
EClass._map.Contains(CS$<>8__locals1.p))
140 PartialMap.<>c__DisplayClass35_1 CS$<>8__locals2;
141 CS$<>8__locals2.c1 =
EClass._map.cells[CS$<>8__locals1.p.x, CS$<>8__locals1.p.z];
142 CS$<>8__locals2.result = HitResult.Valid;
143 if (CS$<>8__locals2.c1.isFloating)
145 CS$<>8__locals2.result = HitResult.Invalid;
147 if (CS$<>8__locals2.result == HitResult.Valid)
149 this.validPoints.Add(CS$<>8__locals1.p.index);
153 CS$<>8__locals2.c1.skipRender =
true;
154 this.cellsMarked.Add(CS$<>8__locals2.c1);
155 if (CS$<>8__locals2.result != HitResult.Valid)
158 int num4 = (int)CS$<>8__locals2.result;
159 Vector3 vector = *CS$<>8__locals1.p.Position();
160 guidePass.Add(vector.x, vector.y, vector.z - 0.01f, (
float)num4, 0.3f);
164 CS$<>8__locals1.<Apply>g__Render|1(cell.sourceFloor, cell.floorDir, 0, ref CS$<>8__locals2);
165 CS$<>8__locals1.<Apply>g__Render|1(cell.sourceBlock, cell.HasWall ? this.FixWall(cell) : cell.blockDir, 0, ref CS$<>8__locals2);
166 CS$<>8__locals1.<Apply>g__Render|1(cell.sourceObj, cell.objDir, 0, ref CS$<>8__locals2);
167 CS$<>8__locals1.<Apply>g__Render|1(cell.sourceBridge, cell.floorDir, (int)((cell.bridgeHeight == 0) ? 0 : (cell.bridgeHeight - cell.height)), ref CS$<>8__locals2);
171 if (data.x -
this.offsetX == i && data.z -
this.offsetZ == j)
175 if (orCreate !=
null)
177 orCreate.OnRenderMarker(CS$<>8__locals1.p,
true, CS$<>8__locals2.result,
true, data.dir, (
int)(height + cell.height) - num);
180 else if (orCreate !=
null)
182 orCreate.OnRenderMarker(CS$<>8__locals1.p,
true, CS$<>8__locals2.result,
true, data.dir, (
int)cell.height);
186 Critter.RebuildCritter(CS$<>8__locals2.c1);
189 if (mode ==
PartialMap.ApplyMode.Apply && CS$<>8__locals2.result == HitResult.Valid)
191 if (Rand.Range(0f, 1f) <
this.ruinChance)
193 this.result.ruined.Add(CS$<>8__locals1.p.index);
195 else if (cell._floor != 77 ||
this.editMode)
197 if (cell._block == 149 && !
this.editMode)
199 CS$<>8__locals2.c1._block = (byte)interior.block.id;
200 CS$<>8__locals2.c1._blockMat = (byte)interior.block.mat;
202 else if (cell._block == 150 && !
this.editMode)
204 CS$<>8__locals2.c1._block = (byte)exterior.block.id;
205 CS$<>8__locals2.c1._blockMat = (byte)exterior.block.mat;
209 CS$<>8__locals2.c1._block = cell._block;
210 CS$<>8__locals2.c1._blockMat = cell._blockMat;
212 if (cell._floor == 2 && !
this.editMode)
214 CS$<>8__locals2.c1._floor = (byte)interior.floor.id;
215 CS$<>8__locals2.c1._floorMat = (byte)interior.floor.mat;
217 else if (cell._floor == 3 && !
this.editMode)
219 CS$<>8__locals2.c1._floor = (byte)exterior.floor.id;
220 CS$<>8__locals2.c1._floorMat = (byte)exterior.floor.mat;
224 CS$<>8__locals2.c1._floor = cell._floor;
225 CS$<>8__locals2.c1._floorMat = cell._floorMat;
227 CS$<>8__locals2.c1._roofBlock = cell._roofBlock;
228 CS$<>8__locals2.c1._roofBlockMat = cell._roofBlockMat;
229 CS$<>8__locals2.c1.obj = cell.obj;
230 CS$<>8__locals2.c1.objMat = cell.objMat;
231 CS$<>8__locals2.c1.objVal = cell.objVal;
232 CS$<>8__locals2.c1.decal = cell.decal;
233 CS$<>8__locals2.c1._dirs = cell._dirs;
234 CS$<>8__locals2.c1._bridge = cell._bridge;
235 CS$<>8__locals2.c1._bridgeMat = cell._bridgeMat;
236 CS$<>8__locals2.c1.bridgePillar = cell.bridgePillar;
237 CS$<>8__locals2.c1.isModified =
true;
238 if (CS$<>8__locals2.c1.HasWall)
240 CS$<>8__locals2.c1.blockDir = this.FixWall(CS$<>8__locals2.c1);
244 CS$<>8__locals2.c1.height = (byte)Mathf.Clamp((
int)(height + cell.height) - num, 0, 255);
245 CS$<>8__locals2.c1.bridgeHeight = (byte)Mathf.Clamp((
int)((cell.bridgeHeight == 0) ? 0 : (CS$<>8__locals2.c1.height + (cell.bridgeHeight - cell.height))), 0, 255);
249 CS$<>8__locals2.c1.height = cell.height;
250 CS$<>8__locals2.c1.bridgeHeight = cell.bridgeHeight;
296 CS$<>8__locals1.p.Set(point.x, point.z);
297 EClass._map.SetReference();
298 EClass._map.things.ForeachReverse(delegate(
Thing t)
300 if (CS$<>8__locals1.<>4__this.validPoints.Contains(t.pos.index) && t.pos.x >= CS$<>8__locals1.minX && t.pos.z >= CS$<>8__locals1.minZ && t.pos.x < CS$<>8__locals1.maxX && t.pos.z < CS$<>8__locals1.maxZ && t.trait.CanBeDestroyed)
305 if (this.exportData !=
null)
307 this.exportData.serializedCards.Restore(
EClass._map,
null,
true,
this);
309 EClass._map.RefreshAllTiles();
310 EClass._map.RefreshAllTiles();
314 public int FixWall(
Cell c)
349 if (this.path.IsEmpty())
353 Map.UpdateMetaData(this.path,
this);
357 public void Save(
int _x,
int _z,
int _w,
int _h)
364 for (
int i = _x; i < _x + this.w; i++)
366 for (
int j = _z; j < _z + this.h; j++)
369 this.value +=
Card.GetTilePrice(cell.sourceBlock, cell.matBlock);
370 this.value +=
Card.GetTilePrice(cell.sourceFloor, cell.matFloor);
371 this.value +=
Card.GetTilePrice(cell.sourceObj, cell.matObj);
372 this.value +=
Card.GetTilePrice(cell.sourceBridge, cell.matBridge);
373 this.value +=
Card.GetTilePrice(cell.sourceRoofBlock, cell.matRoofBlock);
378 if (thing.trait.CanCopyInBlueprint && thing.pos.Within(_x, _z, _w, _h) && thing.IsInstalled)
380 this.value += thing.GetPrice(CurrencyType.Money,
false, PriceType.Default,
null) * thing.Num;
390 partialMap.ruinChance = 0f;
391 partialMap.Apply(pos,
PartialMap.ApplyMode.Apply);
396 public static PartialMap Load(
string path =
null)
398 bool flag = path.IsEmpty();
403 if (!File.Exists(path))
408 if (metaData ==
null || metaData.partial ==
null)
417 partial.exportData =
EClass._zone.Import(path);
425 this.map =
GameIO.LoadFile<
Map>(EClass._zone.pathTemp +
"map");
426 this.map.Load(
EClass._zone.pathTemp,
false,
this);
427 if (this.map ==
null)
429 Debug.Log(
"Map is null:" + this.name +
"/" +
PartialMap.PathTemp);
432 EClass._map.SetReference();
433 this.baseHeight = 255;
434 this.baseHeightWater = 255;
435 for (
int i = 0; i < this.w; i++)
437 for (
int j = 0; j < this.h; j++)
439 Cell cell = this.map.cells[i, j];
440 if ((
int)cell.height <
this.baseHeight)
442 this.baseHeightWater = (int)cell.height;
444 if ((
int)cell.height <
this.baseHeight && !cell.IsFloorWater)
446 this.baseHeight = (int)cell.height;
450 if (this.baseHeight == 255)
457 public static void Delete(
string path)
459 string fullFileNameWithoutExtension = path.GetFullFileNameWithoutExtension();
461 IO.DeleteFile(fullFileNameWithoutExtension +
".jpg");
462 IO.DeleteFile(fullFileNameWithoutExtension +
".txt");
466 public static void ExportDialog(
string dir =
null)
468 EClass.core.WaitForEndOfFrame(delegate
470 string pathDest = StandaloneFileBrowser.SaveFilePanel(
"Export Map Piece", dir ?? CorePath.MapPieceSaveUser,
"new map piece",
"mp");
471 if (!
string.IsNullOrEmpty(pathDest))
474 Msg.SayRaw(
"Exported Zone");
480 public static void SavePreview(
string path,
string pathDest)
482 EClass.core.actionsNextFrame.Add(delegate
484 string fileName = CorePath.Temp +
"preview.jpg";
485 Texture2D texture2D = ScreenCapture.CaptureScreenshotAsTexture();
488 RenderTexture renderTexture =
new RenderTexture(num, num2, 0);
489 renderTexture.Create();
490 RenderTexture active = RenderTexture.active;
491 RenderTexture.active = renderTexture;
492 Graphics.Blit(texture2D, renderTexture);
493 Texture2D texture2D2 =
new Texture2D(num, num2, texture2D.format,
false);
494 texture2D2.ReadPixels(
new Rect(0f, 0f, (
float)num, (
float)num2), 0, 0);
496 RenderTexture.active = active;
497 renderTexture.Release();
498 File.WriteAllBytes(fileName, texture2D2.EncodeToJPG());
499 ZipFile zipFile = ZipFile.Read(path);
500 zipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
501 zipFile.AddFile(fileName,
"");
502 zipFile.Save(pathDest);
504 IO.DeleteFile(fileName);
505 UnityEngine.Object.Destroy(texture2D2);
506 UnityEngine.Object.Destroy(texture2D);
507 UnityEngine.Object.Destroy(renderTexture);
512 public static bool relative;
540 public int baseHeight;
544 public int baseHeightWater;
552 public bool allowRotate;
556 public bool ignoreBlock;
559 public int localOffsetX;
562 public int localOffsetZ;
574 public bool editMode;
577 public bool procedural;
580 public float ruinChance;
589 public List<Cell> cellsMarked =
new List<Cell>();
592 public HashSet<int> validPoints =
new HashSet<int>();
598 public enum ApplyMode
614 public bool hasLight;
617 public List<int> ruined =
new List<int>();