更改
This commit is contained in:
@@ -141,6 +141,13 @@ namespace ArachnaeSwarm
|
||||
|
||||
foreach(var order in producingOrders)
|
||||
{
|
||||
// 关键修复:检查时间戳有效性
|
||||
if (order.productionUntilTick <= 0)
|
||||
{
|
||||
Log.Error($"Invalid productionUntilTick: {order.productionUntilTick} for {order.process?.thingDef?.defName}. Skipping.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(hasFuel && isTempSafe)
|
||||
{
|
||||
order.ticksUnderOptimalConditions++;
|
||||
@@ -150,10 +157,8 @@ namespace ArachnaeSwarm
|
||||
float tempDelta = (ambientTemperature > Props.maxSafeTemperature) ? ambientTemperature - Props.maxSafeTemperature : Props.minSafeTemperature - ambientTemperature;
|
||||
order.temperaturePenaltyPercent = Mathf.Min(1f, order.temperaturePenaltyPercent + tempDelta * Props.penaltyPerDegreePerTick);
|
||||
}
|
||||
if (!hasFuel)
|
||||
{
|
||||
order.productionUntilTick++;
|
||||
}
|
||||
// 修复:移除原来的 order.productionUntilTick++ 逻辑
|
||||
// 没有燃料时暂停生产
|
||||
}
|
||||
|
||||
if (FuelComp != null)
|
||||
@@ -217,14 +222,27 @@ namespace ArachnaeSwarm
|
||||
|
||||
private void FinishProduction(QueuedProcessOrder order)
|
||||
{
|
||||
var qualityDetails = GetEstimatedQualityDetails(order);
|
||||
QualityCategory finalQuality = qualityDetails.quality;
|
||||
|
||||
for (int i = 0; i < Props.spawnCount.RandomInRange; i++)
|
||||
if (order.process == null)
|
||||
{
|
||||
Thing product = ThingMaker.MakeThing(order.process.thingDef);
|
||||
product.TryGetComp<CompQuality>()?.SetQuality(finalQuality, ArtGenerationContext.Colony);
|
||||
GenPlace.TryPlaceThing(product, parent.Position, parent.Map, ThingPlaceMode.Near);
|
||||
Log.Warning("FinishProduction called but order.process is null. Skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var qualityDetails = GetEstimatedQualityDetails(order);
|
||||
QualityCategory finalQuality = qualityDetails.quality;
|
||||
|
||||
for (int i = 0; i < Props.spawnCount.RandomInRange; i++)
|
||||
{
|
||||
Thing product = ThingMaker.MakeThing(order.process.thingDef);
|
||||
product.TryGetComp<CompQuality>()?.SetQuality(finalQuality, ArtGenerationContext.Colony);
|
||||
GenPlace.TryPlaceThing(product, parent.Position, parent.Map, ThingPlaceMode.Near);
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"Error in FinishProduction for {order.process.thingDef.defName}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,6 +324,26 @@ namespace ArachnaeSwarm
|
||||
Log.Warning($"CompQueuedInteractiveProducer: Could not find a matching ProcessDef for '{order.tempThingDefName}' after loading. The item may have been removed. Removing order.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 关键修复:检查加载后的时间戳有效性
|
||||
if (order.productionUntilTick > 0)
|
||||
{
|
||||
// 如果生产结束时间已经过去,立即完成生产
|
||||
if (Find.TickManager.TicksGame >= order.productionUntilTick)
|
||||
{
|
||||
Log.Warning($"Production time already passed for {order.tempThingDefName}. Finishing immediately.");
|
||||
FinishProduction(order);
|
||||
return true;
|
||||
}
|
||||
// 如果时间戳异常(比如超过游戏当前时间太多),重新计算
|
||||
else if (order.productionUntilTick - Find.TickManager.TicksGame > order.process.productionTicks * 10)
|
||||
{
|
||||
Log.Warning($"Abnormal production time detected for {order.tempThingDefName}. Recalculating.");
|
||||
float speedFactor = 1f + (FacilitiesComp?.GetStatOffset(StatDef.Named("ARA_IncubationSpeedFactor")) ?? 0f);
|
||||
int modifiedDelay = (int)(order.process.productionTicks / speedFactor);
|
||||
order.productionUntilTick = Find.TickManager.TicksGame + modifiedDelay;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
@@ -419,4 +457,4 @@ namespace ArachnaeSwarm
|
||||
return 10f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user