MapSensor.cs 858 B

1234567891011121314151617181920212223242526272829303132
  1. using CSVReader;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class MapSensor : IMapSensor
  5. {
  6. public override void SetSensorList(Dictionary<int, GameObject> sensors)
  7. {
  8. SensorList = sensors;
  9. }
  10. public override List<InputObject> MapToWorldPositions(List<InputObject> inputs)
  11. {
  12. if (inputs.Count == 0)
  13. {
  14. Debug.LogError("Input to Map was of Length 0!");
  15. return inputs;
  16. }
  17. inputs.ForEach(x =>
  18. {
  19. if (!SensorList.ContainsKey(x.SensorID))
  20. {
  21. Debug.LogError("SensorID not Found!");
  22. return;
  23. }
  24. x.Pos = SensorList[x.SensorID].transform.TransformPoint(x.Pos);
  25. x.Rot = SensorList[x.SensorID].transform.TransformDirection(x.Rot);
  26. });
  27. return inputs;
  28. }
  29. }