using System;
using Patterns_And_Principles.Patterns.The_Observer_Pattern.WithoutEvent.Script._02_RealWorldUsage.Subject;
using UnityEngine;

namespace Patterns_And_Principles.Patterns.The_Observer_Pattern.WithoutEvent.Script._02_RealWorldUsage
{
    public class ClientObserver : MonoBehaviour
    {
        private BikeController _bikeController;

        private void Start()
        {
            _bikeController = (BikeController)FindObjectOfType(typeof(BikeController));
        }

        private void OnGUI()
        {
            if (GUILayout.Button("Damage Bike"))
            {
                if (_bikeController)
                {
                    _bikeController.TakeDamage(15f);
                }
            }

            if (GUILayout.Button("Toggle Turbo"))
            {
                if (_bikeController)
                {
                    _bikeController.ToggleTurbo();
                }
            }
        }
    }
}