VRage.Game.ModAPI.Ingame.IMySlimBlock VRage.Game.ModAPI.Ingame.IMyCubeGrid.GetCubeBlock(Vector3I position)
 {
     VRage.Game.ModAPI.Ingame.IMySlimBlock block = GetCubeBlock(position);
     if (block != null && block.FatBlock != null)
     {
         if ((block.FatBlock is MyTerminalBlock) && (block.FatBlock as MyTerminalBlock).IsAccessibleForProgrammableBlock)
         {
             return(block);
         }
     }
     return(null);
 }
 public static string BlockName(this VRage.Game.ModAPI.Ingame.IMySlimBlock slimBlock)
 {
     if (slimBlock != null)
     {
         var terminalBlock = slimBlock.FatBlock as Sandbox.ModAPI.Ingame.IMyTerminalBlock;
         if (terminalBlock != null)
         {
             return(string.Format("{0}.{1}", terminalBlock.CubeGrid != null ? terminalBlock.CubeGrid.DisplayName : "Unknown Grid", terminalBlock.CustomName));
         }
         else
         {
             return(string.Format("{0}.{1}", slimBlock.CubeGrid != null ? slimBlock.CubeGrid.DisplayName : "Unknown Grid", slimBlock.BlockDefinition.ToString()));
         }
     }
     else
     {
         return("(none)");
     }
 }
Exemplo n.º 3
0
        private Vector3 targetRandomBlock()
        {
            if (activeEnemy is IMyCharacter)
            {
                return(activeEnemy.WorldAABB.Center);
            }

            var grid = activeEnemy as IMyCubeGrid;

            if (grid == null)
            {
                return(activeEnemy.WorldAABB.Center);
            }

            for (int i = 0; i < 3; i++)
            {
                if (targetedBlock == null)
                {
                    var blocks = new List <VRage.Game.ModAPI.IMySlimBlock>();
                    grid.GetBlocks(blocks);
                    targetedBlock = blocks[MyRandom.Instance.Next(blocks.Count - 1)];
                }

                if (targetedBlock != null)
                {
                    var pos = grid.GridIntegerToWorld(targetedBlock.Position);
                    if (targetedBlock.FatBlock != null)
                    {
                        pos = targetedBlock.FatBlock.WorldAABB.Center;
                    }
                    if (hasDirectLOS(pos, activeEnemy))
                    {
                        return(pos);
                    }
                }
            }


            return(activeEnemy.WorldAABB.Center);
        }
 public static SyncBlockId GetSyncBlockId(VRage.Game.ModAPI.Ingame.IMySlimBlock slimBlock)
 {
     if (slimBlock == null)
     {
         return(null);
     }
     if (slimBlock.FatBlock != null)
     {
         return(new SyncBlockId()
         {
             EntityId = slimBlock.FatBlock.EntityId
         });
     }
     else if (slimBlock.CubeGrid != null)
     {
         return(new SyncBlockId()
         {
             EntityId = 0, GridId = slimBlock.CubeGrid.EntityId, Position = slimBlock.Position
         });
     }
     return(null);
 }