public void RecordMaxGee()
        {
            if (FlightGlobals.ActiveVessel == null)
            {
                return;
            }
            LaunchEvent activeLaunch = GetLaunch(FlightGlobals.ActiveVessel);

            if (activeLaunch != null)
            {
                MaxGeeEvent maxGeeEv = new MaxGeeEvent();
                maxGeeEv.gee = activeLaunch.maxGee;
                if (activeLaunch.maxGee > activeLaunch.GetEventMaxGee())
                {
                    activeLaunch.AddEvent(maxGeeEv);
                }

                foreach (ProtoCrewMember kerbal in FlightGlobals.ActiveVessel.GetVesselCrew())
                {
                    LaunchCrewEvent crewLaunch = GetKerbalLaunch(kerbal.name);
                    if (crewLaunch.maxGee < activeLaunch.maxGee)
                    {
                        MaxGeeCrewEvent geeEv = new MaxGeeCrewEvent();
                        geeEv.gee = activeLaunch.maxGee;
                        if (crewLaunch.GetEventMaxGee() < activeLaunch.maxGee)
                        {
                            crewLaunch.AddEvent(geeEv);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        internal IEnumerable <string> GetShips()
        {
            List <string> ships = new List <string>();
            //ships.Add(vesselName);
            LaunchCrewEvent     lauEv = this;
            List <EvaCrewEvent> evas  = new List <EvaCrewEvent>();

            foreach (var flightEvent in subsequentEvents)
            {
                if (flightEvent is LaunchCrewEvent)
                {
                    evas  = new List <EvaCrewEvent>();
                    lauEv = flightEvent as LaunchCrewEvent;
                }
                else if (flightEvent is EvaCrewEvent)
                {
                    evas.Add(flightEvent as EvaCrewEvent);
                }
                else if (flightEvent is EndFlightCrewEvent)
                {
                    ships.Add(lauEv.vesselName + "(" + TicksToShortTime(flightEvent.time - lauEv.time) + ", EVA - " + evas.Count.ToString() + ")");
                    lauEv = null;
                    evas  = new List <EvaCrewEvent>();
                }
            }

            if (lauEv != null)
            {
                ships.Add(lauEv.vesselName + "(" + TicksToShortTime(EventProcessor.GetTimeInTicks() - lauEv.time) + ", EVA - " + evas.Count.ToString() + ")");
            }

            return(ships);
        }
        internal void OnCrewBoardVessel(GameEvents.FromToAction <Part, Part> data)
        {
            LaunchCrewEvent crewLaunch      = GetKerbalLaunch(data.from.vessel.vesselName);
            EvaCrewEndEvent evaCrewEndEvent = new EvaCrewEndEvent();

            crewLaunch.AddEvent(evaCrewEndEvent);
        }
        internal void OnCrewKilled(EventReport data)
        {
            string          kerbalName = data.sender;
            DeathCrewEvent  death      = new DeathCrewEvent();
            LaunchCrewEvent kerbal     = GetKerbalLaunch(kerbalName);

            if (kerbal != null)
            {
                kerbal.AddEvent(death);
            }
        }
        internal void UpdateDynamic()
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }
            if (FlightGlobals.ActiveVessel == null)
            {
                return;
            }
            LaunchEvent activeLaunch = GetLaunch(FlightGlobals.ActiveVessel);

            if (activeLaunch != null)
            {
                ProtoVessel item = FlightGlobals.ActiveVessel.protoVessel;
                double      currentVesselSpeed = item.vesselRef.obt_speed;
                if (item.situation == Vessel.Situations.FLYING || item.situation == Vessel.Situations.PRELAUNCH)
                {
                    currentVesselSpeed = item.vesselRef.srfSpeed;
                }
                if (currentVesselSpeed > activeLaunch.maxSpeed)
                {
                    activeLaunch.maxSpeed = currentVesselSpeed;
                }

                if (activeLaunch.maxGee < FlightGlobals.ActiveVessel.geeForce)
                {
                    activeLaunch.maxGee = FlightGlobals.ActiveVessel.geeForce;
                }
                foreach (ProtoCrewMember kerbal in FlightGlobals.ActiveVessel.GetVesselCrew())
                {
                    LaunchCrewEvent crewLaunch = GetKerbalLaunch(kerbal.name);
                    if (crewLaunch.maxGee < FlightGlobals.ActiveVessel.geeForce)
                    {
                        crewLaunch.maxGee = FlightGlobals.ActiveVessel.geeForce;
                    }
                }

                if (activeLaunch.GetLastEvent() is LandingEvent)
                {
                    double altitude = FlightGlobals.ActiveVessel.RevealAltitude();
                    if (altitude - FlightGlobals.ActiveVessel.terrainAltitude > 10)
                    {
                        activeLaunch.AddEvent(new FlyingEvent());
                    }
                }
                float currentMass = 0;
                foreach (var part in FlightGlobals.ActiveVessel.parts)
                {
                    currentMass += part.GetResourceMass() + part.mass;
                }
                activeLaunch.currentMass = currentMass;
            }
        }
 private void RecordCrewDockingEvent(Vessel from, Vessel to)
 {
     foreach (ProtoCrewMember kerbal in from.GetVesselCrew())
     {
         DockingCrewEvent landingCrewEvent = new DockingCrewEvent();
         LaunchCrewEvent  crewLaunch       = GetKerbalLaunch(kerbal.name);
         crewLaunch.AddEvent(landingCrewEvent);
     }
     foreach (ProtoCrewMember kerbal in to.GetVesselCrew())
     {
         DockingCrewEvent landingCrewEvent = new DockingCrewEvent();
         LaunchCrewEvent  crewLaunch       = GetKerbalLaunch(kerbal.name);
         crewLaunch.AddEvent(landingCrewEvent);
     }
 }
        internal void OnCrewOnEva(GameEvents.FromToAction <Part, Part> data)
        {
            if (VesselType.EVA != data.to.vessel.vesselType)
            {
                return;
            }
            LaunchCrewEvent crewLaunch   = GetKerbalLaunch(data.to.vessel.vesselName);
            EvaCrewEvent    evaCrewEvent = new EvaCrewEvent();

            crewLaunch.AddEvent(evaCrewEvent);

            LaunchEvent launch = GetLaunch(data.from.vessel);

            if (launch != null)
            {
                EvaEvent evaEvent = new EvaEvent();
                launch.AddEvent(evaEvent);
            }
        }
        private void RecordCrewLaunch(Vessel vessel)
        {
            long currentLaunchTime = GetTimeInTicks();

            foreach (ProtoCrewMember kerbal in vessel.GetVesselCrew())
            {
                LaunchCrewEvent crewSubLaunch = new LaunchCrewEvent();
                crewSubLaunch.name       = kerbal.name;
                crewSubLaunch.time       = currentLaunchTime;
                crewSubLaunch.vesselName = vessel.vesselName;

                LaunchCrewEvent crewLaunch = GetKerbalLaunch(kerbal.name);
                if (crewLaunch == null)
                {
                    crewLaunches.Add(crewSubLaunch);
                }
                else
                {
                    crewLaunch.AddEvent(crewSubLaunch);
                }
            }
        }
        public void RecordLanding(Vessel vessel)
        {
            if (vessel.isEVA)
            {
                return;
            }
            LandingEvent landing = new LandingEvent();

            landing.mainBodyName = vessel.mainBody.name;
            landing.biome        = getBiomeName(vessel.mainBody, vessel.longitude, vessel.latitude);
            LaunchEvent launch = GetLaunch(vessel);

            if (launch != null)
            {
                FlightEvent flightEvent = launch.GetLastEvent();
                if (flightEvent is EvaEvent && (landing.time - flightEvent.time) / TimeSpan.TicksPerSecond < 1)
                {
                    return;
                }
                if (flightEvent is LandingEvent)
                {
                    if (((landing.time - flightEvent.time) / TimeSpan.TicksPerSecond < 2))
                    {
                        return;
                    }
                }
                launch.AddEvent(landing);
            }


            foreach (ProtoCrewMember kerbal in vessel.GetVesselCrew())
            {
                LandingCrewEvent landingCrewEvent = new LandingCrewEvent();
                LaunchCrewEvent  crewLaunch       = GetKerbalLaunch(kerbal.name);
                crewLaunch.AddEvent(landingCrewEvent);
            }
        }
Beispiel #10
0
        private void DrawKerbalWindow(int id)
        {
            if (GUI.Button(new Rect(kerbalWindowRect.width - 28, 2, 25, 16), "X"))
            {
                needToShowKerbal = false;
            }
            LaunchCrewEvent kerbal = EventProcessor.Instance.crewLaunches[kerbalIdToShow];

            Rect     captionRect = new Rect(0, 2, kerbalWindowRect.width, 16);
            string   txt         = "Kerbal: " + kerbal.name;
            GUIStyle currentStyle;

            if (!kerbal.IsAlive())
            {
                currentStyle = destroyedStyle;
            }
            else
            {
                currentStyle = proceedingStyle;
            }
            currentStyle.fontStyle = FontStyle.Bold;
            currentStyle.alignment = TextAnchor.MiddleCenter;
            GUI.Label(captionRect, txt, currentStyle);
            currentStyle.fontStyle = FontStyle.Normal;
            currentStyle.alignment = TextAnchor.MiddleLeft;

            //количество полетов, длительность (накопительно), количество выходов в открытый космос и их общая длительность (накопительно), количество стыковок,  количество посадок.
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            GUILayout.Label("Kerbal name", boldtext);
            GUILayout.Label("Flights", boldtext);
            GUILayout.Label("Max Gee", boldtext);
            GUILayout.Label("Total flight time", boldtext);
            GUILayout.Label("EVAs time", boldtext);
            GUILayout.Label("EVAs", boldtext);
            GUILayout.Label("Dockings", boldtext);
            GUILayout.Label("Landings", boldtext);
            GUILayout.Label("Idle time", boldtext);
            GUILayout.EndVertical();

            GUILayout.BeginVertical();

            GUILayout.Label(kerbal.name);
            GUILayout.Label(kerbal.GetLaunchesCount().ToString());
            GUILayout.Label(Utils.CorrectNumber(kerbal.maxGee.ToString()) + " G");
            GUILayout.Label(Utils.TicksToTotalTime(kerbal.GetTotalFlightTime()));
            GUILayout.Label(Utils.TicksToTotalTime(kerbal.GetTotalEvasTime()));
            GUILayout.Label(kerbal.GetEvasCount().ToString());
            GUILayout.Label(kerbal.GetDockingsCount().ToString());
            GUILayout.Label(kerbal.GetLandingsCount().ToString());
            GUILayout.Label(Utils.TicksToTotalTime(kerbal.GetIdleTime()));
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Box("Ships");
            shipsScrollViewVector = GUILayout.BeginScrollView(shipsScrollViewVector, GUILayout.Height((kerbalWindowRect.height - 130)));
            foreach (string shipName in kerbal.GetShips())
            {
                GUILayout.Label(shipName);
            }
            GUILayout.EndScrollView();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            ProcessPopup();
            GUI.DragWindow(new Rect(0, 0, 10000, 20));
        }