-
-
\ No newline at end of file
diff --git a/1.6/1.6/Defs/Thing_building/ARA_NutrientNetworkBuilding.xml b/1.6/1.6/Defs/Thing_building/ARA_NutrientNetworkBuilding.xml
index 242a19c..d58e1a8 100644
--- a/1.6/1.6/Defs/Thing_building/ARA_NutrientNetworkBuilding.xml
+++ b/1.6/1.6/Defs/Thing_building/ARA_NutrientNetworkBuilding.xml
@@ -176,7 +176,7 @@
+
+
\ No newline at end of file
diff --git a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj
index 85f6577..6b46fbc 100644
--- a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj
+++ b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj
@@ -145,6 +145,7 @@
+
diff --git a/Source/ArachnaeSwarm/Building_Comps/CompAutoEjector.cs b/Source/ArachnaeSwarm/Building_Comps/CompAutoEjector.cs
new file mode 100644
index 0000000..411fa1a
--- /dev/null
+++ b/Source/ArachnaeSwarm/Building_Comps/CompAutoEjector.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Linq;
+using RimWorld;
+using Verse;
+
+namespace ArachnaeSwarm
+{
+ // Properties for the new component
+ public class CompProperties_AutoEjector : CompProperties
+ {
+ public int checkInterval = 250; // Check roughly every 4 seconds
+ public float ejectAtPercent = 1.0f; // Eject when fuel reaches this percentage of max capacity (1.0 = 100%)
+ public Type targetComp = typeof(CompRefuelable); // The specific CompRefuelable class to target, can be overridden in XML
+
+ public CompProperties_AutoEjector()
+ {
+ this.compClass = typeof(CompAutoEjector);
+ }
+ }
+
+ // The component logic
+ public class CompAutoEjector : ThingComp
+ {
+ private CompProperties_AutoEjector Props => (CompProperties_AutoEjector)this.props;
+ private CompRefuelable refuelableComp;
+
+ public override void PostSpawnSetup(bool respawningAfterLoad)
+ {
+ base.PostSpawnSetup(respawningAfterLoad);
+
+ // Find the specific refuelable component specified in XML
+ this.refuelableComp = this.parent.GetComps()
+ .FirstOrDefault(comp => comp.GetType() == this.Props.targetComp);
+
+ if (this.refuelableComp == null)
+ {
+ Log.Warning($"[ArachnaeSwarm] CompAutoEjector on {parent.def.defName} could not find a CompRefuelable of type '{this.Props.targetComp.FullName}' to monitor.");
+ }
+ }
+
+ public override void CompTick()
+ {
+ base.CompTick();
+
+ // Check if we have a valid refuelable comp and it's time to check
+ if (this.refuelableComp != null &&
+ this.parent.IsHashIntervalTick(this.Props.checkInterval))
+ {
+ // Check if fuel has reached or exceeded the configured percentage of the MAX capacity
+ if (this.refuelableComp.FuelPercentOfMax >= this.Props.ejectAtPercent)
+ {
+ // Call the public EjectFuel() method.
+ this.refuelableComp.EjectFuel();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file