// Show vehicle name on scrap list private static void AftereInit_SetName(GeoManufactureItem __instance, IManufacturable item) { try { if (item is GeoUnitWrapper unit) { __instance.ItemName.text = unit.GetName(); __instance.CurrentlyOwnedQuantityText.transform.parent.gameObject.SetActive(false); } else { __instance.CurrentlyOwnedQuantityText.transform.parent.gameObject.SetActive(true); } } catch (Exception ex) { Error(ex); } }
// Do the scrap after user confirmation private static void OnScrapConfirmation(UIModuleManufacturing me, MessageBoxCallbackResult answer, IManufacturable item, GeoscapeViewContext context) { try { if (answer.DialogResult != MessageBoxResult.Yes) { return; } GeoFaction faction = context.ViewerFaction; GeoLevelController geoLevel = context.Level; if (item is GeoUnitWrapper) { if (item is GeoPlaneWrapper plane) { Info("Scraping airplane {0}", plane.GetName()); GeoVehicle vehicle = plane.Vehicle; GeoSite site = vehicle.CurrentSite; foreach (GeoCharacter chr in vehicle.Characters.ToList()) { Info("Moving {0} to {1}", chr.DisplayName, site.Name); vehicle.RemoveCharacter(chr); site.AddCharacter(chr); } faction.ScrapItem(plane); vehicle.Travelling = true; // Unset vehicle.CurrentSite and triggers site.VehicleLeft vehicle.Destroy(); } else if (item is GeoTankWrapper tank) { Info("Scraping tank {0}", tank.GetName()); faction.ScrapItem(tank); faction.RemoveCharacter(tank.GroundVehicle); geoLevel.DestroyTacUnit(tank.GroundVehicle); } } Info("Scrap done, refreshing list"); typeof(UIModuleManufacturing).GetMethod("DoFilter", NonPublic | Instance).Invoke(me, new object[] { null, null }); } catch (Exception ex) { Error(ex); } }