本文整理汇总了C#中Sandbox.Game.Entities.MyCubeBlock类的典型用法代码示例。如果您正苦于以下问题:C# MyCubeBlock类的具体用法?C# MyCubeBlock怎么用?C# MyCubeBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyCubeBlock类属于Sandbox.Game.Entities命名空间,在下文中一共展示了MyCubeBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public void Init(MyCubeBlock myBlock, ConveyorLinePosition a, ConveyorLinePosition b, MyObjectBuilder_ConveyorLine.LineType type, MyObjectBuilder_ConveyorLine.LineConductivity conductivity = MyObjectBuilder_ConveyorLine.LineConductivity.FULL)
{
CubeBlock = myBlock;
ConnectingPosition1 = a;
ConnectingPosition2 = b;
// Neighbour grid position of one of the connecting positions is inside this block
var linePosition = (myBlock as IMyConveyorSegmentBlock).ConveyorSegment.ConnectingPosition1.NeighbourGridPosition;
ConveyorLine = myBlock.CubeGrid.GridSystems.ConveyorSystem.GetDeserializingLine(linePosition);
if (ConveyorLine == null)
{
ConveyorLine = new MyConveyorLine();
if (IsCorner)
ConveyorLine.Init(a, b, myBlock.CubeGrid, type, conductivity, CalculateCornerPosition());
else
ConveyorLine.Init(a, b, myBlock.CubeGrid, type, conductivity, (Vector3I?)null);
}
else
{
Debug.Assert(ConveyorLine.Type == type, "Conveyor line type mismatch on segment deserialization");
}
myBlock.SlimBlock.ComponentStack.IsFunctionalChanged += CubeBlock_IsFunctionalChanged;
}
示例2: MyUpgradableBlockComponent
public MyUpgradableBlockComponent(MyCubeBlock parent)
{
Debug.Assert(parent != null);
ConnectionPositions = new HashSet<ConveyorLinePosition>();
Refresh(parent);
}
示例3: RemoveGenerated
private static bool RemoveGenerated(HkdBreakableBody b, MyCubeBlock block)
{
if (MyFakes.REMOVE_GENERATED_BLOCK_FRACTURES && ContainsGenerated(block))
{
if (b.BreakableShape.IsCompound())
{
b.BreakableShape.GetChildren(m_tmpInfos);
for (int i = 0; i < m_tmpInfos.Count; i++)
{
if (DontCreateFracture(m_tmpInfos[i].Shape))
{
m_tmpInfos.RemoveAt(i);
i--;
}
}
if (m_tmpInfos.Count == 0)
{
return true;
}
m_tmpInfos.Clear();
}
else if (DontCreateFracture(b.BreakableShape))
{
return true;
}
}
return false;
}
示例4: Refresh
public void Refresh(MyCubeBlock parent)
{
ConnectionPositions.Clear();
var positions = MyMultilineConveyorEndpoint.GetLinePositions(parent, "detector_upgrade");
foreach (var position in positions)
{
ConnectionPositions.Add(MyMultilineConveyorEndpoint.PositionToGridCoords(position, parent));
}
}
示例5: MyGuiScreenCubeBuilder
public MyGuiScreenCubeBuilder(int scrollOffset = 0, MyCubeBlock owner = null)
: base(scrollOffset, owner)
{
MySandboxGame.Log.WriteLine("MyGuiScreenCubeBuilder.ctor START");
Static = this;
m_scrollOffset = scrollOffset / 6.5f;
m_size = new Vector2(1, 1);
m_canShareInput = true;
m_drawEvenWithoutFocus = true;
EnabledBackgroundFade = true;
m_screenOwner = owner;
RecreateControls(true);
MySandboxGame.Log.WriteLine("MyGuiScreenCubeBuilder.ctor END");
}
示例6: CreateFracturePiece
public static MyFracturedPiece CreateFracturePiece(HkdBreakableBody b, ref MatrixD worldMatrix, List<MyDefinitionId> originalBlocks, MyCubeBlock block = null, bool sync = true)
{
System.Diagnostics.Debug.Assert(Sync.IsServer, "Only on server");
if (block != null)
{
if (RemoveGenerated(b, block))
{
return null;
}
}
ProfilerShort.Begin("CreateFracturePiece");
var fracturedPiece = MyFracturedPiecesManager.Static.GetPieceFromPool(0);
fracturedPiece.InitFromBreakableBody(b, worldMatrix, block);
fracturedPiece.NeedsUpdate |= Common.MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
//fracturedPiece.Physics.RigidBody.ContactPointCallbackDelay = 0;
//fracturedPiece.Physics.RigidBody.ContactPointCallbackEnabled = true;
ProfilerShort.End();
ProfilerShort.Begin("MyEntities.Add");
MyEntities.Add(fracturedPiece);
ProfilerShort.End();
if (block == null)
{
fracturedPiece.OriginalBlocks.Clear();
fracturedPiece.OriginalBlocks.AddRange(originalBlocks);
MyPhysicalModelDefinition def;
if(MyDefinitionManager.Static.TryGetDefinition<MyPhysicalModelDefinition>(originalBlocks[0], out def))
fracturedPiece.Physics.MaterialType = def.PhysicalMaterial.Id.SubtypeId;
}
if (sync)
MySyncDestructions.CreateFracturePiece((Sandbox.Common.ObjectBuilders.MyObjectBuilder_FracturedPiece)fracturedPiece.GetObjectBuilder());
return fracturedPiece;
}
示例7: CreateFracturePiece
public static MyFracturedPiece CreateFracturePiece(HkdBreakableBody b, ref MatrixD worldMatrix, List<MyDefinitionId> originalBlocks, MyCubeBlock block = null, bool sync = true)
{
System.Diagnostics.Debug.Assert(Sync.IsServer, "Only on server");
if (IsBodyWithoutGeneratedFracturedPieces(b, block))
return null;
ProfilerShort.Begin("CreateFracturePiece");
var fracturedPiece = MyFracturedPiecesManager.Static.GetPieceFromPool(0);
fracturedPiece.InitFromBreakableBody(b, worldMatrix, block);
fracturedPiece.NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
//fracturedPiece.Physics.RigidBody.ContactPointCallbackDelay = 0;
//fracturedPiece.Physics.RigidBody.ContactPointCallbackEnabled = true;
ProfilerShort.End();
if (originalBlocks != null && originalBlocks.Count != 0)
{
fracturedPiece.OriginalBlocks.Clear();
fracturedPiece.OriginalBlocks.AddRange(originalBlocks);
MyPhysicalModelDefinition def;
if (MyDefinitionManager.Static.TryGetDefinition<MyPhysicalModelDefinition>(originalBlocks[0], out def))
fracturedPiece.Physics.MaterialType = def.PhysicalMaterial.Id.SubtypeId;
}
// Check valid shapes from block definitions.
if (MyFakes.ENABLE_FRACTURE_PIECE_SHAPE_CHECK)
fracturedPiece.DebugCheckValidShapes();
ProfilerShort.Begin("MyEntities.Add");
MyEntities.RaiseEntityCreated(fracturedPiece);
MyEntities.Add(fracturedPiece);
ProfilerShort.End();
return fracturedPiece;
}
示例8: MyUseObjectWardrobe
public MyUseObjectWardrobe(IMyEntity owner, string dummyName, MyModelDummy dummyData, uint key)
: base(owner, dummyData)
{
Block = owner as MyCubeBlock;
LocalMatrix = dummyData.Matrix;
}
示例9: OnAddedToContainer
public override void OnAddedToContainer()
{
base.OnAddedToContainer();
m_cubeBlock = Container.Entity as MyCubeBlock;
}
示例10: ConveyorSystem_BlockRemoved
private void ConveyorSystem_BlockRemoved(MyCubeBlock obj)
{
m_interactedGridOwners.Remove(obj);
if (m_leftShowsGrid) LeftTypeGroup_SelectedChanged(m_leftTypeGroup);
if (m_rightShowsGrid) RightTypeGroup_SelectedChanged(m_rightTypeGroup);
if (m_dragAndDropInfo != null)
{
ClearDisabledControls();
DisableInvalidWhileDragging();
}
}
示例11: MyBatteryBlock_IsWorkingChanged
void MyBatteryBlock_IsWorkingChanged(MyCubeBlock obj)
{
UpdateMaxOutputAndEmissivity();
ResourceSink.Update();
}
示例12: Add
public void Add(MyCubeBlock block)
{
bool added = m_inventoryBlocks.Add(block);
System.Diagnostics.Debug.Assert(added, "Double add");
var handler = BlockAdded;
if (handler != null) handler(block);
}
示例13: MyUpgradeModule_IsWorkingChanged
void MyUpgradeModule_IsWorkingChanged(MyCubeBlock obj)
{
RefreshEffects();
UpdateEmissivity();
}
示例14: ContainsBlockWithoutGeneratedFracturedPieces
/// <summary>
/// Returns true if the block (or any block in compound) does not generate generate fractured pieces.
/// </summary>
private static bool ContainsBlockWithoutGeneratedFracturedPieces(MyCubeBlock block)
{
if (!block.BlockDefinition.CreateFracturedPieces)
return true;
if (block is MyCompoundCubeBlock)
{
foreach (var b in (block as MyCompoundCubeBlock).GetBlocks())
if (!b.BlockDefinition.CreateFracturedPieces)
return true;
}
if (block is MyFracturedBlock)
{
foreach (var def in (block as MyFracturedBlock).OriginalBlocks)
if (!MyDefinitionManager.Static.GetCubeBlockDefinition(def).CreateFracturedPieces)
return true;
}
return false;
}
示例15: ContainsGenerated
private static bool ContainsGenerated(MyCubeBlock block)
{
if (block.BlockDefinition.IsGeneratedBlock)
return true;
if (block is MyCompoundCubeBlock)
{
foreach (var b in (block as MyCompoundCubeBlock).GetBlocks())
if (b.BlockDefinition.IsGeneratedBlock)
return true;
}
if (block is MyFracturedBlock)
{
foreach (var def in (block as MyFracturedBlock).OriginalBlocks)
if (MyDefinitionManager.Static.GetCubeBlockDefinition(def).IsGeneratedBlock)
return true;
}
return false;
}