Esempio n. 1
0
        public static string GetPartTitle(Part part)
        {
            string baseName = part.partInfo.title;

            if (part.Modules == null)
            {
                return(baseName);
            }

            // Find the active core
            ITestFlightCore core = TestFlightUtil.GetCore(part);

            if (core == null)
            {
                return(baseName);
            }

            if (String.IsNullOrEmpty(core.Title))
            {
                return(baseName);
            }
            else
            {
                return(core.Title);
            }
        }
Esempio n. 2
0
        // Methods for accessing the TestFlight modules on a given part

        public static string GetFullPartName(Part part)
        {
            string baseName = part.name;

            if (part.Modules == null)
            {
                return(baseName);
            }

            // New query system
            // Find the active core
            ITestFlightCore core = TestFlightUtil.GetCore(part);

            if (core == null)
            {
                return(baseName);
            }
            // Look if it has an alias and use that if present
            string query = core.Configuration;

            if (query.Contains(":"))
            {
                return(query.Split(new char[1] {
                    ':'
                })[1]);
            }
            // Otherwise use part.name
            else
            {
                return(baseName);
            }
        }
Esempio n. 3
0
 public void OnEnable()
 {
     if (core == null)
     {
         core = TestFlightUtil.GetCore(this.part, Configuration);
     }
 }
Esempio n. 4
0
 public override void OnStart(StartState state)
 {
     base.OnStart(state);
     if (core == null)
     {
         core = TestFlightUtil.GetCore(this.part, Configuration);
     }
 }
Esempio n. 5
0
 IEnumerator GetCore()
 {
     while (core == null)
     {
         core = TestFlightUtil.GetCore(this.part);
         yield return(null);
     }
 }
 public virtual float DoRepair()
 {
     Failed = false;
     ITestFlightCore core = TestFlightUtil.GetCore(this.part, Configuration);
     if (core != null)
         core.ModifyFlightData(duRepair, true);
     return 0;
 }
 /// <summary>
 /// Triggers the failure controlled by the failure module
 /// </summary>
 public virtual void DoFailure()
 {
     Failed = true;
     ITestFlightCore core = TestFlightUtil.GetCore(this.part, Configuration);
     if (core != null)
     {
         core.ModifyFlightData(duFail, true);
         FlightLogger.eventLog.Add(String.Format("[{0}] {1} failed: {2}", KSPUtil.PrintTimeCompact((int)Math.Floor(this.vessel.missionTime), false), core.Title, failureTitle));
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Triggers the failure controlled by the failure module
        /// </summary>
        public virtual void DoFailure()
        {
            Failed = true;
            ITestFlightCore core = TestFlightUtil.GetCore(this.part, Configuration);

            if (core != null)
            {
                core.ModifyFlightData(duFail, true);
            }
        }
Esempio n. 9
0
        public virtual float DoRepair()
        {
            Failed = false;
            ITestFlightCore core = TestFlightUtil.GetCore(this.part);

            if (core != null)
            {
                core.ModifyFlightData(duRepair, true);
            }
            return(0);
        }
Esempio n. 10
0
        /// <summary>
        /// Triggers the failure controlled by the failure module
        /// </summary>
        public virtual void DoFailure()
        {
            Failed = true;
            ITestFlightCore core = TestFlightUtil.GetCore(this.part);

            if (core != null)
            {
                core.ModifyFlightData(duFail, true);
            }
            FlightLogger.eventLog.Add(String.Format("[{0}] {1} failed: {2}", TestFlightUtil.FormatTime(this.vessel.missionTime), TestFlightUtil.GetPartTitle(this.part), failureTitle));
        }
Esempio n. 11
0
        public static void Log(string message, Part loggingPart)
        {
            ITestFlightCore core  = TestFlightUtil.GetCore(loggingPart);
            bool            debug = false;

            if (core != null)
            {
                debug = core.DebugEnabled;
            }
            TestFlightUtil.Log(message, debug);
        }
Esempio n. 12
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            core = TestFlightUtil.GetCore(this.part);

            if (core == null)
            {
                StartCoroutine("GetCore");
            }
        }
 public override void OnStart(StartState state)
 {
     base.OnStart(state);
     if (core == null)
     {
         core = TestFlightUtil.GetCore(this.part, Configuration);
     }
     if (core != null)
     {
         Startup();
     }
     verboseDebugging = core.DebugEnabled;
 }
Esempio n. 14
0
        // INTERNAL methods

        IEnumerator Attach()
        {
            while (this.part == null || this.part.partInfo == null || this.part.partInfo.partPrefab == null || this.part.Modules == null)
            {
                yield return(null);
            }

            while (core == null)
            {
                core = TestFlightUtil.GetCore(this.part, Configuration);
                yield return(null);
            }

            Startup();
        }
Esempio n. 15
0
        IEnumerator Attach()
        {
            while (this.part == null || this.part.partInfo == null || this.part.partInfo.partPrefab == null || this.part.Modules == null)
            {
                yield return(null);
            }

            while (core == null)
            {
                core = TestFlightUtil.GetCore(this.part, Configuration);
                if (core != null)
                {
                    Log(String.Format("Attached to Core({0})", core.Configuration));
                }
                yield return(null);
            }

            Startup();
        }