using UnityEngine; using Ashwild.Interaction; namespace Ashwild.Crafting { /// /// A world workstation the player interacts with to open the crafting panel with this station's /// recipes unlocked. It declares which station it is and nothing more: the recipe catalog, the /// filtering and the craft itself all stay in , which this simply hands /// the station type to. /// /// Multiplayer: deliberately a plain MonoBehaviour, NOT a NetworkBehaviour. Unlike a chest or a /// cooking station it owns no shared state — a craft only consumes and produces in the crafting /// player's own (client-authoritative) inventory — so two players using the same bench at once can /// never clobber each other and there is strictly nothing to replicate. The object it sits on is /// still a networked build (it carries BuiltStructure like any placed structure); this component /// just does not participate in that. /// [DisallowMultipleComponent] public class CraftingStation : MonoBehaviour, IInteractable { #region Serialized Fields [Header("Station")] [Tooltip("Recipes requiring this exact station become craftable while its panel is open.")] [SerializeField] private CraftingStationType stationType = CraftingStationType.Workbench; [Tooltip("Name shown in the interaction prompt.")] [SerializeField] private string displayName = "Établi"; #endregion #region Public API /// /// Which station this is — the key CraftingManager filters recipes against. /// public CraftingStationType StationType => stationType; #endregion #region Unity Lifecycle /// /// Warns early when the station is left on None, which would unlock nothing beyond hand crafting /// and read as a broken bench in game. /// private void Awake() { if (stationType == CraftingStationType.None) Debug.LogError($"[CraftingStation] '{name}' has its station type left on None — it will unlock no recipe.", this); } #endregion #region IInteractable /// /// Prompt shown while aiming at the station. /// public string InteractionPrompt => $"Utiliser {displayName}"; /// /// Opens the crafting panel bound to this station. Runs on the interacting client only — nothing /// here is replicated, every player browses their own panel. /// public void Interact() { if (CraftingManager.Instance == null) { Debug.LogError("[CraftingStation] No CraftingManager in the scene — cannot open the crafting panel.", this); return; } CraftingManager.Instance.OpenStation(this); } #endregion } }