Example #1
0
 public bool Equals(VesselKit other) => id != Guid.Empty && id == other.id;
 public AssemblyKitInfo(VesselKit kit) : base(kit)
 {
 }
 public override bool CanConstruct(VesselKit kit) => !kit.HasLaunchClamps;
 public virtual bool CanConstruct(VesselKit kit) => true;
 public bool CanConstruct(VesselKit vessel_kit) =>
 (!vessel_kit.HasLaunchClamps &&
  SpawnManager != null &&
  SpawnManager.MetricFits(vessel_kit.ShipMetric));
        IEnumerator <YieldInstruction> spawn_empty_container(string part_name)
        {
            if (vessel_spawner.LaunchInProgress)
            {
                Utils.Message("In progress...");
                yield break;
            }
            if (Opened)
            {
                Utils.Message("Need to close assembly space first");
                Close();
                yield break;
            }
            yield return(new WaitForEndOfFrame());

            yield return(new WaitForFixedUpdate());

            var kit_ship = new VesselKit().CreateShipConstruct(part_name, part.flagURL);

            if (kit_ship == null)
            {
                yield break;
            }
            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");
                yield break;
            }
            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();
                yield break;
            }
            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();
                yield break;
            }
            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();
                yield break;
            }
            GroundConstructionScenario.SaveGame(vessel.name + "-before_spawn_empty");
            yield return(StartCoroutine(spawn_kit_vessel(kit_ship)));
        }
Example #7
0
 protected IAssemblySpace find_best_assembly_space(VesselKit kit, Vessel vsl) =>
 find_best_assembly_space(kit, VesselKitInfo.GetKitContainers <IAssemblySpace>(vsl));
Example #8
0
 protected IAssemblySpace find_best_assembly_space(VesselKit kit, Part p) =>
 find_best_assembly_space(kit, p.FindModulesImplementing <IAssemblySpace>());
Example #9
0
        protected virtual IAssemblySpace find_assembly_space(VesselKit kit, bool best)
        {
            var spaces = get_assembly_spaces();

            return(best ? find_best_assembly_space(kit, spaces) : find_assembly_space(kit, spaces));
        }