-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix rendering of maps and add chunk config per map #49
Conversation
alvrs
commented
Jun 30, 2022
•
edited
Loading
edited
- Fixes issues with "black holes" on maps with tilesize different from the tileset's tilesize (fix: fix rendering of maps and add chunk config per map #49 (comment))
- Only include relevant tilesets on tilemaps (fix: fix rendering of maps and add chunk config per map #49 (comment))
- Adds config for chunk sizes per map instead of global: fix: fix rendering of maps and add chunk config per map #49 (comment)
- Adds a padding around the viewport to "prerender" areas around the viewport and avoid panning into unrendered areas: fix: fix rendering of maps and add chunk config per map #49 (comment)
- Adds config for rpc/webRpc via get params: fix: fix rendering of maps and add chunk config per map #49 (comment)
putTile.width = map.tileWidth; | ||
putTile.height = map.tileHeight; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Phaser is automatically setting the tile width/hight to the tileset tileWith/tileHeight when setting a single tile: https://github.com/photonstorm/phaser/blob/1591ebdb777a9be5c706fc18f86a6107fb66717f/src/tilemaps/components/PutTileAt.js#L78-L79
Out tileset has a tile size of 16x16px, but we explicitly want to render it at a larger size for our Tactic/Strategic map with lower level of detail / larger tile sizes. So we have to manually reset the tile size to the map tile size here.
tilesets: Object.entries(tilesets) | ||
.filter(([key]) => relevantTilesets.includes(key)) | ||
.map(([, tileset]) => tileset), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were including all tilesets on every map, now we only include the ones relevant for this map (currently we only have one tileset, but we might have different ones for different LOD maps in the future)
const { layers, backgroundTile, tileWidth, tileHeight, animationInterval, tileAnimations, chunkSize } = | ||
config.maps[mapKey]; | ||
|
||
// Setup chunks | ||
const chunks = createChunks(camera.worldView$, chunkSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chunk sizes can now be configured per map instead of global (before chunk sizes for the lowest LOD map was 2x2 tiles, way too small and way to high chunking overhead)
map(({ x, y, width, height }) => | ||
// Calculate current chunks from the world view | ||
getChunksInArea( | ||
{ | ||
x: x - padding, | ||
y: y - padding, | ||
width: width + 2 * padding, | ||
height: height + 2 * padding, | ||
}, | ||
chunkSize | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We extend the viewport for chunking by 100px on each side to "prerender" beyond the actual viewport and avoid panning into unrendered areas
const jsonRpc = params.get("rpc") || undefined; | ||
const wsRpc = params.get("wsRpc") || (jsonRpc && jsonRpc.replace("http", "ws")); | ||
const checkpointUrl = params.get("checkpoint") || undefined; | ||
const devMode = params.get("dev") === "true" || false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible to configure rpc/wsRpc now via get params as well
* Nyc david components (#17) * feat(std-contracts): add basic components to std lib * feat(solecs): add componentID getter to component.sol * refactor(ri-contracts): use new base components from stdlib * feat(ri-contracts): add new components and contract functions * feat(ri-client): adding components and action system * feat(network): make decoder error when key not passed in * feat(recs): expose getEntitiesWithValue function * fix(ri-client): replace get component value with query * feat(vscode): add std-contract mapping to vscode * refactor(ri-client): remove spawncreaturesystem and old logs * fix(std-contracts): fix solidity compiler and export settings * feat(network,recs,ri): correctly handle component removal events (#20) * Persona / Launcher Integration (#18) * refactor(ri/client): fix up the interface for action creators * feat(ri): hook ri up to launcher and persona * fix(ri): use 31337 as local chain id everywhere * feat: integrate persona and player entity when spawning * feat: join game with persona integrated * fix(solecs,ri): fix remappings * fix(ri/client): add lodash to ri client * feat(contract): check entity owner when moving * fix(ri/contracts): fix Diamond upgrade hardhat task and make it faster * fix(ri/contract): remove garbage function Co-authored-by: ludens <ludens@lattice.xyz> * fix: make ecs-browser compatible with recs v2 * feat(ri): update ri to support recs v2 * feat(ri): create stamina system with a global turn timer (#25) * chore: update constants for lattice chain (#26) * Ability to select and move multiple units (#27) * feat(ri): remove area selection * feat: spawn multiple units when joining game - can select a specific unit and move it * feat(ri-contracts): add spawn point and mineable components (#28) * feat: add persona-js package, add simple ri launcher (#29) * feat(persona-js): add boilerplate for ts library * feat(ri-launcher): add boilerplate for ri launcher * fix(ri-client): use new world disposer in boot.tsx * feat(ri-launcher): add auto mint of persona * feat(persona-js): add persona types and utils * feat(ri-launcher): add simple boot screen * build: yarn install * chore(ri-launcher): rename game address config * feat(ri-launcher): make config configurable * fix(ri-launcher): remove logs * feat(ri-client): change tile size from 24 to 16 and update art to latest ember-art tileset and atlas (#30) * beginnings of a UI (#31) * feat(ri): make a UI system for registering components in an area of the screen - beginnings of a real UI * feat: paint persona colors on entities owned by that persona * feat: LOD (#33) * feat(ri): silly cluster lod + remove component browser * feat(ri): add tactical view * fix: properly hue hero sprite (#32) * fix: can highlight coord 0 (#34) * fix: some fixes (#35) * fix: manually edit auto generated snapshot ts file (#36) * feat(client): performance improvements (#37) * feat(network): optimize local cache * fix(ri-launcher): fix passing checkpoint service * feat(client): cache checkpoint, fix maps * fix(network): await cache promise * feat(ri/client): modify outline shader to accept color input (#39) * feat(ri/client): modify outline shader to accept color input * fix(ri/client): pipeline hack is no longer needed * chore(phaserx): remove log * feat(phaserx): support any number of map chunks at once * chore(recs): remove v1 * chore(client): remove check for entities with pos in joinGame * chore(client): remove outdated log * chore(client): clean up moveEntity api function * chore(client): remove unnecessary gas limits * chore(phaserx): set game object origin to 0,0 * chore(client): remove teleportation * chore(contracts): remove duplicate contract * chore(client): rename Window to Cell * docs(std-contracts): add info about exports.txt to Readme.md * feat(contracts): add param for amount of stamina to reduce to reduceStamina * chore(network): fix typo * chore(network): update persona.js * chore(persona-js): add overrides as optional param * fix: a couple review fixes * fix: more review changes * Opaque Entity Types (#40) * feat: add opaque types for EntityID and EntityIndex (formerly just string and number types) * fix(recs): translate entity indices to IDs when using Proxy fragments * Update packages/ecs-browser/src/EntityEditor.tsx Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * fix(recs): remove mistaken EntityID in component type Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * fix: more review fixes * fix(network): fix cache worker memory leak * fix(client): remove unperformant pixel map * fix(network): fix cache (#41) * docs(client): update comment about throttling application of ecs events * fix(client): remove previous path in createDrawPotentialPathSystem * chore: add optional update to sync system and simplify sync of CurrentStamina/LocalCurrentStamina * fix(client): align tile highlight with tile grid * fix(contract): remove onlyOwner, fix build * fix(ri/client): remove manual gasLimit on moveEntity * fix(ri/client): fix PotentialPath render position * refactor(ri/client): refactor(ri/client): no longer support area select i removed area selection because it doesn't make sense for the current prototype. the previous implementation would go through every Selectable entity, assuming anything could potentially be in the area. that was no longer necessary. * fix(ri/client): fix selection test to not expect area selection * fix(ri/client): properly update local stamina inside move action * feat(ri): add a concept of DEV_MODE (#42) * feat(ri): add DEV_MODE * fix(ri/client): feed DEV_MODE param through to contract setup * Update packages/ri/client/src/layers/Network/createNetworkLayer.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * refactor(ri): stamina as one component * fix(client): more efficient memory handling in cache and sync worker (#43) * fix: fix cache once more (actually no more memory leako) * chore: remove unused logs * fix: await storing values before storing block number * chore(contracts): pull out logic from EmberFacet to separate facets and libs (#44) * feat(ri/contracts): make LibStamina * feat(ri/contracts): make Move and PlayerJoin facets * chore: update require message * chore: update require message Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * fix: fix turn timer and hardhat block time (#45) * fix: make sure hardhat block time is in sync with local time * fix(ri): make the UI render every second without component updates * fix(ri/client): fix DevHighlight rendering * fix: hot module replacement (#46) * fix: add empty dependency array to useEffect in ComponentRenderer * fix: hot module replacement * fix: self-revie * newTurn$ stream (#48) * feat(ri): create newTurn$ stream * refactor: i understand rxjs now? * refactor(ri): refactor CurrentStaminaSystem to use a combined Stamina update and newTurn stream * chore: remove unused import * refactor(ri/client): refactor turn$ to be more rxjs-y * fix: woops * fix: fix rendering of maps and add chunk config per map (#49) * fix(phaserx): set tile size to map tileSize instead of tileset tileSize * feat(phaserx): add padding around viewport to avoid black areas while panning * feat(launcher): make rpc configurable via get params * feat(phaserx): allow configuration of chunks per map * fix: self review * fix: self review * feat: improve react UI engine, refactor component browser (#50) * fix(ecs-browser): fix ComponentBrowser by hooking into Component update streams * fix(ecs-browser): load current values for component values when expanding entities - before, the ComponentEditor components were waiting for an update to display anything * feat(ecs-browser): sort components by id in the query filter shortcuts * refactor(ecs-browser): create useComponentValueStream hook and use it in ecs-browser * chore: align std-client version number to mud * fix: review fixes * chore: review * fix(contracts): undo stamina component id change * feat(ecs-browser): allow queries to be written without q and c prefix Co-authored-by: alvrs <alvarius@lattice.xyz> Co-authored-by: Big Nuge <davidkolop@gmail.com> Co-authored-by: ludens <ludens@lattice.xyz> Co-authored-by: andrii dobroshynski <24281657+andriidski@users.noreply.github.com> Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> Co-authored-by: alvrs <alvarius@lattice.xyz>
* Nyc david components (latticexyz#17) * feat(std-contracts): add basic components to std lib * feat(solecs): add componentID getter to component.sol * refactor(ri-contracts): use new base components from stdlib * feat(ri-contracts): add new components and contract functions * feat(ri-client): adding components and action system * feat(network): make decoder error when key not passed in * feat(recs): expose getEntitiesWithValue function * fix(ri-client): replace get component value with query * feat(vscode): add std-contract mapping to vscode * refactor(ri-client): remove spawncreaturesystem and old logs * fix(std-contracts): fix solidity compiler and export settings * feat(network,recs,ri): correctly handle component removal events (latticexyz#20) * Persona / Launcher Integration (latticexyz#18) * refactor(ri/client): fix up the interface for action creators * feat(ri): hook ri up to launcher and persona * fix(ri): use 31337 as local chain id everywhere * feat: integrate persona and player entity when spawning * feat: join game with persona integrated * fix(solecs,ri): fix remappings * fix(ri/client): add lodash to ri client * feat(contract): check entity owner when moving * fix(ri/contracts): fix Diamond upgrade hardhat task and make it faster * fix(ri/contract): remove garbage function Co-authored-by: ludens <ludens@lattice.xyz> * fix: make ecs-browser compatible with recs v2 * feat(ri): update ri to support recs v2 * feat(ri): create stamina system with a global turn timer (latticexyz#25) * chore: update constants for lattice chain (latticexyz#26) * Ability to select and move multiple units (latticexyz#27) * feat(ri): remove area selection * feat: spawn multiple units when joining game - can select a specific unit and move it * feat(ri-contracts): add spawn point and mineable components (latticexyz#28) * feat: add persona-js package, add simple ri launcher (latticexyz#29) * feat(persona-js): add boilerplate for ts library * feat(ri-launcher): add boilerplate for ri launcher * fix(ri-client): use new world disposer in boot.tsx * feat(ri-launcher): add auto mint of persona * feat(persona-js): add persona types and utils * feat(ri-launcher): add simple boot screen * build: yarn install * chore(ri-launcher): rename game address config * feat(ri-launcher): make config configurable * fix(ri-launcher): remove logs * feat(ri-client): change tile size from 24 to 16 and update art to latest ember-art tileset and atlas (latticexyz#30) * beginnings of a UI (latticexyz#31) * feat(ri): make a UI system for registering components in an area of the screen - beginnings of a real UI * feat: paint persona colors on entities owned by that persona * feat: LOD (latticexyz#33) * feat(ri): silly cluster lod + remove component browser * feat(ri): add tactical view * fix: properly hue hero sprite (latticexyz#32) * fix: can highlight coord 0 (latticexyz#34) * fix: some fixes (latticexyz#35) * fix: manually edit auto generated snapshot ts file (latticexyz#36) * feat(client): performance improvements (latticexyz#37) * feat(network): optimize local cache * fix(ri-launcher): fix passing checkpoint service * feat(client): cache checkpoint, fix maps * fix(network): await cache promise * feat(ri/client): modify outline shader to accept color input (latticexyz#39) * feat(ri/client): modify outline shader to accept color input * fix(ri/client): pipeline hack is no longer needed * chore(phaserx): remove log * feat(phaserx): support any number of map chunks at once * chore(recs): remove v1 * chore(client): remove check for entities with pos in joinGame * chore(client): remove outdated log * chore(client): clean up moveEntity api function * chore(client): remove unnecessary gas limits * chore(phaserx): set game object origin to 0,0 * chore(client): remove teleportation * chore(contracts): remove duplicate contract * chore(client): rename Window to Cell * docs(std-contracts): add info about exports.txt to Readme.md * feat(contracts): add param for amount of stamina to reduce to reduceStamina * chore(network): fix typo * chore(network): update persona.js * chore(persona-js): add overrides as optional param * fix: a couple review fixes * fix: more review changes * Opaque Entity Types (latticexyz#40) * feat: add opaque types for EntityID and EntityIndex (formerly just string and number types) * fix(recs): translate entity indices to IDs when using Proxy fragments * Update packages/ecs-browser/src/EntityEditor.tsx Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * fix(recs): remove mistaken EntityID in component type Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * fix: more review fixes * fix(network): fix cache worker memory leak * fix(client): remove unperformant pixel map * fix(network): fix cache (latticexyz#41) * docs(client): update comment about throttling application of ecs events * fix(client): remove previous path in createDrawPotentialPathSystem * chore: add optional update to sync system and simplify sync of CurrentStamina/LocalCurrentStamina * fix(client): align tile highlight with tile grid * fix(contract): remove onlyOwner, fix build * fix(ri/client): remove manual gasLimit on moveEntity * fix(ri/client): fix PotentialPath render position * refactor(ri/client): refactor(ri/client): no longer support area select i removed area selection because it doesn't make sense for the current prototype. the previous implementation would go through every Selectable entity, assuming anything could potentially be in the area. that was no longer necessary. * fix(ri/client): fix selection test to not expect area selection * fix(ri/client): properly update local stamina inside move action * feat(ri): add a concept of DEV_MODE (latticexyz#42) * feat(ri): add DEV_MODE * fix(ri/client): feed DEV_MODE param through to contract setup * Update packages/ri/client/src/layers/Network/createNetworkLayer.ts Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * refactor(ri): stamina as one component * fix(client): more efficient memory handling in cache and sync worker (latticexyz#43) * fix: fix cache once more (actually no more memory leako) * chore: remove unused logs * fix: await storing values before storing block number * chore(contracts): pull out logic from EmberFacet to separate facets and libs (latticexyz#44) * feat(ri/contracts): make LibStamina * feat(ri/contracts): make Move and PlayerJoin facets * chore: update require message * chore: update require message Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> * fix: fix turn timer and hardhat block time (latticexyz#45) * fix: make sure hardhat block time is in sync with local time * fix(ri): make the UI render every second without component updates * fix(ri/client): fix DevHighlight rendering * fix: hot module replacement (latticexyz#46) * fix: add empty dependency array to useEffect in ComponentRenderer * fix: hot module replacement * fix: self-revie * newTurn$ stream (latticexyz#48) * feat(ri): create newTurn$ stream * refactor: i understand rxjs now? * refactor(ri): refactor CurrentStaminaSystem to use a combined Stamina update and newTurn stream * chore: remove unused import * refactor(ri/client): refactor turn$ to be more rxjs-y * fix: woops * fix: fix rendering of maps and add chunk config per map (latticexyz#49) * fix(phaserx): set tile size to map tileSize instead of tileset tileSize * feat(phaserx): add padding around viewport to avoid black areas while panning * feat(launcher): make rpc configurable via get params * feat(phaserx): allow configuration of chunks per map * fix: self review * fix: self review * feat: improve react UI engine, refactor component browser (latticexyz#50) * fix(ecs-browser): fix ComponentBrowser by hooking into Component update streams * fix(ecs-browser): load current values for component values when expanding entities - before, the ComponentEditor components were waiting for an update to display anything * feat(ecs-browser): sort components by id in the query filter shortcuts * refactor(ecs-browser): create useComponentValueStream hook and use it in ecs-browser * chore: align std-client version number to mud * fix: review fixes * chore: review * fix(contracts): undo stamina component id change * feat(ecs-browser): allow queries to be written without q and c prefix Co-authored-by: alvrs <alvarius@lattice.xyz> Co-authored-by: Big Nuge <davidkolop@gmail.com> Co-authored-by: ludens <ludens@lattice.xyz> Co-authored-by: andrii dobroshynski <24281657+andriidski@users.noreply.github.com> Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com> Co-authored-by: alvrs <alvarius@lattice.xyz>