Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
GoalCellSensor.cs
Go to the documentation of this file.
1 using System.Collections.Generic;
6 using UnityEngine;
7 
8 namespace droid.Runtime.Prototyping.Sensors.Grid {
9  [AddComponentMenu(
10  SensorComponentMenuPath._ComponentMenuPath + "GoalCell" + SensorComponentMenuPath._Postfix)]
11  public class GoalCellSensor : Sensor,
12  IHasTriple {
13  [SerializeField] EmptyCell _current_goal;
14  [SerializeField] Vector3 _current_goal_position;
15 
16  [SerializeField] bool _draw_names = true;
17 
18  [SerializeField] int _order_index;
19 
22  public int OrderIndex { get { return this._order_index; } set { this._order_index = value; } }
23 
26  public bool DrawNames { get { return this._draw_names; } set { this._draw_names = value; } }
27 
31  public override string PrototypingTypeName { get { return "GoalObserver"; } }
32 
35  public EmptyCell CurrentGoal {
36  get {
37  this.UpdateObservation();
38  return this._current_goal;
39  }
40  set { this._current_goal = value; }
41  }
42 
46  public Vector3 ObservationValue {
47  get { return this._current_goal_position; }
48  private set { this._current_goal_position = value; }
49  }
50 
54  public Space3 TripleSpace { get; } = new Space3();
55 
56  public override IEnumerable<float> FloatEnumerable {
57  get {
58  return new[] {
59  this._current_goal_position.x,
60  this._current_goal_position.y,
61  this._current_goal_position.z
62  };
63  }
64  }
65 
68  public override void UpdateObservation() {
69  if (this._current_goal) {
70  this._current_goal_position = this._current_goal.transform.position;
71  }
72  }
73 
74  #if UNITY_EDITOR
75  void OnDrawGizmosSelected() {
76  if (this.DrawNames) {
77  if (this._current_goal) {
78  NeodroidDrawingUtilities.DrawString(this._current_goal.name,
79  this._current_goal.transform.position,
80  Color.green);
81  }
82  }
83  }
84  #endif
85  }
86 }