I want  buildingPanelManager.UpdateProduction(this, isDay, progress, message); always be updated with the correct values, now it is not doing it, how do I fix it

using System;
using System.Collections;
using System.Collections.Generic;
using Game.ImprovedAI;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Serialization;
using Random = UnityEngine.Random;

namespace Game.Systems.Buildings
{
    public class ArcherCamp : BuildingBase
    {

        [Header("Building Stats")]
        [SerializeField] private GameObject archerPrefab;
        [SerializeField] private float timeToTrain = 5f;

        private List<ArcherController> archers = new List<ArcherController>();
        private List<ArcherController> disabledArchers = new List<ArcherController>();

        private bool isTraining = false; // Indicates if soldier is currently being trained
        private GameObject currentArcher;
        private Bounds spawnBounds;
        private string message;
        private float progress;
    
        
        public override void Init()
        { 
           base.Init();
           isDay = true;
           GameManager.Instance.OnDayStart += DayAction;
           GameManager.Instance.OnNightStart += NightAction;
           GameManager.Instance.BuilderManager.AddBuildingToQueue(this);
           GameManager.Instance.VillagerTracker.AddSoldierBuilding(this);
           
           if (GameManager.Instance.immediateBuild)
           {
               MarkAsComplete();
           }
           else
           {
               GameManager.Instance.BuilderManager.AddBuildingToQueue(this);
           }
           
           message = "0 Soldiers in Queue";
           progress = 0;

        }

        public override void InitPanel()
        {
            base.InitPanel();
            showingPanel = true;
            buildingPanelManager.Init(BuildingPanelType.D, name, description, this);
        }
        
        private void Update()
        {
            if (!isTraining && pendingSoldiers > 0)
            {
                StartTraining();
            }

            if (buildingPanelManager != null && showingPanel)
            {
                buildingPanelManager?.UpdateHealth(this, buildingHealth.health, buildingHealth.maxHealth);
                buildingPanelManager.UpdateProduction(this, isDay, progress, message);
            }
        }

        public override void BuildingAction()
        {
            base.BuildingAction();
        }

        public override void AssignedVillager()
        {
            base.AssignedVillager();
            pendingSoldiers++;

            // If training is not in progress, start training
            if (!isTraining)
            {
                StartTraining();
            }
        }

        public override void RemoveVillager()
        {
            base.RemoveVillager();
            if (assignedVillagers > 0)
            {
                assignedVillagers--;
                ArcherController archer = archers[0];
                archer.gameObject.SetActive(false);
                disabledArchers.Add(archer);
                archers.RemoveAt(0);
                archer.DisableUnit();                
            }
        }

        public void RegenerateSoldier(ArcherController archer)
        {
            pendingSoldiers++;
            disabledArchers.Add(archer);
            archers.Remove(archer);
        }
        
        private void StartTraining()
        {
            if (pendingSoldiers > 0)
            {
                isTraining = true; // Set training flag to true
                StartCoroutine(TrainSoldier()); // Start the training coroutine
            }
        }

        private IEnumerator TrainSoldier()
        {
            float elapsedTime = 0; // Track the elapsed time

            // Loop for the duration of ‘timeToTrain’
            while (elapsedTime < timeToTrain)
            {
        
                // Increment the elapsed time by the time since the last frame
                if (isDay)
                {
                    elapsedTime += Time.deltaTime;
                }

                // Calculate the training progress as a percentage
                progress = Mathf.Clamp01(elapsedTime / timeToTrain);
                
                message = pendingSoldiers > 0 ? $"Soldiers in Queue {pendingSoldiers}";

                // Wait until the next frame
                yield return null;
            }

            if (pendingSoldiers <= 0)
            {
                message = $"No soldiers in Queue";
                progress = 0;
                yield break;
            }

            pendingSoldiers--; // Get the next villager from the queue

            CreateSoldier();

            isTraining = false; // Reset training flag
        }

        private void CreateSoldier()
        {
            if (disabledArchers.Count == 0)
            {
                GameObject archerGO = Instantiate(archerPrefab, GetRandomPositionInArea(), Quaternion.Euler(0, 180, 0));
                ArcherController archer = archerGO.GetComponent<ArcherController>();
                if (archer != null)
                {
                    archer.Init(this, archerGO.transform.position);
                    archers.Add(archer);
                }
            }
            else
            {
                ArcherController soldier = disabledArchers[0];
                soldier.gameObject.SetActive(true);
                soldier.transform.position = GetRandomPositionInArea();
                soldier.transform.rotation = quaternion.Euler(0, 180, 0);
                soldier.Init(this, soldier.transform.position);
                disabledArchers.RemoveAt(0);
                archers.Add(soldier);
            }
        }

        public Vector3 GetRandomPositionInArea()
        {
            // Set the center of the spawn area. It is the position of the GameObject this script is attached to.
            Vector3 center = spawnPoint.transform.position;
            
            Vector3 areaSize = new Vector3(3.8f, 0f, 1.8f);

            // Calculate the min and max bounds for X and Z coordinates.
            Vector3 min = center - areaSize * 0.5f;
            Vector3 max = center + areaSize * 0.5f;

            // Choose a random position within the defined bounds
            Vector3 randomPosition = new Vector3(
                Random.Range(min.x, max.x),
                center.y, // This example spawns objects at the height of the center.
                Random.Range(min.z, max.z)
            );

            return randomPosition;
        }

        public void DayAction(object sender, EventArgs args)
        {
            isDay = true;
        }
        
        public void NightAction(object sender, EventArgs args)
        {
            isDay = false;
        }
        
        public override void DemolishedAction()
        {
            base.DemolishedAction();
            if (pendingSoldiers > 0)
            {
                GameManager.Instance.VillagersPlacer.AddVillagers(assignedVillagers);
            }
            buildingHealth.TakeDamage(float.MaxValue, true);
            GameManager.Instance.VillagerTracker.RemoveSoldierBuilding(this);
        }
        
        public override void DestroyedAction()
        {
            base.DestroyedAction();
            if (showingPanel)
            {
                GameManager.Instance.BuildingPanelManager.DisableAllPanels();
            }
            StopAllCoroutines();
        }
        
        void OnDestroy()
        {
            // Stop all coroutines when the farm object is destroyed
            StopAllCoroutines();
            GameManager.Instance.OnDayStart -= DayAction;
            GameManager.Instance.OnNightStart -= NightAction;
        }
    }
}