暂存线
This commit is contained in:
Binary file not shown.
@@ -10,7 +10,8 @@ namespace ArachnaeSwarm
|
||||
{
|
||||
public List<ThingDef> linkableBuildings;
|
||||
public float maxDistance = 999f;
|
||||
|
||||
public string lineTexturePath = "Things/Special/Power/Wire";
|
||||
|
||||
public CompProperties_LineDrawer()
|
||||
{
|
||||
compClass = typeof(CompLineDrawer);
|
||||
@@ -21,6 +22,19 @@ namespace ArachnaeSwarm
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -44,7 +58,7 @@ namespace ArachnaeSwarm
|
||||
linkedBuildings.Clear();
|
||||
if (Props.linkableBuildings.NullOrEmpty()) return;
|
||||
|
||||
var potentialTargets = parent.Map.listerBuildings.allBuildingsColonist.Where(b =>
|
||||
var potentialTargets = parent.Map.listerBuildings.allBuildingsColonist.Where(b =>
|
||||
b != parent &&
|
||||
Props.linkableBuildings.Contains(b.def) &&
|
||||
parent.Position.DistanceTo(b.Position) <= Props.maxDistance
|
||||
@@ -63,7 +77,12 @@ namespace ArachnaeSwarm
|
||||
base.PostPrintOnto(layer);
|
||||
foreach (var building in linkedBuildings)
|
||||
{
|
||||
PowerNetGraphics.PrintWirePieceConnecting(layer, this.parent, building, false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user