示例#1
0
文件: Drone.cs 项目: ESearcy/SE_MOD
        //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 &&
                    (!((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 < 20)
                {
                    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.StopSpin();
                    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);
        }