1 | <?php |
||
36 | class Entity implements EntityInterface |
||
37 | { |
||
38 | |||
39 | protected $components = array(); |
||
40 | |||
41 | protected $animations = array(); |
||
42 | |||
43 | 51 | public function __construct() |
|
64 | |||
65 | 26 | public function init() |
|
67 | |||
68 | 26 | public function defaults() |
|
70 | |||
71 | /** |
||
72 | * Position component |
||
73 | * |
||
74 | * All entities inherently have the position component. |
||
75 | * |
||
76 | * @param number $x |
||
|
|||
77 | * @param number $y |
||
78 | * @param number $z |
||
79 | * @return Entity |
||
80 | */ |
||
81 | 51 | public function position($x = 0, $y = 0, $z = 0): EntityInterface |
|
86 | |||
87 | /** |
||
88 | * Rotation component |
||
89 | * |
||
90 | * All entities inherently have the rotation component. |
||
91 | * |
||
92 | * @param number $x |
||
93 | * @param number $y |
||
94 | * @param number $z |
||
95 | * @return EntityInterface |
||
96 | */ |
||
97 | 51 | public function rotation($x = 0, $y = 0, $z = 0): EntityInterface |
|
102 | |||
103 | /** |
||
104 | * Scale component |
||
105 | * |
||
106 | * All entities inherently have the scale component. |
||
107 | * |
||
108 | * @param number $x |
||
109 | * @param number $y |
||
110 | * @param number $z |
||
111 | * @return EntityInterface |
||
112 | */ |
||
113 | 51 | public function scale($x = 0, $y = 0, $z = 0): EntityInterface |
|
118 | |||
119 | /** |
||
120 | * Animations |
||
121 | * |
||
122 | * @param string $name |
||
123 | * @return AnimationInterface |
||
124 | */ |
||
125 | 1 | public function animation(string $name = 'untitled'): AnimationInterface |
|
129 | |||
130 | /** |
||
131 | * Load component for this entity |
||
132 | * |
||
133 | * @param string $component_name |
||
134 | * @throws BadComponentCallException |
||
135 | * @return ComponentInterface|null |
||
136 | */ |
||
137 | 51 | public function component(string $component_name) |
|
152 | |||
153 | /** |
||
154 | * Handle entity components |
||
155 | * |
||
156 | * Since we might need to customize these to have |
||
157 | * custom components loaded as $this->methosd aswell therefore |
||
158 | * we have these placeholder magic methods here |
||
159 | * |
||
160 | * @param string $component_name |
||
161 | * @param array $args |
||
162 | */ |
||
163 | 11 | public function __call(string $component_name, array $args) |
|
173 | |||
174 | /** |
||
175 | * Create and add DOM element of the entity |
||
176 | * |
||
177 | * @param unknown $aframe_dom |
||
178 | * @return DOMElement |
||
179 | */ |
||
180 | 5 | public function DOMElement(&$aframe_dom): DOMElement |
|
198 | } |
||
199 |