public synchronized void linbeg(int id, int frame, Coord s, Coord t, int c) {
   Gob g = getgob(id, frame);
   if (g == null) return;
   LinMove lm = new LinMove(g, s, t, c);
   g.setattr(lm);
   if (isplayerid(id)) ismoving = true;
 }
Esempio n. 2
0
 private void makeflavor() {
   @SuppressWarnings("unchecked")
   Collection<Gob>[] fo = (Collection<Gob>[]) new Collection[cutn.x * cutn.y];
   for (int i = 0; i < fo.length; i++) fo[i] = new LinkedList<Gob>();
   Coord c = new Coord(0, 0);
   Coord tc = gc.mul(cmaps);
   int i = 0;
   Random rnd = new Random(id);
   for (c.y = 0; c.y < cmaps.x; c.y++) {
     for (c.x = 0; c.x < cmaps.y; c.x++, i++) {
       Tileset set = tileset(tiles[i]);
       if (set.flavobjs.size() > 0) {
         if (rnd.nextInt(set.flavprob) == 0) {
           Resource r = set.flavobjs.pick(rnd);
           double a = rnd.nextDouble() * 2 * Math.PI;
           Gob g = new Flavobj(c.add(tc).mul(tilesz).add(tilesz.div(2)), a);
           g.setattr(new ResDrawable(g, r));
           Coord cc = c.div(cutsz);
           fo[cc.x + (cc.y * cutn.x)].add(g);
         }
       }
     }
   }
   this.fo = fo;
 }
 public synchronized void cres(int id, int frame, Indir<Resource> res, Message sdt) {
   Gob g = getgob(id, frame);
   if (g == null) return;
   ResDrawable d = (ResDrawable) g.getattr(Drawable.class);
   if ((d == null) || (d.res != res) || (d.sdt.blob.length > 0) || (sdt.blob.length > 0)) {
     g.setattr(new ResDrawable(g, res, sdt));
   }
 }
 public synchronized void avatar(int id, int frame, List<Indir<Resource>> layers) {
   Gob g = getgob(id, frame);
   if (g == null) return;
   Avatar ava = g.getattr(Avatar.class);
   if (ava == null) {
     ava = new Avatar(g);
     g.setattr(ava);
   }
   ava.setlayers(layers);
 }
 public synchronized void layers(
     int id, int frame, Indir<Resource> base, List<Indir<Resource>> layers) {
   Gob g = getgob(id, frame);
   if (g == null) return;
   Layered lay = (Layered) g.getattr(Drawable.class);
   if ((lay == null) || (lay.base != base)) {
     lay = new Layered(g, base);
     g.setattr(lay);
   }
   lay.setlayers(layers);
 }
 public synchronized void buddy(int id, int frame, String name, int group, int type) {
   Gob g = getgob(id, frame);
   if (g == null) return;
   if ((name.length() == 0) && (group == 0) && (type == 0)) {
     g.delattr(KinInfo.class);
   } else {
     KinInfo b = g.getattr(KinInfo.class);
     if (b == null) {
       g.setattr(new KinInfo(g, name, group, type));
     } else {
       b.update(name, group, type);
     }
   }
 }
 public synchronized void drawoff(int id, int frame, Coord off) {
   Gob g = getgob(id, frame);
   if (g == null) return;
   if ((off.x == 0) && (off.y == 0)) {
     g.delattr(DrawOffset.class);
   } else {
     DrawOffset dro = g.getattr(DrawOffset.class);
     if (dro == null) {
       dro = new DrawOffset(g, off);
       g.setattr(dro);
     } else {
       dro.off = off;
     }
   }
 }
 public synchronized void speak(int id, int frame, Coord off, String text) {
   Gob g = getgob(id, frame);
   if (g == null) return;
   if (text.length() < 1) {
     g.delattr(Speaking.class);
   } else {
     Speaking m = g.getattr(Speaking.class);
     if (m == null) {
       g.setattr(new Speaking(g, off, text));
     } else {
       m.off = off;
       m.update(text);
     }
   }
 }
 public synchronized void follow(int id, int frame, int oid, Coord off, int szo) {
   Gob g = getgob(id, frame);
   if (g == null) return;
   if (oid == -1) {
     g.delattr(Following.class);
   } else {
     Following flw = g.getattr(Following.class);
     if (flw == null) {
       flw = new Following(g, oid, off, szo);
       g.setattr(flw);
     } else {
       flw.tgt = oid;
       flw.doff = off;
       flw.szo = szo;
     }
   }
 }
 public synchronized void health(int id, int frame, int hp) {
   Gob g = getgob(id, frame);
   if (g == null) return;
   g.setattr(new GobHealth(g, hp));
 }
 public synchronized void homing(int id, int frame, int oid, Coord tc, int v) {
   Gob g = getgob(id, frame);
   if (g == null) return;
   g.setattr(new Homing(g, oid, tc, v));
 }
 public synchronized void lumin(int id, int frame, Coord off, int sz, int str) {
   Gob g = getgob(id, frame);
   if (g == null) return;
   g.setattr(new Lumin(g, off, sz, str));
 }