using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace SC.XR.Unity.Module_InputSystem.InputDeviceGC {

    public class InputDeviceGCPartEventConnect : InputDeviceGCPartEventBase {

        InputDevicePartDispatchEventGC inputDevicePartDispatchEventGC;
        public InputDeviceGCPartEventConnect(InputDevicePartDispatchEventGC inputDevicePartDispatchEventGC) : base(inputDevicePartDispatchEventGC) {
            this.inputDevicePartDispatchEventGC = inputDevicePartDispatchEventGC;
        }

        public override void OnSCStart() {
            base.OnSCStart();
            newevent = previousEvent = currentEvent = GCEventType.Null;
        }

        GCEventType newevent;

        protected override void OnUpdateEvent() {

            currentEvent = GCEventType.Null;

            if (inputDevicePartDispatchEventGC.inputDeviceGCPart.inputDataGC.isConnected == true) {
                newevent = GCEventType.Connect;
            } else if (inputDevicePartDispatchEventGC.inputDeviceGCPart.inputDataGC.isConnected == false) {
                newevent = GCEventType.DisConnect;
            }

            if (newevent != previousEvent) {
                previousEvent = newevent;
                currentEvent = newevent;
            }
        }
    }
}