|
@@ -27,6 +27,8 @@ namespace KairoEngine.VoxelBuildingSystem
|
|
|
[ReadOnly] public int currentRotationIndex;
|
|
|
|
|
|
[ReadOnly] public VoxelBuildingTool tool = VoxelBuildingTool.Build;
|
|
|
+
|
|
|
+ [ReadOnly] public List<Vector3Int> rotationList = new List<Vector3Int>();
|
|
|
public ChunkSystem<VoxelBuildData> chunkSystem;
|
|
|
[HideInInspector] public Dictionary<Vector3Int, BuildingBehaviour> buildings = new Dictionary<Vector3Int, BuildingBehaviour>();
|
|
|
[HideInInspector] public List<BuildingBehaviour> buildingList = new List<BuildingBehaviour>();
|
|
@@ -188,7 +190,6 @@ namespace KairoEngine.VoxelBuildingSystem
|
|
|
return positionList;
|
|
|
}
|
|
|
|
|
|
- public List<Vector3Int> rotationList = new List<Vector3Int>();
|
|
|
private void SetupRotationList()
|
|
|
{
|
|
|
rotationList = new List<Vector3Int>
|
|
@@ -212,6 +213,73 @@ namespace KairoEngine.VoxelBuildingSystem
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public Vector3Int GetConnectorPositionOffset(VoxelConnectorData connector, Vector3Int size, int rotationIndex)
|
|
|
+ {
|
|
|
+ Vector3Int pos = connector.position;
|
|
|
+ switch (rotationIndex)
|
|
|
+ {
|
|
|
+ default:
|
|
|
+ case 0: return connector.position;
|
|
|
+ case 1: return new Vector3Int(pos.z, pos.y, (pos.x * -1) + size.x - 1);
|
|
|
+ case 2: return new Vector3Int((pos.x * -1) + size.x - 1, pos.y, (pos.z * -1) + size.z - 1);
|
|
|
+ case 3: return new Vector3Int((pos.z * -1) + size.z - 1, pos.y, pos.x);
|
|
|
+ }
|
|
|
+ // switch (connector.direction)
|
|
|
+ // {
|
|
|
+ // default:
|
|
|
+ // case TargetDirection.Back: return connector.position;
|
|
|
+ // case TargetDirection.Left: return new Vector3Int(pos.z, pos.y, (pos.x * -1) + size.x - 1);
|
|
|
+ // case TargetDirection.Front: return new Vector3Int((pos.x * -1) + size.x - 1, pos.y, (pos.z * -1) + size.z - 1);
|
|
|
+ // case TargetDirection.Right: return new Vector3Int((pos.z * -1) + size.z - 1, pos.y, pos.x);
|
|
|
+ // case TargetDirection.Up: return new Vector3Int(pos.x, (pos.y * -1) + size.y - 1, pos.z);
|
|
|
+ // case TargetDirection.Down: return new Vector3Int(pos.x, pos.y * -1, pos.z);
|
|
|
+ // }
|
|
|
+ }
|
|
|
+
|
|
|
+ public Vector3Int GetPositionOffsetFromDirection(int rotationIndex, VoxelConnectorData connector)
|
|
|
+ {
|
|
|
+ switch (rotationIndex)
|
|
|
+ {
|
|
|
+ default:
|
|
|
+ case 0:
|
|
|
+ switch (connector.direction)
|
|
|
+ {
|
|
|
+ default:
|
|
|
+ case TargetDirection.Down: return new Vector3Int(0, 0, -1);
|
|
|
+ case TargetDirection.Left: return new Vector3Int(-1, 0, 0);
|
|
|
+ case TargetDirection.Up: return new Vector3Int(0, 0, 1);
|
|
|
+ case TargetDirection.Right: return new Vector3Int(1, 0, 0);
|
|
|
+ }
|
|
|
+ case 1:
|
|
|
+ switch (connector.direction)
|
|
|
+ {
|
|
|
+ default:
|
|
|
+ case TargetDirection.Down: return new Vector3Int(-1, 0, 0);
|
|
|
+ case TargetDirection.Left: return new Vector3Int(0, 0, 1);
|
|
|
+ case TargetDirection.Up: return new Vector3Int(1, 0, 0);
|
|
|
+ case TargetDirection.Right: return new Vector3Int(0, 0, -1);
|
|
|
+ }
|
|
|
+ case 2:
|
|
|
+ switch (connector.direction)
|
|
|
+ {
|
|
|
+ default:
|
|
|
+ case TargetDirection.Down: return new Vector3Int(0, 0, 1);
|
|
|
+ case TargetDirection.Left: return new Vector3Int(1, 0, 0);
|
|
|
+ case TargetDirection.Up: return new Vector3Int(0, 0, -1);
|
|
|
+ case TargetDirection.Right: return new Vector3Int(-1, 0, 0);
|
|
|
+ }
|
|
|
+ case 3:
|
|
|
+ switch (connector.direction)
|
|
|
+ {
|
|
|
+ default:
|
|
|
+ case TargetDirection.Down: return new Vector3Int(1, 0, 0);
|
|
|
+ case TargetDirection.Left: return new Vector3Int(0, 0, -1);
|
|
|
+ case TargetDirection.Up: return new Vector3Int(-1, 0, 0);
|
|
|
+ case TargetDirection.Right: return new Vector3Int(0, 0, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public enum VoxelBuildingTool
|