-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathIEntity.java
More file actions
433 lines (374 loc) · 16 KB
/
IEntity.java
File metadata and controls
433 lines (374 loc) · 16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
package org.andengine.entity;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import org.andengine.engine.Engine;
import org.andengine.engine.camera.Camera;
import org.andengine.engine.handler.IDrawHandler;
import org.andengine.engine.handler.IUpdateHandler;
import org.andengine.engine.handler.runnable.RunnableHandler;
import org.andengine.entity.modifier.IEntityModifier;
import org.andengine.entity.modifier.IEntityModifier.IEntityModifierMatcher;
import org.andengine.entity.scene.ITouchArea;
import org.andengine.entity.scene.Scene;
import org.andengine.util.IDisposable;
import org.andengine.util.adt.color.Color;
import org.andengine.util.adt.transformation.Transformation;
/**
* (c) 2010 Nicolas Gramlich
* (c) 2011 Zynga Inc.
*
* @author Nicolas Gramlich
* @since 11:20:25 - 08.03.2010
*/
public interface IEntity extends IDrawHandler, IUpdateHandler, IDisposable, ITouchArea {
// ===========================================================
// Constants
// ===========================================================
public static final int TAG_DEFAULT = 0;
public static final int ZINDEX_DEFAULT = 0;
public static final float OFFSET_CENTER_X_DEFAULT = 0.5f;
public static final float OFFSET_CENTER_Y_DEFAULT = 0.5f;
public static final float ROTATION_DEFAULT = 0;
public static final float ROTATION_OFFSET_DEFAULT = 0;
public static final float ROTATION_CENTER_X_DEFAULT = 0.5f;
public static final float ROTATION_CENTER_Y_DEFAULT = 0.5f;
public static final float SCALE_X_DEFAULT = 1;
public static final float SCALE_Y_DEFAULT = 1;
public static final float SCALE_CENTER_X_DEFAULT = 0.5f;
public static final float SCALE_CENTER_Y_DEFAULT = 0.5f;
public static final float SKEW_X_DEFAULT = 0;
public static final float SKEW_Y_DEFAULT = 0;
public static final float SKEW_CENTER_X_DEFAULT = 0.5f;
public static final float SKEW_CENTER_Y_DEFAULT = 0.5f;
// ===========================================================
// Methods
// ===========================================================
public boolean isVisible();
public void setVisible(final boolean pVisible);
public boolean isIgnoreUpdate();
public void setIgnoreUpdate(boolean pIgnoreUpdate);
public boolean isChildrenVisible();
public void setChildrenVisible(final boolean pChildrenVisible);
public boolean isChildrenIgnoreUpdate();
public void setChildrenIgnoreUpdate(boolean pChildrenIgnoreUpdate);
public int getTag();
public void setTag(final int pTag);
public int getZIndex();
public void setZIndex(final int pZIndex);
public boolean hasParent();
public IEntity getParent();
public void setParent(final IEntity pEntity);
public IEntity getRootEntity();
public float getX();
public float getY();
public void setX(final float pX);
public void setY(final float pY);
public void setPosition(final IEntity pOtherEntity);
public void setPosition(final float pX, final float pY);
public float getWidth();
public float getHeight();
/**
* It is very likely you do NOT want to use this method!
* @return
*/
@Deprecated
public float getWidthScaled();
/**
* It is very likely you do NOT want to use this method!
* @return
*/
@Deprecated
public float getHeightScaled();
public void setHeight(final float pHeight);
public void setWidth(final float pWidth);
public void setSize(final float pWidth, final float pHeight);
public float getOffsetCenterX();
public float getOffsetCenterY();
public void setOffsetCenterX(final float pOffsetCenterX);
public void setOffsetCenterY(final float pOffsetCenterY);
public void setOffsetCenter(final float pOffsetCenterX, final float pOffsetCenterY);
public boolean isRotated();
public float getRotation();
public void setRotation(final float pRotation);
public float getRotationOffset();
public void setRotationOffset(final float pRotationOffset);
public float getRotationCenterX();
public float getRotationCenterY();
public void setRotationCenterX(final float pRotationCenterX);
public void setRotationCenterY(final float pRotationCenterY);
public void setRotationCenter(final float pRotationCenterX, final float pRotationCenterY);
public boolean isScaled();
public float getScaleX();
public float getScaleY();
public void setScaleX(final float pScaleX);
public void setScaleY(final float pScaleY);
public void setScale(final float pScale);
public void setScale(final float pScaleX, final float pScaleY);
public float getScaleCenterX();
public float getScaleCenterY();
public void setScaleCenterX(final float pScaleCenterX);
public void setScaleCenterY(final float pScaleCenterY);
public void setScaleCenter(final float pScaleCenterX, final float pScaleCenterY);
public boolean isSkewed();
public float getSkewX();
public float getSkewY();
public void setSkewX(final float pSkewX);
public void setSkewY(final float pSkewY);
public void setSkew(final float pSkew);
public void setSkew(final float pSkewX, final float pSkewY);
public float getSkewCenterX();
public float getSkewCenterY();
public void setSkewCenterX(final float pSkewCenterX);
public void setSkewCenterY(final float pSkewCenterY);
public void setSkewCenter(final float pSkewCenterX, final float pSkewCenterY);
public boolean isRotatedOrScaledOrSkewed(); // TODO What about the new offset?
public void setAnchorCenterX(final float pAnchorCenterX);
public void setAnchorCenterY(final float pAnchorCenterY);
public void setAnchorCenter(final float pAnchorCenterX, final float pAnchorCenterY);
public float getRed();
public float getGreen();
public float getBlue();
public float getAlpha();
public Color getColor();
public void setRed(final float pRed);
public void setGreen(final float pGreen);
public void setBlue(final float pBlue);
public void setAlpha(final float pAlpha);
public void setColor(final Color pColor);
public void setColor(final int pARGBPackedInt);
public void setColor(final float pRed, final float pGreen, final float pBlue);
public void setColor(final float pRed, final float pGreen, final float pBlue, final float pAlpha);
/**
* @return a shared(!) float[] of length 2.
*/
public float[] getSceneCenterCoordinates();
/**
* @param pReuse must be of length 2.
* @return <code>pReuse</code> as a convenience.
*/
public float[] getSceneCenterCoordinates(final float[] pReuse);
/**
* @param pX
* @param pY
* @return a shared(!) float[] of length 2.
*/
public float[] convertLocalCoordinatesToParentCoordinates(final float pX, final float pY);
/**
* @param pX
* @param pY
* @param pReuse must be of length 2.
* @return <code>pReuse</code> as a convenience.
*/
public float[] convertLocalCoordinatesToParentCoordinates(final float pX, final float pY, final float[] pReuse);
/**
* @param pCoordinates must be of length 2.
* @return a shared(!) float[] of length 2.
*/
public float[] convertLocalCoordinatesToParentCoordinates(final float[] pCoordinates);
/**
* @param pCoordinates must be of length 2.
* @param pReuse must be of length 2.
* @return <code>pReuse</code> as a convenience.
*/
public float[] convertLocalCoordinatesToParentCoordinates(final float[] pCoordinates, final float[] pReuse);
/**
* @param pX
* @param pY
* @return a shared(!) float[] of length 2.
*/
public float[] convertParentCoordinatesToLocalCoordinates(final float pX, final float pY);
/**
* @param pX
* @param pY
* @param pReuse must be of length 2.
* @return <code>pReuse</code> as a convenience.
*/
public float[] convertParentCoordinatesToLocalCoordinates(final float pX, final float pY, final float[] pReuse);
/**
* @param pCoordinates must be of length 2.
* @return a shared(!) float[] of length 2.
*/
public float[] convertParentCoordinatesToLocalCoordinates(final float[] pCoordinates);
/**
* @param pCoordinates must be of length 2.
* @param pReuse must be of length 2.
* @return <code>pReuse</code> as a convenience.
*/
public float[] convertParentCoordinatesToLocalCoordinates(final float[] pCoordinates, final float[] pReuse);
/**
* @param pX
* @param pY
* @return a shared(!) float[] of length 2.
*/
public float[] convertLocalCoordinatesToSceneCoordinates(final float pX, final float pY);
/**
* @param pX
* @param pY
* @param pReuse must be of length 2.
* @return <code>pReuse</code> as a convenience.
*/
public float[] convertLocalCoordinatesToSceneCoordinates(final float pX, final float pY, final float[] pReuse);
/**
* @param pCoordinates must be of length 2.
* @return a shared(!) float[] of length 2.
*/
public float[] convertLocalCoordinatesToSceneCoordinates(final float[] pCoordinates);
/**
* @param pCoordinates must be of length 2.
* @param pReuse must be of length 2.
* @return <code>pReuse</code> as a convenience.
*/
public float[] convertLocalCoordinatesToSceneCoordinates(final float[] pCoordinates, final float[] pReuse);
/**
* @param pX
* @param pY
* @return a shared(!) float[] of length 2.
*/
public float[] convertSceneCoordinatesToLocalCoordinates(final float pX, final float pY);
/**
* @param pX
* @param pY
* @param pReuse must be of length 2.
* @return <code>pReuse</code> as a convenience.
*/
public float[] convertSceneCoordinatesToLocalCoordinates(final float pX, final float pY, final float[] pReuse);
/**
* @param pCoordinates must be of length 2.
* @return a shared(!) float[] of length 2.
*/
public float[] convertSceneCoordinatesToLocalCoordinates(final float[] pCoordinates);
/**
* @param pCoordinates must be of length 2.
* @param pReuse must be of length 2.
* @return <code>pReuse</code> as a convenience.
*/
public float[] convertSceneCoordinatesToLocalCoordinates(final float[] pCoordinates, final float[] pReuse);
public Transformation getLocalToSceneTransformation();
public Transformation getSceneToLocalTransformation();
public Transformation getLocalToParentTransformation();
public Transformation getParentToLocalTransformation();
public int getChildCount();
public void onAttached();
public void onDetached();
public void attachChild(final IEntity pEntity);
public IEntity getChildByTag(final int pTag);
public IEntity getChildByMatcher(final IEntityMatcher pEntityMatcher);
public IEntity getChildByIndex(final int pIndex);
public IEntity getFirstChild();
public IEntity getLastChild();
/**
* @param pEntityMatcher
* @return all children (recursively!) that match the supplied {@link IEntityMatcher}.
*/
public ArrayList<IEntity> query(final IEntityMatcher pEntityMatcher);
/**
* @param pEntityMatcher
* @return the first child (recursively!) that matches the supplied {@link IEntityMatcher} or <code>null</code> if none matches..
*/
public IEntity queryFirst(final IEntityMatcher pEntityMatcher);
/**
* @param pEntityMatcher
* @param pResult the {@link List} to put the result into.
* @return all children (recursively!) that match the supplied {@link IEntityMatcher}.
*/
public <L extends List<IEntity>> L query(final IEntityMatcher pEntityMatcher, final L pResult);
/**
* @param pEntityMatcher
* @return the first child (recursively!) that matches the supplied {@link IEntityMatcher} or <code>null</code> if none matches..
* @throws ClassCastException when the supplied {@link IEntityMatcher} matched an {@link IEntity} that was not of the requested subtype.
*/
public <S extends IEntity> S queryFirstForSubclass(final IEntityMatcher pEntityMatcher);
/**
* @param pEntityMatcher
* @return all children (recursively!) that match the supplied {@link IEntityMatcher}.
* @throws ClassCastException when the supplied {@link IEntityMatcher} matched an {@link IEntity} that was not of the requested subtype.
*/
public <S extends IEntity> ArrayList<S> queryForSubclass(final IEntityMatcher pEntityMatcher) throws ClassCastException;
/**
* @param pEntityMatcher
* @param pResult the {@link List} to put the result into.
* @return all children (recursively!) that match the supplied {@link IEntityMatcher}.
* @throws ClassCastException when the supplied {@link IEntityMatcher} matched an {@link IEntity} that was not of the requested subtype.
*/
public <L extends List<S>, S extends IEntity> L queryForSubclass(final IEntityMatcher pEntityMatcher, final L pResult) throws ClassCastException;
/**
* Immediately sorts the {@link IEntity}s based on their ZIndex. Sort is stable.
*/
public void sortChildren();
/**
* Sorts the {@link IEntity}s based on their ZIndex. Sort is stable.
* In contrast to {@link #sortChildren()} this method is particularly useful to avoid multiple sorts per frame.
* @param pImmediate if <code>true</code>, the sorting is executed immediately.
* If <code>false</code> the sorting is executed before the next (visible) drawing of the children of this {@link IEntity}.
*/
public void sortChildren(final boolean pImmediate);
/**
* Sorts the {@link IEntity}s based on the {@link Comparator} supplied. Sort is stable.
* @param pEntityComparator
*/
public void sortChildren(final IEntityComparator pEntityComparator);
public boolean detachSelf();
/**
* <b><i>WARNING:</i> This function should be called from within
* {@link RunnableHandler#postRunnable(Runnable)} which is registered
* to a {@link Scene} or the {@link Engine} itself, because otherwise
* it may throw an {@link IndexOutOfBoundsException} in the
* Update-Thread or the GL-Thread!</b>
*/
public boolean detachChild(final IEntity pEntity);
/**
* <b><i>WARNING:</i> This function should be called from within
* {@link RunnableHandler#postRunnable(Runnable)} which is registered
* to a {@link Scene} or the {@link Engine} itself, because otherwise
* it may throw an {@link IndexOutOfBoundsException} in the
* Update-Thread or the GL-Thread!</b>
*/
public IEntity detachChild(final int pTag);
/**
* <b><i>WARNING:</i> This function should be called from within
* {@link RunnableHandler#postRunnable(Runnable)} which is registered
* to a {@link Scene} or the {@link Engine} itself, because otherwise
* it may throw an {@link IndexOutOfBoundsException} in the
* Update-Thread or the GL-Thread!</b>
*/
public IEntity detachChild(final IEntityMatcher pEntityMatcher);
/**
* <b><i>WARNING:</i> This function should be called from within
* {@link RunnableHandler#postRunnable(Runnable)} which is registered
* to a {@link Scene} or the {@link Engine} itself, because otherwise
* it may throw an {@link IndexOutOfBoundsException} in the
* Update-Thread or the GL-Thread!</b>
*/
public boolean detachChildren(final IEntityMatcher pEntityMatcher);
public void detachChildren();
public void callOnChildren(final IEntityParameterCallable pEntityParameterCallable);
public void callOnChildren(final IEntityParameterCallable pEntityParameterCallable, final IEntityMatcher pEntityMatcher);
public void registerUpdateHandler(final IUpdateHandler pUpdateHandler);
public boolean unregisterUpdateHandler(final IUpdateHandler pUpdateHandler);
public boolean unregisterUpdateHandlers(final IUpdateHandlerMatcher pUpdateHandlerMatcher);
public int getUpdateHandlerCount();
public void clearUpdateHandlers();
public void registerEntityModifier(final IEntityModifier pEntityModifier);
public boolean unregisterEntityModifier(final IEntityModifier pEntityModifier);
public boolean unregisterEntityModifiers(final IEntityModifierMatcher pEntityModifierMatcher);
public int getEntityModifierCount();
public void resetEntityModifiers();
public void clearEntityModifiers();
public boolean isCullingEnabled();
public void setCullingEnabled(final boolean pCullingEnabled);
/**
* Will only be performed if {@link #isCullingEnabled()} is true.
*
* @param pCamera the currently active camera to perform culling checks against.
* @return <code>true</code> when this object is visible by the {@link Camera}, <code>false</code> otherwise.
*/
public boolean isCulled(final Camera pCamera);
public boolean collidesWith(final IEntity pOtherEntity);
public void setUserData(final Object pUserData);
public Object getUserData();
public void toString(final StringBuilder pStringBuilder);
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}