using System; using UnityEngine; namespace Unity.MLAgents.Sensors { /// /// An interface for GridSensor perception that defines the grid cells and collider detecting strategies. /// internal interface IGridPerception { bool RotateWithAgent { get; set; } LayerMask ColliderMask { get; set; } /// Converts the index of the cell to the 3D point (y is zero) relative to grid center /// Vector3 of the position of the center of the cell relative to grid center /// The index of the cell Vector3 GetCellLocalPosition(int cellIndex); /// /// Converts the index of the cell to the 3D point (y is zero) in world space /// based on the result from GetCellLocalPosition() /// /// Vector3 of the position of the center of the cell in world space /// The index of the cell Vector3 GetCellGlobalPosition(int cellIndex); Quaternion GetGridRotation(); /// /// Perceive the latest grid status. Detect colliders for each cell, parse the collider arrays, /// then trigger registered sensors to encode and update with the new grid status. /// void Perceive(); /// /// Same as Perceive(), but only load data for debug gizmo. /// void UpdateGizmo(); /// /// Register a sensor to this GridPerception to receive the grid perception results. /// When the GridPerception perceive a new observation, registered sensors will be triggered /// to encode the new observation and update its data. /// void RegisterSensor(GridSensorBase sensor); /// /// Register an internal debug sensor. /// Debug sensors will only be triggered when drawing debug gizmos. /// void RegisterDebugSensor(GridSensorBase debugSensor); } }