use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.
the class StringsManager method addMappingForClass.
private static void addMappingForClass(Class<?> clazz) {
for (Field f : clazz.getDeclaredFields()) {
if (f.isSynthetic()) {
continue;
}
int key;
try {
key = f.getInt(null);
} catch (IllegalAccessException | IllegalArgumentException e) {
throw new TrackedRuntimeException(e);
}
String name = f.getName();
keyToInt.put(name, key);
}
}
use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.
the class TextureCache method getBitmap.
public static Bitmap getBitmap(Object src) {
if (src instanceof String) {
String resName = (String) src;
InputStream stream = ModdingMode.getInputStream(resName);
if (stream != null) {
return BitmapFactory.decodeStream(stream);
}
throw new TrackedRuntimeException("Failed to load " + resName + "(mod: " + ModdingMode.activeMod() + ")");
} else if (src instanceof Bitmap) {
return (Bitmap) src;
}
throw new TrackedRuntimeException("Bad resource source for Bitmap " + src.getClass().getName());
}
use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.
the class PredesignedLevel method create.
@Override
public void create(int w, int h) {
try {
width = mLevelDesc.getInt("width");
height = mLevelDesc.getInt("height");
initSizeDependentStuff();
JSONArray map = mLevelDesc.getJSONArray("map");
for (int i = 0; i < map.length(); i++) {
set(i, map.getInt(i));
}
readLevelParams();
placeObjects();
setupLinks();
} catch (JSONException e) {
throw new TrackedRuntimeException(e);
}
buildFlagMaps();
cleanWalls();
createMobs();
createItems();
createScript();
}
use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.
the class RandomLevel method create.
@Override
public void create(int w, int h) {
try {
width = mLevelDesc.getInt("width");
height = mLevelDesc.getInt("height");
initSizeDependentStuff();
feeling = DungeonGenerator.getLevelFeeling(levelId);
if (mLevelDesc.has("items")) {
JSONArray itemsDesc = mLevelDesc.getJSONArray("items");
for (int i = 0; i < itemsDesc.length(); ++i) {
JSONObject itemDesc = itemsDesc.optJSONObject(i);
Item item = ItemFactory.createItemFromDesc(itemDesc);
addItemToSpawn(item);
}
}
} catch (JSONException e) {
throw new TrackedRuntimeException(e);
} catch (InstantiationException e) {
throw new TrackedRuntimeException(e);
} catch (IllegalAccessException e) {
throw new TrackedRuntimeException(e);
}
do {
Arrays.fill(map, feeling == Feeling.CHASM ? Terrain.CHASM : Terrain.WALL);
} while (!build());
buildFlagMaps();
cleanWalls();
createMobs();
createItems();
createScript();
}
use of com.nyrds.android.util.TrackedRuntimeException in project pixel-dungeon-remix by NYRDS.
the class RandomLevel method createMob.
@Override
protected Mob createMob() {
try {
if (mLevelDesc.has("mobs")) {
JSONArray mobsDesc = mLevelDesc.getJSONArray("mobs");
if (mobsSpawned < mobsDesc.length()) {
JSONObject mobDesc = mobsDesc.optJSONObject(mobsSpawned);
mobsSpawned++;
String kind = mobDesc.getString("kind");
Mob mob = MobFactory.mobByName(kind);
mob.fromJson(mobDesc);
setMobSpawnPos(mob);
return mob;
}
}
} catch (JSONException e) {
throw new TrackedRuntimeException("invalid mob desc", e);
} catch (Exception e) {
EventCollector.logException(e);
}
return super.createMob();
}
Aggregations