Beispiel #1
0
 public SpriteLink(Resource res, Message buf) {
   res.super();
   int ver = buf.uint8();
   if (ver != 1)
     throw (new Resource.LoadException("Unknown spritelink version: " + ver, getres()));
   Map<Integer, Factory> refs = new IntMap<Factory>(16);
   while (true) {
     int id = buf.int16();
     if (id < 0) break;
     char t = (char) buf.uint8();
     Factory f;
     switch (t) {
       case 't':
         f = new ByTile(res, buf, refs);
         break;
       case 'r':
         f = new ByRes(res, buf, refs);
         break;
       default:
         throw (new Resource.LoadException("Unknown spritelink type: `" + t + "'", getres()));
     }
     refs.put(id, f);
   }
   this.f = refs.get(buf.int16());
 }
Beispiel #2
0
 public void tilemap(Message msg) {
   while (!msg.eom()) {
     int id = msg.uint8();
     String resnm = msg.string();
     int resver = msg.uint16();
     nsets[id] = new Resource.Spec(resnm, resver);
   }
 }
Beispiel #3
0
 private ByTile(Resource res, Message buf, Map<Integer, Factory> refs) {
   tag = new String[buf.uint8()];
   sub = new Factory[tag.length];
   for (int i = 0; i < tag.length; i++) {
     tag[i] = buf.string();
     sub[i] = refs.get(buf.int16());
   }
   def = refs.get(buf.int16());
 }
 public static int decnum(Message sdt) {
   if (sdt == null) return (0);
   int ret = 0, off = 0;
   while (!sdt.eom()) {
     ret |= sdt.uint8() << off;
     off += 8;
   }
   return (ret);
 }
Beispiel #5
0
 public void invalblob(Message msg) {
   int type = msg.uint8();
   if (type == 0) {
     invalidate(msg.coord());
   } else if (type == 1) {
     Coord ul = msg.coord();
     Coord lr = msg.coord();
     trim(ul, lr);
   } else if (type == 2) {
     trimall();
   }
 }
 /*    */ public Sprite create(Sprite.Owner owner, Resource res, Message sdt) {
   /* 61 */ int m = sdt.uint8();
   /* 62 */ GrowingPlant spr = new GrowingPlant(owner, res);
   /* 63 */ spr.addnegative();
   /* 64 */ Random rnd = owner.mkrandoom();
   /* 65 */ for (int i = 0; i < this.num; i++) {
     /* 66 */ Coord c =
         new Coord(rnd.nextInt(this.neg.bs.x), rnd.nextInt(this.neg.bs.y)).add(this.neg.bc);
     /* 67 */ Tex s = this.strands[m][rnd.nextInt(this.strands[m].length)];
     /* 68 */ spr.add(s, 0, MapView.m2s(c), new Coord(s.sz().x / 2, s.sz().y).inv());
     /*    */ }
   /* 70 */ return spr;
   /*    */ }
 public Sprite create(Owner owner, Resource res, Message sdt) {
   int m = sdt.uint8();
   GrowingPlant spr = new GrowingPlant(owner, res);
   spr.addnegative();
   Random rnd = owner.mkrandoom();
   int n = Config.simple_plants ? 1 : num;
   for (int i = 0; i < n; i++) {
     Coord c;
     if (Config.simple_plants) {
       c = neg.bc.add(neg.bs).sub(5, 5);
     } else {
       c = new Coord(rnd.nextInt(neg.bs.x), rnd.nextInt(neg.bs.y)).add(neg.bc);
     }
     Tex s = strands[m][rnd.nextInt(strands[m].length)];
     spr.add(s, 0, MapView.m2s(c), new Coord(s.sz().x / 2, s.sz().y).inv());
   }
   return (spr);
 }
Beispiel #8
0
 public void fill(Message msg) {
   String mmname = msg.string().intern();
   if (mmname.equals("")) mnm = null;
   else mnm = mmname;
   int[] pfl = new int[256];
   while (true) {
     int pidx = msg.uint8();
     if (pidx == 255) break;
     pfl[pidx] = msg.uint8();
   }
   Message blob = msg.inflate();
   id = blob.int64();
   for (int i = 0; i < tiles.length; i++) tiles[i] = blob.uint8();
   for (int i = 0; i < z.length; i++) z[i] = blob.int16();
   for (int i = 0; i < ol.length; i++) ol[i] = 0;
   while (true) {
     int pidx = blob.uint8();
     if (pidx == 255) break;
     int fl = pfl[pidx];
     int type = blob.uint8();
     Coord c1 = new Coord(blob.uint8(), blob.uint8());
     Coord c2 = new Coord(blob.uint8(), blob.uint8());
     int ol;
     if (type == 0) {
       if ((fl & 1) == 1) ol = 2;
       else ol = 1;
     } else if (type == 1) {
       if ((fl & 1) == 1) ol = 8;
       else ol = 4;
     } else {
       throw (new RuntimeException("Unknown plot type " + type));
     }
     for (int y = c1.y; y <= c2.y; y++) {
       for (int x = c1.x; x <= c2.x; x++) {
         this.ol[x + (y * cmaps.x)] |= ol;
       }
     }
   }
   invalidate();
 }