private static bool Override_Attack(GeoFaction __instance, GeoVehicle vehicle, GeoSite site, GeoLevelController ____level) { try { Verbo("{0} wants to attack {1}.", vehicle.Name, site.Name); if (ShouldStopFight(____level, vehicle?.Owner)) { Info("{0} attack prevented at {2}.", __instance.Name.Localize(), vehicle.Name, site.Name); return(false); } lastAttacker = vehicle.Owner; return(true); } catch (Exception ex) { return(Error(ex)); } }
private static bool CanScrap(GeoVehicle plane, bool checkVehicleBay) { GeoSite site = plane.CurrentSite; if (plane.Travelling || site == null || site.Type != GeoSiteType.PhoenixBase) { return(false); } if (!(site.GetComponent <GeoPhoenixBase>() is GeoPhoenixBase pxBase)) { return(false); } return(!checkVehicleBay || CanScrapVehicles(pxBase)); }
// 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); } }
public GeoPlaneWrapper(GeoVehicle vehicle) : base(planeDefs[vehicle.VehicleDef]) { this.Vehicle = vehicle; }