```
feat(ARA_NutrientNetwork): 移除独立的连线绘制组件并整合进营养供应器 将原本独立的 CompLineDrawer 组件功能整合进 CompNutrientProvider, 移除了冗余的 XML 配置和对应的 C# 类文件。现在连线绘制逻辑由营养 供应器组件统一处理,简化了网络建筑之间的连接可视化实现。 同时保留了可配置的连线材质路径,确保视觉表现可定制。 ```
This commit is contained in:
@@ -128,7 +128,6 @@
|
||||
<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" />
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
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 string lineTexturePath = "Things/Special/Power/Wire";
|
||||
|
||||
public CompProperties_LineDrawer()
|
||||
{
|
||||
compClass = typeof(CompLineDrawer);
|
||||
}
|
||||
}
|
||||
|
||||
public class CompLineDrawer : ThingComp
|
||||
{
|
||||
private CompProperties_LineDrawer Props => (CompProperties_LineDrawer)props;
|
||||
private List<Thing> linkedBuildings = new List<Thing>();
|
||||
private Material lineMat;
|
||||
|
||||
private Material LineMat
|
||||
{
|
||||
get
|
||||
{
|
||||
if (lineMat == null)
|
||||
{
|
||||
lineMat = MaterialPool.MatFrom(Props.lineTexturePath, ShaderDatabase.Transparent, Color.white);
|
||||
}
|
||||
return lineMat;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Vector3 center = (this.parent.TrueCenter() + this.parent.Graphic.DrawOffset(this.parent.Rotation) + building.TrueCenter() + building.Graphic.DrawOffset(building.Rotation)) / 2f;
|
||||
center.y = AltitudeLayer.SmallWire.AltitudeFor();
|
||||
Vector3 v = building.TrueCenter() - this.parent.TrueCenter();
|
||||
Vector2 size = new Vector2(1f, v.MagnitudeHorizontal());
|
||||
float rot = v.AngleFlat();
|
||||
Printer_Plane.PrintPlane(layer, center, size, this.LineMat, rot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,19 @@ namespace ArachnaeSwarm
|
||||
{
|
||||
private CompRefuelableNutrition selfRefuelable;
|
||||
private new CompProperties_NutrientProvider Props => (CompProperties_NutrientProvider)props;
|
||||
private Material lineMat;
|
||||
|
||||
private Material LineMat
|
||||
{
|
||||
get
|
||||
{
|
||||
if (lineMat == null)
|
||||
{
|
||||
lineMat = MaterialPool.MatFrom(Props.lineTexturePath, ShaderDatabase.Transparent, Color.white);
|
||||
}
|
||||
return lineMat;
|
||||
}
|
||||
}
|
||||
|
||||
public override void PostSpawnSetup(bool respawningAfterLoad)
|
||||
{
|
||||
@@ -102,5 +115,20 @@ namespace ArachnaeSwarm
|
||||
}
|
||||
return comp.TargetFuelLevel;
|
||||
}
|
||||
|
||||
public override void PostPrintOnto(SectionLayer layer)
|
||||
{
|
||||
base.PostPrintOnto(layer);
|
||||
foreach (var building in LinkedBuildings)
|
||||
{
|
||||
if (building == null) continue;
|
||||
Vector3 center = (this.parent.TrueCenter() + this.parent.Graphic.DrawOffset(this.parent.Rotation) + building.TrueCenter() + building.Graphic.DrawOffset(building.Rotation)) / 2f;
|
||||
center.y = AltitudeLayer.SmallWire.AltitudeFor();
|
||||
Vector3 v = building.TrueCenter() - this.parent.TrueCenter();
|
||||
Vector2 size = new Vector2(1f, v.MagnitudeHorizontal());
|
||||
float rot = v.AngleFlat();
|
||||
Printer_Plane.PrintPlane(layer, center, size, this.LineMat, rot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ namespace ArachnaeSwarm
|
||||
public class CompProperties_NutrientProvider : CompProperties_Facility
|
||||
{
|
||||
public float maxEfficiency = 0.9f;
|
||||
public string lineTexturePath = "Things/Special/Power/Wire";
|
||||
|
||||
public CompProperties_NutrientProvider()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user