Code/AdvancedMappingTools/AmtPart.cs

A data-only Component that stores metadata for one building part generated by Advanced Mapping Tools: part id, generator, kind, seed, dimensions, generated transform and material/geometry hashes, override/settings/history JSON strings and gameplay tags. It has no runtime behaviour, it exists so part data persists in the scene file.

using Sandbox;
using System.Collections.Generic;

namespace AdvancedMappingTools;
public enum PartState
{
	Generated,
	ManuallyCreated,
	Modified,
	Locked,
	Hidden,
	Disabled,
	Excluded,
	PendingUpdate,
	Error,
	Protected
}

/// <summary>
/// What Advanced Mapping Tools knows about one building part. It lives in the scene file,
/// so parts stay independent objects and keep their generator data across saves.
/// It does nothing at runtime.
/// </summary>
[Title( "Davelix Part" ), Category( "Davelix Construct" ), Icon( "extension" )]
public sealed class AmtPart : Component
{
	/// <summary>
	/// Stable path inside its generator, for example floor0/front/window1/frame/top.
	/// </summary>
	[Property] public string PartId { get; set; }

	/// <summary>
	/// Which generator made this part, empty for parts made by hand.
	/// </summary>
	[Property] public string Generator { get; set; }

	/// <summary>
	/// What this part is, for example WallPanel, FrameBar or Step.
	/// </summary>
	[Property] public string Kind { get; set; }

	/// <summary>
	/// Which seed and regeneration group this part belongs to, for example roof or glass.
	/// </summary>
	[Property] public string Category { get; set; }

	[Property] public PartState State { get; set; } = PartState.Generated;

	[Property] public int Seed { get; set; }

	/// <summary>
	/// True when the look of this part really comes from its seed.
	/// </summary>
	[Property, ReadOnly] public bool UsesSeed { get; set; }

	[Property] public Vector3 Dimensions { get; set; }

	[Property] public int Version { get; set; } = 1;

	/// <summary>
	/// The local transform the generator gave this part. Anything else is a manual change.
	/// </summary>
	[Property, ReadOnly] public Transform GeneratedTransform { get; set; }

	/// <summary>
	/// Hash of the geometry the generator gave this part. Anything else is a manual change.
	/// </summary>
	[Property, ReadOnly] public int GeneratedGeometry { get; set; }

	/// <summary>
	/// Hash of the materials the generator gave this part. Anything else is a manual change.
	/// </summary>
	[Property, ReadOnly] public int GeneratedMaterial { get; set; }

	/// <summary>Face-to-material assignment fingerprint. Zero denotes a legacy baseline.</summary>
	[Property, ReadOnly]
	public int GeneratedFaceMaterials { get; set; }

	/// <summary>
	/// The colour the generator gave this part. Anything else is a manual change.
	/// </summary>
	[Property, ReadOnly] public Color GeneratedTint { get; set; } = Color.White;

	/// <summary>
	/// Generator settings on the root part of a generated object, as JSON.
	/// </summary>
	[Property, ReadOnly, TextArea] public string Settings { get; set; }

	/// <summary>
	/// Every part id the generator has placed, on the root part. A part in this list
	/// that no longer exists was deleted by hand and stays deleted.
	/// </summary>
	[Property, ReadOnly, TextArea] public string KnownParts { get; set; }

	/// <summary>
	/// Values this one part was given by hand, as JSON. They win over the generator.
	/// </summary>
	[Property, ReadOnly, TextArea] public string Overrides { get; set; }

	/// <summary>
	/// One line per change made to this part.
	/// </summary>
	[Property, ReadOnly, TextArea] public string History { get; set; }

	/// <summary>
	/// Gameplay tags for this part: Breakable, Climbable, Cover, Loot Spot.
	/// They are stored on the part and can be read by game code.
	/// </summary>
	[Property] public List<string> GameTags { get; set; } = [];
}