Example #1
0
        //All three must be true
        //Ship is not trash
        //Ship Controlls are functional
        //Weapons Exist on ship
        //There have been a few added restrictions that must be true for a ship[ to be alive
        public bool IsAlive()
        {
            string errors      = "";
            bool   shipWorking = true;

            try
            {
                if (ShipControls != null &&
                    (!((Sandbox.ModAPI.Ingame.IMyCubeBlock)ShipControls).IsWorking)) // ||
                //!((Sandbox.ModAPI.Ingame.IMyCubeBlock) ShipControls).IsWorking))
                {
                    errors     += "Ship Controlls are down: ";
                    shipWorking = false;
                }
                if (ShipControls == null)
                {
                    errors     += "Ship Controlls are down: ";
                    shipWorking = false;
                }


                List <IMyTerminalBlock> allBlocks = new List <IMyTerminalBlock>();
                GridTerminalSystem.GetBlocks(allBlocks);
                if (Ship != null && allBlocks.Count < 10)
                {
                    errors     += "Ship Too Small: ";
                    shipWorking = false;
                }

                if (Ship != null && Ship.Physics.Mass < 1000)
                {
                    errors     += "Ship Too Small: ";
                    shipWorking = false;
                }

                if (Ship != null && Ship.IsTrash())
                {
                    errors     += "The ship is trashed: ";
                    shipWorking = false;
                }
                if (Ship == null)
                {
                    errors     += "The ship is trashed: ";
                    shipWorking = false;
                }

                if (Ship != null && !Ship.InScene)
                {
                    errors     += "The ship is trashed: ";
                    shipWorking = false;
                }

                if (!shipWorking && navigation != null)
                {
                    navigation.TurnOffGyros(false);
                    ManualFire(false);
                    _beaconName = "Disabled Drone: " + errors;
                    NameBeacon();
                }
                if (!shipWorking)
                {
                    Util.GetInstance().Log("[Drone.IsAlive] A Drone Has Died -> ", "droneDeaths.txt");
                }
            }

            catch
            {
                shipWorking = false;
            }
            return(shipWorking);
        }