Exemplo n.º 1
0
        internal static bool StripEngine(MechLabPanel panel, IMechLabDraggableItem item)
        {
            if (item.ItemType != MechLabDraggableItemType.MechComponentItem)
            {
                return(false);
            }

            var componentRef = item.ComponentRef;

            var engineRef = componentRef.GetEngineRef();

            if (engineRef == null)
            {
                return(false);
            }

            //Control.mod.Logger.LogDebug("MechLabInventoryWidget.OnAddItem " + componentRef.Def.Description.Id + " UID=" + componentRef.SimGameUID);

            foreach (var componentDefID in engineRef.GetInternalComponents())
            {
                //Control.mod.Logger.LogDebug("MechLabInventoryWidget.OnAddItem extracting componentDefID=" + componentDefID);
                var @ref = CreateMechComponentRef(componentDefID, panel.sim, panel.dataManager);

                var mechLabItemSlotElement = panel.CreateMechComponentItem(@ref, false, item.MountedLocation, item.DropParent);
                mechLabItemSlotElement.gameObject.transform.localScale = Vector3.one;
                panel.OnAddItem(mechLabItemSlotElement, false);
            }
            engineRef.ClearInternalComponents();

            SaveEngineState(engineRef, panel);

            return(true);
        }