Exemple #1
0
 public ModBrickCell(float distance, ModBrickGrid grid, Vector3 worldPos, Vector3I gridPos)
 {
     Distance = distance;
     CellGrid = grid;
     WorldPos = worldPos;
     GridPos  = gridPos;
 }
        private Vector3 ChooseBestSnappingPosition()
        {
            var bestSnap = _potentialGridCellsWorld.Min(x => x.Distance); // todo: check up on this

            _potentialBestSnapCell = _potentialGridCellsWorld.FirstOrDefault(x => x.Distance == bestSnap);

            _currentGrid = _potentialBestSnapCell.CellGrid;

            // get the world position of that snappable stud:
            Vector3 position = _potentialBestSnapCell.WorldPos;

            // make sure entire brick is offset according to tube/stub being snapped to:
            position.x = position.x - _potentialBestSnapCell.TubeLocalPos.x;
            position.y = position.y - ModBrickMetrics.ThirdHeight / 2;
            position.z = position.z - _potentialBestSnapCell.TubeLocalPos.z;

            return(position);
        }