Exemple #1
0
        void FromEVA(GameEvents.FromToAction <Part, Part> data)
        {
            // contract configurator calls this event with both parts being the same when it adds a passenger
            if (data.from == data.to)
            {
                return;
            }

            String prop_name = Lib.EvaPropellantName();

            // for each resource in the eva kerbal
            for (int i = 0; i < data.from.Resources.Count; ++i)
            {
                // get the resource
                PartResource res = data.from.Resources[i];

                // add leftovers to the vessel
                data.to.RequestResource(res.resourceName, -res.amount);
            }

            // merge drives data
            Drive.Transfer(data.from.vessel, data.to.vessel, true);

            // forget EVA vessel data
            Cache.PurgeVesselCaches(data.from.vessel);
            //Drive.Purge(data.from.vessel);

            // update boarded vessel
            this.OnVesselModified(data.to.vessel);

            // execute script
            data.to.vessel.KerbalismData().computer.Execute(data.to.vessel, ScriptType.eva_in);
        }
Exemple #2
0
        void FromEVA(GameEvents.FromToAction <Part, Part> data)
        {
            String prop_name = Lib.EvaPropellantName();

            // for each resource in the eva kerbal
            for (int i = 0; i < data.from.Resources.Count; ++i)
            {
                // get the resource
                PartResource res = data.from.Resources[i];

                // add leftovers to the vessel
                data.to.RequestResource(res.resourceName, -res.amount);
            }

            // merge drives data
            Drive.Transfer(data.from.vessel, data.to.vessel, true);

            // forget vessel data
            DB.vessels.Remove(Lib.VesselID(data.from.vessel));
            Drive.Purge(data.from.vessel);

            Cache.PurgeObjects(data.from.vessel);
            Cache.PurgeObjects(data.to.vessel);

            // execute script
            DB.Vessel(data.to.vessel).computer.Execute(data.to.vessel, ScriptType.eva_in);
        }
Exemple #3
0
        public void StoreData()
        {
            // disable for dead eva kerbals
            Vessel v = FlightGlobals.ActiveVessel;

            if (v == null || EVA.IsDead(v))
            {
                return;
            }

            // transfer data
            Drive.Transfer(v, vessel, v.isEVA);
        }
		void VesselDock(GameEvents.FromToAction<Part, Part> e)
		{
			// note:
			//  we do not forget vessel data here, it just became inactive
			//  and ready to be implicitly activated again on undocking
			//  we do however tweak the data of the vessel being docked a bit,
			//  to avoid states getting out of sync, leading to unintuitive behaviours
			VesselData vd = DB.Vessel(e.from.vessel);
			vd.msg_belt = false;
			vd.msg_signal = false;
			vd.storm_age = 0.0;
			vd.storm_time = 0.0;
			vd.storm_state = 0;
			vd.supplies.Clear();
			vd.scansat_id.Clear();

			// merge drives data
			Drive.Transfer(e.from.vessel, e.to.vessel);
		}
Exemple #5
0
        public void StoreData()
        {
            // disable for dead eva kerbals
            Vessel v = FlightGlobals.ActiveVessel;

            if (v == null || EVA.IsDead(v))
            {
                return;
            }

            // transfer data
            if (!Drive.Transfer(v, drive, PreferencesScience.Instance.sampleTransfer || Lib.CrewCount(v) > 0))
            {
                Message.Post
                (
                    Lib.Color(Lib.BuildString("WARNING: not evering copied"), Lib.Kolor.Red, true),
                    Lib.BuildString("Storage is at capacity")
                );
            }
        }
Exemple #6
0
        void FromEVA(GameEvents.FromToAction <Part, Part> data)
        {
            // contract configurator calls this event with both parts being the same when it adds a passenger
            if (data.from == data.to)
            {
                return;
            }

            // for each resource in the eva kerbal
            for (int i = 0; i < data.from.Resources.Count; ++i)
            {
                // get the resource
                PartResource res = data.from.Resources[i];

                // add leftovers to the vessel
                data.to.RequestResource(res.resourceName, -res.amount);
            }

#if !KSP15_16 && !KSP17 && !KSP18 && !KSP110
            string evaPropName = Lib.EvaPropellantName();
            if (evaPropName != "EVA Propellant")
            {
                KerbalEVA kerbalEVA = data.from.FindModuleImplementing <KerbalEVA>();
                List <ProtoPartResourceSnapshot> propContainers = new List <ProtoPartResourceSnapshot>();
                if (kerbalEVA.ModuleInventoryPartReference != null)
                {
                    foreach (StoredPart storedPart in kerbalEVA.ModuleInventoryPartReference.storedParts.Values)
                    {
                        ProtoPartResourceSnapshot propContainer = storedPart.snapshot.resources.Find(p => p.resourceName == evaPropName);
                        if (propContainer != null && propContainer.amount > 0.0)
                        {
                            propContainers.Add(propContainer);
                        }
                    }
                }

                if (propContainers.Count > 0)
                {
                    // get vessel resources handler
                    ResourceInfo evaPropOnVessel  = ResourceCache.GetResource(data.to.vessel, evaPropName);
                    double       storageAvailable = evaPropOnVessel.Capacity - evaPropOnVessel.Amount;

                    foreach (ProtoPartResourceSnapshot propContainer in propContainers)
                    {
                        double stored = Math.Min(propContainer.amount, storageAvailable);
                        storageAvailable -= stored;
                        evaPropOnVessel.Produce(stored, ResourceBroker.Generic);
                        propContainer.amount = Math.Max(propContainer.amount - stored, 0.0);

                        if (storageAvailable <= 0.0)
                        {
                            break;
                        }
                    }

                    // Explaination :
                    // - The ProtoCrewMember has already been removed from the EVA part and added to the vessel part
                    // - It's inventory has already been saved
                    // - The stock ModuleInventoryPart.RefillEVAPropellantOnBoarding() method has already been called
                    // So to set the correct amount of EVA prop, we :
                    // - Harmony patch ModuleInventoryPart.RefillEVAPropellantOnBoarding() so it doesn't refill anything
                    // - Grab the ProtoCrewMember on the vessel part
                    // - Call the SaveInventory() method again, with the modified amount on the inventory StoredPart
                    data.to.protoModuleCrew[data.to.protoModuleCrew.Count - 1].SaveInventory(kerbalEVA.ModuleInventoryPartReference);
                }
            }
#endif

            // merge drives data
            Drive.Transfer(data.from.vessel, data.to.vessel, true);

            // forget EVA vessel data
            Cache.PurgeVesselCaches(data.from.vessel);
            //Drive.Purge(data.from.vessel);

            // update boarded vessel
            this.OnVesselModified(data.to.vessel);

            // execute script
            data.to.vessel.KerbalismData().computer.Execute(data.to.vessel, ScriptType.eva_in);
        }