using UnityEngine;
using Valve.VR;
using Zarnitza.FireExtinguisherVR.FireExtinguisher;
using Zarnitza.FireExtinguisherVR.Menu.Messages;
using Zarnitza.FireExtinguisherVR.MessageBus;
using Zarnitza.FireExtinguisherVR.Messages;
using Zarnitza.FireExtinguisherVR.Quests;
using Zenject;

public class ControlBoxFireExtinguishers : MonoBehaviour
{
    [Inject]
    private ISubscriber subscriber = null;

    [Inject]
    private IPublisher publisher = null;

    [SerializeField]
    private FireExtinguisherInstaller FireExtinguisherOP;
    [SerializeField]
    private FireExtinguisherInstaller FireExtinguisherOU;
    [SerializeField]
    private FireExtinguisherInstaller FireExtinguisherOVP;


    [SerializeField]
    private SteamVR_Behaviour_Pose FireExtinguisherTipOP;
    [SerializeField]
    private SteamVR_Behaviour_Pose FireExtinguisherTipOU;
    [SerializeField]
    private SteamVR_Behaviour_Pose FireExtinguisherTipOVP;


    [SerializeField]
    private SteamVR_Action_Pose controllerBasePoseAction;

    [SerializeField]
    private SteamVR_Action_Pose controllerBasePoseTipAction;


    private SteamVR_Action_Pose controllerOPPoseTipAction;
    private SteamVR_Action_Pose controllerOVPPoseTipAction;
    private SteamVR_Action_Pose controllerOUPoseTipAction;

    private SteamVR_Action_Pose controllerOPPoseAction;
    private SteamVR_Action_Pose controllerOVPPoseAction;
    private SteamVR_Action_Pose controllerOUPoseAction;


    private SteamVR_Behaviour_Pose controllerOPPoseTipBehaviour;
    private SteamVR_Behaviour_Pose controllerOVPPoseTipBehaviour;
    private SteamVR_Behaviour_Pose controllerOUPoseTipBehaviour;

    private SteamVR_Behaviour_Pose controllerOPPoseBehaviour;
    private SteamVR_Behaviour_Pose controllerOVPPoseBehaviour;
    private SteamVR_Behaviour_Pose controllerOUPoseBehaviour;

    private void Start()
    {
        subscriber.Subscriber<SwitchFireExtinguisherMessage>(SwitchFireExtinguisher);


        controllerOPPoseAction = FireExtinguisherOP.GetComponent<SteamVR_Behaviour_Pose>().poseAction;
        controllerOVPPoseAction = FireExtinguisherOVP.GetComponent<SteamVR_Behaviour_Pose>().poseAction;
        controllerOUPoseAction = FireExtinguisherOU.GetComponent<SteamVR_Behaviour_Pose>().poseAction;

        controllerOPPoseTipAction = FireExtinguisherTipOP.poseAction;
        controllerOVPPoseTipAction = FireExtinguisherTipOVP.poseAction;
        controllerOUPoseTipAction = FireExtinguisherTipOU.poseAction;


        controllerOPPoseTipBehaviour = FireExtinguisherTipOP;
        controllerOVPPoseTipBehaviour = FireExtinguisherTipOVP;
        controllerOUPoseTipBehaviour = FireExtinguisherTipOU;

        controllerOPPoseBehaviour = FireExtinguisherOP.GetComponent<SteamVR_Behaviour_Pose>();
        controllerOVPPoseBehaviour = FireExtinguisherOVP.GetComponent<SteamVR_Behaviour_Pose>();
        controllerOUPoseBehaviour = FireExtinguisherOU.GetComponent<SteamVR_Behaviour_Pose>();

        controllerBasePoseAction = controllerOPPoseAction;
        controllerBasePoseTipAction = controllerOPPoseTipAction;

        var fireExtinguisher = FireExtinguisherOP.gameObject.GetComponent<FireExtinguisher>();
        publisher.Publish(new ActivationCurrentFireExtinguisherMessage(fireExtinguisher));
    }

    public void Setting(SettingsFireExtinguishersMessage message)
    {
        FireExtinguisherOP.gameObject.SetActive(message.FireExtinguishersOP);
        FireExtinguisherOU.gameObject.SetActive(message.FireExtinguishersOU);
        FireExtinguisherOVP.gameObject.SetActive(message.FireExtinguishersOVP);
    }

    private void SwitchFireExtinguisher(SwitchFireExtinguisherMessage message)
    {
        switch (message.FireExtinguisherType)
        {
            case FireExtinguisherType.OP:
                RestoreValuesBody();
                RestoreValuesTip();
                OffAllFireExtinguishers();
                FireExtinguisherOP.gameObject.SetActive(true);
                controllerOPPoseBehaviour.poseAction = controllerBasePoseAction;
                controllerOPPoseTipBehaviour.poseAction = controllerBasePoseTipAction;

                publisher.Publish(new ActivationCurrentFireExtinguisherMessage(FireExtinguisherOP.gameObject.GetComponent<FireExtinguisher>()));
                break;
            case FireExtinguisherType.OU:
                RestoreValuesBody();
                RestoreValuesTip();
                OffAllFireExtinguishers();
                FireExtinguisherOU.gameObject.SetActive(true);
                controllerOUPoseBehaviour.poseAction = controllerBasePoseAction;
                controllerOUPoseTipBehaviour.poseAction = controllerBasePoseTipAction;

                publisher.Publish(new ActivationCurrentFireExtinguisherMessage(FireExtinguisherOU.gameObject.GetComponent<FireExtinguisher>()));
                break;
            case FireExtinguisherType.OVP:
                RestoreValuesBody();
                RestoreValuesTip();
                OffAllFireExtinguishers();
                FireExtinguisherOVP.gameObject.SetActive(true);
                controllerOVPPoseBehaviour.poseAction = controllerBasePoseAction;
                controllerOVPPoseTipBehaviour.poseAction = controllerBasePoseTipAction;

                publisher.Publish(new ActivationCurrentFireExtinguisherMessage(FireExtinguisherOVP.gameObject.GetComponent<FireExtinguisher>()));
                break;
        }
    }
    private void RestoreValuesBody()
    {
        controllerOPPoseBehaviour.poseAction = controllerOPPoseAction;
        controllerOUPoseBehaviour.poseAction = controllerOUPoseAction;
        controllerOVPPoseBehaviour.poseAction = controllerOVPPoseAction;
    }
    private void RestoreValuesTip()
    {
        controllerOPPoseTipBehaviour.poseAction = controllerOPPoseTipAction;
        controllerOUPoseTipBehaviour.poseAction = controllerOUPoseTipAction;
        controllerOVPPoseTipBehaviour.poseAction = controllerOVPPoseTipAction;
    }
    private void OffAllFireExtinguishers()
    {
        FireExtinguisherOP.gameObject.SetActive(false);
        FireExtinguisherOU.gameObject.SetActive(false);
        FireExtinguisherOVP.gameObject.SetActive(false);
    }
    private void OnEnable()
    {
        subscriber.UnSudscribe<SwitchFireExtinguisherMessage>(SwitchFireExtinguisher);
    }
}
можешь помочь с рефакторингом