当前位置: 首页>>代码示例>>C#>>正文


C# Cube.MySlimBlock类代码示例

本文整理汇总了C#中Sandbox.Game.Entities.Cube.MySlimBlock的典型用法代码示例。如果您正苦于以下问题:C# MySlimBlock类的具体用法?C# MySlimBlock怎么用?C# MySlimBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MySlimBlock类属于Sandbox.Game.Entities.Cube命名空间,在下文中一共展示了MySlimBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetBattlePoints

        public static ulong GetBattlePoints(MySlimBlock slimBlock)
        {
            Debug.Assert(slimBlock.BlockDefinition.Points > 0);
            ulong pts = (ulong)(slimBlock.BlockDefinition.Points > 0 ? slimBlock.BlockDefinition.Points : 1);

            if (slimBlock.BlockDefinition.IsGeneratedBlock)
                pts = 0;

            // Get points from container items
            IMyInventoryOwner inventoryOwner = slimBlock.FatBlock as IMyInventoryOwner;
            if (inventoryOwner != null)
            {
                var inventory = inventoryOwner.GetInventory(0);
                if (inventory != null)
                {
                    foreach (var item in inventory.GetItems())
                    {
                        if (item.Content is MyObjectBuilder_BlockItem)
                        {
                            MyObjectBuilder_BlockItem blockItem = item.Content as MyObjectBuilder_BlockItem;
                            pts += GetBattlePoints(blockItem.BlockDefId);
                        }
                    }
                }
            }

            return pts;
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:28,代码来源:MyBattleHelper.cs

示例2: GetWrapper

        public static SlimBlockWrapper GetWrapper(MySlimBlock slimBlock)
        {
            if (slimBlock.FatBlock == null)
                return new SlimBlockWrapper(slimBlock);

            MyCubeBlock block = slimBlock.FatBlock;

            if (block is MyThrust)
                return new ThrustWrapper(slimBlock);
            if (block is MyGyro)
                return new GyroWrapper(slimBlock);
            if (block is MyLargeTurretBase)
                return new TurretWrapper(slimBlock);
            if (block is MyBatteryBlock)
                return new BatteryWrapper(slimBlock);
            if (block is MyShipToolBase)
                return new ShipToolWrapper(slimBlock);
            if(block is MyLandingGear)
                return new LandingGearWrapper( slimBlock );
            if(block is MyShipConnector)
                return new ConnectorWrapper( slimBlock );

            if (block is MyFunctionalBlock)
                return new FunctionalBlockWrapper(slimBlock);

            return new CubeBlockWrapper(slimBlock);
        }
开发者ID:rexxar-tc,项目名称:SEServerExtender,代码行数:27,代码来源:SlimBlockWrapper.cs

示例3: MarkBlockChanged

        // Actually, this function marks even cubes around the block to make sure that any changes caused in their triangles
        // will be reflected in the navigation mesh.
        public void MarkBlockChanged(MySlimBlock block)
        {
            Vector3I min = block.Min - Vector3I.One;
            Vector3I max = block.Max + Vector3I.One;

            Vector3I pos = min;
            for (var it = new Vector3I.RangeIterator(ref block.Min, ref block.Max); it.IsValid(); it.GetNext(out pos))
            {
                m_changedCubes.Add(pos);
            }

            Vector3I minCell = CubeToCell(ref min);
            Vector3I maxCell = CubeToCell(ref max);

            pos = minCell;
            for (var it = new Vector3I.RangeIterator(ref minCell, ref maxCell); it.IsValid(); it.GetNext(out pos))
            {
                m_changedCells.Add(pos);

                MyCellCoord cellCoord = new MyCellCoord(0, pos);
                ulong packedCell = cellCoord.PackId64();

                TryClearCell(packedCell);
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:27,代码来源:MyGridHighLevelHelper.cs

示例4: CubeGrid_OnBlockAdded

 void CubeGrid_OnBlockAdded(MySlimBlock obj)
 {
     if (obj != SlimBlock)
     {
         m_needsRefresh = true;
     }
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MyUpgradeModule.cs

示例5: RemoveEdgeInfo

 public void RemoveEdgeInfo(Vector3 point0, Vector3 point1, MySlimBlock owner)
 {
     var hash = CalculateEdgeHash(point0, point1);
     var pos = (point0 + point1) * 0.5f;
     var cell = GetCell(pos);
     if (cell.RemoveEdgeInfo(hash, owner))
         m_dirtyCells.Add(cell);
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:8,代码来源:MyCubeGridRenderData.cs

示例6: Add

 public void Add(MySlimBlock block)
 {
     bool isStatic = MyCubeGrid.IsInVoxels(block);
     var element = new Element(isStatic);
     if (!isStatic)
         element.CurrentOffset = 0.05f;
     Lookup[block.Position] = element;
     m_blocksChanged = true;
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:9,代码来源:MyOndraSimulator.cs

示例7: MyGeneratedBlockLocation

 public MyGeneratedBlockLocation(MySlimBlock refBlock, MyCubeBlockDefinition blockDefinition, Vector3I position, Vector3I forward, Vector3I up, ushort? blockIdInCompound = null, MyGridInfo gridInfo = null)
 {
     RefBlock = refBlock;
     BlockDefinition = blockDefinition;
     Position = position;
     Orientation = new MyBlockOrientation(Base6Directions.GetDirection(ref forward), Base6Directions.GetDirection(ref up));
     BlockIdInCompound = blockIdInCompound;
     GridInfo = gridInfo;
     GeneratedBlockType = MyStringId.NullOrEmpty;
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:10,代码来源:MyAdditionalModelGeneratorBase.cs

示例8: AddEdgeInfo

        public void AddEdgeInfo(ref Vector3 point0, ref Vector3 point1, ref Vector3 normal0, ref Vector3 normal1, Color color, MySlimBlock owner)
        {
            var hash = CalculateEdgeHash(point0, point1);
            var pos = (point0 + point1) * 0.5f;
            Vector3I direction = Vector3I.Round((point0 - point1) / m_gridRender.GridSize);

            MyEdgeInfo info = new MyEdgeInfo(ref pos, ref direction, ref normal0, ref normal1, ref color, MyStringHash.GetOrCompute(owner.BlockDefinition.EdgeType));
            var cell = GetCell(pos);
            if (cell.AddEdgeInfo(hash, info, owner))
                m_dirtyCells.Add(cell);
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:11,代码来源:MyCubeGridRenderData.cs

示例9: DoDamageSynced

        internal static void DoDamageSynced(MySlimBlock block, float damage, MyDamageType damageType)
        {
            Debug.Assert(Sync.IsServer);
            var msg = new DoDamageSlimBlockMsg();
            msg.GridEntityId = block.CubeGrid.EntityId;
            msg.Position = block.Position;
            msg.Damage = damage;

            block.DoDamage(damage, damageType);
            Sync.Layer.SendMessageToAll<DoDamageSlimBlockMsg>(ref msg);
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:11,代码来源:MySyncHelper.cs

示例10: DrawSemiTransparentBox

        public static void DrawSemiTransparentBox(MyCubeGrid grid, MySlimBlock block, Color color, bool onlyWireframe = false, string lineMaterial = null, Vector4? lineColor = null)
        {
            var min = (block.Min * grid.GridSize) - new Vector3(grid.GridSize / 2.0f + 0.02f);
            var max = (block.Max * grid.GridSize) + new Vector3(grid.GridSize / 2.0f + 0.02f);
            BoundingBoxD boxr = new BoundingBoxD(min, max);
            MatrixD gridMatrix = grid.WorldMatrix;
            var lColor = Color.White;
            if (lineColor.HasValue)
            {
                lColor = lineColor.Value;
            }

            MySimpleObjectDraw.DrawTransparentBox(ref gridMatrix, ref boxr, ref lColor, MySimpleObjectRasterizer.Wireframe, 1, 0.04f, null, lineMaterial, false);
            if (!onlyWireframe)
            {
                Color faceColor = new Color(color * 0.2f, 0.3f);
                MySimpleObjectDraw.DrawTransparentBox(ref gridMatrix, ref boxr, ref faceColor, MySimpleObjectRasterizer.Solid, 0, 0.04f, "Square", null, true);
            }
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:19,代码来源:MyCubeBuilder-Draw.cs

示例11: MarkBlockChanged

        // Actually, this function marks even cubes around the block to make sure that any changes caused in their triangles
        // will be reflected in the navigation mesh.
        public void MarkBlockChanged(MySlimBlock block)
        {
            Vector3I min = block.Min - Vector3I.One;
            Vector3I max = block.Max + Vector3I.One;

            Vector3I pos = min;
            for (var it = new Vector3I_RangeIterator(ref block.Min, ref block.Max); it.IsValid(); it.GetNext(out pos))
            {
                m_changedCubes.Add(pos);
            }

            Vector3I minCell = CubeToCell(ref min);
            Vector3I maxCell = CubeToCell(ref max);

            pos = minCell;
            for (var it = new Vector3I_RangeIterator(ref minCell, ref maxCell); it.IsValid(); it.GetNext(out pos))
            {
                m_changedCells.Add(pos);
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:22,代码来源:MyGridHighLevelHelper.cs

示例12: ConnectionAllowed

 private bool ConnectionAllowed(ref Vector3I otherBlockPos, ref Vector3I faceNormal, MySlimBlock other)
 {
     if (MyStructuralIntegrity.Enabled && CubeGrid.StructuralIntegrity != null)
     {
         if (!CubeGrid.StructuralIntegrity.IsConnectionFine(this, other))
             return false;
     }
     if(DisconnectFaces.Count > 0 && DisconnectFaces.Contains(faceNormal))
         return false;
     return FatBlock == null || !FatBlock.CheckConnectionAllowed || FatBlock.ConnectionAllowed(ref otherBlockPos, ref faceNormal, other.BlockDefinition);
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:11,代码来源:MySlimBlock.cs

示例13: HideIntersectedBlock

        private void HideIntersectedBlock()
        {
            if (m_instantBuildingEnabled)
            {
                return;
            }

            var character = MySession.Static.LocalCharacter;
            if (character == null)
            {
                return;
            }

            Vector3D position = character.GetHeadMatrix(true).Translation;
            if (ProjectedGrid == null) return;

            Vector3I gridPosition = ProjectedGrid.WorldToGridInteger(position);
            MySlimBlock cubeBlock = ProjectedGrid.GetCubeBlock(gridPosition);
            if (cubeBlock != null)
            {
                if (Math.Abs(cubeBlock.Dithering) < 1.0f)
                {
                    if (m_hiddenBlock != cubeBlock)
                    {
                        if (m_hiddenBlock != null)
                        {
                            ShowCube(m_hiddenBlock, CanBuild(m_hiddenBlock));
                        }
                        HideCube(cubeBlock);
                        m_hiddenBlock = cubeBlock;
                    }
                }
            }
            else
            {
                if (m_hiddenBlock != null)
                {
                    ShowCube(m_hiddenBlock, CanBuild(m_hiddenBlock));
                    m_hiddenBlock = null;
                }
            }
        }
开发者ID:Rynchodon,项目名称:SpaceEngineers,代码行数:42,代码来源:MyProjectorBase.cs

示例14: SetTransparency

        protected virtual void SetTransparency(MySlimBlock cubeBlock, float transparency)
        {
            //This is intended. It signals to the shader to render it in a special way.
            transparency = -transparency;

            if (cubeBlock.Dithering == transparency && cubeBlock.CubeGrid.Render.Transparency == transparency)
            {
                return;
            }
            cubeBlock.CubeGrid.Render.Transparency = transparency;
            cubeBlock.Dithering = transparency;
            cubeBlock.UpdateVisual();

            var block = cubeBlock.FatBlock;
            if (block != null)
            {
                SetTransparencyForSubparts(block, transparency);
            }

            if (block != null && block.UseObjectsComponent != null && block.UseObjectsComponent.DetectorPhysics != null)
            {
                block.UseObjectsComponent.DetectorPhysics.Enabled = false;
            }
        }
开发者ID:Rynchodon,项目名称:SpaceEngineers,代码行数:24,代码来源:MyProjectorBase.cs

示例15: HideCube

 public void HideCube(MySlimBlock cubeBlock)
 {
     SetTransparency(cubeBlock, 1f);
 }
开发者ID:Rynchodon,项目名称:SpaceEngineers,代码行数:4,代码来源:MyProjectorBase.cs


注:本文中的Sandbox.Game.Entities.Cube.MySlimBlock类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。