Exemplo n.º 1
0
        public bool IsPowered()
        {
            if (!ActiveEntity())
            {
                return(false);
            }

            if (string.IsNullOrWhiteSpace(MyVisualScriptLogicProvider.GetEntityName(CubeGrid.EntityId)))
            {
                MyVisualScriptLogicProvider.SetName(CubeGrid.EntityId, CubeGrid.EntityId.ToString());
            }

            return(MyVisualScriptLogicProvider.HasPower(CubeGrid.EntityId.ToString()));
        }
Exemplo n.º 2
0
        public GridValidator(long gridEntityId)
        {
            entityId   = gridEntityId;
            entityName = MyVisualScriptLogicProvider.GetEntityName(entityId);

            entity = MyVisualScriptLogicProvider.GetEntityByName(entityName);

            if (string.IsNullOrEmpty(entityName) == true)
            {
                entityName = entityId.ToString();
                MyVisualScriptLogicProvider.SetName(entityId, entityName);
            }

            gridStatus = GridStatus.Ok;
            ownerId    = MyVisualScriptLogicProvider.GetOwner(entityName);
        }
        public static bool CheckGridBlocksForAutopilot(IMyCubeGrid grid)
        {
            var blockList = new List <IMySlimBlock>();

            grid.GetBlocks(blockList, x => x.FatBlock != null);
            bool hasAutopilot = false;

            foreach (var block in blockList.Where(x => x.FatBlock as IMyRemoteControl != null))
            {
                var remote = block.FatBlock as IMyRemoteControl;

                if (remote.IsAutoPilotEnabled == true)
                {
                    Logger.AddMsg("Cargo Ship Has Autopilot: " + grid.CustomName, true);
                    hasAutopilot = true;
                    break;
                }

                if (string.IsNullOrWhiteSpace(remote.Name) == true)
                {
                    MyVisualScriptLogicProvider.SetName(remote.EntityId, remote.EntityId.ToString());
                }

                if (string.IsNullOrWhiteSpace(MyVisualScriptLogicProvider.DroneGetCurrentAIBehavior(remote.Name)) == false)
                {
                    Logger.AddMsg("Cargo Ship Has Behavior: " + grid.CustomName, true);
                    hasAutopilot = true;
                    break;
                }

                if (remote.EnabledDamping == true)
                {
                    Logger.AddMsg("Cargo Ship Has Dampeners: " + grid.CustomName, true);
                    hasAutopilot = true;
                    break;
                }
            }

            if (hasAutopilot == true)
            {
                NoLongerMonitorGrids.Add(grid);
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        public GridEntity(IMyEntity entity) : base(entity)
        {
            Type     = EntityType.Grid;
            CubeGrid = entity as IMyCubeGrid;

            LinkedGrids = new List <GridEntity>();

            AllTerminalBlocks = new List <BlockEntity>();
            Antennas          = new List <BlockEntity>();
            Beacons           = new List <BlockEntity>();
            Containers        = new List <BlockEntity>();
            Controllers       = new List <BlockEntity>();
            Gravity           = new List <BlockEntity>();
            Guns       = new List <BlockEntity>();
            JumpDrives = new List <BlockEntity>();
            Mechanical = new List <BlockEntity>();
            Medical    = new List <BlockEntity>();
            NanoBots   = new List <BlockEntity>();
            Production = new List <BlockEntity>();
            Power      = new List <BlockEntity>();
            RivalAi    = new List <BlockEntity>();
            Shields    = new List <BlockEntity>();
            Thrusters  = new List <BlockEntity>();
            Tools      = new List <BlockEntity>();
            Turrets    = new List <BlockEntity>();

            BlockListReference = new Dictionary <BlockTypeEnum, List <BlockEntity> >();
            BlockListReference.Add(BlockTypeEnum.All, AllTerminalBlocks);
            BlockListReference.Add(BlockTypeEnum.Antennas, Antennas);
            BlockListReference.Add(BlockTypeEnum.Beacons, Beacons);
            BlockListReference.Add(BlockTypeEnum.Containers, Containers);
            BlockListReference.Add(BlockTypeEnum.Controllers, Controllers);
            BlockListReference.Add(BlockTypeEnum.Gravity, Gravity);
            BlockListReference.Add(BlockTypeEnum.Guns, Guns);
            BlockListReference.Add(BlockTypeEnum.JumpDrives, JumpDrives);
            BlockListReference.Add(BlockTypeEnum.Mechanical, Mechanical);
            BlockListReference.Add(BlockTypeEnum.Medical, Medical);
            BlockListReference.Add(BlockTypeEnum.NanoBots, NanoBots);
            BlockListReference.Add(BlockTypeEnum.Production, Production);
            BlockListReference.Add(BlockTypeEnum.Power, Power);
            BlockListReference.Add(BlockTypeEnum.RivalAi, RivalAi);
            BlockListReference.Add(BlockTypeEnum.Shields, Shields);
            BlockListReference.Add(BlockTypeEnum.Thrusters, Thrusters);
            BlockListReference.Add(BlockTypeEnum.Tools, Tools);
            BlockListReference.Add(BlockTypeEnum.Turrets, Turrets);

            if (CubeGrid.Physics == null)
            {
                CubeGrid.OnPhysicsChanged += PhysicsCheck;
            }
            else
            {
                HasPhysics = true;
            }

            if (string.IsNullOrWhiteSpace(MyVisualScriptLogicProvider.GetEntityName(CubeGrid.EntityId)))
            {
                MyVisualScriptLogicProvider.SetName(CubeGrid.EntityId, CubeGrid.EntityId.ToString());
            }

            var blockList = new List <IMySlimBlock>();

            CubeGrid.GetBlocks(blockList);

            foreach (var block in blockList)
            {
                NewBlockAdded(block);
            }

            CubeGrid.OnBlockAdded += NewBlockAdded;
            CubeGrid.OnGridSplit  += GridSplit;
        }