public void RefreshPart() { if (!HighLogic.LoadedSceneIsEditor || refreshed) { return; } SYP = part.FindModuleImplementing <ModuleSYPartTracker>(); if (SYP.TimesRecovered == 0) { SYP.MakeFresh(); } refreshed = true; }
//forces ScrapYard to refresh the part if it's needed. public void RefreshPart() { if (!HighLogic.LoadedSceneIsEditor || refreshed) { return; } SYP = part.FindModuleImplementing <ModuleSYPartTracker>(); Debug.Log("[OhScrap]: Attempting to refresh part " + SYP.ID); if (SYP.TimesRecovered == 0) { SYP.MakeFresh(); Debug.Log("[OhScrap]: Refreshed. New ID is " + SYP.ID); } else { Debug.Log("[OhScrap]: " + SYP.ID + " has been recovered " + SYP.TimesRecovered + " times. No need to refresh"); } refreshed = true; }
public void InventoryChangedEventListener(InventoryPart p, bool added) { //if removed then check if we should remove a corresponding part from the EditorLogic vessel if (!added) { if (EditorLogic.fetch?.ship?.Parts?.Count > 0) { //see if this part is on it, if so, overwrite it with a new one foreach (Part part in EditorLogic.fetch.ship.Parts) { InventoryPart shipPart = new InventoryPart(part); if (p.ID == shipPart.ID) { ModuleSYPartTracker module = part.Modules["ModuleSYPartTracker"] as ModuleSYPartTracker; module.MakeFresh(); break; //There can only be one part with this ID } } } } Logging.Log($"InventoryChangedEvent - part: '{p.Name}' added? {added}"); }