Example #1
0
        /// <summary>Creates a new part from scene.</summary>
        public KIS_Item(Part part, ModuleKISInventory inventory, int quantity = 1)
        {
            // Get part node
            this.availablePart = PartLoader.getPartInfoByName(part.partInfo.name);
            this.partNode      = new ConfigNode();
            KIS_Shared.PartSnapshot(part).CopyTo(this.partNode);
            // init config
            this.InitConfig(availablePart, inventory, quantity);
            // Get mass
            this.resourceMass = part.GetResourceMass();
            ModuleKISInventory itemInventory = part.GetComponent <ModuleKISInventory>();

            if (itemInventory)
            {
                this.contentMass = itemInventory.GetContentMass();
                this.contentCost = itemInventory.GetContentCost();
                if (itemInventory.invName != "")
                {
                    this.inventoryName = itemInventory.invName;
                }
            }
        }
Example #2
0
 public void OnSave(ConfigNode node)
 {
     node.AddValue("partName", this.availablePart.name);
     node.AddValue("slot", slot);
     node.AddValue("quantity", quantity);
     node.AddValue("equipped", equipped);
     node.AddValue("resourceMass", resourceMass);
     node.AddValue("contentMass", contentMass);
     node.AddValue("contentCost", contentCost);
     if (inventoryName != "")
     {
         node.AddValue("inventoryName", inventoryName);
     }
     // Items in pod and container may have equipped status True but they are not actually equipped,
     // so there is no equipped part.
     if (equipped && equippedPart != null &&
         (equipMode == EquipMode.Part || equipMode == EquipMode.Physic))
     {
         Debug.LogFormat("Update config node of equipped part: {0}", availablePart.title);
         partNode.ClearData();
         KIS_Shared.PartSnapshot(equippedPart).CopyTo(partNode);
     }
     partNode.CopyTo(node.AddNode("PART"));
 }