This commit is contained in:
2025-09-08 18:34:28 +08:00
parent 82b3855fc8
commit ebe217223d
3 changed files with 34 additions and 8 deletions

Binary file not shown.

View File

@@ -85,7 +85,7 @@ namespace ArachnaeSwarm
}
else
{
yield return new FloatMenuOption("StartProduction".Translate(process.thingDef.label), () =>
yield return new FloatMenuOption("StartProduction".Translate(process.thingDef.label), () =>
{
this.selectedProcess = process;
Job job = JobMaker.MakeJob(DefDatabase<JobDef>.GetNamed("ARA_AddProcessToQueueJob"), parent);
@@ -170,18 +170,30 @@ namespace ArachnaeSwarm
}
}
private void FinishProduction(QueuedProcessOrder order)
private (QualityCategory quality, float baseScore, float penalty) GetEstimatedQualityDetails(QueuedProcessOrder order)
{
float progress = (float)order.ticksUnderOptimalConditions / order.process.productionTicks;
if (order == null || Props.qualityThresholds.NullOrEmpty())
{
return (QualityCategory.Normal, 0f, 0f);
}
float progress = (order.process.productionTicks > 0) ? (float)order.ticksUnderOptimalConditions / order.process.productionTicks : 1f;
float finalQualityPercent = Mathf.Clamp01(progress - order.temperaturePenaltyPercent);
QualityCategory finalQuality = QualityCategory.Awful;
if (!Props.qualityThresholds.NullOrEmpty())
foreach (var threshold in Props.qualityThresholds.OrderByDescending(q => q.threshold))
{
foreach (var threshold in Props.qualityThresholds.OrderByDescending(q => q.threshold))
if (finalQualityPercent >= threshold.threshold)
{
if (finalQualityPercent >= threshold.threshold) { finalQuality = threshold.quality; break; }
finalQuality = threshold.quality;
break;
}
}
return (finalQuality, progress, order.temperaturePenaltyPercent);
}
private void FinishProduction(QueuedProcessOrder order)
{
var qualityDetails = GetEstimatedQualityDetails(order);
QualityCategory finalQuality = qualityDetails.quality;
for (int i = 0; i < Props.spawnCount.RandomInRange; i++)
{
@@ -214,10 +226,16 @@ namespace ArachnaeSwarm
foreach (var order in producingNow)
{
int remainingTicks = order.productionUntilTick - Find.TickManager.TicksGame;
sb.AppendLine($" - {order.process.thingDef.LabelCap}: {remainingTicks.ToStringTicksToPeriod(true, false, true, true)}");
var qualityDetails = GetEstimatedQualityDetails(order);
sb.AppendLine($" - {order.process.thingDef.LabelCap}: {remainingTicks.ToStringTicksToPeriod(true, false, true, true)} (品质: {qualityDetails.quality.GetLabel()})");
}
}
// 添加温度信息
string tempStr = "CurrentTemperature".Translate(parent.AmbientTemperature.ToStringTemperature("F0"));
tempStr += $" ({"SafeTemperatureRange".Translate()}: {Props.minSafeTemperature.ToStringTemperature("F0")} ~ {Props.maxSafeTemperature.ToStringTemperature("F0")})";
sb.AppendLine(tempStr);
return sb.ToString().TrimEnd();
}

View File

@@ -10,12 +10,20 @@ namespace ArachnaeSwarm
public List<ThingDef> blacklist;
}
public class ProcessDef
public class ProcessDef : IExposable
{
public ThingDef thingDef;
public int productionTicks;
public float totalNutritionNeeded;
public ResearchProjectDef requiredResearch;
public void ExposeData()
{
Scribe_Defs.Look(ref thingDef, "thingDef");
Scribe_Values.Look(ref productionTicks, "productionTicks", 0);
Scribe_Values.Look(ref totalNutritionNeeded, "totalNutritionNeeded", 0f);
Scribe_Defs.Look(ref requiredResearch, "requiredResearch");
}
}
public class QualityThreshold