v0.7.5: added support for more dynamic custom tilemaps

This commit is contained in:
Evan Debenham 2019-09-22 23:43:03 -04:00
parent 59186a3840
commit 96dd6eff82
3 changed files with 26 additions and 3 deletions

View File

@ -245,17 +245,24 @@ public class Tilemap extends Visual {
if (length <= 0)
return;*/
NoosaScript script = NoosaScriptNoLighting.get();
NoosaScript script = script();
texture.bind();
script.uModel.valueM4( matrix );
script.lighting(
rm, gm, bm, am,
ra, ga, ba, aa );
script.camera( camera );
script.drawQuadSet( buffer, size, 0 );
}
protected NoosaScript script(){
return NoosaScriptNoLighting.get();
}
@Override
public void destroy() {

View File

@ -753,6 +753,15 @@ public class GameScene extends PixelScene {
if (scene != null) scene.healthIndicators.add(indicator);
}
public static void add( CustomTilemap t, boolean wall ){
if (scene == null) return;
if (wall){
scene.addCustomWall(t);
} else {
scene.addCustomTile(t);
}
}
public static void effect( Visual effect ) {
scene.effects.add( effect );
}

View File

@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.tiles;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.watabou.noosa.Image;
import com.watabou.noosa.NoosaScript;
import com.watabou.noosa.TextureFilm;
import com.watabou.noosa.Tilemap;
import com.watabou.utils.Bundlable;
@ -36,7 +37,7 @@ public abstract class CustomTilemap implements Bundlable {
public int tileW = 1, tileH = 1; //width and height in tiles
protected Object texture;
private Tilemap vis = null;
protected Tilemap vis = null;
public void pos(int pos) {
pos( pos%Dungeon.level.width(), pos/Dungeon.level.width() );
@ -82,7 +83,13 @@ public abstract class CustomTilemap implements Bundlable {
public Tilemap create(){
if (vis != null && vis.alive) vis.killAndErase();
vis = new Tilemap(texture, new TextureFilm( texture, SIZE, SIZE ));
vis = new Tilemap(texture, new TextureFilm( texture, SIZE, SIZE )){
@Override
protected NoosaScript script() {
//allow lighting for custom tilemaps
return NoosaScript.get();
}
};
vis.x = tileX*SIZE;
vis.y = tileY*SIZE;
return vis;