7 namespace droid.Runtime.Prototyping.Internals.StateValidation {
12 [SerializeField]
Actor _actor;
15 [SerializeField] Transform _goal;
18 [SerializeField]
bool _only_initial_state =
true;
25 public override string PrototypingTypeName {
get {
return "ValidityChecker"; } }
30 protected override void Clear() {
32 this._goal = FindObjectOfType<Transform>();
36 this._actor = FindObjectOfType<Actor>();
39 if (!this._environment) {
40 this._environment = FindObjectOfType<AbstractPrototypingEnvironment>();
43 if (this._obstructions.Length <= 0) {
44 this._obstructions = FindObjectsOfType<Obstruction>();
47 if (!this._playable_area) {
48 this._playable_area = FindObjectOfType<BoundingBox>();
54 void ValidateState() {
59 if (this._playable_area != null && !this._playable_area.
Bounds.Intersects(
this._actor.ActorBounds)) {
60 this._environment.
Terminate(
"Actor outside playable area");
63 if (this._playable_area != null
64 && !this._playable_area.
Bounds.Intersects(
this._goal.GetComponent<Collider>().bounds)) {
65 this._environment.
Terminate(
"Goal outside playable area");
68 foreach (var obstruction
in this._obstructions) {
69 if (obstruction != null
70 && obstruction.GetComponent<Collider>().bounds.Intersects(
this._actor.ActorBounds)) {
71 this._environment.
Terminate(
"Actor overlapping obstruction");
74 if (obstruction != null
75 && obstruction.GetComponent<Collider>().bounds
76 .Intersects(
this._goal.GetComponent<Collider>().bounds)) {
77 this._environment.
Terminate(
"Goal overlapping obstruction");
87 public override void PreStep() { this.ValidateState(); }
92 public override void Step() { this.ValidateState(); }
97 public override void PostStep() { this.ValidateState(); }
void Terminate(string reason="None")
Termination of an episode, can be supplied with a reason for various purposes debugging or clarificat...
override void EnvironmentReset()