mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-21 20:18:14 +07:00
Added support for invisible entities
Added support for invisible entities, e.g., placeholders for actual entities Added some logging for unknown DS1 objects (when no backing id can be found)
This commit is contained in:
parent
d818d97900
commit
77c851a5ce
@ -3,12 +3,14 @@ package com.riiablo.entity;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.assets.AssetDescriptor;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectIntMap;
|
||||
import com.badlogic.gdx.utils.Pools;
|
||||
import com.riiablo.Riiablo;
|
||||
import com.riiablo.codec.Animation;
|
||||
import com.riiablo.codec.COF;
|
||||
@ -24,6 +26,8 @@ import com.riiablo.map.MapRenderer;
|
||||
import com.riiablo.screen.GameScreen;
|
||||
import com.riiablo.widget.Label;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@ -447,10 +451,19 @@ public abstract class Entity {
|
||||
shapes.end();
|
||||
batch.begin();
|
||||
batch.setShader(null);
|
||||
Riiablo.fonts.consolas12.draw(batch, String.format("%s%n%s %s %s%n%02d/%02d %d",
|
||||
classname, token, type.MODE[mode], WCLASS[wclass],
|
||||
animation.getFrame(), (animation.getNumFramesPerDir() - 1), animation.getFrameDelta()),
|
||||
x, y - Tile.SUBTILE_HEIGHT50, 0, Align.center, false);
|
||||
StringBuilder builder = new StringBuilder(64)
|
||||
.append(classname).append('\n')
|
||||
.append(token).append(' ').append(type.MODE[mode]).append(' ').append(WCLASS[wclass]).append('\n');
|
||||
if (animation != null) {
|
||||
builder
|
||||
.append(StringUtils.leftPad(Integer.toString(animation.getFrame()), 2))
|
||||
.append('/')
|
||||
.append(StringUtils.leftPad(Integer.toString(animation.getNumFramesPerDir() - 1), 2))
|
||||
.append(' ')
|
||||
.append(animation.getFrameDelta());
|
||||
}
|
||||
GlyphLayout layout = Riiablo.fonts.consolas12.draw(batch, builder.toString(), x, y - Tile.SUBTILE_HEIGHT50, 0, Align.center, false);
|
||||
Pools.free(layout);
|
||||
batch.end();
|
||||
batch.setShader(Diablo.shader);
|
||||
shapes.begin(ShapeRenderer.ShapeType.Line);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.riiablo.entity;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
@ -50,7 +51,10 @@ public class Monster extends Entity {
|
||||
assert object.type == DS1.Object.DYNAMIC_TYPE;
|
||||
String id = Riiablo.files.obj.getType1(ds1.getAct(), object.id);
|
||||
MonStats.Entry monstats = Riiablo.files.monstats.get(id);
|
||||
if (monstats == null) return null; // TODO: Which ones fall under this case?
|
||||
if (monstats == null) {
|
||||
Gdx.app.error(TAG, "Unknown dynamic entity id: " + id + "; object=" + object);
|
||||
return null;
|
||||
}
|
||||
|
||||
Monster monster = new Monster(map, zone, object, monstats);
|
||||
if (monstats.AI.equalsIgnoreCase("Idle")) {
|
||||
|
@ -37,8 +37,11 @@ public class Object extends Entity {
|
||||
assert object.type == DS1.Object.STATIC_TYPE;
|
||||
int id = Riiablo.files.obj.getType2(ds1.getAct(), object.id);
|
||||
Objects.Entry base = Riiablo.files.objects.get(id);
|
||||
if (base == null) return null; // TODO: Which ones fall under this case?
|
||||
if (!base.Draw) return null; // TODO: Not yet
|
||||
if (base == null) {
|
||||
Gdx.app.error(TAG, "Unknown static entity id: " + id + "; object=" + object);
|
||||
return null;
|
||||
}
|
||||
//if (!base.Draw) return null;
|
||||
return new Object(map, zone, object, base);
|
||||
}
|
||||
|
||||
@ -83,7 +86,7 @@ public class Object extends Entity {
|
||||
|
||||
@Override
|
||||
public void drawShadow(PaletteIndexedBatch batch) {
|
||||
if (base.BlocksLight[mode]) super.drawShadow(batch);
|
||||
if (base.Draw && base.BlocksLight[mode]) super.drawShadow(batch);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user