Exemplo n.º 1
0
        private float ReclaimResource(string resource, double amount,
								  string vessel_name, string name=null)
        {
            PartResourceDefinition res_def;
            res_def = PartResourceLibrary.Instance.GetDefinition (resource);
            VesselResources recycler = new VesselResources (vessel);

            if (res_def == null) {
            return 0;
            }

            if (name == null) {
            name = resource;
            }
            double remain = amount;
            // any resources that can't be pumped or don't flow just "evaporate"
            // FIXME: should this be a little smarter and convert certain such
            // resources into rocket parts?
            if (res_def.resourceTransferMode != ResourceTransferMode.NONE
            && res_def.resourceFlowMode != ResourceFlowMode.NO_FLOW) {
            remain = recycler.TransferResource (resource, amount);
            }
            Debug.Log (String.Format ("[EL] {0}-{1}: {2} taken {3} reclaimed, {4} lost", vessel_name, name, amount, amount - remain, remain));
            return (float) (amount * res_def.density);
        }
		internal void SetupCraftResources (Vessel vsl)
		{
			craftResources = new VesselResources (vsl);
			foreach (var br in buildCost.optional) {
				var amount = craftResources.ResourceAmount (br.name);
				craftResources.TransferResource (br.name, -amount);
			}
		}
Exemplo n.º 3
0
        public float RecycleVessel(Vessel v)
        {
            float ConversionEfficiency = 0.8f;
            double amount;
            VesselResources scrap = new VesselResources (v);

            PartResourceDefinition rp_def;
            string target_resource = ExSettings.HullRecycleTarget;
            rp_def = PartResourceLibrary.Instance.GetDefinition (target_resource);

            if (FlightGlobals.ActiveVessel == v)
            FlightGlobals.ForceSetActiveVessel (this.vessel);
            float mass = 0;
            foreach (var crew in v.GetVesselCrew ()) {
            mass += RecycleKerbal (crew, null);
            }
            foreach (string resource in scrap.resources.Keys) {
            amount = scrap.ResourceAmount (resource);
            mass += ReclaimResource (resource, amount, v.name);
            scrap.TransferResource (resource, -amount);
            }
            float hull_mass = v.GetTotalMass ();
            amount = hull_mass * ConversionEfficiency / rp_def.density;
            mass += ReclaimResource (target_resource, amount, v.name, String.Format ("hull({0})", target_resource));
            v.Die ();
            return mass;
        }