diff --git a/core/src/com/riiablo/engine/Engine.java b/core/src/com/riiablo/engine/Engine.java index b00e91e3..24065b07 100644 --- a/core/src/com/riiablo/engine/Engine.java +++ b/core/src/com/riiablo/engine/Engine.java @@ -4,6 +4,7 @@ import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.PooledEngine; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.MathUtils; +import com.badlogic.gdx.utils.IntIntMap; import com.riiablo.Riiablo; import com.riiablo.codec.COF; import com.riiablo.codec.excel.Levels; @@ -255,6 +256,23 @@ public class Engine extends PooledEngine { warpComponent.index = index; warpComponent.dstLevel = dstLevel; warpComponent.warp = warp; + IntIntMap substs = warpComponent.substs; + if (warp.LitVersion) { + // FIXME: Below will cover overwhelming majority of cases -- need to solve act 5 ice cave case where 3 tiles are used + // I think this can be done by checking if there's a texture with the same id, else it's a floor warp + if (subIndex < 2) { + for (int i = 0; i < 2; i++) { + substs.put(DT1.Tile.Index.create(orientation, mainIndex, i), DT1.Tile.Index.create(orientation, mainIndex, i + warp.Tiles)); + } + } else { + substs.put(DT1.Tile.Index.create(0, subIndex, 0), DT1.Tile.Index.create(0, subIndex, 4)); + substs.put(DT1.Tile.Index.create(0, subIndex, 1), DT1.Tile.Index.create(0, subIndex, 5)); + substs.put(DT1.Tile.Index.create(0, subIndex, 2), DT1.Tile.Index.create(0, subIndex, 6)); + substs.put(DT1.Tile.Index.create(0, subIndex, 3), DT1.Tile.Index.create(0, subIndex, 7)); + } + } else { + //substs = EMPTY_INT_INT_MAP; + } BBoxComponent boxComponent = createComponent(BBoxComponent.class); boxComponent.box = box; diff --git a/core/src/com/riiablo/engine/component/WarpComponent.java b/core/src/com/riiablo/engine/component/WarpComponent.java index a6d6915b..77d8e895 100644 --- a/core/src/com/riiablo/engine/component/WarpComponent.java +++ b/core/src/com/riiablo/engine/component/WarpComponent.java @@ -1,6 +1,7 @@ package com.riiablo.engine.component; import com.badlogic.ashley.core.Component; +import com.badlogic.gdx.utils.IntIntMap; import com.badlogic.gdx.utils.Pool; import com.riiablo.codec.excel.Levels; import com.riiablo.codec.excel.LvlWarp; @@ -10,10 +11,13 @@ public class WarpComponent implements Component, Pool.Poolable { public LvlWarp.Entry warp; public Levels.Entry dstLevel; + public final IntIntMap substs = new IntIntMap(); + @Override public void reset() { index = -1; warp = null; dstLevel = null; + substs.clear(); } } diff --git a/core/src/com/riiablo/engine/system/WarpSystem.java b/core/src/com/riiablo/engine/system/WarpSystem.java new file mode 100644 index 00000000..b4a4cc88 --- /dev/null +++ b/core/src/com/riiablo/engine/system/WarpSystem.java @@ -0,0 +1,44 @@ +package com.riiablo.engine.system; + +import com.badlogic.ashley.core.ComponentMapper; +import com.badlogic.ashley.core.Entity; +import com.badlogic.ashley.core.Family; +import com.badlogic.ashley.systems.IteratingSystem; +import com.riiablo.engine.Flags; +import com.riiablo.engine.component.MapComponent; +import com.riiablo.engine.component.WarpComponent; +import com.riiablo.map.Map; + +public class WarpSystem extends IteratingSystem { + private final ComponentMapper warpComponent = ComponentMapper.getFor(WarpComponent.class); + + private Map map; + + public WarpSystem() { + super(Family.all(WarpComponent.class, MapComponent.class).get()); + } + + public Map getMap() { + return map; + } + + public void setMap(Map map) { + if (this.map != map) { + this.map = map; + } + } + + @Override + public void update(float delta) { + map.clearWarpSubsts(); + super.update(delta); + } + + @Override + protected void processEntity(Entity entity, float delta) { + WarpComponent warpComponent = this.warpComponent.get(entity); + if ((entity.flags & Flags.SELECTED) == Flags.SELECTED) { + map.addWarpSubsts(warpComponent.substs); + } + } +} diff --git a/core/src/com/riiablo/map/Map.java b/core/src/com/riiablo/map/Map.java index a1c2c24b..44c17e1d 100644 --- a/core/src/com/riiablo/map/Map.java +++ b/core/src/com/riiablo/map/Map.java @@ -667,6 +667,10 @@ public class Map implements Disposable { } } + public void clearWarpSubsts() { + this.warpSubsts.clear(); + } + private MapGraph mapGraph = new MapGraph(this); private IndexedAStarPathFinder pathFinder = new IndexedAStarPathFinder<>(mapGraph, true);