eye-therapy-2 / Assets / Scripts / Fireman / FiremanInputManager.cs
FiremanInputManager.cs
Raw
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Events;
using System;

public class FiremanInputManager : MonoBehaviour, IListener
{
    public InputEvent waterHoseEvent;

    private InputActions input;

    void Awake()
    {
        input = new InputActions();

        EventManager.Instance.AddListener(EVENT_TYPE.ON_VR_CONTROLMODE_SWITCHED, this);
    }

    private void OnEnable()
    {
        input.FiremanInput.Enable();

        // Shoot
        input.FiremanInput.Shoot.performed += OnWaterHose;
        input.FiremanInput.Shoot.canceled += OnWaterHose;
    }

    private void OnDisable()
    {
        // Shoot
        input.FiremanInput.Shoot.performed -= OnWaterHose;
        input.FiremanInput.Shoot.canceled -= OnWaterHose;

        input.FiremanInput.Disable();
    }

    private void OnWaterHose(InputAction.CallbackContext ctx)
    {
        waterHoseEvent.Invoke(ctx);
    }

    public void OnEvent<T>(EVENT_TYPE eventType, Component Sender, T param = default)
    {
        switch(eventType)
        {
            case EVENT_TYPE.ON_VR_CONTROLMODE_SWITCHED:

                break;
        }
    }
}