Editor/Road/ArchFenceManifest.cs
using System;
using System.Collections.Generic;
using System.Linq;
using Sandbox;
namespace Sunless.Architecture;
public sealed class ArchFenceManifest : ArchKindManifest<ArchFencePart>, IArchNormalizes {
public override ArchKind Kind => ArchKind.Fence;
public override string Slot => "Fences";
public override IEnumerable<Type> Hosts => new[] { typeof( ArchBuilding ) };
// A fence rings a yard rather than a street, so it belongs to Buildings however much it reads as infrastructure.
public override ArchLayerDomain Domain => ArchLayerDomain.Buildings;
public override string Label => "Fence";
public override string Glyph => ArchIcons.Get( "subtool_fence", "fence" );
public override string Subtool => ArchSubtools.Fence;
public override int DirectRank => 13;
public override ArchLayerStage Stage( object payload ) => ArchLayerStage.Structure;
// Plans saved before fences carried a curve - lift the old path onto nodes once.
public void Normalize( ArchPlan plan ) {
if ( plan is null ) {
return;
}
foreach ( var building in plan.Buildings ) {
foreach ( var fence in building.Fences.Where( entry => entry.Path.Count >= 2 && entry.Nodes.Count == 0 ) ) {
fence.Nodes = fence.Path.Select( ArchCurveNode.At ).ToList();
fence.Path = new List<Vector3>();
}
}
}
}