本文整理汇总了C#中IMyCubeGrid.GetCubeBlock方法的典型用法代码示例。如果您正苦于以下问题:C# IMyCubeGrid.GetCubeBlock方法的具体用法?C# IMyCubeGrid.GetCubeBlock怎么用?C# IMyCubeGrid.GetCubeBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMyCubeGrid
的用法示例。
在下文中一共展示了IMyCubeGrid.GetCubeBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateBlockModel
/// <summary>
/// Updates the appearance of the block if the integrity has changed. Only used for welding/griding.
/// </summary>
private static void UpdateBlockModel(IMySlimBlock realBlock, IMyCubeGrid holoGrid)
{
IMySlimBlock holoBlock = holoGrid.GetCubeBlock(realBlock.Position);
Static.logger.debugLog(holoBlock == null, "holoBlock == null", Logger.severity.FATAL);
float realIntegrityRatio = (realBlock.BuildIntegrity - realBlock.CurrentDamage) / realBlock.MaxIntegrity;
float holoIntegrityRatio = (holoBlock.BuildIntegrity - holoBlock.CurrentDamage) / holoBlock.MaxIntegrity;
if (realIntegrityRatio == holoIntegrityRatio)
return;
float min, max;
if (realIntegrityRatio > holoIntegrityRatio)
{
max = realIntegrityRatio;
min = holoIntegrityRatio;
}
else
{
max = holoIntegrityRatio;
min = realIntegrityRatio;
}
if (((MyCubeBlockDefinition)realBlock.BlockDefinition).ModelChangeIsNeeded(min, max))
{
holoGrid.RemoveBlock(holoBlock);
MyObjectBuilder_CubeBlock objBuilder = realBlock.GetObjectBuilder();
objBuilder.EntityId = 0L;
holoGrid.AddBlock(objBuilder, false);
IMyCubeBlock cubeBlock = holoGrid.GetCubeBlock(realBlock.Position).FatBlock;
if (cubeBlock != null)
SetupProjection(cubeBlock);
}
}
示例2: rejectionIntersects
/// <summary>
/// Rejection test for intersection with the profiled grid.
/// </summary>
/// <param name="grid">Grid whose cells will be rejected and compared to the profiled grid's rejections.</param>
/// <returns>True iff there is a collision</returns>
public bool rejectionIntersects(IMyCubeGrid grid, IMyCubeBlock ignore, out MyEntity entity, out Vector3? pointOfObstruction)
{
m_logger.debugLog(m_grid == null, "m_grid == null", Logger.severity.FATAL);
//m_logger.debugLog("testing grid: " + grid.getBestName(), "rejectionIntersects()");
GridCellCache gridCache = GridCellCache.GetCellCache(grid);
MatrixD toLocal = m_grid.WorldMatrixNormalizedInv;
Line pathLine = Path.get_Line();
float minDist = m_grid.GridSize + grid.GridSize;
//if (!m_landing)
// minDist += NotLandingBuffer;
float pathRadius = Path.Radius + minDist;
float minDistSquared = minDist * minDist;
MyEntity entity_in = null;
Vector3? pointOfObstruction_in = null;
using (m_lock_rejcectionCells.AcquireSharedUsing())
gridCache.ForEach(cell => {
Vector3 world = grid.GridIntegerToWorld(cell);
//m_logger.debugLog("checking position: " + world, "rejectionIntersects()");
if (pathLine.PointInCylinder(pathRadius, world))
{
//m_logger.debugLog("point in cylinder: " + world, "rejectionIntersects()");
Vector3 local = Vector3.Transform(world, toLocal);
if (rejectionIntersects(local, minDistSquared))
{
entity_in = grid.GetCubeBlock(cell).FatBlock as MyEntity ?? grid as MyEntity;
if (ignore != null && entity_in == ignore)
return false;
pointOfObstruction_in = pathLine.ClosestPoint(world);
return true;
}
}
return false;
});
if (pointOfObstruction_in.HasValue)
{
entity = entity_in;
pointOfObstruction = pointOfObstruction_in;
return true;
}
entity = null;
pointOfObstruction = null;
return false;
}