From ba9aa340be51a6f3c4484e7ee99fc4dc50fae40b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Thu, 2 Jun 2022 12:38:42 +0200 Subject: [PATCH] 01/06 --- .vscode/settings.json | 3 +- app/bin/main/PokeMudry.class | Bin 777 -> 659 bytes app/bin/main/Screen/Hero$Direction.class | Bin 0 -> 1195 bytes app/bin/main/Screen/Hero.class | Bin 0 -> 4049 bytes app/bin/main/Screen/ScreenMap.class | Bin 266 -> 9329 bytes app/bin/main/lumberjack_sheet32.png | Bin 0 -> 1236 bytes app/bin/main/map/test_couloir.tmx | 26 +- app/bin/main/testHER.class | Bin 0 -> 1472 bytes app/src/main/java/PokeMudry.java | 2 + app/src/main/java/Screen/Hero.java | 189 +++++++++++++++ app/src/main/java/Screen/ScreenMap.java | 229 +++++++++++++++++- app/src/main/java/testHER.java | 55 +++++ app/src/main/resources/lumberjack_sheet32.png | Bin 0 -> 1236 bytes app/src/main/resources/map/test_couloir.tmx | 26 +- 14 files changed, 502 insertions(+), 28 deletions(-) create mode 100644 app/bin/main/Screen/Hero$Direction.class create mode 100644 app/bin/main/Screen/Hero.class create mode 100644 app/bin/main/lumberjack_sheet32.png create mode 100644 app/bin/main/testHER.class create mode 100644 app/src/main/java/Screen/Hero.java create mode 100644 app/src/main/java/testHER.java create mode 100644 app/src/main/resources/lumberjack_sheet32.png diff --git a/.vscode/settings.json b/.vscode/settings.json index b2d444a..1ad73b8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "cSpell.words": [ - "pokemudry" + "pokemudry", + "Spritesheet" ] } \ No newline at end of file diff --git a/app/bin/main/PokeMudry.class b/app/bin/main/PokeMudry.class index a53aaff82118b77a64476875026de8e38d7b8094..4e0a6c64965b307817c0ea77df6fded59c6fe36c 100644 GIT binary patch delta 135 zcmeBVo6O2}>ff$?3=9nB3`!HZK25e{+{?&3`8#6>Dq29bnn1Q{X6AP*!N85F?k6#>h; B4jKRe delta 203 zcmbQt+R4Us>ff$?3=9nB3~Cd(K3TEkCT8X_GKgtJ`(!1SCFKPeSfO1R> FssQd&BIW=9 diff --git a/app/bin/main/Screen/Hero$Direction.class b/app/bin/main/Screen/Hero$Direction.class new file mode 100644 index 0000000000000000000000000000000000000000..4bbc909a5b2727c53e0ecea6f5bc610cea8bde1d GIT binary patch literal 1195 zcmZ`&T~pIQ6g^AYrY(_=0tE`92ufR!it?eh@-a}PVm^a{QCXv3cwmRRP->67&VV`C%4BvcXr42c+Iz6 zM@5LC@7OxEat+I==Za42grTSMnqgG`FC)(o+BtYzW(dD2z1%w_s26udC|7iyp|@DB z?9W!W^h(iS7<<=MC0eL8Y{&N38I*LUN&?&NdmcqN4u*t=Aq+D_3Z0T7a8E-V5s}Sm=!M46uiFkUw@!|@ zcW50oIC;?Bn$@UUo-MFEj6*?!ocbT_CYd|68ZAyqDxK-pXB-PyRPm5uAmIP3>GKl} zIXq&BS)ON|)!a{K4B23p2S>*=qAADe#57Ii1lj-vCqJ?D*OITr8 z3G%iZR)ALqyyemQJ^&nEFbA!FDyf}%$xq6+w?b=XnYE-cw}>2Yyd!!hA$({T}B$Yj5KXv zASGr^j1cX`E%Xt;pU`K*;#dC;W+n!d3k;rPM1s+f1Y;7U!V*kKa62NwlmvHG38tez zNI_}S$7Y7w7&FXp8xw{ZX=BPT)i$P$bIg3Dt9o#s{!_vf5@cnF@?p$j1j|Tb3xjwd zt3)Mz2pywK)UIe)&CX9=VD3gJLIvoMG?}YNOYs;o$ad(f^h$!BY-7fJrDU(ng7CYq zOk84q;fuUb*!ru+t}Vo9TOM~bvSdiy6;H72C7%2Q>&^>dRcfx`sf^F?Tri2xkjD#} J*19~;{{c*A?|lFO literal 0 HcmV?d00001 diff --git a/app/bin/main/Screen/Hero.class b/app/bin/main/Screen/Hero.class new file mode 100644 index 0000000000000000000000000000000000000000..7016af7eb2b08f9540d1df73af189e294d231a47 GIT binary patch literal 4049 zcmb7HYkL#d5q{T}E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XV|xZ zgW<+i3;3?cU5-obOXyxePt`nHHIH$AbfhuS(A3bhgnt| zt_FgC9hZR*qGiEn;|>^JvvPc5_~dtC10bKB)9!Er!s7 zGgT>RE&JPAPDyJyC8K!E^<3G{67tf{rN&j(Kg6JkNMJ&%iSK@v{s zU2Lr+TkKTjyDY{e`dSCtBTkErvBWff_KY*9DXyn+7!%B1hPY(;E${@NgPiJxJPo(kYTc(*O%A4MMJr64~p0T#bCKIW@@nE03VX>j z^H}fj%{*3y>l`^KHOKYZN(^CQ3Vc9HxI{{rXUlwq-MCCsSIBu+xy2`p=NjX=QRREQ z?0fuH-$OqB(d*~&^OEn65q?QfOFOYVc>}-Tu)Bk|PPxTy;JiD$vWQpzyA-~_7JON? zZA*FE7Q*@#lmVcfb0w{#f`rF0v}T$LHZ0rtn(| zzMH}a6#O@Zc?xwmh07E?t}yZ$-oC~>H}IFn2BNYNThYcb%+ux(j(dnxH^(0IlmD)k zn%3pR6;1#Gf#f%YV9bY4{!LC+ILhrRj@{-)8!oecitE&qpL4UkK0EvXGa)ri`9JV~ BR#5-| literal 0 HcmV?d00001 diff --git a/app/bin/main/Screen/ScreenMap.class b/app/bin/main/Screen/ScreenMap.class index e4d88c611fd51c9b5359cfa8229d94dd63be7b7f..a1bae3042f87f9fbfe92b6847fa97c6f2bbc84ae 100644 GIT binary patch literal 9329 zcmb_i3w%`NmH(f~%-qT3f*~$>f>yLH#@uHARrwaxy|y?0(DpziL^AGzQC z?)lDl&i_2WZ+!QUFTD!jYm^?la)!?1u2Ba3~s%b%&O&+hBF3 z1jQSz!4;`+sy`_>rrrMDpNd37T++<1DO zq!N)>ck>aL6$)bSZz{{>R;tf=7R(Nsq`TsO^9b_aJH=qNyfI zU@CdYL@E3_I>SU6`~jRPFjH1Cb!lh3KN^oD^xIh`jzxvRfWV2PxJ*ub?|Hugf@nmO z3QJ{tH7zZ*9m-?2i4$>>#ziD%E$Q!FXC+pK*F_l%W$p3KaI_B@>+tl1MC+u#)lqM5mS1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Vab+G- z-eE?Nt38u~15|_SXtka!P#$0|6G|2-mzGGyrH@Wd2gY(rq1C*U_*`Bt2_mtWS!C@V z&N&@JkWcWJfD+tpYvoks(yUgc)T)QvD3Yy#hy2;iIs84haJ9+x9~RB#v9!rs)aWZ} z^lM5gm;TsxR@Nn&kTNgo*}f)C;_s(rQ&V6!9;^(wem>Y_NK-D5$^6p8=LQDN zReU~#r|}%0PW@R+(*t)BoVyr!chi~fVXC;7T<&K>wu8JLz*PQfv5@Op@i4hPLQXqz z4IZPTJkUQ(^YfdtL$0Z(lnZkSI7195#sEngKc@%wZZlz4)J?kM9{}1QJMK%Bc delta 121 zcmez9(Z$4d>ff$?3=9nB3<49m^d{FbNw9J9Ft9SPO^#xAo$Mnf6U?Bo;fiy3W$H>43B$*ia0h*@_ Ae*gdg diff --git a/app/bin/main/lumberjack_sheet32.png b/app/bin/main/lumberjack_sheet32.png new file mode 100644 index 0000000000000000000000000000000000000000..84f3de8fbab0152498b444a56b7da5eaa085185d GIT binary patch literal 1236 zcmV;_1S|WAP)C0000WV@Og>004R= z004l4008;_004mL004C`008P>0026e000+nl3&F}00009a7bBm000XT000XT0n*)m z`~Uy|PEbr#MF0Q*000078!!weK@~k^CRT?i76m;c3rPe7P&Wu$Cn01G4rD(YaZe74 zUp2Rx4!(vN$pZt}w;tY~CF8b=>i_`n#dPzlqxH(g`PQ@y0k6aW0004WQchCSOh22NThfZep zT5n#~@w)p3pwY~~9vBa~eHhI=G2l?pXy%ClMVWab;OF7ooWCWO z2#9|ZO{(<--@r2ic7tfTUawzY*J(ZPyqTv4>{f}tYSJIPnI{6tpC{D}-^7yxG@#nS zH}PB`lbvS*+wHOK+GCU+w_7XE1j2E9Y5VpPrN`|tSa~84F5%*Omux-CTV|dZ5X3*h zm!rI8=3fu^vupRKeH*1mclLJvc>sRj?|V@v-+C0^%o77{;`i`H?&i%r6L6i%iIUIp z-;}6RB_0=aDg^Wb$R%wyO*}Ll4+=Lu%DW^4l*a|Ls*zI?$AiL6VBZ^2kL&{rGVYHFDMEk2E4<5Ks&c+nCE#I)<3Vd?15X4*^WBdH*qeDK;OAsR-pq4>Om?0Ngtl|i zytk{4N7vbTDxkL1PO(G*0g?~O69eG8c!7ND3w(kH4n7}H4un1Y5IlT}_aVS94^R~X zr&zwj8j)XkzIFe=dm&ddc;!n2B%{~2zXNXHt8~2l#`BKny>R*w?s*y9xH+K-X-)!IbZh!bw5z|19d-8_XBl5@NWBod+Q#~ zsfl|#PXxRg>fcn8$jVa#Qt6f#)pV6cJ{fr?ApWf7KPeV+GtUf2tvhL+M0TDT@F)#? zJ5L2N*?BI|xqJ7P>e~i8PX*LYD|3H7Dd5`4+cm&Yxivt|Wy=w1R{&Beg9szXw@&J_kD97@T%LVZH z0>KvtG_#9t7bW$N<(nRnQhjvj_N(0Q3+DT3K%{k_hlF}_$toxaHYQQd&H}lkhUH0Y8 zJT<_dvoABx1u{M3>+=Qg_IyFv2haNferZ7de1KHTHcF2!gy%f`oX6kN@__Px&xgb( y_;b$R;1>hr2cZ4@`2xuDd_iBIFR0HKu>2pMXy>%}a3RP50000 - + - + - + @@ -6683,19 +6683,19 @@ - + - + - + @@ -6887,19 +6887,19 @@ - + - + - + @@ -8967,7 +8967,7 @@ - + 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21, 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21, @@ -8981,7 +8981,7 @@ 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21 - + 956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956, 956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956, @@ -8995,7 +8995,7 @@ 921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921 - + @@ -9021,7 +9021,7 @@ - + 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21, 40,40,40,8,9,40,40,40,40,40,40,40,40,40,40,8,9,40,40,40, diff --git a/app/bin/main/testHER.class b/app/bin/main/testHER.class new file mode 100644 index 0000000000000000000000000000000000000000..fb1fa77eabab042002148759733d4e4aafe44aa1 GIT binary patch literal 1472 zcmah|+inwA6kR8FGI%_WiIdQfKm&nNJAq8OgqtZ1IWe4ONe#Ghr|ISERD}TXZBue?RECN|M=hk0M6jLfi3|fmd*Ie z+)V>%fs(swugZ<4UGpBD@N7>u*W$2Y{~kuMvr?Cr8jZT|I?U8lb6M84YV z!*smrHw7|Pt&qs+b;l?5p5ndg182jr>rPO!m*U6|YUR?hfqsGAUkWl&KsEzbS?ETO z$tX)CC#n&={~JJTAPg$(KvnLuuwQ9TtClD|3>G4%vFf`wW#Gw3V60f(X~ zik-N{zVdBhM>m5#tn2 z8<^UGaXAd@(g_sC8C7|=vr@k-XK@Z?1LxU(!v0y7g$wwVW725R+Ox$D&c&4n(v8bs zpLD|OBuZ!JE{9A&ROmxu)@=ANP(EF@Fx~cP*1{a-Y2lMFX)8=3XVmN z?zwBUOAnyA6t*H)&iiUaEj@*ksskKkdWw|-rWz_nJ&ZZs{LgS_a}`{>$2VcVWY7gm zCxK}>##TE4y~uNy!EW^F;u&VE;=Xq%+}XsyYYe`F*u)RpK)nfjj_kcG%y$6xVF-I! zEHJ#KW{NunXuQJU8;oqjm}CO_DSn^>!qA!oe#9sXRYTLvRJpqdG4TcmzQh<}S9=qT zJ?%V=!3rG0;Y0xERiiCazCs%wAKApug!~(&k+(ROdW)0);%o}HxAEJp?x)S8WH`{l zF}%ewjEnd!;ox0sjt@vD9G>F1H1ZeeP~mf0KZS&L=2`yv3*;E*{=v+jIHXSpu)y

frameTime) { + dt -= frameTime; + currentFrame = (currentFrame + 1) % nFrames; + + if(currentFrame == 0){ + move = false; + lastPosition = new Vector2(newPosition); + position = new Vector2(newPosition); + } + } + } + + /** + * @return True if the hero is actually doing a step. + */ + public boolean isMoving(){ + return move; + } + + /** + * @param speed The new speed of the hero. + */ + public void setSpeed(float speed){ + this.speed = speed; + } + + /** + * Do a step on the given direction + * @param direction The direction to go. + */ + public void go(Direction direction){ + move = true; + switch(direction){ + case RIGHT: + newPosition.add(SPRITE_WIDTH, 0); + break; + case LEFT: + newPosition.add(-SPRITE_WIDTH, 0); + break; + case UP: + newPosition.add(0, SPRITE_HEIGHT); + break; + case DOWN: + newPosition.add(0, -SPRITE_HEIGHT); + break; + default: + break; + } + + turn(direction); + } + + /** + * Turn the hero on the given direction without do any step. + * @param direction The direction to turn. + */ + public void turn(Direction direction){ + switch(direction){ + case RIGHT: + textureY = 2; + break; + case LEFT: + textureY = 1; + break; + case UP: + textureY = 3; + break; + case DOWN: + textureY = 0; + break; + default: + break; + } + } + + /** + * Draw the character on the graphic object. + * @param g Graphic object. + */ + public void draw(GdxGraphics g) { + g.draw(ss.sprites[textureY][currentFrame], position.x, position.y); + } +} diff --git a/app/src/main/java/Screen/ScreenMap.java b/app/src/main/java/Screen/ScreenMap.java index 367e361..87d120f 100644 --- a/app/src/main/java/Screen/ScreenMap.java +++ b/app/src/main/java/Screen/ScreenMap.java @@ -1,5 +1,232 @@ package Screen; +import ch.hevs.gdx2d.lib.GdxGraphics; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; +import com.badlogic.gdx.maps.MapObject; +import com.badlogic.gdx.maps.MapObjects; +import com.badlogic.gdx.maps.MapProperties; +import com.badlogic.gdx.maps.tiled.*; +import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; +import com.badlogic.gdx.math.Vector2; +import java.util.Map; +import java.util.TreeMap; +import java.util.Vector; + public class ScreenMap { - + // key management + public Map keyStatus = new TreeMap(); + + // character + private Hero hero; + + // tiles management + private Vector tiledLayer = new Vector<>(); + private MapObjects doors; + Map tMap = new TreeMap(); + Map tMapRenderer = new TreeMap(); + private String map = "test_couloir"; + public float zoom; + private int width; + private int tileWidth; + private int height; + private int tileHeight; + + // position + Vector2 pannel = new Vector2(30, 30); + + private void createMap(String name){ + TiledMap tm =new TmxMapLoader().load("app/src/main/resources/map/"+ name + ".tmx"); + tMap.put(name,tm); + tMapRenderer.put(name,new OrthogonalTiledMapRenderer(tm)); + } + + public void init() { + + // Create hero + hero = new Hero(9, 4); + + // Set initial zoom + zoom = 1; + + // init keys status + keyStatus.put(Input.Keys.UP, false); + keyStatus.put(Input.Keys.DOWN, false); + keyStatus.put(Input.Keys.LEFT, false); + keyStatus.put(Input.Keys.RIGHT, false); + + // create map + createMap("test"); + createMap("test_couloir"); + } + + public void graphicRender(GdxGraphics g) { + g.clear(); + + for (int i = 0; i < 100; i++) { + try { tiledLayer.add((TiledMapTileLayer) tMap.get(map).getLayers().get(i)); } catch (Exception e) { } + } + TiledMapTileLayer tl = tiledLayer.get(0); + width = tl.getWidth(); + tileWidth = (int) tl.getTileWidth(); + height = tl.getHeight(); + tileHeight = (int) tl.getTileHeight(); + System.out.println(width + " x " + height + " - " + tileWidth + " x " + tileHeight); + try { + doors = tMap.get(map).getLayers().get("door").getObjects(); + } catch (Exception e) { } + + // Hero activity + manageHero(); + // System.out.println(hero.getPosition().x + " - " + hero.getPosition().y); + + // Camera follows the hero + g.zoom(zoom); + g.moveCamera(hero.getPosition().x, hero.getPosition().y, width * tileWidth, height * tileHeight); + + // Render the tileMap + tMapRenderer.get(map).setView(g.getCamera()); + tMapRenderer.get(map).render(); + + // Draw the hero + hero.animate(Gdx.graphics.getDeltaTime()); + hero.draw(g); + + g.drawFPS(); + } + + private Vector getTile(Vector2 position, int offsetX, int offsetY) { + Vector tiles = new Vector<>(); + for (TiledMapTileLayer tl : tiledLayer) { + int x = (int) (position.x / width) + offsetX; + int y = (int) (position.y / height) + offsetY; + System.out.println("tl: " + tl); + TiledMapTile cell = tl.getCell(x, y).getTile(); + try { + + System.out.println("cell: "+ cell); + tiles.add(cell); + } catch (Exception e) { System.out.println("shit");} + } + + return tiles; + } + + private boolean isWalkable(Vector tile) { + if (tile == null) return false; + boolean walkable = false; + System.out.println("tile: " + tile); + + for (TiledMapTile tiledMapTile : tile) { + System.out.println("tiledMapTile: " + tiledMapTile); + Object test = tiledMapTile.getProperties().get("walkable"); + walkable = Boolean.parseBoolean(test.toString()) ? true:walkable; + } + + //System.out.println(" walkable: " + walkable); + return walkable; + } + + private float getSpeed(Vector tile) { + float speed = 0; + for (TiledMapTile tiledMapTile : tile) { + Object test = tiledMapTile.getProperties().get("speed"); + float newSpeed = Float.parseFloat(test.toString()); + speed = newSpeed > speed ? newSpeed:speed; + } + return speed; + } + + private String getName(TiledMap tile) { + Object test = tile.getProperties().get("name"); + return test.toString(); + } + + private boolean isDoor(Vector2 position) { + boolean onDoor = false; + Integer x = null; + Integer y = null; + int ox = 0; + int oy = 0; + try { + x = (int) (position.x / 32); //tiledLayer.getTileWidth() + y = (int) (position.y / 32); //tiledLayer.getTileHeight() + } catch (Exception e) { } + + for (MapObject object : doors){ + MapProperties mapProperties = null; + try { mapProperties = object.getProperties(); } catch (Exception e) { } + try { ox = (int) ((float) mapProperties.get("x")); } catch (Exception e) { } + try { oy = (int) ((float) mapProperties.get("y")); } catch (Exception e) { } + + oy-=288; + oy/=-1; + + ox /= 32; + oy /= 32; + + String id = null; + try { id = mapProperties.get("id").toString(); } catch (Exception e) { } + //if(x != null && y != null) System.out.println(id + ": " + x + " x " + y + " - " + ox + " x " + oy); + + if (x != null || y != null) onDoor = (x == ox && y == oy) ? true:onDoor; + } + + return onDoor; + } + + private void manageHero() { + + // Do nothing if hero is already moving + if (!hero.isMoving()) { + + // Compute direction and next cell + Vector nextCell = new Vector<>(); + Hero.Direction goalDirection = Hero.Direction.NULL; + + if (keyStatus.get(Input.Keys.RIGHT)) { + goalDirection = Hero.Direction.RIGHT; + nextCell = getTile(hero.getPosition(), 1, 0); + } else if (keyStatus.get(Input.Keys.LEFT)) { + goalDirection = Hero.Direction.LEFT; + nextCell = getTile(hero.getPosition(), -1, 0); + } else if (keyStatus.get(Input.Keys.UP)) { + goalDirection = Hero.Direction.UP; + nextCell = getTile(hero.getPosition(), 0, 1); + } else if (keyStatus.get(Input.Keys.DOWN)) { + goalDirection = Hero.Direction.DOWN; + nextCell = getTile(hero.getPosition(), 0, -1); + } + + // Is the move valid ? + if (isWalkable(nextCell)) { + // Go + hero.setSpeed(getSpeed(nextCell)); + hero.go(goalDirection); + } else { + // Face the wall + hero.turn(goalDirection); + } + + + if(isDoor(hero.getPosition())){ + /* + switch(getName(tMap.get(map))){ + case "test": + if(hero.getPosition().x == 32 && hero.getPosition().y == 288){ + hero.setPosition(576, 256); + map = "desert"; + } + break; + default: + + break; + } + */ + + System.out.println("it's a door"); + } + } + } + } diff --git a/app/src/main/java/testHER.java b/app/src/main/java/testHER.java new file mode 100644 index 0000000..03b5f7f --- /dev/null +++ b/app/src/main/java/testHER.java @@ -0,0 +1,55 @@ +import com.badlogic.gdx.Input; + +import Screen.ScreenMap; +import ch.hevs.gdx2d.desktop.PortableApplication; +import ch.hevs.gdx2d.lib.GdxGraphics; + +public class testHER extends PortableApplication{ + + private static ScreenMap sm; + + + public static void main(String[] args) { + sm = new ScreenMap(); + new testHER(); + } + + @Override + public void onInit() { + sm.init(); + } + + @Override + public void onGraphicRender(GdxGraphics g) { + sm.graphicRender(g); + } + + @Override + public void onKeyUp(int keycode) { + super.onKeyUp(keycode); + + sm.keyStatus.put(keycode, false); + } + + @Override + public void onKeyDown(int keycode) { + super.onKeyDown(keycode); + + switch (keycode) { + case Input.Keys.Z: + if (sm.zoom == 1.0) { + sm.zoom = 2.0f; + } else if (sm.zoom == 2.0) { + sm.zoom = 4; + } else { + sm.zoom = 1; + } + return; + + default: + break; + } + sm.keyStatus.put(keycode, true); + } + +} diff --git a/app/src/main/resources/lumberjack_sheet32.png b/app/src/main/resources/lumberjack_sheet32.png new file mode 100644 index 0000000000000000000000000000000000000000..84f3de8fbab0152498b444a56b7da5eaa085185d GIT binary patch literal 1236 zcmV;_1S|WAP)C0000WV@Og>004R= z004l4008;_004mL004C`008P>0026e000+nl3&F}00009a7bBm000XT000XT0n*)m z`~Uy|PEbr#MF0Q*000078!!weK@~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-8967,7 +8967,7 @@ - + 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21, 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21, @@ -8981,7 +8981,7 @@ 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21 - + 956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956, 956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956,956, @@ -8995,7 +8995,7 @@ 921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921,921 - + @@ -9021,7 +9021,7 @@ - + 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21, 40,40,40,8,9,40,40,40,40,40,40,40,40,40,40,8,9,40,40,40,