gg.easy.airship 0.1.2221 → 0.1.2222
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
using System;
|
|
2
2
|
using System.Collections;
|
|
3
3
|
using System.Collections.Generic;
|
|
4
|
+
using System.ComponentModel;
|
|
4
5
|
using System.Diagnostics;
|
|
5
6
|
using System.IO;
|
|
6
7
|
using System.Linq;
|
|
@@ -406,7 +407,7 @@ using Object = UnityEngine.Object;
|
|
|
406
407
|
|
|
407
408
|
if (!showProgressBar && (compileFlags & TypeScriptCompileFlags.DisplayProgressBar) != 0) {
|
|
408
409
|
showProgressBar = true;
|
|
409
|
-
UpdateCompilerProgressBar(0f, $"Starting to compile TypeScript code...");
|
|
410
|
+
UpdateCompilerProgressBar(0f, $"Starting to compile TypeScript code...", false);
|
|
410
411
|
}
|
|
411
412
|
|
|
412
413
|
if (!File.Exists(Path.Join(project.Package.Directory, "package.json"))) {
|
|
@@ -427,13 +428,14 @@ using Object = UnityEngine.Object;
|
|
|
427
428
|
return; // ??
|
|
428
429
|
}
|
|
429
430
|
|
|
430
|
-
|
|
431
|
-
|
|
431
|
+
Process compilerProcess = null;
|
|
432
|
+
bool cancelled = false;
|
|
433
|
+
|
|
434
|
+
try {
|
|
432
435
|
if (fullClean) {
|
|
433
436
|
UpdateCompilerProgressBarText($"Preparing TypeScript project");
|
|
434
437
|
var success = RunNpmInstall(packageDir);
|
|
435
|
-
if (!success)
|
|
436
|
-
{
|
|
438
|
+
if (!success) {
|
|
437
439
|
Debug.LogWarning("Failed to install NPM dependencies");
|
|
438
440
|
return;
|
|
439
441
|
}
|
|
@@ -441,18 +443,42 @@ using Object = UnityEngine.Object;
|
|
|
441
443
|
|
|
442
444
|
compilationState.FilesToCompileCount = 0;
|
|
443
445
|
compilationState.CompiledFileCount = 0;
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
446
|
+
|
|
447
|
+
compilerProcess = RunNodeCommand(project.Directory,
|
|
448
|
+
$"{TypescriptLocationCommandLine} {arguments.GetCommandString(CompilerCommand.BuildOnly)}");
|
|
449
|
+
TypescriptLogService.LogInfo(
|
|
450
|
+
$"Executed compiler build instance '{arguments.GetCommandString(CompilerCommand.BuildOnly)}' at pid {compilerProcess.Id}");
|
|
447
451
|
AttachBuildOutputToUnityConsole(project, arguments, compilerProcess, packageDir);
|
|
448
|
-
|
|
452
|
+
|
|
449
453
|
while (!compilerProcess.HasExited) {
|
|
450
454
|
if (compilationState.FilesToCompileCount == 0) continue;
|
|
451
|
-
|
|
452
|
-
|
|
455
|
+
|
|
456
|
+
cancelled = UpdateCompilerProgressBar(
|
|
457
|
+
compilationState.CompiledFileCount / (float)compilationState.FilesToCompileCount,
|
|
458
|
+
$"Compiling TypeScript files {compilationState.CompiledFileCount}/{project.CompilationState.FilesToCompileCount}...",
|
|
459
|
+
true);
|
|
460
|
+
if (cancelled) {
|
|
461
|
+
compilerProcess.Kill();
|
|
462
|
+
}
|
|
453
463
|
}
|
|
454
|
-
|
|
464
|
+
|
|
455
465
|
// compilerProcess.WaitForExit();
|
|
466
|
+
} catch (Win32Exception ex) {
|
|
467
|
+
if (compilerProcess != null) {
|
|
468
|
+
switch (compilerProcess.ExitCode) {
|
|
469
|
+
case ExitCodeKill:
|
|
470
|
+
if (cancelled) {
|
|
471
|
+
Debug.Log("Typescript compiler build process was killed by user");
|
|
472
|
+
} else {
|
|
473
|
+
Debug.LogError("Typescript compiler build process was killed by system");
|
|
474
|
+
Debug.LogException(ex);
|
|
475
|
+
}
|
|
476
|
+
break;
|
|
477
|
+
default:
|
|
478
|
+
Debug.LogException(ex);
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
456
482
|
}
|
|
457
483
|
catch (Exception ex)
|
|
458
484
|
{
|
|
@@ -462,10 +488,16 @@ using Object = UnityEngine.Object;
|
|
|
462
488
|
|
|
463
489
|
private static bool showProgressBar = false;
|
|
464
490
|
private static float progress = 0;
|
|
465
|
-
private static
|
|
491
|
+
private static bool UpdateCompilerProgressBar(float progress, string text, bool cancellable) {
|
|
466
492
|
TypescriptCompilationService.progress = progress;
|
|
467
|
-
if (!showProgressBar) return;
|
|
493
|
+
if (!showProgressBar) return false;
|
|
494
|
+
|
|
495
|
+
if (cancellable) {
|
|
496
|
+
return EditorUtility.DisplayCancelableProgressBar(TsCompilerService, text, progress);
|
|
497
|
+
}
|
|
498
|
+
|
|
468
499
|
EditorUtility.DisplayProgressBar(TsCompilerService, text, progress);
|
|
500
|
+
return false;
|
|
469
501
|
}
|
|
470
502
|
|
|
471
503
|
private static bool UpdateCompilerProgressBarCancellable(float progress, string text) {
|
|
@@ -32,7 +32,7 @@ public class WorldSaveFile : ScriptableObject {
|
|
|
32
32
|
public VoxelData[] data;
|
|
33
33
|
public uint[] color;
|
|
34
34
|
public Dictionary<ushort, BinaryBlob> customData;
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
public SaveChunk(Vector3Int key, VoxelData[] data, uint[] color, Dictionary<ushort, BinaryBlob> customData) {
|
|
37
37
|
this.key = key;
|
|
38
38
|
this.data = data;
|
|
@@ -45,7 +45,7 @@ public class WorldSaveFile : ScriptableObject {
|
|
|
45
45
|
writer.Write(key.x);
|
|
46
46
|
writer.Write(key.y);
|
|
47
47
|
writer.Write(key.z);
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
// Write colors:
|
|
50
50
|
writer.Write((uint)color.Length);
|
|
51
51
|
var colorPoolLen = color.Length * sizeof(uint);
|
|
@@ -53,7 +53,7 @@ public class WorldSaveFile : ScriptableObject {
|
|
|
53
53
|
Buffer.BlockCopy(color, 0, colorPool, 0, colorPoolLen);
|
|
54
54
|
writer.Write(colorPool, 0, colorPoolLen);
|
|
55
55
|
ArrayPool<byte>.Shared.Return(colorPool);
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
// Write voxel data:
|
|
58
58
|
writer.Write((uint)data.Length);
|
|
59
59
|
var dataPoolLen = data.Length * sizeof(ushort);
|
|
@@ -113,7 +113,7 @@ public class WorldSaveFile : ScriptableObject {
|
|
|
113
113
|
voxelData.Add(c);
|
|
114
114
|
}
|
|
115
115
|
ArrayPool<byte>.Shared.Return(dataBytes);
|
|
116
|
-
|
|
116
|
+
|
|
117
117
|
// Read custom data:
|
|
118
118
|
if (version >= 3) {
|
|
119
119
|
var numCustomElements = reader.ReadInt32();
|
|
@@ -271,21 +271,21 @@ public class WorldSaveFile : ScriptableObject {
|
|
|
271
271
|
// Don't save empty chunks
|
|
272
272
|
if (!foundVoxel) continue;
|
|
273
273
|
|
|
274
|
-
|
|
274
|
+
|
|
275
275
|
// Debug.Log("Valid Chunk: " + chunk.Value.chunkKey);
|
|
276
276
|
var chunkData = new SaveChunk(chunk.Key, data, chunk.Value.color, chunk.Value.customDataMap);
|
|
277
277
|
savedChunks.Add(chunkData);
|
|
278
278
|
finalChunkCounter++;
|
|
279
279
|
}
|
|
280
|
-
|
|
280
|
+
|
|
281
281
|
// Serialize:
|
|
282
282
|
using var memStream = new MemoryStream();
|
|
283
283
|
using var writer = new BinaryWriter(memStream);
|
|
284
|
-
|
|
284
|
+
|
|
285
285
|
// Serializer version:
|
|
286
286
|
const ushort version = 2;
|
|
287
287
|
writer.Write(version);
|
|
288
|
-
|
|
288
|
+
|
|
289
289
|
// Serialize chunks:
|
|
290
290
|
writer.Write((uint)savedChunks.Count);
|
|
291
291
|
// Debug.Log("Writing chunk size: " + savedChunks.Count);
|
|
@@ -293,13 +293,13 @@ public class WorldSaveFile : ScriptableObject {
|
|
|
293
293
|
// Debug.Log("Serializing chunk: " + chunk.key);
|
|
294
294
|
chunk.Serialize(writer, version);
|
|
295
295
|
}
|
|
296
|
-
|
|
296
|
+
|
|
297
297
|
// Compress:
|
|
298
298
|
var buffer = memStream.GetBuffer();
|
|
299
299
|
var bufferSpan = new ReadOnlySpan<byte>(buffer, 0, (int)memStream.Length);
|
|
300
300
|
chunksCompressed = VoxelCompressUtil.CompressToByteArrayV2(bufferSpan);
|
|
301
301
|
chunksCompressedV2 = true;
|
|
302
|
-
|
|
302
|
+
|
|
303
303
|
#if UNITY_EDITOR
|
|
304
304
|
if (!Application.isPlaying) {
|
|
305
305
|
Debug.Log($"Saved {finalChunkCounter} chunks to {name} (raw: {FormatDataSize(memStream.Length)}) (compressed: {FormatDataSize(chunksCompressed.Length)})");
|
|
@@ -330,7 +330,7 @@ public class WorldSaveFile : ScriptableObject {
|
|
|
330
330
|
for (int i = 0; i < data.Count; i++) {
|
|
331
331
|
BlockId fileBlockId = VoxelWorld.GetVoxelDataId(data[i]);
|
|
332
332
|
ushort extraBits = VoxelWorld.GetVoxelDataExtraBits(data[i]);
|
|
333
|
-
|
|
333
|
+
|
|
334
334
|
bool found = blockRemapping.TryGetValue(fileBlockId, out var updatedBlockId);
|
|
335
335
|
if (found) {
|
|
336
336
|
VoxelData vox = (VoxelData)(updatedBlockId | extraBits);
|
|
@@ -344,11 +344,11 @@ public class WorldSaveFile : ScriptableObject {
|
|
|
344
344
|
#endif
|
|
345
345
|
|
|
346
346
|
writeChunk.readWriteVoxel[i] = vox;
|
|
347
|
-
|
|
347
|
+
|
|
348
348
|
// Note: This is a huge GC alloc penalty, but these aren't really used (and are recomputed on first use anyway),
|
|
349
349
|
// thus, this line has been commented out for now:
|
|
350
350
|
// writeChunk.keysWithVoxels.Add(i);
|
|
351
|
-
|
|
351
|
+
|
|
352
352
|
if (writeColor) {
|
|
353
353
|
writeChunk.color[i] = color[i];
|
|
354
354
|
}
|
|
@@ -372,6 +372,11 @@ public class WorldSaveFile : ScriptableObject {
|
|
|
372
372
|
Dictionary<BlockId, BlockId> blockRemapping = new();
|
|
373
373
|
|
|
374
374
|
foreach (var blockIdToScopeName in this.blockIdToScopeName) {
|
|
375
|
+
// Example code for fixing missing block
|
|
376
|
+
// if (blockIdToScopeName.name == "@Easy/VoxelWorld:Grass 1") {
|
|
377
|
+
// blockRemapping[blockIdToScopeName.id] = this.blockIdToScopeName.Find((s) => s.name == "@Easy/VoxelWorld:Grass").id;
|
|
378
|
+
// continue;
|
|
379
|
+
// }
|
|
375
380
|
|
|
376
381
|
//see if this block exists in the world blockfiles
|
|
377
382
|
var definition = world.voxelBlocks.GetBlockDefinitionByStringId(blockIdToScopeName.name);
|
|
@@ -389,7 +394,7 @@ public class WorldSaveFile : ScriptableObject {
|
|
|
389
394
|
// If compressed data is available, use that instead:
|
|
390
395
|
if (chunksCompressed != null && chunksCompressed.Length > 0) {
|
|
391
396
|
Profiler.BeginSample("ReadVoxelWorldChunks");
|
|
392
|
-
|
|
397
|
+
|
|
393
398
|
// Decompress and deserialize chunks:
|
|
394
399
|
Profiler.BeginSample("DecompressChunks");
|
|
395
400
|
using var decompressedStream = chunksCompressedV2
|
|
@@ -400,7 +405,7 @@ public class WorldSaveFile : ScriptableObject {
|
|
|
400
405
|
var reader = new BinaryReader(decompressedStream);
|
|
401
406
|
var version = reader.ReadUInt16();
|
|
402
407
|
var numChunks = reader.ReadUInt32();
|
|
403
|
-
|
|
408
|
+
|
|
404
409
|
var data = new List<VoxelData>();
|
|
405
410
|
var color = new List<uint>();
|
|
406
411
|
var customData = new Dictionary<ushort, BinaryBlob>();
|
|
@@ -408,13 +413,13 @@ public class WorldSaveFile : ScriptableObject {
|
|
|
408
413
|
for (uint i = 0; i < numChunks; i++) {
|
|
409
414
|
data.Clear();
|
|
410
415
|
color.Clear();
|
|
411
|
-
|
|
416
|
+
|
|
412
417
|
Profiler.BeginSample("Deserialize");
|
|
413
418
|
var key = SaveChunk.Deserialize(reader, version, data, color, customData);
|
|
414
419
|
Profiler.EndSample();
|
|
415
|
-
|
|
420
|
+
|
|
416
421
|
counter += 1;
|
|
417
|
-
|
|
422
|
+
|
|
418
423
|
Profiler.BeginSample("LoadChunkIntoVoxelWorld");
|
|
419
424
|
try {
|
|
420
425
|
LoadChunkIntoVoxelWorld(world, blockRemapping, key, data, color, customData);
|
|
@@ -423,7 +428,7 @@ public class WorldSaveFile : ScriptableObject {
|
|
|
423
428
|
}
|
|
424
429
|
Profiler.EndSample();
|
|
425
430
|
}
|
|
426
|
-
|
|
431
|
+
|
|
427
432
|
Profiler.EndSample();
|
|
428
433
|
} else {
|
|
429
434
|
Debug.Log("Loading non compressed chunk");
|
|
@@ -439,7 +444,7 @@ public class WorldSaveFile : ScriptableObject {
|
|
|
439
444
|
Debug.Log($"[Voxel World]: Loaded {counter} chunks");
|
|
440
445
|
}
|
|
441
446
|
#endif
|
|
442
|
-
|
|
447
|
+
|
|
443
448
|
Profiler.EndSample();
|
|
444
449
|
}
|
|
445
450
|
|