diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.dll b/1.6/1.6/Assemblies/ArachnaeSwarm.dll index 961cec6..e2258e1 100644 Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.dll and b/1.6/1.6/Assemblies/ArachnaeSwarm.dll differ 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 b49ef62..b2048ec 100644 --- a/1.6/1.6/Defs/Thing_building/ARA_NutrientNetworkBuilding.xml +++ b/1.6/1.6/Defs/Thing_building/ARA_NutrientNetworkBuilding.xml @@ -5,17 +5,17 @@ ARA_NutrientNetworkTower 一个中央营养供给设施。它可以自动为链接到的、需要营养的建筑补充燃料。它本身需要被手动填充大量的生物质。 - (3,3) + (5,5) ArachnaeSwarm/Building/ARA_ResearchBench Graphic_Multi CutoutComplex - (3,4.5) + (5,6.7) Building PassThroughOnly 70 - Rare + Normal 0.5 300 @@ -57,8 +57,6 @@
  • - -
  • ARA_GrowthVat
  • @@ -370,12 +368,6 @@ true -
  • - -
  • ARA_NutrientNetworkTower
  • - - -
  • meat_vat @@ -390,6 +382,12 @@ 12.5 true
  • + +
  • + +
  • ARA_NutrientNetworkTower
  • + + @@ -448,8 +446,8 @@ Laboratory 4 - +
  • 100.0 @@ -461,25 +459,21 @@ true true
  • + +
  • ARA_NutrientNetworkTower
  • - - - NutrientTransmissionEfficiency - 0.05 - - -
  • -
  • ARA_BioforgeIncubator
  • ARA_BioforgeIncubator_Thing
  • - - ARA_IncubationSpeedFactor - 0.1 - + + 0.05 + 0.1 + + +
  • ARA_NutrientNetworkTower
  • diff --git a/Source/ArachnaeSwarm/.vs/ArachnaeSwarm/v17/.suo b/Source/ArachnaeSwarm/.vs/ArachnaeSwarm/v17/.suo index 16a3d9e..4a177bd 100644 Binary files a/Source/ArachnaeSwarm/.vs/ArachnaeSwarm/v17/.suo and b/Source/ArachnaeSwarm/.vs/ArachnaeSwarm/v17/.suo differ diff --git a/Source/ArachnaeSwarm/Building_Comps/ARA_NutrientNetwork/CompFacility_GrowthVatBooster.cs b/Source/ArachnaeSwarm/Building_Comps/ARA_NutrientNetwork/CompFacility_GrowthVatBooster.cs index f110ef2..1bf796d 100644 --- a/Source/ArachnaeSwarm/Building_Comps/ARA_NutrientNetwork/CompFacility_GrowthVatBooster.cs +++ b/Source/ArachnaeSwarm/Building_Comps/ARA_NutrientNetwork/CompFacility_GrowthVatBooster.cs @@ -6,7 +6,8 @@ namespace ArachnaeSwarm { public class CompProperties_GrowthVatBooster : CompProperties_Facility { - public StatModifier statOffset; // 从XML读取 + // We will use the base class's statOffsets field. + // public List statOffsets; public CompProperties_GrowthVatBooster() { @@ -16,30 +17,31 @@ namespace ArachnaeSwarm public class CompFacility_GrowthVatBooster : CompFacility { - private new CompProperties_GrowthVatBooster Props => (CompProperties_GrowthVatBooster)props; - - private List cachedStatOffsets = new List(); - private bool lastHadPawn = false; - private Building_NutrientVat Vat => parent as Building_NutrientVat; public override List StatOffsets { get { - // Building_Enterable 使用 innerContainer 存放 Pawn - bool hasPawn = Vat != null && Vat.innerContainer.Any; - if (cachedStatOffsets.Count == 0 || hasPawn != lastHadPawn) + // If the vat contains a pawn, return the stat offsets defined in XML. + if (Vat != null && Vat.innerContainer.Any) { - cachedStatOffsets.Clear(); - if (hasPawn && Props.statOffset != null) - { - cachedStatOffsets.Add(Props.statOffset); - } - lastHadPawn = hasPawn; + return base.StatOffsets; // Returns the list from Props.statOffsets } - return cachedStatOffsets; + + // Otherwise, return an empty list, providing no bonus. + return new List(); } } + + public override string CompInspectStringExtra() + { + // If we are not providing any bonus, don't call the base method to avoid empty lines. + if (StatOffsets.NullOrEmpty()) + { + return null; + } + return base.CompInspectStringExtra(); + } } } \ No newline at end of file diff --git a/Source/ArachnaeSwarm/Building_Comps/ARA_NutrientNetwork/CompNutrientProvider.cs b/Source/ArachnaeSwarm/Building_Comps/ARA_NutrientNetwork/CompNutrientProvider.cs index 4f230d0..4224ae7 100644 --- a/Source/ArachnaeSwarm/Building_Comps/ARA_NutrientNetwork/CompNutrientProvider.cs +++ b/Source/ArachnaeSwarm/Building_Comps/ARA_NutrientNetwork/CompNutrientProvider.cs @@ -2,6 +2,7 @@ using RimWorld; using Verse; using System.Linq; using UnityEngine; +using System.Text; namespace ArachnaeSwarm { @@ -15,37 +16,90 @@ namespace ArachnaeSwarm selfRefuelable = parent.GetComp(); } - public override void CompTickRare() + public override string CompInspectStringExtra() { - base.CompTickRare(); + StringBuilder sb = new StringBuilder(); + + float efficiency = Mathf.Clamp(parent.GetStatValue(StatDef.Named("NutrientTransmissionEfficiency")), 0f, 0.1f); + sb.AppendLine("生物质传输效率".Translate() + ": " + efficiency.ToStringPercent()); + + sb.AppendLine("链接的建筑".Translate() + ":"); + + if (LinkedBuildings.NullOrEmpty()) + { + sb.AppendLine(" (" + "None".Translate() + ")"); + } + else + { + foreach (var building in LinkedBuildings) + { + var comp = (building as ThingWithComps)?.GetComp(); + if (comp != null) + { + bool needsFuel = NeedsFuel(comp); + sb.AppendLine($" - {building.LabelCap}: {comp.Fuel:F0}/{comp.Props.fuelCapacity:F0} (目标: {comp.TargetFuelLevel:F0}) -> {(needsFuel ? "需要" : "不需要")}"); + } + } + } + + return sb.ToString().TrimEnd(); + } + + public override void CompTick() + { + base.CompTick(); + // Log.Message($"[NutrientProvider] CompTick called for {parent.Label}."); // This will be too spammy + + if (!parent.IsHashIntervalTick(250)) + { + return; + } + + Log.Message($"[NutrientProvider] Rare Tick Logic executing for {parent.Label}."); if (selfRefuelable == null || !selfRefuelable.HasFuel) { return; } - // 找到最需要燃料的已连接建筑 var targetBuilding = LinkedBuildings .Select(b => new { Building = b, Comp = (b as ThingWithComps)?.GetComp() }) - .Where(x => x.Comp != null && x.Comp.Fuel < x.Comp.TargetFuelLevel) - .OrderBy(x => x.Comp.Fuel / x.Comp.Props.fuelCapacity) // 按燃料百分比排序 + .Where(x => x.Comp != null && NeedsFuel(x.Comp)) + .OrderBy(x => x.Comp.Fuel / x.Comp.Props.fuelCapacity) .FirstOrDefault(); if (targetBuilding != null) { var consumerComp = targetBuilding.Comp; - float fuelNeeded = consumerComp.TargetFuelLevel - consumerComp.Fuel; + float desiredLevel = GetDesiredFuelLevel(consumerComp); + float fuelNeeded = desiredLevel - consumerComp.Fuel; float fuelToTransfer = Mathf.Min(fuelNeeded, selfRefuelable.Fuel); - // 计算效率加成,并设置上限为 10% float efficiency = Mathf.Clamp(parent.GetStatValue(StatDef.Named("NutrientTransmissionEfficiency")), 0f, 0.1f); float finalCost = fuelToTransfer * (1 - efficiency); + + Log.Message($"[NutrientProvider] Found target: {targetBuilding.Building.Label}. Fuel: {consumerComp.Fuel:F0}/{consumerComp.Props.fuelCapacity:F0}. Needs: {fuelNeeded:F2}. Transferring: {fuelToTransfer:F2}. Final cost: {finalCost:F2}"); selfRefuelable.ConsumeFuel(finalCost); consumerComp.ReceiveFuel(fuelToTransfer); - - // 可以在这里添加一个 Mote 来显示传输效果 } } + + private bool NeedsFuel(CompRefuelableNutrition comp) + { + if (comp == null) return false; + return comp.Fuel < GetDesiredFuelLevel(comp); + } + + private float GetDesiredFuelLevel(CompRefuelableNutrition comp) + { + // If target is 0 (initial default) or max (UI default), treat as "fill to full". + if (comp.TargetFuelLevel <= 0.01f || comp.TargetFuelLevel >= comp.Props.fuelCapacity * 0.99f) + { + return comp.Props.fuelCapacity; + } + // Otherwise, respect the player's custom setting. + return comp.TargetFuelLevel; + } } } \ No newline at end of file