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


C# IMyEntity.GetAttachedGrids方法代码示例

本文整理汇总了C#中IMyEntity.GetAttachedGrids方法的典型用法代码示例。如果您正苦于以下问题:C# IMyEntity.GetAttachedGrids方法的具体用法?C# IMyEntity.GetAttachedGrids怎么用?C# IMyEntity.GetAttachedGrids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMyEntity的用法示例。


在下文中一共展示了IMyEntity.GetAttachedGrids方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TurnOnShip

        private void TurnOnShip(IMyEntity shipEntity, out int reactorCounter, out int batteryCounter)
        {
            reactorCounter = 0;
            batteryCounter = 0;
            var grids = shipEntity.GetAttachedGrids();

            foreach (var cubeGrid in grids)
            {
                var blocks = new List<Sandbox.ModAPI.IMySlimBlock>();
                cubeGrid.GetBlocks(blocks, f => f.FatBlock != null
                    && f.FatBlock is IMyFunctionalBlock
                    && (f.FatBlock.BlockDefinition.TypeId == typeof(MyObjectBuilder_Reactor)
                      || f.FatBlock.BlockDefinition.TypeId == typeof(MyObjectBuilder_BatteryBlock)));

                var list = blocks.Select(f => (IMyFunctionalBlock)f.FatBlock).Where(f => !f.Enabled).ToArray();

                foreach (var item in list)
                {
                    item.RequestEnable(true);

                    if (item.BlockDefinition.TypeId == typeof(MyObjectBuilder_Reactor))
                        reactorCounter++;
                    else
                        batteryCounter++;
                }
            }
        }
开发者ID:DigTron,项目名称:Space-Engineers-Admin-script-mod,代码行数:27,代码来源:CommandShipOn.cs

示例2: DeleteShip

        private void DeleteShip(IMyEntity shipEntity)
        {
            var grids = shipEntity.GetAttachedGrids(AttachedGrids.Static);

            foreach (var cubeGrid in grids)
            {
                // ejects any player prior to deleting the grid.
                cubeGrid.EjectControllingPlayers();

                var name = cubeGrid.DisplayName;

                // This will Delete the entity and sync to all.
                // Using this, also works with player ejection in the same Tick.
           
                cubeGrid.SyncObject.SendCloseRequest();

                MyAPIGateway.Utilities.ShowMessage("ship", "'{0}' deleted.", name);
            }
        }
开发者ID:Intueor,项目名称:Space-Engineers-Admin-script-mod,代码行数:19,代码来源:CommandShipDelete.cs

示例3: ChangeCubeShareMode

        private void ChangeCubeShareMode(IMyEntity selectedShip, MyOwnershipShareModeEnum shareMode)
        {
            var grids = selectedShip.GetAttachedGrids(AttachedGrids.Static);
            foreach (var grid in grids)
            {
                var blocks = new List<IMySlimBlock>();
                grid.GetBlocks(blocks, f => f.FatBlock != null && f.FatBlock.OwnerId != 0);

                foreach (var block in blocks)
                    block.FatBlock.ChangeOwner(block.FatBlock.OwnerId, shareMode);
            }
        }
开发者ID:Intueor,项目名称:Space-Engineers-Admin-script-mod,代码行数:12,代码来源:CommandShipOwnerShare.cs

示例4: MoveShipByOffset

        private static bool MoveShipByOffset(IMyEntity cubeGrid, Vector3D worldOffset, bool safely, Action<Vector3D> updatedPosition, Action noSafeLocationMessage)
        {
            var grids = cubeGrid.GetAttachedGrids();
            var currentPosition = cubeGrid.GetPosition();
            Vector3D position = cubeGrid.GetPosition() + worldOffset;

            if (safely)
            {
                var worldVolume = grids[0].WorldVolume;
                foreach (var grid in grids)
                {
                    worldVolume.Include(grid.WorldVolume);
                }

                // TODO: determine good location for moving one ship to another, checking for OrientedBoundingBox.Intersects() for a tighter fit.
                if (!FindEntityFreePosition(ref position, cubeGrid, worldVolume))
                {
                    if (noSafeLocationMessage != null)
                        noSafeLocationMessage.Invoke();
                    return false;
                }
            }

            foreach (var grid in grids)
                MessageSyncEntity.Process(grid, SyncEntityType.Position, position);

            if (updatedPosition != null)
                updatedPosition.Invoke(currentPosition);

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

示例5: MoveShipToShip

        public static bool MoveShipToShip(IMyEntity shipGrid, IMyEntity targetshipGrid)
        {
            // TODO: determine good location for moving one ship to another, checking for OrientedBoundingBox.Intersects().

            //// Move the ship the player is piloting.
            //var cubeGrid = MyAPIGateway.Session.Player.Controller.ControlledEntity.Entity.GetTopMostParent();
            var grids = shipGrid.GetAttachedGrids();
            //var worldOffset = position - MyAPIGateway.Session.Player.Controller.ControlledEntity.Entity.GetPosition();

            MyAPIGateway.Utilities.ShowMessage("Incomplete", "This function not complete. Cannot transport piloted Ship to another ship.");

            foreach (var grid in grids)
            {
                //grid.SetPosition(grid.GetPosition() + worldOffset);
            }

            //save teleport in history
            //CommandBack.SaveTeleportInHistory(currentPosition);

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

示例6: GetPower

 private bool GetPower(IMyEntity shipEntity)
 {
     var grids = shipEntity.GetAttachedGrids();
     return false;
 }
开发者ID:zerty,项目名称:Space-Engineers-Admin-script-mod,代码行数:5,代码来源:CommandShipClean.cs

示例7: ChangeCubeShareMode

        private void ChangeCubeShareMode(IMyEntity selectedShip, long oldPlayer, long newPlayer, MyOwnershipShareModeEnum shareMode)
        {
            var grids = selectedShip.GetAttachedGrids();
            foreach (var grid in grids)
            {
                var blocks = new List<IMySlimBlock>();
                // we only want to change the share of blocks you own currently.
                grid.GetBlocks(blocks, f => f.FatBlock != null && f.FatBlock.OwnerId == oldPlayer);

                foreach (var block in blocks)
                    block.FatBlock.ChangeOwner(newPlayer, shareMode);
            }
        }
开发者ID:DigTron,项目名称:Space-Engineers-Admin-script-mod,代码行数:13,代码来源:CommandShipOwnerShare.cs


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