Example #1
0
    public void draw(PGraphics buf) {

      if (pos == null) {
        log.warn("Actor {} has no position", name);
        return;
      }
      buf.pushMatrix();
      buf.stroke(Utils.color("ffffff"), opacity);
      buf.strokeWeight(1);
      buf.fill(color, opacity);
      buf.translate(pos.x, pos.y, pos.z);
      buf.box(jobSize);
      buf.popMatrix();
    }
Example #2
0
 public void jobEnded() {
   defunct = true;
   color = Utils.color("000000");
   // opacity = 0; // just in case
 }
Example #3
0
  public class JobActor extends Actor {

    protected String name;
    protected String username;
    protected int color = Utils.color("ff0000");
    protected float opacity = 150;
    protected Set<Motion> tweens = new HashSet<Motion>();
    protected boolean queued = false;
    protected boolean defunct = false;

    JobActor(PVector pos, String username) {
      super(pos);
      this.username = username;
    }

    public void update() {
      if (isInMotion()) {
        Set<Motion> toRemove = new HashSet<Motion>();
        for (Motion m : tweens) {
          if (!m.isPlaying()) {
            if (m.getPosition() == 0) {
              m.play();
            } else {
              toRemove.add(m);
            }
          } else {
            m.update();
          }
        }
        for (Motion m : toRemove) {
          tweens.remove(m);
        }
      }
    }

    public boolean isInMotion() {
      return !tweens.isEmpty();
    }

    public void draw(PGraphics buf) {

      if (pos == null) {
        log.warn("Actor {} has no position", name);
        return;
      }
      buf.pushMatrix();
      buf.stroke(Utils.color("ffffff"), opacity);
      buf.strokeWeight(1);
      buf.fill(color, opacity);
      buf.translate(pos.x, pos.y, pos.z);
      buf.box(jobSize);
      buf.popMatrix();
    }

    public JobActor copy() {
      JobActor copy = new JobActor(pos, username);
      copy.name = name;
      copy.color = this.color;
      return copy;
    }

    public String getName() {
      return name;
    }

    public void setName(String name) {
      this.name = name;
    }

    public String getUsername() {
      return username;
    }

    public float getOpacity() {
      return opacity;
    }

    public void setOpacity(float opacity) {
      this.opacity = opacity;
    }

    public Set<Motion> getTweens() {
      return tweens;
    }

    public boolean isDefunct() {
      return defunct;
    }

    public void jobStarted() {}

    public void jobEnded() {
      defunct = true;
      color = Utils.color("000000");
      // opacity = 0; // just in case
    }
  }