|
|
@@ -126,13 +126,36 @@ namespace Pixi.Robots |
|
|
|
timer.Stop(); |
|
|
|
Logging.MetaLog($"Completed API calls in {timer.ElapsedMilliseconds}ms"); |
|
|
|
float3 position = new Player(PlayerType.Local).Position; |
|
|
|
position.y += (float)blockSize; |
|
|
|
position.y += (float)(blockSize * CubeSize * 3); // 3 is roughly the max height of any cube in RC |
|
|
|
CubeInfo[] cubes = CubeUtility.ParseCubes(robot); |
|
|
|
// move origin closer to player (since bots are rarely built at the garage bay origin) |
|
|
|
if (cubes.Length == 0) |
|
|
|
{ |
|
|
|
Logging.CommandLogError($"Robot data contains no cubes"); |
|
|
|
return; |
|
|
|
} |
|
|
|
float3 minPosition = cubes[0].position; |
|
|
|
for (int c = 0; c < cubes.Length; c++) |
|
|
|
{ |
|
|
|
float3 cubePos = cubes[c].position; |
|
|
|
if (cubePos.x < minPosition.x) |
|
|
|
{ |
|
|
|
minPosition.x = cubePos.x; |
|
|
|
} |
|
|
|
if (cubePos.y < minPosition.y) |
|
|
|
{ |
|
|
|
minPosition.y = cubePos.y; |
|
|
|
} |
|
|
|
if (cubePos.z < minPosition.z) |
|
|
|
{ |
|
|
|
minPosition.z = cubePos.z; |
|
|
|
} |
|
|
|
} |
|
|
|
Block[][] blocks = new Block[cubes.Length][]; |
|
|
|
for (int c = 0; c < cubes.Length; c++) // sometimes I wish this were C++ |
|
|
|
{ |
|
|
|
CubeInfo cube = cubes[c]; |
|
|
|
float3 realPosition = (cube.position * (float)blockSize * CubeSize) + position; |
|
|
|
float3 realPosition = ((cube.position - minPosition) * (float)blockSize * CubeSize) + position; |
|
|
|
if (cube.block == BlockIDs.TextBlock && !string.IsNullOrEmpty(cube.name)) |
|
|
|
{ |
|
|
|
// TextBlock block ID means it's a placeholder |
|
|
@@ -143,6 +166,7 @@ namespace Pixi.Robots |
|
|
|
blocks[c] = new Block[] { Block.PlaceNew(cube.block, realPosition, cube.rotation, cube.color, cube.darkness, CubeSize) }; |
|
|
|
} |
|
|
|
} |
|
|
|
int blockCount = 0; |
|
|
|
for (int c = 0; c < cubes.Length; c++) |
|
|
|
{ |
|
|
|
CubeInfo cube = cubes[c]; |
|
|
@@ -152,8 +176,9 @@ namespace Pixi.Robots |
|
|
|
//Logging.MetaLog($"Block is {blocks[c][0].Type} and was placed as {cube.block}"); |
|
|
|
blocks[c][0].Specialise<TextBlock>().Text = cube.name; |
|
|
|
} |
|
|
|
blockCount += blocks[c].Length; |
|
|
|
} |
|
|
|
Logging.CommandLog($"Placed {robot.name} by {robot.addedByDisplayName} ({cubes.Length} cubes) beside you"); |
|
|
|
Logging.CommandLog($"Placed {robot.name} by {robot.addedByDisplayName} beside you ({cubes.Length}RC -> {blockCount}GC)"); |
|
|
|
} |
|
|
|
|
|
|
|
private static void DumpBlockStructure(string filename) |
|
|
|