本文整理汇总了C#中MyCubeGrid.CalculateMergeTransform方法的典型用法代码示例。如果您正苦于以下问题:C# MyCubeGrid.CalculateMergeTransform方法的具体用法?C# MyCubeGrid.CalculateMergeTransform怎么用?C# MyCubeGrid.CalculateMergeTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyCubeGrid
的用法示例。
在下文中一共展示了MyCubeGrid.CalculateMergeTransform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGridPlacementOnGrid
protected bool TestGridPlacementOnGrid(MyCubeGrid previewGrid, ref MyGridPlacementSettings settings, MyCubeGrid hitGrid)
{
bool retval = true;
Vector3I gridOffset = hitGrid.WorldToGridInteger(m_pastePosition);
MatrixI transform = hitGrid.CalculateMergeTransform(previewGrid, gridOffset);
if (MyDebugDrawSettings.DEBUG_DRAW_COPY_PASTE)
MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, 60.0f), "First grid offset: " + gridOffset.ToString(), Color.Red, 1.0f);
retval = retval && hitGrid.GridSizeEnum == previewGrid.GridSizeEnum && hitGrid.CanMergeCubes(previewGrid, gridOffset);
retval = retval && MyCubeGrid.CheckMergeConnectivity(hitGrid, previewGrid, gridOffset);
// Check if any block connects to hit grid
if (retval)
{
bool connected = false;
foreach (var block in previewGrid.CubeBlocks)
{
if (block.FatBlock is MyCompoundCubeBlock)
{
MyCompoundCubeBlock compoundBlock = block.FatBlock as MyCompoundCubeBlock;
foreach (var blockInCompound in compoundBlock.GetBlocks())
{
connected |= CheckConnectivityOnGrid(blockInCompound, ref transform, ref settings, hitGrid);
if (connected)
break;
}
}
else
{
connected |= CheckConnectivityOnGrid(block, ref transform, ref settings, hitGrid);
}
if (connected)
break;
}
retval &= connected;
}
if (retval)
{
foreach (var block in previewGrid.CubeBlocks)
{
if (block.FatBlock is MyCompoundCubeBlock)
{
MyCompoundCubeBlock compoundBlock = block.FatBlock as MyCompoundCubeBlock;
foreach (var blockInCompound in compoundBlock.GetBlocks())
{
retval = retval && TestBlockPlacementOnGrid(blockInCompound, ref transform, ref settings, hitGrid);
if (!retval)
break;
}
}
else
{
retval = retval && TestBlockPlacementOnGrid(block, ref transform, ref settings, hitGrid);
}
if (!retval)
break;
}
}
return retval;
}