ConditionManager.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using Routes;
  3. using Sensors;
  4. using SicknessReduction.Haptic;
  5. using SicknessReduction.Visual.DoF;
  6. using SicknessReduction.Visual.Vignetting;
  7. using UnityEngine;
  8. public enum SicknessMeasure
  9. {
  10. Vignetting,
  11. DepthOfField,
  12. VirtualHelmet,
  13. Fan,
  14. Vibration,
  15. None
  16. }
  17. [Serializable]
  18. public struct Condition
  19. {
  20. public int routeNumber;
  21. public SicknessMeasure activeMeasure;
  22. }
  23. public class ConditionManager : MonoBehaviour
  24. {
  25. [Header("Game Objects")] public RouteManager routeManager;
  26. public DynamicVignetting dynamicVignetting;
  27. public DynamicDoF dynamicDoF;
  28. public GameObject virtualHelmet;
  29. public FanController fanController;
  30. public VibrationController vibrationController;
  31. public GameObject ppVolume;
  32. public SensorStatus waitForSensors;
  33. [Header("Configuration")] public Condition[] conditions;
  34. public int activeCondition;
  35. private void OnEnable()
  36. {
  37. var c = conditions[activeCondition];
  38. routeManager.selectedRoute = c.routeNumber;
  39. ppVolume.SetActive(false);
  40. fanController.enabled = c.activeMeasure == SicknessMeasure.Fan;
  41. vibrationController.enabled = c.activeMeasure == SicknessMeasure.Vibration;
  42. virtualHelmet.SetActive(c.activeMeasure == SicknessMeasure.VirtualHelmet);
  43. ppVolume.SetActive(c.activeMeasure == SicknessMeasure.DepthOfField);
  44. dynamicDoF.enabled = c.activeMeasure == SicknessMeasure.DepthOfField;
  45. dynamicVignetting.enabled = c.activeMeasure == SicknessMeasure.Vignetting;
  46. waitForSensors.waitForMqtt =
  47. c.activeMeasure == SicknessMeasure.Vibration || c.activeMeasure == SicknessMeasure.Fan;
  48. }
  49. }