本文整理汇总了C#中Sandbox.Game.Entities.MyCubeGrid.CanAddCubes方法的典型用法代码示例。如果您正苦于以下问题:C# MyCubeGrid.CanAddCubes方法的具体用法?C# MyCubeGrid.CanAddCubes怎么用?C# MyCubeGrid.CanAddCubes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sandbox.Game.Entities.MyCubeGrid
的用法示例。
在下文中一共展示了MyCubeGrid.CanAddCubes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGridPlacement
private static void TestGridPlacement(ref MyGridPlacementSettings settings, ref MatrixD worldMatrix, ref MyCubeGrid touchingGrid, float gridSize, bool isStatic, ref BoundingBoxD localAABB, MyCubeBlockDefinition blockDefinition,
MyBlockOrientation? blockOrientation, ref bool entityOverlap, ref bool touchingStaticGrid, MyCubeGrid grid)
{
var worldAabb = localAABB.Transform(ref worldMatrix);
var invWorldMatrix = grid.PositionComp.WorldMatrixNormalizedInv;
var otherLocalAabb = worldAabb.Transform(ref invWorldMatrix);
Vector3D minToWorld = Vector3D.Transform(localAABB.Min, worldMatrix);
Vector3D maxToWorld = Vector3D.Transform(localAABB.Max, worldMatrix);
Vector3D tempMinLocal = Vector3D.Transform(minToWorld, invWorldMatrix);
Vector3D tempMaxLocal = Vector3D.Transform(maxToWorld, invWorldMatrix);
Vector3D otherMinLocal = Vector3D.Min(tempMinLocal, tempMaxLocal);
Vector3D otherMaxLocal = Vector3D.Max(tempMinLocal, tempMaxLocal);
var scaledMin = (otherMinLocal + gridSize / 2) / grid.GridSize;
var scaledMax = (otherMaxLocal - gridSize / 2) / grid.GridSize;
var tempMin = Vector3I.Round(scaledMin);
var tempMax = Vector3I.Round(scaledMax);
var min = Vector3I.Min(tempMin, tempMax);
var max = Vector3I.Max(tempMin, tempMax);
MyBlockOrientation? gridBlockOrientation = null;
if (MyFakes.ENABLE_COMPOUND_BLOCKS && isStatic && grid.IsStatic && blockOrientation != null)
{
Matrix blockRotation;
blockOrientation.Value.GetMatrix(out blockRotation);
Matrix rotationInGrid = blockRotation * worldMatrix;
rotationInGrid = rotationInGrid * invWorldMatrix;
rotationInGrid.Translation = Vector3.Zero;
Base6Directions.Direction forwardDir = Base6Directions.GetForward(ref rotationInGrid);
Base6Directions.Direction upDir = Base6Directions.GetUp(ref rotationInGrid);
if (Base6Directions.IsValidBlockOrientation(forwardDir, upDir))
gridBlockOrientation = new MyBlockOrientation(forwardDir, upDir);
}
if (!grid.CanAddCubes(min, max, gridBlockOrientation, blockDefinition))
{
entityOverlap = true;
return;
}
if (settings.CanAnchorToStaticGrid && grid.IsTouchingAnyNeighbor(min, max))
{
touchingStaticGrid = true;
if (touchingGrid == null)
touchingGrid = grid;
}
}