(Feat) Add Build

This commit is contained in:
2026-07-22 12:56:13 +02:00
parent 3657b870d8
commit 0052b0d98e
244 changed files with 35752 additions and 3112 deletions
@@ -3,6 +3,25 @@ using Ashwild.Inventory;
namespace Ashwild.Building
{
/// <summary>
/// What a buildable is allowed to rest on. This is the one placement rule that genuinely differs
/// per structure — a foundation sits on terrain, a wall or a ceiling only makes sense attached to
/// something — so it is authored here rather than configured globally on BuildManager (which keeps
/// owning the project-wide layer masks: what blocks a build does not vary per build).
///
/// <see cref="GroundOrSnap"/> is deliberately the zero value: Unity deserializes a missing field to
/// 0, so buildables authored before this rule existed keep their old, permissive behaviour instead
/// of silently becoming unplaceable.
/// </summary>
public enum PlacementSupport
{
/// <summary>Free placement anywhere the aim lands, or connected to a socket. Foundations, floors.</summary>
GroundOrSnap,
/// <summary>Only valid while connected to a matching socket. Walls, ceilings, roofs.</summary>
SnapOnly
}
/// <summary>
/// Authoring data for one buildable structure shown in the construction menu (a wall, a
/// floor, a door, ...). Mirrors the ScriptableObject-for-data / MonoBehaviour-for-logic
@@ -35,6 +54,14 @@ namespace Ashwild.Building
[Tooltip("Resources consumed from the builder's inventory on each placement. Leave empty for a free build.")]
[SerializeField] private BuildCost[] cost;
[Header("Placement")]
[Tooltip("Where this structure may be committed. Walls, ceilings and roofs should be Snap Only so they cannot be dropped in mid-air; foundations and floors stay Ground Or Snap.")]
[SerializeField] private PlacementSupport support = PlacementSupport.GroundOrSnap;
[Header("Health")]
[Tooltip("Hit points the placed structure starts with. Damage subtracts from this (server-authoritative in BuildRegistry); at 0 the build is destroyed. A manual demolition refunds the cost in proportion to the health left.")]
[SerializeField] private float maxHealth = 100f;
#endregion
#region Public API
@@ -45,6 +72,8 @@ namespace Ashwild.Building
public GameObject GhostPrefab => ghostPrefab;
public GameObject BuiltPrefab => builtPrefab;
public BuildCost[] Cost => cost;
public float MaxHealth => maxHealth;
public PlacementSupport Support => support;
/// <summary>
/// Whether the given inventory holds enough of every cost line to place this structure once.