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

            foreach (var cubeGrid in grids)
            {
                var blocks = new List <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)
                {
                    MessageSyncBlock.Process(item, SyncBlockType.PowerOff);

                    if (item.BlockDefinition.TypeId == typeof(MyObjectBuilder_Reactor))
                    {
                        reactorCounter++;
                    }
                    else
                    {
                        batteryCounter++;
                    }
                }
            }
        }
コード例 #2
0
 private static void Process(IMyEntity entity, MessageSyncBlock syncEntity)
 {
     if (MyAPIGateway.Multiplayer.MultiplayerActive)
     {
         ConnectionHelper.SendMessageToAll(syncEntity);
     }
     else
     {
         syncEntity.CommonProcess(entity);
     }
 }