コード例 #1
0
        void VesselDestroyed(Vessel v)
        {
            // rescan the damn kerbals
            // - vessel crew is empty at destruction time
            // - we can't even use the flightglobal roster, because sometimes it isn't updated yet at this point
            HashSet <string> kerbals_alive = new HashSet <string>();
            HashSet <string> kerbals_dead  = new HashSet <string>();

            foreach (Vessel ov in FlightGlobals.Vessels)
            {
                foreach (ProtoCrewMember c in Lib.CrewList(ov))
                {
                    kerbals_alive.Add(c.name);
                }
            }
            foreach (string key in DB.Kerbals().Keys)
            {
                if (!kerbals_alive.Contains(key))
                {
                    kerbals_dead.Add(key);
                }
            }
            foreach (string n in kerbals_dead)
            {
                // we don't know if the kerbal really is dead, or if it is just not currently assigned to a mission
                DB.KillKerbal(n, false);
            }

            // purge the caches
            ResourceCache.Purge(v);                 // works with loaded and unloaded vessels
            //Drive.Purge(v);				// works with loaded and unloaded vessels
            Cache.PurgeVesselCaches(v);             // works with loaded and unloaded vessels
        }
コード例 #2
0
        void VesselTerminated(ProtoVessel pv)
        {
            // forget all kerbals data
            foreach (ProtoCrewMember c in pv.GetVesselCrew())
            {
                DB.KillKerbal(c.name, true);
            }

            // purge the caches
            ResourceCache.Purge(pv);
            Cache.PurgeVesselCaches(pv);
            //Drive.Purge(pv);
        }
コード例 #3
0
        void VesselTerminated(ProtoVessel pv)
        {
            // forget all kerbals data
            foreach (ProtoCrewMember c in pv.GetVesselCrew())
            {
                DB.KillKerbal(c.name, true);
            }

            DB.vessels.Remove(Lib.VesselID(pv));

            // purge the caches
            ResourceCache.Purge(pv);
            Drive.Purge(pv);
            Cache.PurgeObjects(pv);
        }
コード例 #4
0
ファイル: Callbacks.cs プロジェクト: judicator/Kerbalism
        void VesselTerminated(ProtoVessel pv)
        {
            // forget all kerbals data
            foreach (ProtoCrewMember c in pv.GetVesselCrew())
            {
                DB.KillKerbal(c.name, true);
            }

            // purge the caches
            ResourceCache.Purge(pv);
            Cache.PurgeVesselCaches(pv);

            // delete data on unloaded vessels only (this is handled trough OnPartWillDie for loaded vessels)
            if (pv.vesselRef != null && !pv.vesselRef.loaded)
            {
                Drive.DeleteDrivesData(pv.vesselRef);
            }
        }
コード例 #5
0
ファイル: Callbacks.cs プロジェクト: lordcirth/Kerbalism-1
        void VesselTerminated(ProtoVessel pv)
        {
            // forget all kerbals data
            foreach (ProtoCrewMember c in pv.GetVesselCrew())
            {
                DB.KillKerbal(c.name, true);
            }

            // for each part
            foreach (ProtoPartSnapshot p in pv.protoPartSnapshots)
            {
                // forget all potential vessel data
                DB.vessels.Remove(p.flightID);
            }

            // purge the caches
            Cache.Purge(pv);
            ResourceCache.Purge(pv);
        }
コード例 #6
0
ファイル: Callbacks.cs プロジェクト: lordcirth/Kerbalism-1
        void VesselDestroyed(Vessel v)
        {
            // for each part
            foreach (Part p in v.parts)
            {
                // forget all potential vessel data
                DB.vessels.Remove(p.flightID);
            }

            // rescan the damn kerbals
            // - vessel crew is empty at destruction time
            // - we can't even use the flightglobal roster, because sometimes it isn't updated yet at this point
            HashSet <string> kerbals_alive = new HashSet <string>();
            HashSet <string> kerbals_dead  = new HashSet <string>();

            foreach (Vessel ov in FlightGlobals.Vessels)
            {
                foreach (ProtoCrewMember c in Lib.CrewList(ov))
                {
                    kerbals_alive.Add(c.name);
                }
            }
            foreach (KeyValuePair <string, KerbalData> p in DB.Kerbals())
            {
                if (!kerbals_alive.Contains(p.Key))
                {
                    kerbals_dead.Add(p.Key);
                }
            }
            foreach (string n in kerbals_dead)
            {
                // we don't know if the kerbal really is dead, or if it is just not currently assigned to a mission
                DB.KillKerbal(n, false);
            }

            // purge the caches
            Cache.Purge(v);
            ResourceCache.Purge(v);
        }
コード例 #7
0
        // kill a kerbal
        // note: you can't kill a kerbal while iterating over vessel crew list, do it outside the loop
        public static void Kill(Vessel v, ProtoCrewMember c)
        {
            // if on pod
            if (!v.isEVA)
            {
                // if vessel is loaded
                if (v.loaded)
                {
                    // find part
                    Part part = null;
                    foreach (Part p in v.parts)
                    {
                        if (p.protoModuleCrew.Find(k => k.name == c.name) != null)
                        {
                            part = p; break;
                        }
                    }

                    // remove kerbal from part
                    part.RemoveCrewmember(c);

                    // and from vessel
                    v.RemoveCrew(c);

                    // then kill it
                    c.Die();
                }
                // if vessel is not loaded
                else
                {
                    // find proto part
                    ProtoPartSnapshot part = null;
                    foreach (ProtoPartSnapshot p in v.protoVessel.protoPartSnapshots)
                    {
                        if (p.HasCrew(c.name))
                        {
                            part = p; break;
                        }
                    }

                    // remove from part
                    part.RemoveCrew(c.name);

                    // and from vessel
                    v.protoVessel.RemoveCrew(c);

                    // flag as dead
                    c.rosterStatus = ProtoCrewMember.RosterStatus.Dead;
                }

                // forget kerbal data
                DB.KillKerbal(c.name, true);
            }
            // else it must be an eva death
            else
            {
                // flag as eva death
                DB.Kerbal(c.name).eva_dead = true;

                // rename vessel
                v.vesselName = c.name + "'s body";
            }

            // remove reputation
            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                Reputation.Instance.AddReputation(-PreferencesBasic.Instance.deathPenalty, TransactionReasons.Any);
            }
        }