private void TransitionToBarracksState(BarracksState barracksState)
        {
            switch (barracksState)
            {
            case BarracksState.UNDER_CONSTRUCTION:
                SetCanAcceptResources(true);
                npcSpawnerBehaviour.SetSpawningEnabled(false);
                npcSpawnerBehaviour.ResetCooldowns();
                break;

            case BarracksState.CONSTRUCTION_FINISHED:
                SetCanAcceptResources(false);
                npcSpawnerBehaviour.SetSpawningEnabled(true);
                npcSpawnerBehaviour.ResetCooldowns();
                break;
            }
            barracksInfo.Send(new BarracksInfo.Update().SetBarracksState(barracksState));
        }
        public void TriggerTransition(BarracksState newState)
        {
            if (barracksInfo == null)
            {
                Debug.LogError("Trying to change state without authority.");
                return;
            }

            if (IsValidTransition(newState))
            {
                Data.barracksState = newState;

                var update = new BarracksInfo.Update();
                update.SetBarracksState(Data.barracksState);
                barracksInfo.Send(update);

                TransitionTo(newState);
            }
            else
            {
                Debug.LogErrorFormat("Barracks: Invalid transition from {0} to {1} detected.", Data.barracksState, newState);
            }
        }