本文整理汇总了C#中Sandbox.Game.Entities.Cube.MySlimBlock.GetObjectBuilder方法的典型用法代码示例。如果您正苦于以下问题:C# MySlimBlock.GetObjectBuilder方法的具体用法?C# MySlimBlock.GetObjectBuilder怎么用?C# MySlimBlock.GetObjectBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sandbox.Game.Entities.Cube.MySlimBlock
的用法示例。
在下文中一共展示了MySlimBlock.GetObjectBuilder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public void Build(MySlimBlock cubeBlock, long owner, long builder, bool requestInstant = true, long builtBy = 0)
{
Quaternion quat = Quaternion.Identity;
var orientation = cubeBlock.Orientation;
Quaternion projQuat = Quaternion.Identity;
Orientation.GetQuaternion(out projQuat);
orientation.GetQuaternion(out quat);
quat = Quaternion.Multiply(ProjectionRotationQuaternion, quat);
quat = Quaternion.Multiply(projQuat, quat);
var projectorGrid = CubeGrid;
var projectedGrid = cubeBlock.CubeGrid;
Vector3I cubeMin = cubeBlock.FatBlock != null ? cubeBlock.FatBlock.Min : cubeBlock.Position;
Vector3I cubeMax = cubeBlock.FatBlock != null ? cubeBlock.FatBlock.Max : cubeBlock.Position;
Vector3I min = projectorGrid.WorldToGridInteger(projectedGrid.GridIntegerToWorld(cubeMin));
Vector3I max = projectorGrid.WorldToGridInteger(projectedGrid.GridIntegerToWorld(cubeMax));
Vector3I pos = projectorGrid.WorldToGridInteger(projectedGrid.GridIntegerToWorld(cubeBlock.Position));
Vector3I projectedMin = new Vector3I(Math.Min(min.X, max.X), Math.Min(min.Y, max.Y), Math.Min(min.Z, max.Z));
Vector3I projectedMax = new Vector3I(Math.Max(min.X, max.X), Math.Max(min.Y, max.Y), Math.Max(min.Z, max.Z));
MyCubeGrid.MyBlockLocation location = new MyCubeGrid.MyBlockLocation(cubeBlock.BlockDefinition.Id, projectedMin, projectedMax, pos, quat, 0, owner);
MyObjectBuilder_CubeBlock objectBuilder = null;
//Find original grid builder
foreach (var blockBuilder in m_originalGridBuilder.CubeBlocks)
{
if ((Vector3I)blockBuilder.Min == cubeMin && blockBuilder.GetId() == cubeBlock.BlockDefinition.Id)
{
objectBuilder = (MyObjectBuilder_CubeBlock)blockBuilder.Clone();
objectBuilder.SetupForProjector();
}
}
if (objectBuilder == null)
{
System.Diagnostics.Debug.Fail("Original object builder could not be found! (AlexFlorea)");
objectBuilder = cubeBlock.GetObjectBuilder();
location.EntityId = MyEntityIdentifier.AllocateId();
}
objectBuilder.ConstructionInventory = null;
objectBuilder.BuiltBy = builtBy;
bool buildInstant = requestInstant && MySession.Static.IsAdminModeEnabled(Sync.MyId);
MyMultiplayer.RaiseEvent(projectorGrid, x => x.BuildBlockRequest, cubeBlock.ColorMaskHSV.PackHSVToUint(), location, objectBuilder, builder, buildInstant, owner);
HideCube(cubeBlock);
}
示例2: Build
public void Build(MySlimBlock cubeBlock, long owner, long builder)
{
Quaternion quat = Quaternion.Identity;
var orientation = cubeBlock.Orientation;
Matrix local;
orientation.GetMatrix(out local);
var gridOrientation = m_clipboard.GetFirstGridOrientationMatrix();
if (gridOrientation != Matrix.Identity)
{
var afterRotation = Matrix.Multiply(local, gridOrientation);
orientation = new MyBlockOrientation(ref afterRotation);
}
Quaternion projQuat = Quaternion.Identity;
Orientation.GetQuaternion(out projQuat);
orientation.GetQuaternion(out quat);
quat = Quaternion.Multiply(projQuat, quat);
var projectorGrid = CubeGrid;
var projectedGrid = cubeBlock.CubeGrid;
Vector3I cubeMin = cubeBlock.FatBlock != null ? cubeBlock.FatBlock.Min : cubeBlock.Position;
Vector3I cubeMax = cubeBlock.FatBlock != null ? cubeBlock.FatBlock.Max : cubeBlock.Position;
Vector3I min = projectorGrid.WorldToGridInteger(projectedGrid.GridIntegerToWorld(cubeMin));
Vector3I max = projectorGrid.WorldToGridInteger(projectedGrid.GridIntegerToWorld(cubeMax));
Vector3I pos = projectorGrid.WorldToGridInteger(projectedGrid.GridIntegerToWorld(cubeBlock.Position));
Vector3I projectedMin = new Vector3I(Math.Min(min.X, max.X), Math.Min(min.Y, max.Y), Math.Min(min.Z, max.Z));
Vector3I projectedMax = new Vector3I(Math.Max(min.X, max.X), Math.Max(min.Y, max.Y), Math.Max(min.Z, max.Z));
MyCubeGrid.MyBlockLocation location = new MyCubeGrid.MyBlockLocation(cubeBlock.BlockDefinition.Id, projectedMin, projectedMax, pos,
quat, 0, owner, builder);
MyObjectBuilder_CubeBlock objectBuilder = null;
//Find original grid builder
foreach (var blockBuilder in m_originalGridBuilder.CubeBlocks)
{
if (blockBuilder.Min == cubeMin && blockBuilder.GetId() == cubeBlock.BlockDefinition.Id)
{
objectBuilder = (MyObjectBuilder_CubeBlock)blockBuilder.Clone();
objectBuilder.SetupForProjector();
}
}
if (objectBuilder == null)
{
System.Diagnostics.Debug.Fail("Original object builder could not be found! (AlexFlorea)");
objectBuilder = cubeBlock.GetObjectBuilder();
location.EntityId = MyEntityIdentifier.AllocateId();
}
objectBuilder.ConstructionInventory = null;
projectorGrid.BuildBlock(cubeBlock.ColorMaskHSV, location, objectBuilder);
HideCube(cubeBlock);
}