(Feat) Add build cost

This commit is contained in:
2026-07-14 14:25:02 +02:00
parent c9e923975d
commit 3657b870d8
27 changed files with 1270 additions and 990 deletions
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using Ashwild.Audio;
using Ashwild.Building;
using Ashwild.Harvesting;
using Ashwild.Interaction;
using Ashwild.Inventory;
@@ -135,6 +137,7 @@ namespace Ashwild.Player
public static event Action<bool> BuildMenuOpenChanged; // the construction menu opened (true) or closed (false)
public static event Action<bool> BuildPlacingChanged; // a build ghost started (true) / stopped (false) being positioned
public static event Action<bool> DemolishModeChanged; // the hammer entered (true) / left (false) demolition mode (right-click held)
public static event Action<IReadOnlyList<BuildCostView>> BuildCostChanged; // the active build's cost to display near the crosshair (null/empty = clear)
// ============================================================
// Cooking events
@@ -305,6 +308,17 @@ namespace Ashwild.Player
BuildPlacingChanged?.Invoke(placing);
}
/// <summary>
/// Publishes the active build's cost lines for the crosshair to render (or a null/empty list to
/// clear it). Owner-side only; BuildManager re-raises it live as the inventory changes so the
/// affordability colouring stays current while a piece is being positioned.
/// </summary>
public static void RaiseBuildCostChanged(IReadOnlyList<BuildCostView> cost)
{
Log(nameof(BuildCostChanged));
BuildCostChanged?.Invoke(cost);
}
/// <summary>
/// Toggles demolition mode (right-click held with the hammer out). Owner-side only; the
/// hammer raises it and BuildManager drives the world-facing targeting/destroy from it.