(); foreach (NPC npc in npcs) { // Randomly s"> (); foreach (NPC npc in npcs) { // Randomly s"> (); foreach (NPC npc in npcs) { // Randomly s">
using UnityEngine;

public class ToolManager : MonoBehaviour
{
    public Tool[] tools;
    public float minDurability = 0f;
    public float maxDurability = 1.0f;
    private int decimalPlaces = 1;

    void Start()
    {
        RandomTools();
        AssignedTool();
    }

    void RandomTools()
    {
        tools = FindObjectsOfType<Tool>();

        foreach (Tool tool in tools)
        {
            tool.durability = Random.Range(minDurability, maxDurability);
            tool.durability = Mathf.Round(tool.durability * Mathf.Pow(10, decimalPlaces)) / Mathf.Pow(10, decimalPlaces);

            // Debug log to display the durability of the tool
            Debug.Log($"Durability of Tool {tool.gameObject.name}: {tool.durability}");

            tool.CalculateRepairUrgency();
        }
    }

    void AssignedTool()
    {
        // Assuming you have NPCs in the scene
        NPC[] npcs = FindObjectsOfType<NPC>();

        foreach (NPC npc in npcs)
        {
            // Randomly select a tool for each NPC
            Tool randomTool = tools[Random.Range(0, tools.Length)];

            // Assign the random tool to the NPC
            npc.AssignTool(randomTool);

            // Log the assigned tool and its durability
            Debug.Log($"Assigned Tool to NPC {npc.gameObject.name}: {randomTool.gameObject.name}, Durability: {randomTool.durability}");
        }
    }
}