-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathIEntity.java
More file actions
286 lines (239 loc) · 10.6 KB
/
IEntity.java
File metadata and controls
286 lines (239 loc) · 10.6 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
package org.anddev.andengine.entity;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.engine.handler.IUpdateHandler;
import org.anddev.andengine.engine.handler.runnable.RunnableHandler;
import org.anddev.andengine.entity.modifier.IEntityModifier;
import org.anddev.andengine.entity.modifier.IEntityModifier.IEntityModifierMatcher;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.opengl.IDrawable;
import org.anddev.andengine.util.IMatcher;
import org.anddev.andengine.util.ParameterCallable;
import org.anddev.andengine.util.Transformation;
/**
* (c) 2010 Nicolas Gramlich
* (c) 2011 Zynga Inc.
*
* @author Nicolas Gramlich
* @since 11:20:25 - 08.03.2010
*/
public interface IEntity extends IDrawable, IUpdateHandler {
// ===========================================================
// Final Fields
// ===========================================================
// ===========================================================
// 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 getZIndex();
public void setZIndex(final int pZIndex);
public boolean hasParent();
public IEntity getParent();
public void setParent(final IEntity pEntity);
public float getX();
public float getY();
public float getInitialX();
public float getInitialY();
public void setInitialPosition();
public void setPosition(final IEntity pOtherEntity);
public void setPosition(final float pX, final float pY);
public boolean isRotated();
public float getRotation();
public void setRotation(final float pRotation);
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 float getRed();
public float getGreen();
public float getBlue();
public float getAlpha();
public void setAlpha(final float pAlpha);
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 pX
* @param pY
* @return a shared(!) float[] of length 2.
*/
public float[] convertLocalToSceneCoordinates(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[] convertLocalToSceneCoordinates(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[] convertLocalToSceneCoordinates(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[] convertLocalToSceneCoordinates(final float[] pCoordinates, final float[] pReuse);
/**
* @param pX
* @param pY
* @return a shared(!) float[] of length 2.
*/
public float[] convertSceneToLocalCoordinates(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[] convertSceneToLocalCoordinates(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[] convertSceneToLocalCoordinates(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[] convertSceneToLocalCoordinates(final float[] pCoordinates, final float[] pReuse);
public Transformation getLocalToSceneTransformation();
public Transformation getSceneToLocalTransformation();
// public Transformation getLocalToParentTransformation(); // TODO Add this method.
// public Transformation getParentToLocalTransformation(); // TODO Add this method.
public int getChildCount();
public void onAttached();
public void onDetached();
public void attachChild(final IEntity pEntity);
public boolean attachChild(final IEntity pEntity, final int pIndex);
public IEntity getChild(final int pIndex);
public IEntity getFirstChild();
public IEntity getLastChild();
public int getChildIndex(final IEntity pEntity);
public boolean setChildIndex(final IEntity pEntity, final int pIndex);
public IEntity findChild(final IEntityMatcher pEntityMatcher);
/**
* @param pEntityMatcher
* @return all children (recursively!) that match the supplied {@link IEntityMatcher}.
*/
public ArrayList<IEntity> query(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 all children (recursively!) that match the supplied {@link IEntityMatcher}.
* @throws ClassCastException when the supplied {@link IEntityMatcher} matched a {@link IEntity} that was not of the requested subtype.
*/
public <S extends IEntity> ArrayList<S> queryForSubclass(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 a {@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;
public boolean swapChildren(final int pIndexA, final int pIndexB);
public boolean swapChildren(final IEntity pEntityA, final IEntity pEntityB);
/**
* Sorts the {@link IEntity}s based on their ZIndex. Sort is stable.
*/
public void sortChildren();
/**
* Sorts the {@link IEntity}s based on the {@link Comparator} supplied. Sort is stable.
* @param pEntityComparator
*/
public void sortChildren(final Comparator<IEntity> 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 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 IEntityCallable pEntityCallable);
public void callOnChildren(final IEntityMatcher pEntityMatcher, final IEntityCallable pEntityCallable);
public void registerUpdateHandler(final IUpdateHandler pUpdateHandler);
public boolean unregisterUpdateHandler(final IUpdateHandler pUpdateHandler);
public boolean unregisterUpdateHandlers(final IUpdateHandlerMatcher pUpdateHandlerMatcher);
public void clearUpdateHandlers();
public void registerEntityModifier(final IEntityModifier pEntityModifier);
public boolean unregisterEntityModifier(final IEntityModifier pEntityModifier);
public boolean unregisterEntityModifiers(final IEntityModifierMatcher pEntityModifierMatcher);
public void clearEntityModifiers();
public void setUserData(Object pUserData);
public Object getUserData();
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
public interface IEntityMatcher extends IMatcher<IEntity> {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Methods
// ===========================================================
@Override
public boolean matches(final IEntity pEntity);
}
public interface IEntityCallable extends ParameterCallable<IEntity> {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Methods
// ===========================================================
@Override
public void call(final IEntity pEntity);
}
}