예제 #1
0
 private void dequeueAddedEntities()
 {
     foreach (var entity in queueAddedEntities)
     {
         if (entity is IMyCubeGrid)
         {
             var grid = entity as IMyCubeGrid;
             //                ModLog.Info("Added Grid:" + grid.CustomName);
             if (grid.Physics != null)
             {
                 //                    ModLog.Info(" Has Physics");
                 GridInit(grid);
             }
             else
             {
                 // it's a projection or a paste in progress
                 //                    ModLog.Info(" NO Physics!");
             }
         }
         else if (entity is IMyPlayer)
         {
             IMyPlayer player = (IMyPlayer)entity;
             ModLog.Info("Added Player:" + player.DisplayName);
         }
     }
     queueAddedEntities.Clear();
 }
예제 #2
0
        public static T GetTerminalBlockMatchingName <T>(this IMyCubeGrid grid, string name) where T : IMyTerminalBlock
        {
            var slimBlocks = new List <IMySlimBlock>();

            if (grid == null)
            {
                return(default(T));
            }
            grid.GetBlocks(slimBlocks, b => b.FatBlock is T);
            foreach (var slim in slimBlocks)
            {
                var terminalBlock = (T)slim.FatBlock;
                if (terminalBlock.CustomName.Contains(name))
                {
                    return(terminalBlock);
                }
            }
            ModLog.Info("Can't find terminal block matching name: " + name);

            return(default(T));// throw new InvalidOperationException("Can't find terminal block matching name: " + name);
        }