예제 #1
0
        public void SpawnEmptyContainer(string part_name)
        {
            if (vessel_spawner.LaunchInProgress)
            {
                Utils.Message("In progress...");
                return;
            }
            if (Opened)
            {
                Utils.Message("Need to close assembly space first");
                Close();
                return;
            }
            var kit_ship = new VesselKit().CreateShipConstruct(part_name, part.flagURL);

            if (kit_ship != null)
            {
                var kit_metric =
                    new Metric(kit_ship.Bounds(kit_ship.parts[0].localRoot.partTransform));
                if (!SpawnManager.MetricFits(kit_metric))
                {
                    kit_ship.Unload();
                    Utils.Message("Container is too big for this assembly space");
                    return;
                }
                PartKit.GetRequirements(kit_ship.Parts[0],
                                        out var assembly_reqs,
                                        out var construction_reqs);
                var need_ec = assembly_reqs.energy + construction_reqs.energy;
                if (!part.TryUseResource(Utils.ElectricCharge.id, need_ec))
                {
                    Utils.Message("Not enough energy to make the container");
                    kit_ship.Unload();
                    return;
                }
                if (assembly_reqs &&
                    !part.TryUseResource(assembly_reqs.resource.id,
                                         assembly_reqs.resource_amount))
                {
                    Utils.Message("Not enough {0} to make the container",
                                  assembly_reqs.resource.name);
                    kit_ship.Unload();
                    return;
                }
                if (construction_reqs &&
                    !part.TryUseResource(construction_reqs.resource.id,
                                         construction_reqs.resource_amount))
                {
                    Utils.Message("Not enough {0} to make the container",
                                  construction_reqs.resource.name);
                    kit_ship.Unload();
                    return;
                }
                GroundConstructionScenario.SaveGame(vessel.name + "-before_spawn_empty");
                StartCoroutine(spawn_kit_vessel(kit_ship));
            }
        }
예제 #2
0
 public static void GetRequirements(
     Part p,
     out Requirements assembly_requirements,
     out Requirements construction_requirements
 )
 {
     var kit = new PartKit(p, false);
     if(kit.CurrentIndex == ASSEMBLY)
     {
         assembly_requirements = kit.RemainingRequirements().Copy();
         kit.SetStageComplete(DIYKit.ASSEMBLY, true);
     }
     else
         assembly_requirements = new Requirements();
     construction_requirements = kit.RemainingRequirements().Copy();
 }
예제 #3
0
 public void GetRecycleInfo(
     Part p,
     float efficiency,
     out DIYKit.Requirements assembly_requirements,
     out DIYKit.Requirements construction_requirements
     )
 {
     PartKit.GetRequirements(p, out assembly_requirements, out construction_requirements);
     if (assembly_requirements)
     {
         assembly_requirements.resource_amount *=
             assembly_requirements.resource.MaxRecycleRatio * efficiency;
         assembly_requirements.energy *= GLB.RecycleEnergyRatio;
     }
     if (construction_requirements)
     {
         construction_requirements.resource_amount *=
             construction_requirements.resource.MaxRecycleRatio * efficiency;
         construction_requirements.energy *= GLB.RecycleEnergyRatio;
     }
 }