diff --git a/Yafc.Model/Data/DataClasses.cs b/Yafc.Model/Data/DataClasses.cs
index f438f539..61fd4697 100644
--- a/Yafc.Model/Data/DataClasses.cs
+++ b/Yafc.Model/Data/DataClasses.cs
@@ -87,6 +87,8 @@ public enum RecipeFlags {
ScaleProductionWithPower = 1 << 3,
/// Set when the technology has a research trigger to craft an item
HasResearchTriggerCraft = 1 << 4,
+ /// Set when the technology has a research trigger to capture a spawner
+ HasResearchTriggerCaptureEntity = 1 << 8,
}
public abstract class RecipeOrTechnology : FactorioObject {
@@ -690,6 +692,16 @@ public class Technology : RecipeOrTechnology { // Technology is very similar to
public Dictionary changeRecipeProductivity { get; internal set; } = [];
internal override FactorioObjectSortOrder sortingOrder => FactorioObjectSortOrder.Technologies;
public override string type => "Technology";
+ ///
+ /// If the technology has a trigger that requires entities, they are stored here.
+ ///
+ /// Lazy-loaded so the database can load and correctly type (eg EntityCrafter, EntitySpawner, etc.) the entities without having to do another pass.
+ public IReadOnlyList triggerEntities => getTriggerEntities.Value;
+
+ ///
+ /// Sets the value used to construct .
+ ///
+ internal Lazy> getTriggerEntities { get; set; } = new Lazy>(() => []);
public override void GetDependencies(IDependencyCollector collector, List temp) {
base.GetDependencies(collector, temp);
diff --git a/Yafc.Parser/Data/FactorioDataDeserializer_RecipeAndTechnology.cs b/Yafc.Parser/Data/FactorioDataDeserializer_RecipeAndTechnology.cs
index a70cbe07..695220df 100644
--- a/Yafc.Parser/Data/FactorioDataDeserializer_RecipeAndTechnology.cs
+++ b/Yafc.Parser/Data/FactorioDataDeserializer_RecipeAndTechnology.cs
@@ -285,6 +285,18 @@ private void LoadResearchTrigger(LuaTable researchTriggerTable, ref Technology t
technology.ingredients = [new Ingredient(GetObject- (craftItemName), craftCount)];
technology.flags = RecipeFlags.HasResearchTriggerCraft;
+ break;
+ case "capture-spawner":
+ technology.flags = RecipeFlags.HasResearchTriggerCaptureEntity;
+ if (researchTriggerTable.Get("entity") is string entity) {
+ technology.getTriggerEntities = new(() => [((Entity)Database.objectsByTypeName["Entity." + entity])]);
+ }
+ else {
+ technology.getTriggerEntities = new(static () =>
+ Database.entities.all.OfType()
+ .Where(e => e.capturedEntityName != null)
+ .ToList());
+ }
break;
default:
errorCollector.Error($"Research trigger of {technology.typeDotName} has an unsupported type {type}", ErrorSeverity.MinorDataLoss);
diff --git a/Yafc/Widgets/ObjectTooltip.cs b/Yafc/Widgets/ObjectTooltip.cs
index aa6eab52..3d3ce425 100644
--- a/Yafc/Widgets/ObjectTooltip.cs
+++ b/Yafc/Widgets/ObjectTooltip.cs
@@ -498,8 +498,10 @@ private static void BuildRecipe(RecipeOrTechnology recipe, ImGui gui) {
}
private static void BuildTechnology(Technology technology, ImGui gui) {
- bool isResearchTriggerCraft = (technology.flags & RecipeFlags.HasResearchTriggerCraft) == RecipeFlags.HasResearchTriggerCraft;
- if (!isResearchTriggerCraft) {
+ bool isResearchTriggerCraft = technology.flags.HasFlag(RecipeFlags.HasResearchTriggerCraft);
+ bool isResearchTriggerCapture = technology.flags.HasFlag(RecipeFlags.HasResearchTriggerCaptureEntity);
+
+ if (!isResearchTriggerCraft && !isResearchTriggerCapture) {
BuildRecipe(technology, gui);
}
@@ -524,6 +526,22 @@ private static void BuildTechnology(Technology technology, ImGui gui) {
_ = gui.BuildFactorioObjectWithAmount(technology.ingredients[0].goods, technology.ingredients[0].amount, ButtonDisplayStyle.ProductionTableUnscaled);
}
}
+ else if (isResearchTriggerCapture) {
+ BuildSubHeader(gui, "Entity capture required");
+ using (gui.EnterGroup(contentPadding)) {
+ if (technology.triggerEntities.Count == 1) {
+ gui.BuildText("Capture:");
+ gui.BuildFactorioObjectButtonWithText(technology.triggerEntities[0]);
+
+ }
+ else {
+ gui.BuildText("Capture one of:");
+ foreach (var entity in technology.triggerEntities) {
+ gui.BuildFactorioObjectButtonWithText(entity);
+ }
+ }
+ }
+ }
if (technology.unlockRecipes.Count > 0) {
BuildSubHeader(gui, "Unlocks recipes");
diff --git a/changelog.txt b/changelog.txt
index 6351aff9..d633120f 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -19,6 +19,7 @@ Version:
Date:
Features:
- (SA) Process accessiblilty of captured spawners, which also fixes biter eggs and subsequent Gleba recipes.
+ - (SA) Add support for the capture-spawner technology trigger.
----------------------------------------------------------------------------------------------------------------------
Version: 2.2.0
Date: November 6th 2024