Example #1
0
        // If scrap list need to be populated, do it
        private static void BeforeSetupQueue_AddVehicleToScrap(GeoscapeViewContext ____context, ItemStorage ____scrapStorage)
        {
            try {
                if (!NeedToAddVehicles)
                {
                    return;
                }
                LoadVehicleDefs();

                GeoPhoenixFaction faction = ____context.ViewerFaction as GeoPhoenixFaction;
                foreach (GeoVehicle v in faction.Vehicles)
                {
                    Verbo("Add {0} to item list", v.Name);
                    ____scrapStorage.AddItem(new GeoPlaneWrapper(v));
                }

                NeedToAddVehicles = false;
            } catch (Exception ex) { Error(ex); }
        }
Example #2
0
        // Replace scrap list with individual vehicles when applicable
        private static void BeforeRefreshItemList_FillWithVehicle(UIModuleManufacturing __instance, ref IEnumerable <IManufacturable> availableItemRecipes,
                                                                  PhoenixGeneralButton ____activeFilterButton, GeoscapeViewContext ____context)
        {
            try {
                if (availableItemRecipes == null || availableItemRecipes.GetType() == typeof(List <IManufacturable>))
                {
                    return;
                }
                if (!IsScrappingVehicles(__instance, ____activeFilterButton))
                {
                    return;
                }

                List <IManufacturable> vList   = new List <IManufacturable>();
                GeoPhoenixFaction      faction = ____context.ViewerFaction as GeoPhoenixFaction;
                TankSites = new Dictionary <GeoTacUnit, GeoSite>();

                if (faction.Vehicles.Count() > 1)
                {
                    foreach (GeoVehicle plane in faction.Vehicles)
                    {
                        if (CanScrap(plane, true))
                        {
                            Verbo("Can scrap airplane {0}", plane.Name);
                            vList.Add(new GeoPlaneWrapper(plane));
                            foreach (var chr in plane.Characters)
                            {
                                if (chr.ClassDef.IsVehicle || chr.ClassDef.IsMutog)
                                {
                                    TankSites.Add(chr, plane.CurrentSite);
                                }
                            }
                        }
                    }
                }
                foreach (GeoPhoenixBase pxbase in faction.Bases)
                {
                    var units = pxbase.Site.TacUnits;
                    if (!units.Any())
                    {
                        continue;
                    }
                    foreach (var chr in units)
                    {
                        if (chr.ClassDef.IsMutog)
                        {
                            TankSites.Add(chr, pxbase.Site);
                        }
                    }
                    if (CanScrapVehicles(pxbase))
                    {
                        Verbo("Can scrap tanks at {0}", pxbase.Site.Name);
                        foreach (var chr in units)
                        {
                            if (chr.ClassDef.IsVehicle)
                            {
                                TankSites.Add(chr, pxbase.Site);
                            }
                        }
                    }
                }
                foreach (GeoCharacter tank in faction.GroundVehicles)
                {
                    if (!TankSites.ContainsKey(tank))
                    {
                        continue;
                    }
                    Verbo("Can scrap tank {0}", tank.DisplayName);
                    vList.Add(new GeoTankWrapper(tank));
                }
                Info("Can scrap {0} vehicles", vList.Count);
                availableItemRecipes = from t in vList select t;
            } catch (Exception ex) { Error(ex); }
        }