source: last-defense/main/Entity.java

Last change on this file was fb4fc67, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 6 years ago

Initial commit, code decompiled from a jar

  • Property mode set to 100644
File size: 1.6 KB
Line 
1package main;
2
3import java.awt.Graphics;
4import java.util.Iterator;
5import java.util.LinkedList;
6import gamegui.Animation;
7
8public 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}
Note: See TracBrowser for help on using the repository browser.