1 using System.Collections.Generic;
10 namespace droid.Runtime.Prototyping.Actors {
14 [AddComponentMenu(ActorComponentMenuPath._ComponentMenuPath +
"Base" + ActorComponentMenuPath._Postfix)]
28 bool _draw_bounds =
false;
32 public Bounds ActorBounds {
34 var col = this.GetComponent<BoxCollider>();
35 this._bounds =
new Bounds(this.transform.position, Vector3.zero);
38 this._bounds.Encapsulate(col.bounds);
41 foreach (var child_col
in this.GetComponentsInChildren<Collider>()) {
42 if (child_col != col) {
43 this._bounds.Encapsulate(child_col.bounds);
51 Dictionary<string, IActuator>
IActor.
Actuators {
get {
return this._Actuators; } }
53 public Transform Transform {
get {
return this.transform; } }
61 Debug.Log($
"Applying {motion} To {this.name}'s Actuators");
66 if (this._Actuators.ContainsKey(motion_actuator_name)
67 && this._Actuators[motion_actuator_name] != null) {
68 this._Actuators[motion_actuator_name].ApplyMotion(motion);
72 Debug.Log($
"Could find not Actuator with the specified name: {motion_actuator_name} on actor {this.name}");
82 if (this._Actuators != null) {
83 foreach (var actuator
in this._Actuators.Values) {
84 actuator?.EnvironmentReset();
94 if (this._Actuators != null) {
95 if (this._Actuators.ContainsKey(identifier)) {
98 Debug.Log($
"Actor {this.name} unregistered Actuator {identifier}");
102 this._Actuators.Remove(identifier);
117 if (!Application.isPlaying) {
118 var manager_script = MonoScript.FromMonoBehaviour(
this);
119 if (MonoImporter.GetExecutionOrder(manager_script) != _script_execution_order) {
120 MonoImporter.SetExecutionOrder(manager_script,
121 _script_execution_order);
122 Debug.LogWarning(
"Execution Order changed, you will need to press play again to make everything function correctly!");
123 EditorApplication.isPlaying =
false;
133 protected override void Clear() { this._Actuators.Clear(); }
139 this.ParentEnvironment =
140 NeodroidUtilities.RegisterComponent(this.ParentEnvironment,
this);
151 if (this._draw_bounds) {
153 Corners.ExtractCorners(this.ActorBounds.center,
this.ActorBounds.extents,
this.transform);
155 Corners.DrawBox(corners[0],
173 if (this.Debugging) {
174 Debug.Log(
"Actor " + this.name +
" has Actuator " + identifier);
178 if (!this._Actuators.ContainsKey(identifier)) {
179 this._Actuators.Add(identifier, actuator);
182 if (this.Debugging) {
183 Debug.Log($
"A Actuator with the identifier {identifier} is already registered");
193 [Header(
"References", order = 99)]
199 [Header(
"General", order = 101)]
201 protected Dictionary<string, IActuator> _Actuators =
new Dictionary<string, IActuator>();
204 const int _script_execution_order = -10;
214 public override string PrototypingTypeName {
get {
return "Actor"; } }
227 this.RegisterActuator(actuator, identifier);
232 public Dictionary<string, IActuator> Actuators {
get {
return this._Actuators; } }
237 get {
return this._environment; }
238 set { this._environment = value; }
Environment to be used with the prototyping components.
override void RegisterComponent()
virtual void ApplyMotion(IMotion motion)
void Register(IActuator actuator)
void UnRegister(IActuator actuator, string identifier)
void RegisterActuator(IActuator actuator, string identifier)
Dictionary< string, IActuator > Actuators
void UnRegister(IActuator actuator)
override void UnRegisterComponent()
void Register(IActuator actuator, string identifier)
virtual void EnvironmentReset()