10 namespace droid.Runtime.Prototyping.Evaluation {
14 [AddComponentMenu(EvaluationComponentMenuPath._ComponentMenuPath
16 + EvaluationComponentMenuPath._Postfix)]
18 [SerializeField]
Actor _actor = null;
20 [SerializeField] Collider _area = null;
21 [SerializeField]
bool _is_resting =
false;
23 [SerializeField]
Obstruction[] _obstructions = null;
29 [SerializeField]
float _resting_time = 3f;
30 [SerializeField]
bool _sparse =
false;
31 [SerializeField] Coroutine _wait_for_resting = null;
32 WaitForSeconds _wait_for_seconds =
new WaitForSeconds(3f);
41 if (this._overlapping ==
ActorOverlapping.Inside_area_ &&
this._is_resting) {
43 if (((KillableActor)this._actor).IsAlive) {
44 this.ParentEnvironment.Terminate(
"Inside goal area");
48 this.ParentEnvironment.Terminate(
"Inside goal area");
54 signal += 1 / Vector3.Distance(this._actor.transform.position,
this._area.transform.position);
57 if (this._playable_area && this._actor) {
58 if (!this._playable_area.
Bounds.Intersects(
this._actor.GetComponent<Collider>().bounds)) {
59 this.ParentEnvironment.Terminate(
"Actor is outside playable area");
70 if (this._wait_for_resting != null) {
71 this.StopCoroutine(this._wait_for_resting);
74 this._is_resting =
false;
77 IEnumerator WaitForResting() {
78 yield
return this._wait_for_seconds;
80 this._is_resting =
true;
85 this._area = FindObjectOfType<Sensor>().gameObject.GetComponent<Collider>();
89 this._actor = FindObjectOfType<Actor>();
92 if (this._obstructions.Length <= 0) {
93 this._obstructions = FindObjectsOfType<Obstruction>();
96 if (!this._playable_area) {
97 this._playable_area = FindObjectOfType<BoundingBox>();
107 .OnTriggerEnterChild,
113 .OnTriggerStayChild);
122 .OnTriggerEnterChild,
128 .OnTriggerStayChild);
129 this._wait_for_seconds =
new WaitForSeconds(this._resting_time);
132 void OnTriggerEnterChild(GameObject child_game_object, Collider other_game_object) {
134 if (child_game_object == this._area.gameObject
135 && other_game_object.gameObject ==
this._actor.gameObject) {
137 if (this.Debugging) {
138 Debug.Log(
"Actor is inside area");
143 if (this._wait_for_resting != null) {
144 this.StopCoroutine(this._wait_for_resting);
147 this._wait_for_resting = this.StartCoroutine(this.WaitForResting());
152 void OnTriggerStayChild(GameObject child_game_object, Collider other_game_object) {
154 if (child_game_object == this._area.gameObject
155 && other_game_object.gameObject ==
this._actor.gameObject) {
157 if (this.Debugging) {
158 Debug.Log(
"Actor is inside area");
167 void OnTriggerExitChild(GameObject child_game_object, Collider other_game_object) {
169 if (child_game_object == this._area.gameObject
170 && other_game_object.gameObject ==
this._actor.gameObject) {
172 if (this.Debugging) {
173 Debug.Log(
"Actor is outside area");
178 if (this._wait_for_resting != null) {
179 this.StopCoroutine(this._wait_for_resting);
override float InternalEvaluate()
override void InternalReset()
override void PostSetup()