void fetchCollidableRects2(int X, int Y) { int cWidth = Terrain.CurrentTerrain.chunkWidth; int cHeight = Terrain.CurrentTerrain.chunkHeight; int X2 = (int) (X % cWidth); int Y2 = (int) (Y % cHeight); if (LastX != (X / cWidth) || LastY != (Y / cHeight)) tiles = Terrain.CurrentTerrain.GetCollisionData(X / cWidth, Y / cHeight); // Gdx.app.debug(""+LastX + " " +LastY, ""+(bobX/cWidth)+" "+(bobY/cHeight)); // long nano = TimeUtils.nanoTime(); if (X2 + (Y2 * cWidth) < cWidth * cHeight) { if (tiles[X2 + (Y2 * cWidth)] > 0) r[0].set(X, Y, 1, 1); else r[0].set(-1, -1, 1, 1); } else { if (Terrain.CurrentTerrain.GetTile(X, Y) > 0) {} } if ((X2 + 1) < cWidth && (Y2) < cHeight && X2 > 0 && Y2 > 0) if (tiles[(X2 + 1) + (Y2 * cWidth)] > 0) r[1].set(X + 1, Y, 1, 1); else r[1].set(-1, -1, 1, 1); else if (Terrain.CurrentTerrain.GetTile(X + 1, Y) > 0) r[1].set(X + 1, Y, 1, 1); if ((X2 + 1) < cWidth && (Y2 + 1) < cHeight && X2 > 0 && Y2 > 0) if (tiles[(X2 + 1) + ((Y2 + 1) * cWidth)] > 0) r[2].set(X + 1, Y + 1, 1, 1); else r[2].set(-1, -1, 1, 1); else if (Terrain.CurrentTerrain.GetTile(X + 1, Y + 1) > 0) r[2].set(X + 1, Y + 1, 1, 1); if ((X2) < cWidth && (Y2 + 1) < cHeight && X2 > 0 && Y2 > 0) if (tiles[X2 + ((Y2 + 1) * cWidth)] > 0) r[3].set(X, Y + 1, 1, 1); else r[3].set(-1, -1, 1, 1); else if (Terrain.CurrentTerrain.GetTile(X, Y + 1) > 0) r[3].set(X, Y + 1, 1, 1); // Gdx.app.debug("TOOKNANO", ""+X+ " " +Y); boolean changed; LastX = X / cWidth; LastY = Y / cHeight; }
@Override public void OnUse(Bob bob, float x, float y, float dist) { // TODO Auto-generated method stub super.OnUse(bob, x, y, dist); if (flag) { int X = (int) x / Terrain.CurrentTerrain.chunkWidth; int Y = (int) y / Terrain.CurrentTerrain.chunkHeight; int x2 = (int) x % Terrain.CurrentTerrain.chunkWidth; int y2 = (int) x % Terrain.CurrentTerrain.chunkWidth; if (parentinv.owner.firstUse()) { if (Terrain.CurrentTerrain.CreateBlock(parentinv.owner, (int) x, (int) y, InvObjID)) Bob.CurrentBob.inventory.AddToBag(name, -1, true); } // Terrain.CurrentTerrain.light.floodStack.add(new Vector3(x,y,0)); flag = false; } }