Skip to content

Territory Layer Update#120

Merged
1brucben merged 10 commits into
v0.2.0from
territorylayerv7
Nov 23, 2025
Merged

Territory Layer Update#120
1brucben merged 10 commits into
v0.2.0from
territorylayerv7

Conversation

@1brucben
Copy link
Copy Markdown
Owner

This pull request introduces significant optimizations and refactoring to the territory rendering and attack execution logic, aiming to improve performance and visual smoothness in the game client. The most impactful changes include switching to more efficient data structures for tile rendering, introducing caching to avoid expensive per-pixel computations, and updating attack processing to occur multiple times per tick for smoother territory transitions.

Rendering and Caching Optimizations:

  • Replaced the PriorityQueue used for tileToRenderQueue in TerritoryLayer.ts with a Set<TileRef>, simplifying the queue management and improving performance. [1] [2] [3]
  • Added per-tile caches (borderCache, defendedCache, and borderColorsCache) to avoid repeated expensive calculations for border and defense status during territory rendering. These caches are invalidated on relevant updates. [1] [2] [3] [4] [5]

Territory Highlighting and Offset Calculations:

  • Refactored territory and spawn highlighting logic to use precomputed offset arrays instead of BFS with custom distance functions, reducing computational overhead and improving responsiveness. [1] [2] [3]

Attack Execution Smoothing:

  • Updated attack execution so that attacks are processed six times per game tick instead of once, resulting in smoother territory changes. This required adjusting the number of tiles processed per subtick and updating the main game loop to handle attack executions separately from other actions. [1] [2] [3]

Code Cleanup:

  • Removed unused imports and debug logging statements from TerritoryLayer.ts for clarity and maintainability. [1] [2]

These changes collectively enhance the game's visual performance and responsiveness, particularly during large-scale territory updates and attacks.

…es, optimize offset calculations for defense posts and spawn highlights
… Uint32Array for pixel manipulation and streamline tile painting logic
…bticks for smoother territory changes and optimize execution handling
…a handling, and streamline rendering logic for improved performance
…es with ATTACK_SUBTICKS_PER_TICK constant for improved clarity and maintainability
@1brucben 1brucben merged commit 9fecde3 into v0.2.0 Nov 23, 2025
4 of 7 checks passed
@El-Magico777 El-Magico777 added this to the v0.1.11 milestone Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants