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

C# ObjectBuilders.MyObjectBuilder_CubeGrid类代码示例

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

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



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

示例1: GetBattlePoints

        public static ulong GetBattlePoints(MyObjectBuilder_CubeGrid[] grids)
        {
            ulong pts = 0;
            foreach (var grid in grids)
                pts += GetBattlePoints(grid);

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


示例2: RequestThrow

 public static void RequestThrow(MyObjectBuilder_CubeGrid grid, Vector3D position, Vector3D linearVelocity, float mass, MyStringId throwSound)
 {
     ThrowMsg msg = new ThrowMsg();
     msg.Grid = grid;
     msg.Position = position;
     msg.LinearVelocity = linearVelocity;
     msg.Mass = mass;
     msg.ThrowSound = throwSound;
     MySession.Static.SyncLayer.SendMessageToServer(ref msg);
 }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:10,代码来源:MySyncThrower.cs


示例3: ProcessCubeGrid

 public void ProcessCubeGrid(MyObjectBuilder_CubeGrid gridBuilder)
 {
     gridBuilder.IsStatic = false;
     foreach (var block in gridBuilder.CubeBlocks)
     {
         var functionalBlock = block as MyObjectBuilder_FunctionalBlock;
         if (functionalBlock != null)
         {
             functionalBlock.Enabled = false;
         }
     }
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:12,代码来源:MyProjectorClipboard.cs


示例4: Contains

        public bool Contains(IMySlimBlock block)
        {
            if (block.CubeGrid == null)
                return false;

            // FatBlock is null for non functional blocks such as armor
            if (block.FatBlock != null)
                return Contains(block.FatBlock);

            // since some blocks aren't an entity we have to deal with them otherwise
            // we'll create an grid that acts as substitute for the block to get an entity that has a collision
            // TODO find a better suited way to get the boundings of an armor block
            var worldPosition = block.CubeGrid.GetPosition() + block.Position;

            // creating grid
            var gridBuilder = new MyObjectBuilder_CubeGrid()
            {
                PersistentFlags = MyPersistentEntityFlags2.None,
                PositionAndOrientation = new MyPositionAndOrientation(worldPosition, Vector3.Forward, Vector3.Up),
                DisplayName = "substitute",
                GridSizeEnum = block.CubeGrid.GridSizeEnum
            };

            // creating cube block
            MyObjectBuilder_CubeBlock cube = new MyObjectBuilder_CubeBlock();
            cube.Min = block.Position;
            cube.SubtypeName = block.CubeGrid.GridSizeEnum == MyCubeSize.Large ? "LargeBlockArmorBlock" : "SmallBlockArmorBlock";
            cube.BuildPercent = 0;
            gridBuilder.CubeBlocks.Add(cube);

            // add grid
            MyAPIGateway.Entities.RemapObjectBuilder(gridBuilder);
            var entity = MyAPIGateway.Entities.CreateFromObjectBuilder(gridBuilder);
            var grid = entity as IMyCubeGrid;
            var blocks = new List<IMySlimBlock>();

            // get blocks
            grid.GetBlocks(blocks, b => b != null);

            if (blocks.Count > 0)
            {
                // found block
                var cubeBlock = blocks[0].FatBlock;
                bool isInside = Contains(cubeBlock);
                grid.Close();
                return isInside;
            }

            return false;
        }
开发者ID:Intueor,项目名称:Space-Engineers-Admin-script-mod,代码行数:50,代码来源:ProtectionArea.cs


示例5: CubeGridEntity

        public CubeGridEntity( MyObjectBuilder_CubeGrid definition )
            : base(definition)
        {
            _cubeBlockManager = new CubeBlockManager( this );
            List<CubeBlockEntity> cubeBlockList = new List<CubeBlockEntity>( );
            foreach ( MyObjectBuilder_CubeBlock cubeBlock in definition.CubeBlocks )
            {
                cubeBlock.EntityId = 0;
                cubeBlockList.Add( new CubeBlockEntity( this, cubeBlock ) );
            }
            _cubeBlockManager.Load( cubeBlockList );

            _lastNameRefresh = DateTime.Now;
            _name = "Cube Grid";
        }
开发者ID:LoganRickert,项目名称:SEServerExtender,代码行数:15,代码来源:CubeGridEntity.cs


示例6: Invoke

        public override bool Invoke(string messageText)
        {
            MatrixD worldMatrix;
            Vector3D position;

            if (MyAPIGateway.Session.Player.Controller.ControlledEntity.Entity.Parent == null)
            {
                worldMatrix = MyAPIGateway.Session.Player.Controller.ControlledEntity.GetHeadMatrix(true, true, false); // dead center of player cross hairs.
                position = worldMatrix.Translation + worldMatrix.Forward * 2.5f; // Spawn item 1.5m in front of player for safety.
            }
            else
            {
                worldMatrix = MyAPIGateway.Session.Player.Controller.ControlledEntity.Entity.WorldMatrix;
                position = worldMatrix.Translation + worldMatrix.Forward * 2.5f + worldMatrix.Up * 0.5f; // Spawn item 1.5m in front of player in cockpit for safety.
            }

            // TODO: multiply vector against current entity.LinearVelocity.
            Vector3 vector = worldMatrix.Forward * 300;

            var gridObjectBuilder = new MyObjectBuilder_CubeGrid()
            {
                PersistentFlags = MyPersistentEntityFlags2.CastShadows | MyPersistentEntityFlags2.InScene,
                GridSizeEnum = MyCubeSize.Large,
                IsStatic = false,
                LinearVelocity = vector,
                AngularVelocity = new SerializableVector3(0, 0, 0),
                PositionAndOrientation = new MyPositionAndOrientation(position, Vector3.Forward, Vector3.Up),
                DisplayName = "Prepare to die."
            };

            MyObjectBuilder_Warhead cube = new MyObjectBuilder_Warhead()
            {
                Min = new SerializableVector3I(0, 0, 0),
                SubtypeName = "LargeWarhead",
                ColorMaskHSV = new SerializableVector3(0, -1, 0),
                EntityId = 0,
                Owner = 0,
                BlockOrientation = new SerializableBlockOrientation(Base6Directions.Direction.Forward, Base6Directions.Direction.Up),
                ShareMode = MyOwnershipShareModeEnum.All,
                CustomName = "Hello. My name is Inigo Montoya. You killed my father. Prepare to die.",
            };

            gridObjectBuilder.CubeBlocks.Add(cube);
            var tempList = new List<MyObjectBuilder_EntityBase>();
            tempList.Add(gridObjectBuilder);
            tempList.CreateAndSyncEntities();
            return true;
        }
开发者ID:zerty,项目名称:Space-Engineers-Admin-script-mod,代码行数:48,代码来源:CommandBomb.cs


示例7: Init

        public virtual void Init(MyObjectBuilder_CubeGrid builder)
        {
	        var thrustComp = CubeGrid.Components.Get<MyEntityThrustComponent>();
			if(thrustComp != null)
				thrustComp.DampenersEnabled = builder.DampenersEnabled;

            if (WheelSystem != null)
                WheelSystem.HandBrake = builder.Handbrake;

            if (MySession.Static.Settings.EnableOxygen)
            {
                GasSystem.Init(builder.OxygenAmount);
            }

            if (MyPerGameSettings.EnableJumpDrive)
            {
                JumpSystem.Init(builder.JumpDriveDirection, builder.JumpElapsedTicks);
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:19,代码来源:MyCubeGridSystems.cs


示例8: LoadFromCubeGrid

        public void LoadFromCubeGrid(IMyCubeGrid grid)
        {
            base.LoadFromEntity(grid as IMyEntity);

            IngameGrid = grid;

            //IngameGrid = grid;
            DisplayName = grid.DisplayName;
            // ToDo: get all owners instead of big (for targeting)
            BigOwners = grid.BigOwners;
            // ToDo: get real spawn owners (for spawning)
            SpawnOwners = grid.BigOwners;
            //IMyEntity entity = grid as IMyEntity;
            Builder = grid.GetObjectBuilder() as MyObjectBuilder_CubeGrid;

            if (Builder == null) {
                Log.Error("Got null builder for entity " + EntityId +
                    ". We will be unable to save it now.", "LoadFromCubeGrid");
            }
            else {
                //Log.Error("Filling builder nulls for " + EntityId, "LoadFromCubeGrid");
                //Builder.FillNullsWithDefaults();
            }
        }
开发者ID:HaoTNN,项目名称:GardenPerformance,代码行数:24,代码来源:ConcealableGrid.cs


示例9: DoesGridHaveFourBeacons

        public static bool DoesGridHaveFourBeacons( MyObjectBuilder_CubeGrid grid )
        {
            int count = 0;
            foreach ( MyObjectBuilder_CubeBlock block in grid.CubeBlocks )
            {
                if ( block is MyObjectBuilder_Beacon )
                    count++;

                if ( count >= 4 )
                    return true;
            }

            return false;
        }
开发者ID:Pingperfect,项目名称:EssentialsPlugin,代码行数:14,代码来源:CubeGrid.cs


示例10: DoesGridHavePowerSupply

 public static bool DoesGridHavePowerSupply( MyObjectBuilder_CubeGrid grid )
 {
     return grid.CubeBlocks.Any( DoesBlockSupplyPower );
 }
开发者ID:Pingperfect,项目名称:EssentialsPlugin,代码行数:4,代码来源:CubeGrid.cs


示例11: SetNewBlueprint

        internal void SetNewBlueprint(MyObjectBuilder_CubeGrid gridBuilder)
        {
            m_originalGridBuilder = gridBuilder;

            var clone = (MyObjectBuilder_CubeGrid)gridBuilder.Clone();

            MyEntities.RemapObjectBuilder(clone);
            m_clipboard.ProcessCubeGrid(clone);

            m_clipboard.SetGridFromBuilder(clone, Vector3.Zero, 0f);

            if (m_instantBuildingEnabled)
            {
                ResetRotation();
                var boundingBox = clone.CalculateBoundingBox();
                // Add 1 to get the center out of the bounds and another 1 for a gap
                m_projectionOffset.Y = Math.Abs((int)(boundingBox.Min.Y / MyDefinitionManager.Static.GetCubeSize(clone.GridSizeEnum))) + 2;
            }

            InitializeClipboard();
        }
开发者ID:blaho,项目名称:SpaceEngineers,代码行数:21,代码来源:MyProjector.cs


示例12: UpdateOnceBeforeFrame

        public override void UpdateOnceBeforeFrame()
        {
            base.UpdateOnceBeforeFrame();

            //Only create projections from real projectors
            if (CubeGrid.Physics != null && m_savedProjection != null)
            {
                var clone = (MyObjectBuilder_CubeGrid)m_savedProjection.Clone();
                MyEntities.RemapObjectBuilder(clone);
                m_clipboard.ProcessCubeGrid(clone);

                m_clipboard.SetGridFromBuilder(clone, Vector3.Zero, 0f);
                m_originalGridBuilder = m_savedProjection;
                m_savedProjection = null;
                InitializeClipboard();
                
                //This will just issue the request
                //It will only remove it only if conditions are not met a few frames later
                RequestRemoveProjection();
            }
            UpdateEmissivity();
        }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:22,代码来源:MyProjector.cs


示例13: blueprintScreen_Closed

        void blueprintScreen_Closed(MyGuiScreenBase source)
        {
            PowerReceiver.Update();
            UpdateIsWorking();
            if (m_clipboard.CopiedGrids.Count == 0 || !IsWorking)
            {
                RemoveProjection(false);
                return;
            }
            if (m_clipboard.GridSize != CubeGrid.GridSize)
            {
                RemoveProjection(false);
                ShowNotification(MySpaceTexts.NotificationProjectorGridSize);
                return;
            }
            if (m_clipboard.CopiedGrids.Count > 1)
            {
                ShowNotification(MySpaceTexts.NotificationProjectorMultipleGrids);
            }

            int largestGridIndex = -1;
            int largestGridBlockCount = -1;
            for (int i = 0; i < m_clipboard.CopiedGrids.Count; i++)
            {
                int currentGridBlockCount = m_clipboard.CopiedGrids[i].CubeBlocks.Count;
                if (currentGridBlockCount > largestGridBlockCount)
                {
                    largestGridBlockCount = currentGridBlockCount;
                    largestGridIndex = i;
                }
            }

            m_originalGridBuilder = (MyObjectBuilder_CubeGrid)m_clipboard.CopiedGrids[largestGridIndex].Clone();

            m_clipboard.ProcessCubeGrid(m_clipboard.CopiedGrids[largestGridIndex]);

            MyEntities.RemapObjectBuilder(m_originalGridBuilder);
            SyncObject.SendNewBlueprint(m_originalGridBuilder);
        }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:39,代码来源:MyProjector.cs


示例14: SetNewBlueprint

        internal void SetNewBlueprint(MyObjectBuilder_CubeGrid gridBuilder)
        {
            m_originalGridBuilder = gridBuilder;

            var clone = (MyObjectBuilder_CubeGrid)gridBuilder.Clone();
            MyEntities.RemapObjectBuilder(clone);
            m_clipboard.ProcessCubeGrid(clone);

            m_clipboard.SetGridFromBuilder(clone, Vector3.Zero, 0f);
            InitializeClipboard();
        }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:11,代码来源:MyProjector.cs


示例15: ActivateShipCreationClipboard

        public void ActivateShipCreationClipboard(MyObjectBuilder_CubeGrid[] grids, Vector3 centerDeltaDirection, float dragVectorLength)
        {
            if (m_shipCreationClipboard.IsActive)
                return;

            MySessionComponentVoxelHand.Static.Enabled = false;
            DeactivateMultiBlockClipboard();
            m_shipCreationClipboard.SetGridFromBuilders(grids, centerDeltaDirection, dragVectorLength);
        }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:9,代码来源:MyCubeBuilder.cs


示例16: ActivateMultiBlockCreationClipboard

        private void ActivateMultiBlockCreationClipboard(MyObjectBuilder_CubeGrid grid, Vector3 centerDeltaDirection, float dragVectorLength)
        {
            if (m_multiBlockCreationClipboard.IsActive)
                return;

            MySessionComponentVoxelHand.Static.Enabled = false;
            m_multiBlockCreationClipboard.SetGridFromBuilder(grid, centerDeltaDirection, dragVectorLength);
        }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:8,代码来源:MyCubeBuilder.cs


示例17: GetAllOwners

        public static List<long> GetAllOwners( MyObjectBuilder_CubeGrid grid )
        {
            Dictionary<long, int> ownerList = new Dictionary<long, int>( );
            foreach ( MyObjectBuilder_CubeBlock block in grid.CubeBlocks )
            {
                if ( block.Owner == 0 )
                    continue;

                if ( ownerList.ContainsKey( block.Owner ) )
                    ownerList[ block.Owner ] = ownerList[ block.Owner ] + 1;
                else
                    ownerList.Add( block.Owner, 1 );
            }

            return ownerList.Select( x => x.Key ).ToList( );
        }
开发者ID:Pingperfect,项目名称:EssentialsPlugin,代码行数:16,代码来源:CubeGrid.cs


示例18: Invoke


//.........这里部分代码省略.........

                    //phys.AddForce(Sandbox.Engine.Physics.MyPhysicsForceType.ADD_BODY_FORCE_AND_BODY_TORQUE, Vector3.Forward, Vector3.Zero, Vector3.Zero);
                    //phys.LinearVelocity = Vector3.Forward;
                    //phys
                }

                //var vm = MyAPIGateway.Session.Player.Controller.ControlledEntity.GetHeadMatrix(true, true, true); // most accurate for player view.
                return true;
            }

            #endregion

            #region test7

            if (messageText.Equals("/test7", StringComparison.InvariantCultureIgnoreCase))
            {
                var character = (MyObjectBuilder_Character)MyAPIGateway.Session.Player.Controller.ControlledEntity.Entity.GetObjectBuilder();

                //var obj = MyAPIGateway.Session.Player.Controller.ControlledEntity.Entity.GetObjectBuilder();
                var obj = MyAPIGateway.Session.Player.Client as IMyEntity;

                MyAPIGateway.Utilities.ShowMessage("isNull", string.Format("{0}", obj == null));
                //MyAPIGateway.Utilities.ShowMessage("Name", string.Format("{0}", obj.GetType().Name));

                return true;
            }

            #endregion

            #region test8

            if (messageText.Equals("/test8A", StringComparison.InvariantCultureIgnoreCase))
            {
                var gridBuilder = new MyObjectBuilder_CubeGrid()
                {
                    PersistentFlags = MyPersistentEntityFlags2.CastShadows | MyPersistentEntityFlags2.InScene,
                    GridSizeEnum = MyCubeSize.Large,
                    IsStatic = true,
                    LinearVelocity = new SerializableVector3(0, 0, 0),
                    AngularVelocity = new SerializableVector3(0, 0, 0),
                    PositionAndOrientation = new MyPositionAndOrientation(Vector3.Zero, Vector3.Forward, Vector3.Up),
                    DisplayName = "test grid"
                };

                Sandbox.Common.ObjectBuilders.MyObjectBuilder_CubeBlock cube = new Sandbox.Common.ObjectBuilders.MyObjectBuilder_CubeBlock();
                cube.Min = new SerializableVector3I(0, 0, 0);
                cube.SubtypeName = "LargeBlockArmorBlock";
                cube.ColorMaskHSV = new SerializableVector3(0, -1, 0);
                cube.ShareMode = MyOwnershipShareModeEnum.None;
                cube.EntityId = 0;
                cube.Owner = 0;
                cube.BlockOrientation = new SerializableBlockOrientation(Base6Directions.Direction.Forward, Base6Directions.Direction.Up);
                cube.ShareMode = Sandbox.Common.ObjectBuilders.MyOwnershipShareModeEnum.All;
                gridBuilder.CubeBlocks.Add(cube);

                // multiple grids...
                //var tempList = new List<MyObjectBuilder_EntityBase>();
                //tempList.Add(gridBuilder);
                //MyAPIGateway.Entities.RemapObjectBuilderCollection(tempList);
                //tempList.ForEach(grid => MyAPIGateway.Entities.CreateFromObjectBuilderAndAdd(grid));
                //MyAPIGateway.Multiplayer.SendEntitiesCreated(tempList);

                // Single grid.
                MyAPIGateway.Entities.RemapObjectBuilder(gridBuilder);
                MyAPIGateway.Entities.CreateFromObjectBuilderAndAdd(gridBuilder);
                MyAPIGateway.Multiplayer.SendEntitiesCreated(new List<MyObjectBuilder_EntityBase> { gridBuilder });
开发者ID:zrisher,项目名称:Space-Engineers-Admin-script-mod,代码行数:67,代码来源:CommandTest.cs


示例19: GetBigOwners

        // might not work? -- updated, needs testing
        public static List<long> GetBigOwners( MyObjectBuilder_CubeGrid grid )
        {
            Dictionary<long, int> ownerList = new Dictionary<long, int>( );
            foreach ( MyObjectBuilder_CubeBlock block in grid.CubeBlocks )
            {
                if ( block.Owner == 0 )
                    continue;

                if ( ownerList.ContainsKey( block.Owner ) )
                    ownerList[ block.Owner ] = ownerList[ block.Owner ] + 1;
                else
                    ownerList.Add( block.Owner, 1 );
            }

            int count = ownerList.OrderBy( x => x.Value ).Select( x => x.Value ).FirstOrDefault( );
            return ownerList.OrderBy( x => x.Value ).Where( x => x.Value == count ).Select( x => x.Key ).ToList( );
        }
开发者ID:Pingperfect,项目名称:EssentialsPlugin,代码行数:18,代码来源:CubeGrid.cs


示例20: SendNewBlueprint

            public void SendNewBlueprint(MyObjectBuilder_CubeGrid projectedGrid)
            {
                var msg = new NewBlueprintMsg();
                msg.EntityId = m_projector.EntityId;
                msg.ProjectedGrid = projectedGrid;

                var ack = new NewBlueprintAckMsg();
                ack.EntityId = m_projector.EntityId;

                m_lastSentCubeGrid = projectedGrid;

                if (Sync.IsServer)
                {
                    Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success);
                    OnNewBlueprintAck(ref ack, null);
                }
                else
                {
                    Sync.Layer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request);
                }
            }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:21,代码来源:MyProjector.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Definitions.MyObjectBuilder_DefinitionBase类代码示例发布时间:2022-05-26
下一篇:
C# ObjectBuilders.MyObjectBuilder_CubeBlock类代码示例发布时间: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