1 | package main;
|
---|
2 |
|
---|
3 | import java.awt.Graphics;
|
---|
4 | import java.util.Iterator;
|
---|
5 | import java.util.LinkedList;
|
---|
6 | import gamegui.Animation;
|
---|
7 |
|
---|
8 | public class Entity {
|
---|
9 | String name;
|
---|
10 | Animation img;
|
---|
11 | Location loc;
|
---|
12 | long timeLastUpdated;
|
---|
13 | public boolean remove;
|
---|
14 | LinkedList<Action> actions;
|
---|
15 |
|
---|
16 | public Entity(final String name, final Animation img) {
|
---|
17 | this.name = name;
|
---|
18 | this.img = img;
|
---|
19 | this.loc = new Location(0.0, 0.0);
|
---|
20 | this.timeLastUpdated = 0L;
|
---|
21 | this.remove = false;
|
---|
22 | this.actions = new LinkedList<Action>();
|
---|
23 | }
|
---|
24 |
|
---|
25 | public Entity(final Entity copy) {
|
---|
26 | this.name = new String(copy.name);
|
---|
27 | this.img = new Animation(copy.img);
|
---|
28 | this.loc = new Location(copy.loc);
|
---|
29 | this.timeLastUpdated = 0L;
|
---|
30 | this.remove = false;
|
---|
31 | this.actions = new LinkedList<Action>();
|
---|
32 | final Iterator<Action> iter = copy.actions.iterator();
|
---|
33 | while (iter.hasNext()) {
|
---|
34 | this.actions.add(iter.next().copy());
|
---|
35 | }
|
---|
36 | }
|
---|
37 |
|
---|
38 | public void setLocation(final Location loc) {
|
---|
39 | this.loc.setLocation(loc);
|
---|
40 | }
|
---|
41 |
|
---|
42 | public void draw(final Graphics g) {
|
---|
43 | this.img.draw(g, this.loc.getX(), this.loc.getY() + this.img.getHeight() / 2);
|
---|
44 | }
|
---|
45 |
|
---|
46 | public void update(final LinkedList<Entity> lstObjects, final LinkedList<Unit> lstTargets) {
|
---|
47 | for (final Action cur : this.actions) {
|
---|
48 | if (cur.readyToPerform()) {
|
---|
49 | this.perform(cur, lstObjects, lstTargets);
|
---|
50 | }
|
---|
51 | }
|
---|
52 | }
|
---|
53 |
|
---|
54 | public void perform(final Action action, final LinkedList<Entity> lstObjects, final LinkedList<Unit> lstTargets) {
|
---|
55 | }
|
---|
56 | }
|
---|