public static bool Prefix(ref GeoUnitDescriptor __result, GeoFaction faction, TacCharacterDef template, BaseStatSheetDef ___BaseStatsSheet, DefRepository ____defRepo, List <TacticalAbilityDef> ____personalAbilityPool) { try { if (template == null) { throw new Exception("Missing template for character"); } GeoUnitDescriptor geoUnitDescriptor = new GeoUnitDescriptor(faction, new GeoUnitDescriptor.UnitTypeDescriptor(template)); GeoUnitDescriptor.ProgressionDescriptor progressionDescriptor = null; foreach (ClassTagDef classTag in template.ClassTags) { SpecializationDef specializationByClassTag = Support.GetSpecializationByClassTag(classTag, ____defRepo.GetAllDefs <SpecializationDef>().ToList()); if (specializationByClassTag != null) { if (progressionDescriptor == null) { Dictionary <int, TacticalAbilityDef> personalAbilitiesByLevel = AbilityGen.GeneratePersonalTraits(___BaseStatsSheet.PersonalAbilitiesCount, template.Data.LevelProgression.Def, specializationByClassTag, ____defRepo, ____personalAbilityPool); progressionDescriptor = new GeoUnitDescriptor.ProgressionDescriptor(specializationByClassTag, personalAbilitiesByLevel); } else { progressionDescriptor.SecondarySpecDef = specializationByClassTag; } } } if (progressionDescriptor != null && template.Data.LevelProgression.IsValid) { progressionDescriptor.Level = template.Data.LevelProgression.Level; progressionDescriptor.ExtraAbilities.AddRange(template.Data.Abilites); } if (progressionDescriptor != null) { geoUnitDescriptor.Progression = progressionDescriptor; } geoUnitDescriptor.BonusStats = template.Data.BonusStats; geoUnitDescriptor.ArmorItems.AddRange(template.Data.BodypartItems.OfType <TacticalItemDef>()); geoUnitDescriptor.Equipment.AddRange(template.Data.EquipmentItems.OfType <TacticalItemDef>()); geoUnitDescriptor.Inventory.AddRange(template.Data.InventoryItems.OfType <TacticalItemDef>()); __result = geoUnitDescriptor; return(false); } catch (Exception e) { Logger.Error(e); return(true); } }
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)); } }
// 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); } }
private static void AfterDefDeploy_BoostDef(GeoHavenDefenseMission __instance, ref int __result, GeoHaven haven) { try { if (haven == null) { return; } GeoFaction attacker = __instance.GetEnemyFaction() is GeoSubFaction sub ? attacker = sub.BaseFaction : __instance.GetEnemyFaction() as GeoFaction; var defender = haven.Site.Owner; Info("{0} of {1} under attack by {2}, defense strength {3}. Alert level {4}.", haven.Site.Name, defender, attacker.GetPPName(), __result, haven.AlertLevel); var conf = Config.Defense_Multiplier; float multiply = conf.Default; switch (haven?.AlertLevel) { case GeoHaven.HavenAlertLevel.Alert: multiply *= conf.Alert; break; case GeoHaven.HavenAlertLevel.HighAlert: multiply *= conf.High_Alert; break; } var geoLevel = haven.Site.GeoLevel; if (IsAlien(attacker)) { multiply *= conf.Attacker_Pandora; } else if (attacker == geoLevel.AnuFaction) { multiply *= conf.Attacker_Anu; } else if (attacker == geoLevel.SynedrionFaction) { multiply *= conf.Attacker_Synedrion; } else if (attacker == geoLevel.NewJerichoFaction) { multiply *= conf.Attacker_NewJericho; } if (IsAlien(defender)) { multiply *= conf.Defender_Pandora; } else if (defender == geoLevel.AnuFaction) { multiply *= conf.Defender_Anu; } else if (defender == geoLevel.SynedrionFaction) { multiply *= conf.Defender_Synedrion; } else if (defender == geoLevel.NewJerichoFaction) { multiply *= conf.Defender_NewJericho; } if (multiply != 1) { __result = (int)Math.Round(__result * multiply); Info("Multiplying defender strength by {0} to {1}", multiply, __result); } } catch (Exception ex) { Error(ex); } }
private static void BeforeAddEntry_AmendEntry(GeoscapeLogEntry entry, GeoscapeLogMessagesDef ____messagesDef, GeoFaction ____faction) { try { if (entry == null || entry.Text != ____messagesDef.AircraftCrewReadyMessage) { return; } var name = (entry.Parameters[0] as LocalizedTextBind)?.Localize(); Verbo("Checking rest message of {0}", name); Func <IGeoCharacterContainer, bool> foundEntry = (e) => e.Name == name; IGeoCharacterContainer container = ____faction.Vehicles.FirstOrDefault(foundEntry) ?? ____faction.Sites.FirstOrDefault(foundEntry); if (container == null) { return; } string note; if (container.GetAllCharacters().Any(e => e.IsInjured)) { note = new LocalizedTextBind("KEY_GEOSCAPE_STAMINA").Localize(); } else if (container.GetAllCharacters().Any(e => e.Fatigue?.IsFullyRested == false)) { note = new LocalizedTextBind("KEY_HEALTH").Localize(); } else { return; } Info("Updating rest message of {0}", name); entry.Text = new LocalizedTextBind(entry.GenerateMessage() + " (" + TitleCase(note) + ")", true); } catch (Exception ex) { Error(ex); } }
private static void CheckHPSTRested(GeoCharacter restedCharacter, List <IGeoCharacterContainer> ____justRestedContainer, GeoFaction ____faction) { try { if (!HP_Changed && !ST_Changed) { return; } if (HP_Changed && !Mod.Config.Notice_On_HP_Only_Heal) { return; } if (ST_Changed && !Mod.Config.Notice_On_Stamina_Only_Heal) { return; } Func <IGeoCharacterContainer, bool> foundRested = (e) => e.GetAllCharacters().Contains(restedCharacter); if (____justRestedContainer.Any(foundRested)) { return; } var container = ____faction.Vehicles.FirstOrDefault(foundRested) ?? ____faction.Sites.FirstOrDefault(foundRested); if (container == null) { return; } if (container.GetAllCharacters().All(c => (HP_Changed && !c.IsInjured) || (ST_Changed && c.Fatigue?.IsFullyRested != false))) { Info("Detected {0} recovery on {1}", HP_Changed ? "HP" : "stamina", container.Name); ____justRestedContainer.Add(container); } } catch (Exception ex) { Error(ex); } }
public bool CanProgressManufacture(GeoFaction faction) => false;
public ItemManufacturing.ManufactureFailureReason CanFinishManufacture(GeoFaction faction) => ItemManufacturing.ManufactureFailureReason.NotManufacturable;
public float GetCostInManufacturePoints(GeoFaction faction) => faction.Def.UseHavenManufacturing ? GetCostInManufacturePoints(faction) : GetFactoryManufactureCost();
public void OnManufacture(GeoFaction faction) => ZyMod.Warn("Attempting to manufacture {0}", GetName());
public ItemManufacturing.ManufactureFailureReason CanFinishManufacture(GeoFaction faction) => CanManufacture(faction);