예제 #1
0
void
Sector::write(lisp::Writer& writer)
{
  writer.write_string("name", name);
  writer.write_float("gravity", gravity);
  writer.write_string("music", music);

  // write spawnpoints
  for(SpawnPoints::iterator i = spawnpoints.begin(); i != spawnpoints.end();
      ++i) {
    SpawnPoint* spawn = *i;
    writer.start_list("spawn-points");
    writer.write_string("name", spawn->name);
    writer.write_float("x", spawn->pos.x);
    writer.write_float("y", spawn->pos.y);
    writer.end_list("spawn-points");
  }

  // write objects
  for(GameObjects::iterator i = gameobjects.begin();
      i != gameobjects.end(); ++i) {
    Serializable* serializable = dynamic_cast<Serializable*> (*i);
    if(serializable)
      serializable->write(writer);
  }
}
예제 #2
0
void
DartTrap::write(lisp::Writer& writer)
{
  writer.start_list("darttrap");
  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);
  writer.write_float("initial-delay", initial_delay);
  writer.write_float("fire-delay", fire_delay);
  writer.write_int("ammo", ammo);
  writer.end_list("darttrap");
}
예제 #3
0
void
Dispenser::write(lisp::Writer& writer)
{
  writer.start_list("dispenser");

  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);
  writer.write_float("cycle", cycle);
  writer.write_string("badguy", badguy);

  writer.end_list("dispenser");
}
예제 #4
0
void
Flame::write(lisp::Writer& writer)
{
  writer.start_list("flame");

  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);
  writer.write_float("radius", radius);
  writer.write_float("speed", speed);

  writer.end_list("flame");
}
예제 #5
0
void save_squirrel_table(HSQUIRRELVM vm, int table_idx, lisp::Writer& writer)
{
  // offset because of sq_pushnull
  if(table_idx < 0)
    table_idx -= 1;
  
  //iterator table
  sq_pushnull(vm);
  while(SQ_SUCCEEDED(sq_next(vm, table_idx))) {
    if(sq_gettype(vm, -2) != OT_STRING) {
      std::cerr << "Table contains non-string key\n";
      continue;
    }
    const char* key;
    sq_getstring(vm, -2, &key);

    switch(sq_gettype(vm, -1)) {
      case OT_INTEGER: {
        int val;
        sq_getinteger(vm, -1, &val);
        writer.write_int(key, val);
        break;
      }
      case OT_FLOAT: {
        float val;
        sq_getfloat(vm, -1, &val);
        writer.write_float(key, val);
        break;
      }
      case OT_BOOL: {
        SQBool val;
        sq_getbool(vm, -1, &val);
        writer.write_bool(key, val);
        break;
      }
      case OT_STRING: {
        const char* str;
        sq_getstring(vm, -1, &str);
        writer.write_string(key, str);
        break;
      }
      case OT_TABLE: {
        writer.start_list(key, true);
        save_squirrel_table(vm, -1, writer);
        writer.end_list(key);
        break;
      }
      case OT_CLOSURE:
        break; // ignore
      case OT_NATIVECLOSURE:
        break;
      default:
        std::cerr << "Can't serialize key '" << key << "' in table.\n";
        break;
    }
    sq_pop(vm, 2);
  }
  sq_pop(vm, 1);
}
예제 #6
0
void
Dart::write(lisp::Writer& writer)
{
  writer.start_list("dart");
  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);
  writer.end_list("dart");
}
예제 #7
0
void
MoleRock::write(lisp::Writer& writer)
{
  writer.start_list("mole_rock");
  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);
  writer.end_list("mole_rock");
}
예제 #8
0
void
Background::write(lisp::Writer& writer)
{
  writer.start_list("background");

  if (image_top.get() != NULL)
    writer.write_string("image-top", imagefile_top);
    
  writer.write_string("image", imagefile);
  if (image_bottom.get() != NULL)
    writer.write_string("image-bottom", imagefile_bottom);

  writer.write_float("speed", speed);
  writer.write_float("speed-y", speed_y);
  writer.write_int("layer", layer);
  
  writer.end_list("background");
}
예제 #9
0
void
Zeekling::write(lisp::Writer& writer)
{
    writer.start_list("zeekling");

    writer.write_float("x", start_position.x);
    writer.write_float("y", start_position.y);

    writer.end_list("zeekling");
}
예제 #10
0
void
SpiderMite::write(lisp::Writer& writer)
{
  writer.start_list("spidermite");

  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);

  writer.end_list("spidermite");
}
예제 #11
0
void
SnowSnail::write(lisp::Writer& writer)
{
  writer.start_list("mriceblock");

  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);

  writer.end_list("snowsnail");
}
예제 #12
0
void
Yeti::write(lisp::Writer& writer)
{
  writer.start_list("yeti");

  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);

  writer.end_list("yeti");
}
예제 #13
0
void
MrBomb::write(lisp::Writer& writer)
{
  writer.start_list("mrbomb");

  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);

  writer.end_list("mrbomb");
}
예제 #14
0
void
MrRocket::write(lisp::Writer& writer)
{
    writer.start_list("mrrocket");

    writer.write_float("x", start_position.x);
    writer.write_float("y", start_position.y);

    writer.end_list("mrrocket");
}
예제 #15
0
void
Totem::write(lisp::Writer& writer)
{
  writer.start_list("totem");

  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);

  writer.end_list("totem");
}
예제 #16
0
void
Jumpy::write(lisp::Writer& writer)
{
  writer.start_list("jumpy");

  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);

  writer.end_list("jumpy");
}
예제 #17
0
void
Fish::write(lisp::Writer& writer)
{
  writer.start_list("fish");

  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);

  writer.end_list("fish");
}
void
BouncingSnowball::write(lisp::Writer& writer)
{
  writer.start_list("bouncingsnowball");

  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);

  writer.end_list("bouncingsnowball");
}
예제 #19
0
void
Statistics::write(lisp::Writer& writer)
{
  writer.write_int("coins-collected", coins);
  writer.write_int("coins-collected-total", total_coins);
  writer.write_int("badguys-killed", badguys);
  writer.write_int("badguys-killed-total", total_badguys);
  writer.write_float("time-needed", time);
  writer.write_int("secrets-found", secrets);
  writer.write_int("secrets-found-total", total_secrets);
}
예제 #20
0
void
WillOWisp::write(lisp::Writer& writer)
{
  writer.start_list("willowisp");

  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);
  writer.write_string("sector", target_sector);
  writer.write_string("spawnpoint", target_spawnpoint);

  writer.end_list("willowisp");
}
예제 #21
0
void
SnowBall::write(lisp::Writer& writer)
{
  writer.start_list("snowball");

  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);

  if (fluffy) {  // don't give us away at every snowball
    writer.write_bool("fluffy", true);
  }

  writer.end_list("snowball");
}
void
WalkingBadguy::write(lisp::Writer& writer)
{
  writer.write_float("x", start_position.x);
  writer.write_float("y", start_position.y);
}