Browse Source

Reduce Sync() events

tags/v0.4.0-beta2
NGnius (Graham) 4 years ago
parent
commit
d0726b9514
3 changed files with 21 additions and 11 deletions
  1. +1
    -1
      Pixi/Robots/CubeInfo.cs
  2. +2
    -2
      Pixi/Robots/CubeUtility.cs
  3. +18
    -8
      Pixi/Robots/RobotCommands.cs

+ 1
- 1
Pixi/Robots/CubeInfo.cs View File

@@ -23,6 +23,6 @@ namespace Pixi.Robots

public float3 scale;

public string placeholder;
public string name;
}
}

+ 2
- 2
Pixi/Robots/CubeUtility.cs View File

@@ -331,7 +331,7 @@ namespace Pixi.Robots
if (!map.ContainsKey(cubeId))
{
result.block = BlockIDs.TextBlock;
result.placeholder = "Unknown cube #" + cubeId.ToString();
result.name = "Unknown cube #" + cubeId.ToString();
//result.rotation = float3.zero;
#if DEBUG
Logging.MetaLog($"Unknown cubeId {cubeId}");
@@ -411,7 +411,7 @@ namespace Pixi.Robots
else
{
result.block = BlockIDs.TextBlock;
result.placeholder = cubeName;
result.name = cubeName;
}
}
}


+ 18
- 8
Pixi/Robots/RobotCommands.cs View File

@@ -58,16 +58,21 @@ namespace Pixi.Robots
float3 position = new Player(PlayerType.Local).Position;
position.y += (float)blockSize;
CubeInfo[] cubes = CubeUtility.ParseCubes(robot.Value);
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) + position;
Block newBlock = Block.PlaceNew(cube.block, realPosition, cube.rotation, cube.color, cube.darkness, scale: cube.scale);
blocks[c] = Block.PlaceNew(cube.block, realPosition, cube.rotation, cube.color, cube.darkness, scale: cube.scale);
}
for (int c = 0; c < cubes.Length; c++)
{
CubeInfo cube = cubes[c];
// the goal is for this to never evaluate to true (ie all cubes are translated correctly)
if (!string.IsNullOrEmpty(cube.placeholder) && cube.block == BlockIDs.TextBlock)
{
newBlock.Specialise<TextBlock>().Text = cube.placeholder;
}
if (!string.IsNullOrEmpty(cube.name) && cube.block == BlockIDs.TextBlock)
{
blocks[c].Specialise<TextBlock>().Text = cube.name;
}
}
Logging.CommandLog($"Placed {robot.Value.name} by {robot.Value.addedByDisplayName} ({cubes.Length} cubes) beside you");
}
@@ -97,15 +102,20 @@ namespace Pixi.Robots
float3 position = new Player(PlayerType.Local).Position;
position.y += (float)blockSize;
CubeInfo[] cubes = CubeUtility.ParseCubes(robot);
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) + position;
Block newBlock = Block.PlaceNew(cube.block, realPosition, cube.rotation, cube.color, cube.darkness, scale: cube.scale);
blocks[c] = Block.PlaceNew(cube.block, realPosition, cube.rotation, cube.color, cube.darkness, scale: cube.scale);
}
for (int c = 0; c < cubes.Length; c++)
{
CubeInfo cube = cubes[c];
// the goal is for this to never evaluate to true (ie all cubes are translated correctly)
if (!string.IsNullOrEmpty(cube.placeholder) && cube.block == BlockIDs.TextBlock)
if (!string.IsNullOrEmpty(cube.name) && cube.block == BlockIDs.TextBlock)
{
newBlock.Specialise<TextBlock>().Text = cube.placeholder;
blocks[c].Specialise<TextBlock>().Text = cube.name;
}
}
Logging.CommandLog($"Placed {robot.name} by {robot.addedByDisplayName} ({cubes.Length} cubes) beside you");


Loading…
Cancel
Save