void StartProduction()
        {
            if (currentlyManufacturing == null)
            {
                ScreenMessages.PostScreenMessage(
                    $"{part.partName} is not set to produce anything!",
                    5f, ScreenMessageStyle.UPPER_CENTER);
            }
            if (storage == null)
            {
                DebugEx.Error("No storage was found for the produced item to be put in!");
            }
            if (storage.isFull())
            {
                DebugEx.Info("Storage was full!");
                return;
            }

            var partConfig = KISAPI.PartNodeUtils.PartSnapshot(currentlyManufacturing.partPrefab);

            DebugEx.Info("Setting KIS to create part: {0}", partConfig.ToString());
            KIS_Shared.CreatePart(
                partConfig,
                vessel.GetWorldPos3D() + vessel.up * 3,
                Quaternion.identity,
                part,
                onPartReady: p => { DebugEx.Info("Made part: {0}", p); storage.AddItem(p, 1, 0); }
                );
            //var manufacturedPart = KIS_Shared.CreatePart(currentlyManufacturing, vessel.transform.position + vessel.transform.up * 4, Quaternion.identity, part);

            //storage.AddItem(manufacturedPart, slot: storage.GetFreeSlot());
        }
Exemplo n.º 2
0
        public static string GetKisStats(AvailablePart part)
        {
            var sb = new StringBuilder();

            sb.AppendLine("Mass: " + part.partPrefab.mass + " tons");
            sb.AppendLine("Volume: " + KIS_Shared.GetPartVolume(part).ToString("0.0") + " litres");
            sb.AppendLine("Costs: " + part.cost + "$");

            foreach (var resourceInfo in part.partPrefab.Resources)
            {
                if (WorkshopRecipeDatabase.HasResourceRecipe(resourceInfo.resourceName))
                {
                    sb.AppendLine(resourceInfo.resourceName + ": " + resourceInfo.maxAmount + " / " + resourceInfo.maxAmount);
                }
                else
                {
                    sb.AppendLine(resourceInfo.resourceName + ": 0 / " + resourceInfo.maxAmount);
                }
            }
            return(sb.ToString());
        }
Exemplo n.º 3
0
 public static bool HasFreeSpace(ModuleKISInventory inventory, WorkshopItem item)
 {
     return(inventory.GetContentVolume() + KIS_Shared.GetPartVolume(item.Part) <= inventory.maxVolume);
 }
Exemplo n.º 4
0
        public static float GetPackedPartVolume(AvailablePart part)
        {
            var moduleKisItem = KISWrapper.GetKisItem(part.partPrefab);

            return(moduleKisItem != null ? moduleKisItem.volumeOverride : KIS_Shared.GetPartVolume(part));
        }