Skip to content
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

[client] 3d models code and assets cleanup #2633

Merged
merged 14 commits into from
Jan 17, 2025
Merged

[client] 3d models code and assets cleanup #2633

merged 14 commits into from
Jan 17, 2025

Conversation

r0man1337
Copy link
Contributor

@r0man1337 r0man1337 commented Jan 9, 2025

  • Removed unused 3D models and renamed paths for consistency.
  • Refactored constants code to achieve better code quality and improve readability.
  • Refactored models management for enhanced structure and maintainability.

Summary by CodeRabbit

Release Notes

  • Refactor

    • Enhanced organization of building models and file paths.
    • Improved categorization of building types and resources.
    • Restructured model loading and retrieval mechanisms.
  • New Features

    • Introduced more granular management of building and biome model paths.
    • Added new enumerations for better resource and building type tracking.
  • Chores

    • Updated ignore list in configuration to manage file processing.
  • Bug Fixes

    • Removed deprecated functionality related to realm management and tick provider.

These updates significantly enhance the clarity and organization of the building management system within the game, improving overall functionality.

Copy link
Contributor

mentatbot bot commented Jan 9, 2025

Hi @r0man1337! You need to be added as a user to interact with me. Please ask @ponderingdemocritus to add you on the settings page.

You are receiving this comment because I am set to review all PRs. That is configurable here.

Copy link

vercel bot commented Jan 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eternum ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2025 4:08pm
eternum-docs ❌ Failed (Inspect) Jan 17, 2025 4:08pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
eternum-landing ⬜️ Ignored (Inspect) Visit Preview Jan 17, 2025 4:08pm

Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

Walkthrough

The pull request introduces a comprehensive reorganization of building and biome model management across multiple files. The changes focus on creating a more structured approach to handling building models by introducing new enums and nested map structures. The modifications enhance the categorization of building types, improve model loading mechanisms, and provide more explicit organization of resources and building groups.

Changes

File Change Summary
client/apps/game/src/three/scenes/constants.ts - Added new enums: BiomeFilenames, BuildingFilenames, BUILDINGS_GROUPS, StructureProgress
- Updated model path constants and types
- Restructured buildingModelPaths and biomeModelPaths into nested object formats
- Cleaned up MinesMaterialsParams section
client/apps/game/src/three/managers/building-preview.ts - Updated buildingModels to use nested Map structure
- Modified getBuildingModel and getBuildingType methods
- Adapted model retrieval logic to new group-based structure
client/apps/game/src/three/scenes/hexception.tsx - Removed Building interface
- Updated buildingModels to use nested Map with groups
- Refined building model loading and retrieval logic
client/apps/landing/src/dojo/setup.ts - Removed export of configManager and introduced it as a local variable within setup function
client/apps/landing/src/hooks/helpers/useRealms.tsx - Removed useRealm custom hook
client/sdk/packages/core/src/provider/tick.ts - Removed TickProvider interface, DefaultTickProvider class, and TickProviderManager class
.knip.json - Removed entry to ignore client/sdk/packages/eternum/global.d.ts and added entry to ignore client/sdk/packages/**

Possibly related PRs

  • fix model manager in landing #2632: The changes in the main PR regarding the restructuring of building model paths and the introduction of new enums for managing building types are related to the modifications in the BuildingPreview class in this PR, which also involves a nested structure for managing building models.
  • Enh/clean assets #2637: The changes in the main PR that enhance the organization and clarity of model paths and filenames are relevant to the overall asset management improvements indicated in this PR, which focuses on cleaning up and organizing assets, although it does not directly modify the same files or structures.

Suggested reviewers

  • bob0005

Poem

🏗️ In the realm of bits and bytes, a change takes flight
Grouped models dance with newfound might
Enums and maps, a rabbit's delight
Organizing code with technical flair so bright
A structure reborn, clean and tight! 🐰✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7f3a6c and 1b11bc3.

📒 Files selected for processing (1)
  • .knip.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .knip.json
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: test-various (test_ownership_systems)
  • GitHub Check: test-various (transport_test)
  • GitHub Check: test-various (guild_test)
  • GitHub Check: test-various (realm_test)
  • GitHub Check: test-various (trade_test)
  • GitHub Check: test-various (resource_bridge_test)
  • GitHub Check: test-various (map_test)
  • GitHub Check: test-various (bank_test)
  • GitHub Check: test-various (hyperstructure_test)
  • GitHub Check: test-various (config_test)
  • GitHub Check: test-various (resources_test)
  • GitHub Check: test-various (position_test)
  • GitHub Check: test-various (owner_test)
  • GitHub Check: test-various (combat_test)
  • GitHub Check: test-various (season_test)
  • GitHub Check: clippy

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Jan 9, 2025

Failed to generate code suggestions for PR

@r0man1337 r0man1337 changed the title [WIP] [client] 3d models code and assets cleanup [client] 3d models code and assets cleanup Jan 14, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
client/apps/game/src/three/components/BuildingPreview.ts (1)

68-70: Remove debug console.log statements to clean up the code.

The console.log statements at lines 68 and 70 are likely used for debugging purposes. Consider removing them to improve code cleanliness in production.

client/apps/game/src/three/scenes/Hexception.tsx (1)

481-483: Avoid using magic numbers; use constants derived from ResourcesIds.

The condition building.resource < 24 uses a magic number (24). It's better to replace it with a constant derived from the ResourcesIds enum to enhance maintainability and readability.

Apply this suggestion:

- if (building.resource && (building.resource < 24 || building.resource === ResourcesIds.AncientFragment)) {
+ // Define MAX_RESOURCE_ID based on ResourcesIds enum
+ const MAX_RESOURCE_ID = /* maximum value from ResourcesIds */;
+ if (building.resource && (building.resource <= MAX_RESOURCE_ID || building.resource === ResourcesIds.AncientFragment)) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4cfbabb and 2a2fdd0.

📒 Files selected for processing (3)
  • client/apps/game/src/three/components/BuildingPreview.ts (5 hunks)
  • client/apps/game/src/three/scenes/Hexception.tsx (4 hunks)
  • client/apps/game/src/three/scenes/constants.ts (2 hunks)
🔇 Additional comments (1)
client/apps/game/src/three/scenes/constants.ts (1)

Line range hint 1-193: The refactoring of constants and enums enhances code organization.

The introduction of BUILDINGS_GROUPS, BUILDINGS_CATEGORIES_TYPES, and the restructuring of model paths improve the clarity and maintainability of the code.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
client/apps/game/src/three/scenes/hexception.tsx (1)

Line range hint 508-509: Check for potential memory leaks with mixers

Stored animation mixers in buildingMixers may lead to memory leaks if not properly disposed when buildings are removed.

Ensure that mixers are disposed and removed from buildingMixers when buildings are removed from the scene.

if (this.buildingMixers.has(key)) {
  this.buildingMixers.get(key).stopAllAction();
  this.buildingMixers.delete(key);
}
🧹 Nitpick comments (9)
client/apps/game/src/three/managers/building-preview.ts (3)

39-45: Avoid using any type in gltf.scene.traverse

Using any for the child parameter loses type safety. Consider specifying a more precise type, such as THREE.Object3D or using a type guard to check for THREE.Mesh.

Apply this diff to improve type safety:

-gltf.scene.traverse((child: any) => {
+gltf.scene.traverse((child) => {
+  if ((child as THREE.Mesh).isMesh) {
     // TypeScript will now recognize child as THREE.Mesh

Alternatively, use a type guard:

gltf.scene.traverse((child) => {
  if (child instanceof THREE.Mesh) {
    // child is now recognized as THREE.Mesh
  }
});

46-46: Ensure consistent key types when using Map

In groupMap.set(building as any, model);, casting building to any can lead to type inconsistencies. Since groupMap is a Map<string, THREE.Group>, explicitly convert building to a string.

Apply this diff to correct the key type:

-groupMap.set(building as any, model);
+groupMap.set(building.toString(), model);

69-71: Remove unnecessary console.log statements

Debugging statements like console.log can clutter the console output in production. Consider removing or properly managing them using a logging framework that can be disabled in production environments.

Apply this diff to remove the logs:

- console.log("categoryMap", categoryMap);
...
- console.log("building", categoryMap.get(building + ""));
client/apps/game/src/three/scenes/hexception.tsx (5)

100-101: Improve readability by adding type aliases

The buildingModels map uses a complex nested type which can be hard to read. Consider introducing type aliases to enhance readability.

Define type aliases at the top of the file:

type BuildingModelData = { model: THREE.Group; animations: THREE.AnimationClip[] };
type BuildingGroupMap = Map<BUILDINGS_CATEGORIES_TYPES, BuildingModelData>;

Then update the buildingModels declaration:

-private buildingModels: Map<
-  BUILDINGS_GROUPS,
-  Map<BUILDINGS_CATEGORIES_TYPES, { model: THREE.Group; animations: THREE.AnimationClip[] }>
-> = new Map();
+private buildingModels: Map<BUILDINGS_GROUPS, BuildingGroupMap> = new Map();

192-229: Duplicate code in loadBuildingModels across classes

The loadBuildingModels method appears similar to the one in BuildingPreview. Consider abstracting this logic into a shared utility function or base class to promote code reuse and reduce duplication.

Extract the common loading logic into a separate utility function or a shared class that both HexceptionScene and BuildingPreview can utilize.


208-215: Avoid using any in model.traverse

Using any type for the child parameter reduces type safety. Use THREE.Object3D or appropriate type guards to maintain type safety.

Apply this diff to specify the type:

-model.traverse((child) => {
+model.traverse((child: THREE.Object3D) => {
  if (child instanceof THREE.Mesh) {

477-486: Simplify building group and type determination

The logic for determining buildingGroup and buildingType can be simplified for clarity and maintainability.

Consider refactoring the code to reduce nesting and improve readability:

let buildingGroup: BUILDINGS_GROUPS;
let buildingType: BUILDINGS_CATEGORIES_TYPES;

if (building.resource && (building.resource < 24 || building.resource === ResourcesIds.AncientFragment)) {
  buildingGroup = BUILDINGS_GROUPS.RESOURCES_MINING;
  buildingType = ResourceIdToMiningType[building.resource as ResourcesIds] as ResourceMiningTypes;
} else if (building.structureType === StructureType.Hyperstructure) {
  buildingGroup = BUILDINGS_GROUPS.HYPERSTRUCTURE;
  buildingType = hyperstructureStageToModel[this.structureStage as StructureProgress];
} else if (this.tileManager.getWonder(this.state.structureEntityId)) {
  buildingGroup = BUILDINGS_GROUPS.WONDER;
  buildingType = WONDER_REALM;
} else {
  buildingGroup = BUILDINGS_GROUPS.BUILDINGS;
  buildingType = BuildingType[building.category].toString() as BUILDINGS_CATEGORIES_TYPES;
}

if (buildingGroup === BUILDINGS_GROUPS.BUILDINGS && buildingType === BuildingType.Castle.toString()) {
  buildingType = castleLevelToRealmCastle[this.structureStage];
  buildingGroup = BUILDINGS_GROUPS.REALMS;
}

215-216: Redundant empty Promise.all callback

The Promise.all(this.modelLoadPromises).then(() => {}); includes an empty then callback which is unnecessary.

Remove the empty callback to clean up the code:

-Promise.all(this.modelLoadPromises).then(() => {});
+Promise.all(this.modelLoadPromises);
client/apps/game/src/three/scenes/constants.ts (1)

99-105: Consider consolidating BUILDINGS_GROUPS enum values

The BUILDINGS_GROUPS enum has string values that may benefit from being constant variables or a string literal union type instead.

If enum semantics are not required, consider using a type alias:

export type BUILDINGS_GROUPS = 'buildings' | 'resources_mining' | 'hyperstructure' | 'realms' | 'wonder';
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a2fdd0 and 0c43854.

📒 Files selected for processing (3)
  • client/apps/game/src/three/managers/building-preview.ts (5 hunks)
  • client/apps/game/src/three/scenes/constants.ts (2 hunks)
  • client/apps/game/src/three/scenes/hexception.tsx (4 hunks)
🧰 Additional context used
🪛 GitHub Actions: knip
client/apps/game/src/three/scenes/constants.ts

[warning] 19-19: Unused exported enum 'BiomeFilenames'


[warning] 39-39: Unused exported enum 'BuildingFilenames'

🔇 Additional comments (5)
client/apps/game/src/three/managers/building-preview.ts (1)

14-14: Good use of a nested Map structure for buildingModels

The change to use a nested Map<BUILDINGS_GROUPS, Map<string, THREE.Group>> for buildingModels improves the organization and categorization of building models by groups, enhancing code maintainability.

client/apps/game/src/three/scenes/constants.ts (4)

19-37: Unused exported enum BiomeFilenames

The BiomeFilenames enum is exported but not used anywhere in the codebase.

Given the pipeline warning:

[warning] 19-19: Unused exported enum 'BiomeFilenames'

Consider removing BiomeFilenames if it's not needed, or ensure it's used where appropriate.

🧰 Tools
🪛 GitHub Actions: knip

[warning] 19-19: Unused exported enum 'BiomeFilenames'


39-68: Unused exported enum BuildingFilenames

Similarly, the BuildingFilenames enum is exported but not used.

As per the pipeline warning:

[warning] 39-39: Unused exported enum 'BuildingFilenames'

Review whether BuildingFilenames is necessary. If not, remove it to clean up the codebase.

🧰 Tools
🪛 GitHub Actions: knip

[warning] 39-39: Unused exported enum 'BuildingFilenames'


114-153: Possible duplication in buildingModelPaths keys

Ensure that all keys in buildingModelPaths are unique and correctly correspond to the enums and types used elsewhere.

Double-check that BuildingType.Resource and ResourceMiningTypes do not overlap unintentionally, which could cause model loading issues.


156-172: Adjust import paths for consistency

In biomeModelPaths, ensure that all paths are correctly constructed and consistent with the actual file structure.

Confirm that BIOMES_MODELS_PATH and the filenames from BiomeFilenames correctly resolve to the existing model files.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
client/apps/game/src/three/scenes/hexception.tsx (1)

Line range hint 393-404: Prevent potential memory leaks by unsubscribing from subscriptions

In the setup method, subscriptions to buildingSubscription and realmSubscription are made. Ensure that these subscriptions are properly unsubscribed when the component is destroyed to prevent memory leaks.

🧹 Nitpick comments (5)
client/apps/game/src/three/managers/building-preview.ts (1)

67-70: Remove unnecessary console.log statements

The console.log statements at lines 67 and 69 appear to be for debugging purposes. It's best practice to remove such statements or replace them with a proper logging mechanism to avoid cluttering the console in production.

Apply this diff to remove the console.log statements:

        const categoryMap = this.buildingModels.get(group);
-       console.log("categoryMap", categoryMap);
        if (categoryMap) {
-         console.log("building", categoryMap.get(building + ""));
          return categoryMap.get(building + "") || null;
        }
client/apps/game/src/three/scenes/constants.ts (2)

1-1: Organize import statements and remove duplicate imports

The THREE library is imported at line 1, which is appropriate. Ensure that all imports are necessary and there are no duplicate imports elsewhere in the file.


27-45: Address unused exported enums BiomeFilenames and BuildingFilenames

The enums BiomeFilenames and BuildingFilenames are exported but not used outside this file, as indicated by the pipeline warnings. If these enums are intended for internal use only, consider removing the export keyword to prevent unused export warnings.

Apply this diff to make the enums internal:

-export enum BiomeFilenames {
+enum BiomeFilenames {
  Bare = "bare.glb",
  Beach = "beach.glb",
  // ... remaining enum entries
}
-
-export enum BuildingFilenames {
+enum BuildingFilenames {
  Bank = "bank.glb",
  ArcheryRange = "archerrange.glb",
  // ... remaining enum entries
}
🧰 Tools
🪛 GitHub Actions: knip

[warning] 27-27: Unused exported enum: BiomeFilenames

client/apps/game/src/three/scenes/hexception.tsx (2)

193-230: Handle model loading errors gracefully

In the loadBuildingModels method, consider adding error handling or retries in case a model fails to load. This can improve the robustness of the application.


478-498: Simplify building type determination logic

The logic for determining buildingGroup and buildingType can be refactored for clarity and maintainability. Consider extracting this logic into a separate method or utilizing a mapping function.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c43854 and e4805b0.

📒 Files selected for processing (3)
  • client/apps/game/src/three/managers/building-preview.ts (5 hunks)
  • client/apps/game/src/three/scenes/constants.ts (3 hunks)
  • client/apps/game/src/three/scenes/hexception.tsx (4 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
client/apps/game/src/three/scenes/constants.ts

[error] 93-93: Shouldn't redeclare 'StructureProgress'. Consider to delete it or rename it.

'StructureProgress' is defined here:

(lint/suspicious/noRedeclare)

🪛 GitHub Actions: knip
client/apps/game/src/three/scenes/constants.ts

[warning] 27-27: Unused exported enum: BiomeFilenames


[warning] 47-47: Unused exported enum: BuildingFilenames


[warning] 93-93: Unused exported enum: StructureProgress

🔇 Additional comments (4)
client/apps/game/src/three/scenes/constants.ts (2)

164-180: Ensure consistency in biomeModelPaths keys

The biomeModelPaths object uses keys of type BiomeType | "Outline". Verify that all keys correspond correctly to the BiomeFilenames entries to prevent any mismatches in model loading.


161-161: Verify the use of BuildingFilenames and BiomeFilenames enums

Despite being declared, the enums BiomeFilenames and BuildingFilenames might not be utilized effectively. Ensure they are used consistently throughout the file to enhance code maintainability and readability.

Please run the following script to check where these enums are being used:

✅ Verification successful

BiomeFilenames and BuildingFilenames enums are properly utilized

Both enums are effectively used throughout the constants file as a centralized source of truth for file naming conventions, providing type safety and consistent path construction for biome and building assets.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all usages of 'BiomeFilenames' and 'BuildingFilenames' in the codebase.

# Search for 'BiomeFilenames' usage
rg 'BiomeFilenames'

# Search for 'BuildingFilenames' usage
rg 'BuildingFilenames'

Length of output: 6964

client/apps/game/src/three/scenes/hexception.tsx (2)

101-102: Type alias BUILDINGS_CATEGORIES_TYPES might not cover all cases

The buildingModels map uses BUILDINGS_CATEGORIES_TYPES as the inner key type. Ensure that this type includes all possible keys used when loading models, especially custom strings like WONDER_REALM, to avoid runtime errors.


500-503: Handle missing hyperstructure models

Ensure that hyperstructureStageToModel covers all possible stages of the hyperstructure. Also, verify that the corresponding models are loaded and available in buildingModels to prevent null references.

Comment on lines 93 to 97
export enum StructureProgress {
STAGE_1 = 0,
STAGE_2 = 1,
STAGE_3 = 2,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix redeclaration of StructureProgress enum

The StructureProgress enum is being redeclared at lines 93-97, but it is already imported from @bibliothecadao/react at line 1. Redeclaring it can cause conflicts and unexpected behavior. Please remove this redeclaration and use the imported StructureProgress instead.

Apply this diff to remove the redeclaration:

-import { StructureProgress } from "@bibliothecadao/react";
...
-export enum StructureProgress {
-  STAGE_1 = 0,
-  STAGE_2 = 1,
-  STAGE_3 = 2,
-}
+// Use the imported StructureProgress from '@bibliothecadao/react'

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Biome (1.9.4)

[error] 93-93: Shouldn't redeclare 'StructureProgress'. Consider to delete it or rename it.

'StructureProgress' is defined here:

(lint/suspicious/noRedeclare)

🪛 GitHub Actions: knip

[warning] 93-93: Unused exported enum: StructureProgress

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
client/apps/landing/src/dojo/setup.ts (1)

13-14: Consider documenting the singleton pattern usage.

The use of ClientConfigManager.instance() indicates a singleton pattern. Consider adding a brief comment explaining why this pattern is used here and its lifecycle management.

+  // Use singleton instance to ensure consistent configuration state across the application
   const configManager = ClientConfigManager.instance();
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4805b0 and a7f3a6c.

📒 Files selected for processing (5)
  • .knip.json (1 hunks)
  • client/apps/game/src/three/scenes/constants.ts (3 hunks)
  • client/apps/landing/src/dojo/setup.ts (1 hunks)
  • client/apps/landing/src/hooks/helpers/useRealms.tsx (0 hunks)
  • client/sdk/packages/core/src/provider/tick.ts (0 hunks)
💤 Files with no reviewable changes (2)
  • client/apps/landing/src/hooks/helpers/useRealms.tsx
  • client/sdk/packages/core/src/provider/tick.ts
🔇 Additional comments (5)
client/apps/landing/src/dojo/setup.ts (1)

13-14: Verify the impact of removing the exported configManager.

The change from a module-level export to a function-local variable improves encapsulation. However, we should verify that no other modules were depending on the removed export.

Let's check for any direct imports of configManager from this file:

✅ Verification successful

The configManager scope change is safe to proceed with

The codebase consistently uses ClientConfigManager.instance() to access the singleton instance, and there are no direct imports of the exported configManager from setup.ts. This change improves encapsulation without affecting any dependencies.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any imports of configManager from setup.ts
rg -l "import.*\{.*configManager.*\}.*from.*setup" 

# Search for any direct references to configManager from setup
rg "configManager.*setup"

Length of output: 80


Script:

#!/bin/bash
# Search for any imports from setup.ts with context
rg -A 2 "from.*setup" 

# Search for ClientConfigManager usage
rg "ClientConfigManager" 

# Search for any direct file references to setup.ts
rg "setup\.ts"

Length of output: 4686

.knip.json (1)

9-9: Verify the relocation of global type definitions.

The change suggests that global type definitions have been moved from the eternum package to the core package. This aligns with the cleanup objectives.

✅ Verification successful

Global type definitions relocation verified

The file has been successfully moved to client/sdk/packages/core/global.d.ts and the old location is properly cleaned up. The configuration change is correct.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the relocation of global type definitions
# Check if the old file is completely removed and the new file exists

echo "Checking for the existence of files:"
fd "global.d.ts$" client/sdk/packages/

Length of output: 160

client/apps/game/src/three/scenes/constants.ts (3)

Line range hint 1-26: Well-organized path constants!

The consolidation of path constants and the clean separation between flat and non-flat modes improves maintainability.


116-195: Excellent organization of building models!

The new structure using BUILDINGS_GROUPS provides:

  • Clear categorization
  • Type-safe mappings
  • Consistent path construction

47-76: Consolidate duplicate model files.

Several building types are using the same model file (market.glb):

  • TradingPost
  • Walls
  • WatchTower

Consider creating distinct models for these buildings to improve visual differentiation.

✅ Verification successful

Model reuse appears intentional but visual distinction would be beneficial

The codebase currently reuses market.glb for TradingPost, Walls, and WatchTower buildings, which appears to be an intentional design choice. While creating distinct models would improve visual clarity, the current implementation is functional.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for duplicate model file usage
echo "Checking for model files in the repository:"
fd "market.glb|walls.glb|watchtower.glb" "models/buildings/"

Length of output: 262


Script:

#!/bin/bash
# First, find all .glb files to understand the model directory structure
echo "Searching for all .glb files in the repository:"
fd -e glb

# Then specifically look for the relevant model files
echo -e "\nSearching for specific model files:"
fd "market.glb|castle|wonder|hyperstructure"

Length of output: 6061

@aymericdelab aymericdelab merged commit 0e9d5b2 into next Jan 17, 2025
22 of 29 checks passed
@aymericdelab aymericdelab deleted the leet/cleanup branch January 17, 2025 16:41
@coderabbitai coderabbitai bot mentioned this pull request Jan 22, 2025
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