暂存
This commit is contained in:
Binary file not shown.
@@ -39,9 +39,22 @@
|
||||
<li>ARA_MorphableResearchBench</li>
|
||||
</linkableBuildings>
|
||||
<maxDistance>80</maxDistance> <!-- 供能范围 -->
|
||||
<maxSimultaneous>10</maxSimultaneous>
|
||||
<maxEfficiency>0.9</maxEfficiency>
|
||||
</li>
|
||||
|
||||
<!-- 全新的、只负责画线的组件 -->
|
||||
<li Class="ArachnaeSwarm.CompProperties_LineDrawer">
|
||||
<linkableBuildings>
|
||||
<li>ARA_BioforgeIncubator</li>
|
||||
<li>ARA_BioforgeIncubator_Thing</li>
|
||||
<li>ARA_JellyVat</li>
|
||||
<li>ARA_GrowthVat</li>
|
||||
<li>ARA_MorphableResearchBench</li>
|
||||
</linkableBuildings>
|
||||
<maxDistance>80</maxDistance>
|
||||
</li>
|
||||
|
||||
<!-- 自身的燃料库 -->
|
||||
<li Class="ArachnaeSwarm.CompProperties_RefuelableNutrition">
|
||||
<fuelCapacity>10000.0</fuelCapacity>
|
||||
@@ -63,6 +76,7 @@
|
||||
<li>ARA_GrowthVat</li>
|
||||
</linkableFacilities>
|
||||
</li>
|
||||
|
||||
</comps>
|
||||
<designationCategory>ARA_Buildings</designationCategory>
|
||||
</ThingDef>
|
||||
|
||||
@@ -107,6 +107,10 @@
|
||||
<Compile Include="Building_Comps\ARA_HunterTrap\CompHunterExplosion.cs" />
|
||||
<Compile Include="Building_Comps\ARA_HunterTrap\CompProperties_HunterExplosion.cs" />
|
||||
<Compile Include="Building_Comps\ARA_HunterTrap\TrapReleaseRandomExtension.cs" />
|
||||
<Compile Include="Building_Comps\ARA_NutrientNetwork\CompFacility_GrowthVatBooster.cs" />
|
||||
<Compile Include="Building_Comps\ARA_NutrientNetwork\CompLineDrawer.cs" />
|
||||
<Compile Include="Building_Comps\ARA_NutrientNetwork\CompNutrientProvider.cs" />
|
||||
<Compile Include="Building_Comps\ARA_NutrientNetwork\CompProperties_NutrientProvider.cs" />
|
||||
<Compile Include="Building_Comps\ARA_NutrientVat\Building_NutrientVat.cs" />
|
||||
<Compile Include="Building_Comps\ARA_NutrientVat\DefModExtension_NutrientVat.cs" />
|
||||
<Compile Include="Building_Comps\ARA_SpawnPawnFromList\CompProperties_SpawnPawnFromList.cs" />
|
||||
@@ -121,9 +125,6 @@
|
||||
<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" />
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class CompProperties_LineDrawer : CompProperties
|
||||
{
|
||||
public List<ThingDef> linkableBuildings;
|
||||
public float maxDistance = 999f;
|
||||
|
||||
public CompProperties_LineDrawer()
|
||||
{
|
||||
compClass = typeof(CompLineDrawer);
|
||||
}
|
||||
}
|
||||
|
||||
public class CompLineDrawer : ThingComp
|
||||
{
|
||||
private CompProperties_LineDrawer Props => (CompProperties_LineDrawer)props;
|
||||
private List<Thing> linkedBuildings = new List<Thing>();
|
||||
|
||||
public override void PostSpawnSetup(bool respawningAfterLoad)
|
||||
{
|
||||
base.PostSpawnSetup(respawningAfterLoad);
|
||||
FindAndLinkBuildings();
|
||||
}
|
||||
|
||||
public override void CompTick()
|
||||
{
|
||||
base.CompTick();
|
||||
if (parent.IsHashIntervalTick(120))
|
||||
{
|
||||
FindAndLinkBuildings();
|
||||
}
|
||||
}
|
||||
|
||||
private void FindAndLinkBuildings()
|
||||
{
|
||||
int previousCount = linkedBuildings.Count;
|
||||
|
||||
linkedBuildings.Clear();
|
||||
if (Props.linkableBuildings.NullOrEmpty()) return;
|
||||
|
||||
var potentialTargets = parent.Map.listerBuildings.allBuildingsColonist.Where(b =>
|
||||
b != parent &&
|
||||
Props.linkableBuildings.Contains(b.def) &&
|
||||
parent.Position.DistanceTo(b.Position) <= Props.maxDistance
|
||||
);
|
||||
|
||||
linkedBuildings.AddRange(potentialTargets);
|
||||
|
||||
if (linkedBuildings.Count != previousCount)
|
||||
{
|
||||
parent.Map.mapDrawer.MapMeshDirty(parent.Position, MapMeshFlagDefOf.Things, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
public override void PostPrintOnto(SectionLayer layer)
|
||||
{
|
||||
base.PostPrintOnto(layer);
|
||||
foreach (var building in linkedBuildings)
|
||||
{
|
||||
PowerNetGraphics.PrintWirePieceConnecting(layer, this.parent, building, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using Verse;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
@@ -10,7 +11,7 @@ namespace ArachnaeSwarm
|
||||
{
|
||||
private CompRefuelableNutrition selfRefuelable;
|
||||
private new CompProperties_NutrientProvider Props => (CompProperties_NutrientProvider)props;
|
||||
|
||||
|
||||
public override void PostSpawnSetup(bool respawningAfterLoad)
|
||||
{
|
||||
base.PostSpawnSetup(respawningAfterLoad);
|
||||
@@ -82,8 +83,6 @@ namespace ArachnaeSwarm
|
||||
float efficiency = Mathf.Clamp(parent.GetStatValue(StatDef.Named("NutrientTransmissionEfficiency")), 0f, Props.maxEfficiency);
|
||||
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);
|
||||
}
|
||||
@@ -97,12 +96,10 @@ namespace ArachnaeSwarm
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user