blob: 393a0a54b3d6c0ded54bc33cd5f88bfc46b93dca (
plain)
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
|
package ch.asynk.tankontank.engine;
import java.util.ArrayList;
import com.badlogic.gdx.utils.Pool;
import com.badlogic.gdx.utils.Disposable;
public class Path implements Disposable, Pool.Poolable
{
public int cost;
public boolean roadMarch;
public ArrayList<Tile> tiles;
public Path()
{
this.cost = -1;
this.roadMarch = true;
this.tiles = null;
}
protected void init(int size)
{
if (tiles == null)
tiles = new ArrayList<Tile>(size);
else
tiles. ensureCapacity(size);
}
@Override
public void reset()
{
cost = -1;
roadMarch = true;
tiles.clear();
}
@Override
public void dispose()
{
tiles.clear();
pathPool.free(this);
}
private static final Pool<Path> pathPool = new Pool<Path>() {
@Override
protected Path newObject() {
return new Path();
}
};
public static Path get(int size)
{
Path p = pathPool.obtain();
p.init(size);
return p;
}
}
|