diff --git a/Sources/iron/Trait.hx b/Sources/iron/Trait.hx index 303fbce5..854385d7 100644 --- a/Sources/iron/Trait.hx +++ b/Sources/iron/Trait.hx @@ -5,7 +5,11 @@ import iron.object.Object; class Trait { public var name: String = ""; - public var object: Object; // Object this trait belongs to + + /** + Object this trait belongs to. + **/ + public var object: Object; var _add: ArrayVoid> = null; var _init: ArrayVoid> = null; @@ -17,65 +21,101 @@ class Trait { public function new() {} + /** + Remove the trait from the object. + **/ public function remove() { object.removeTrait(this); } + /** + Trait is added to an object. + **/ public function notifyOnAdd(f: Void->Void) { if (_add == null) _add = []; _add.push(f); } + /** + Object which this trait belongs to is added to scene. + **/ public function notifyOnInit(f: Void->Void) { if (_init == null) _init = []; _init.push(f); App.notifyOnInit(f); } + /** + Object which this trait belongs to is removed from scene. + **/ public function notifyOnRemove(f: Void->Void) { if (_remove == null) _remove = []; _remove.push(f); } + /** + Add game logic handler. + **/ public function notifyOnUpdate(f: Void->Void) { if (_update == null) _update = []; _update.push(f); App.notifyOnUpdate(f); } + /** + Remove game logic handler. + **/ public function removeUpdate(f: Void->Void) { _update.remove(f); App.removeUpdate(f); } + /** + Add late game logic handler. + **/ public function notifyOnLateUpdate(f: Void->Void) { if (_lateUpdate == null) _lateUpdate = []; _lateUpdate.push(f); App.notifyOnLateUpdate(f); } + /** + Remove late game logic handler. + **/ public function removeLateUpdate(f: Void->Void) { _lateUpdate.remove(f); App.removeLateUpdate(f); } + /** + Add render handler. + **/ public function notifyOnRender(f: kha.graphics4.Graphics->Void) { if (_render == null) _render = []; _render.push(f); App.notifyOnRender(f); } + /** + Remove render handler. + **/ public function removeRender(f: kha.graphics4.Graphics->Void) { _render.remove(f); App.removeRender(f); } + /** + Add 2D render handler. + **/ public function notifyOnRender2D(f: kha.graphics2.Graphics->Void) { if (_render2D == null) _render2D = []; _render2D.push(f); App.notifyOnRender2D(f); } + /** + Remove 2D render handler. + **/ public function removeRender2D(f: kha.graphics2.Graphics->Void) { _render2D.remove(f); App.removeRender2D(f);