• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Cube.MySlimBlock类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ShowCube

 public void ShowCube(MySlimBlock cubeBlock, bool canBuild)
 {
     ProfilerShort.Begin("SetTransparency");
     if (canBuild)
     {
         SetTransparency(cubeBlock, MyGridConstants.BUILDER_TRANSPARENCY);
     }
     else
     {
         SetTransparency(cubeBlock, MyGridConstants.PROJECTOR_TRANSPARENCY);
     }
     ProfilerShort.End();
 }
开发者ID:Rynchodon,项目名称:SpaceEngineers,代码行数:13,代码来源:MyProjectorBase.cs


示例17: 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);
        }
开发者ID:Rynchodon,项目名称:SpaceEngineers,代码行数:51,代码来源:MyProjectorBase.cs


示例18: OnBlockRemoved

        public virtual void OnBlockRemoved(MySlimBlock block)
        {
            IMyConveyorEndpointBlock conveyorEndpointBlock = block.FatBlock as IMyConveyorEndpointBlock;
            if (conveyorEndpointBlock != null)
                ConveyorSystem.FlagForRecomputation();

            IMyConveyorSegmentBlock conveyorSegmentBlock = block.FatBlock as IMyConveyorSegmentBlock;
            if (conveyorSegmentBlock != null)
                ConveyorSystem.FlagForRecomputation();

            if (ShipSoundComponent != null && block.FatBlock as MyThrust != null)
                ShipSoundComponent.ShipHasChanged = true;
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:13,代码来源:MyCubeGridSystems.cs


示例19: cubeGrid_OnBlockRemoved

 void cubeGrid_OnBlockRemoved(MySlimBlock block)
 {
     m_simulator.Remove(block);
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:4,代码来源:MyStructuralIntegrity.cs


示例20: IsConnectionFine

 public bool IsConnectionFine(MySlimBlock blockA, MySlimBlock blockB)
 {
     return m_simulator.IsConnectionFine(blockA, blockB);
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:4,代码来源:MyStructuralIntegrity.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Cube.MyTerminalBlock类代码示例发布时间:2022-05-26
下一篇:
C# Cube.MyGridPlacementSettings类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap