InputDeviceGCPartEventCharging.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using UnityEngine;
  7. namespace SC.XR.Unity.Module_InputSystem.InputDeviceGC {
  8. public class InputDeviceGCPartEventCharging : InputDeviceGCPartEventBase {
  9. InputDevicePartDispatchEventGC inputDevicePartDispatchEventGC;
  10. public InputDeviceGCPartEventCharging(InputDevicePartDispatchEventGC inputDevicePartDispatchEventGC) : base(inputDevicePartDispatchEventGC) {
  11. this.inputDevicePartDispatchEventGC = inputDevicePartDispatchEventGC;
  12. }
  13. public override void OnSCStart() {
  14. base.OnSCStart();
  15. if (inputDevicePartDispatchEventGC.inputDeviceGCPart.inputDataGC.isCharging == true) {
  16. currentEvent = GCEventType.BATTERY_STATUS_CHARGING;
  17. } else if (inputDevicePartDispatchEventGC.inputDeviceGCPart.inputDataGC.isCharging == false) {
  18. currentEvent = GCEventType.BATTERY_STATUS_DISCHARGING;
  19. }
  20. newevent = previousEvent = currentEvent;
  21. }
  22. GCEventType newevent;
  23. protected override void OnUpdateEvent() {
  24. currentEvent = GCEventType.Null;
  25. if (inputDevicePartDispatchEventGC.inputDeviceGCPart.inputDataGC.isCharging == true) {
  26. newevent = GCEventType.BATTERY_STATUS_CHARGING;
  27. } else if (inputDevicePartDispatchEventGC.inputDeviceGCPart.inputDataGC.isCharging == false) {
  28. newevent = GCEventType.BATTERY_STATUS_DISCHARGING;
  29. }
  30. if (newevent != previousEvent) {
  31. previousEvent = newevent;
  32. currentEvent = newevent;
  33. }
  34. }
  35. }
  36. }