IInteractor.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. namespace Rokid.UXR.Interaction
  3. {
  4. public struct InteractorStateChangeArgs
  5. {
  6. public InteractorState PreviousState { get; }
  7. public InteractorState NewState { get; }
  8. public InteractorStateChangeArgs(
  9. InteractorState previousState,
  10. InteractorState newState)
  11. {
  12. PreviousState = previousState;
  13. NewState = newState;
  14. }
  15. }
  16. /// <summary>
  17. /// IInteractorView defines the view for an object that can interact with other objects.
  18. /// 定义可以与其他对象交互的对象的视图
  19. /// </summary>
  20. public interface IInteractorView
  21. {
  22. int Identifier { get; }
  23. public object Data { get; }
  24. bool HasCandidate { get; }
  25. object CandidateProperties { get; }
  26. bool HasInteractable { get; }
  27. bool HasSelectedInteractable { get; }
  28. InteractorState State { get; }
  29. event Action<InteractorStateChangeArgs> WhenStateChanged;
  30. event Action WhenPreprocessed;
  31. event Action WhenProcessed;
  32. event Action WhenPostprocessed;
  33. }
  34. public interface IUpdateDriver
  35. {
  36. bool IsRootDriver { get; set; }
  37. void Drive();
  38. }
  39. /// <summary>
  40. /// IInteractor defines an object that can interact with other objects
  41. /// and can handle selection events to change its state.
  42. /// 定义了一个可以与其他对象交互并可以处理选择事件以改变其状态的对象。
  43. /// </summary>
  44. public interface IInteractor : IInteractorView, IUpdateDriver
  45. {
  46. void Preprocess();
  47. void Process();
  48. void Postprocess();
  49. void ProcessCandidate();
  50. void Enable();
  51. void Disable();
  52. void Hover();
  53. void Unhover();
  54. void Select();
  55. void Unselect();
  56. bool ShouldHover { get; }
  57. bool ShouldUnhover { get; }
  58. bool ShouldSelect { get; }
  59. bool ShouldUnselect { get; }
  60. }
  61. }