暂存
This commit is contained in:
@@ -121,6 +121,9 @@
|
||||
<Compile Include="Building_Comps\WULA_MutiFuelSpawner\CompRefuelableWithKey.cs" />
|
||||
<Compile Include="Building_Comps\WULA_MutiFuelSpawner\IFuelSource.cs" />
|
||||
<Compile Include="Building_Comps\WULA_MutiFuelSpawner\Patch_CompRefuelableWithKey.cs" />
|
||||
<Compile Include="Building_Comps\ARA_NutrientNetwork\CompFacility_GrowthVatBooster.cs" />
|
||||
<Compile Include="Building_Comps\ARA_NutrientNetwork\CompNutrientProvider.cs" />
|
||||
<Compile Include="Building_Comps\ARA_NutrientNetwork\CompProperties_NutrientProvider.cs" />
|
||||
<Compile Include="Hediffs\ARA_ConfigurableMutant\Hediff_ConfigurableMutant.cs" />
|
||||
<Compile Include="Hediffs\ARA_ConfigurableMutant\Hediff_NecroticVirus_Configurable.cs" />
|
||||
<Compile Include="Hediffs\ARA_ConfigurableMutant\HediffComp_NecroticTransformation.cs" />
|
||||
|
||||
@@ -68,6 +68,11 @@ namespace ArachnaeSwarm
|
||||
Messages.Message("MessageRefueled".Translate(parent.LabelShort, totalNutritionGained.ToString("0.##"), Props.fuelGizmoLabel), parent, MessageTypeDefOf.PositiveEvent);
|
||||
}
|
||||
}
|
||||
|
||||
public void ReceiveFuel(float amount)
|
||||
{
|
||||
base.Refuel(amount);
|
||||
}
|
||||
|
||||
public override string CompInspectStringExtra()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class CompProperties_GrowthVatBooster : CompProperties_Facility
|
||||
{
|
||||
public StatModifier statOffset; // 从XML读取
|
||||
|
||||
public CompProperties_GrowthVatBooster()
|
||||
{
|
||||
compClass = typeof(CompFacility_GrowthVatBooster);
|
||||
}
|
||||
}
|
||||
|
||||
public class CompFacility_GrowthVatBooster : CompFacility
|
||||
{
|
||||
private new CompProperties_GrowthVatBooster Props => (CompProperties_GrowthVatBooster)props;
|
||||
|
||||
private List<StatModifier> cachedStatOffsets = new List<StatModifier>();
|
||||
private bool lastHadPawn = false;
|
||||
|
||||
private Building_NutrientVat Vat => parent as Building_NutrientVat;
|
||||
|
||||
public override List<StatModifier> StatOffsets
|
||||
{
|
||||
get
|
||||
{
|
||||
// Building_Enterable 使用 innerContainer 存放 Pawn
|
||||
bool hasPawn = Vat != null && Vat.innerContainer.Any;
|
||||
if (cachedStatOffsets.Count == 0 || hasPawn != lastHadPawn)
|
||||
{
|
||||
cachedStatOffsets.Clear();
|
||||
if (hasPawn && Props.statOffset != null)
|
||||
{
|
||||
cachedStatOffsets.Add(Props.statOffset);
|
||||
}
|
||||
lastHadPawn = hasPawn;
|
||||
}
|
||||
return cachedStatOffsets;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class CompNutrientProvider : CompFacility
|
||||
{
|
||||
private CompRefuelableNutrition selfRefuelable;
|
||||
|
||||
public override void PostSpawnSetup(bool respawningAfterLoad)
|
||||
{
|
||||
base.PostSpawnSetup(respawningAfterLoad);
|
||||
selfRefuelable = parent.GetComp<CompRefuelableNutrition>();
|
||||
}
|
||||
|
||||
public override void CompTickRare()
|
||||
{
|
||||
base.CompTickRare();
|
||||
|
||||
if (selfRefuelable == null || !selfRefuelable.HasFuel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 找到最需要燃料的已连接建筑
|
||||
var targetBuilding = LinkedBuildings
|
||||
.Select(b => new { Building = b, Comp = (b as ThingWithComps)?.GetComp<CompRefuelableNutrition>() })
|
||||
.Where(x => x.Comp != null && x.Comp.Fuel < x.Comp.TargetFuelLevel)
|
||||
.OrderBy(x => x.Comp.Fuel / x.Comp.Props.fuelCapacity) // 按燃料百分比排序
|
||||
.FirstOrDefault();
|
||||
|
||||
if (targetBuilding != null)
|
||||
{
|
||||
var consumerComp = targetBuilding.Comp;
|
||||
float fuelNeeded = consumerComp.TargetFuelLevel - 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);
|
||||
|
||||
selfRefuelable.ConsumeFuel(finalCost);
|
||||
consumerComp.ReceiveFuel(fuelToTransfer);
|
||||
|
||||
// 可以在这里添加一个 Mote 来显示传输效果
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using RimWorld;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class CompProperties_NutrientProvider : CompProperties_Facility
|
||||
{
|
||||
public CompProperties_NutrientProvider()
|
||||
{
|
||||
compClass = typeof(CompNutrientProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user