Skip to content
This repository was archived by the owner on Oct 19, 2025. It is now read-only.

Feature/may bug fixes#70

Open
rorychatt wants to merge 2 commits intomainfrom
feature/may-bug-fixes
Open

Feature/may bug fixes#70
rorychatt wants to merge 2 commits intomainfrom
feature/may-bug-fixes

Conversation

@rorychatt
Copy link
Collaborator

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces support for static entities and portal-based teleportation, updates DTO definitions, and integrates a new StaticEntityManager to handle scene additions.

  • Defined StaticEntityDto and PortalDto, and updated SpaceMapData, PlayerDto, and AlienDto types.
  • Extended KeyboardService to track player position, portals, and trigger teleport requests.
  • Added loadStaticEntities, enhanced updateSpacemap, and integrated StaticEntityManager in the game component.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/app/game/types/SpaceMapData.ts Added DTOs for static entities and portals, refined map types
src/app/game/services/keyboard.service.ts Implemented J key teleport handling and portal tracking
src/app/game/services/hub.service.ts Added requestTeleport to server request types
src/app/game/game.utils.ts Imported static entities, added loadStaticEntities, updated map logic
src/app/game/game.component.ts Initialized StaticEntityManager, wired teleport events, and portal updates
src/app/game/StaticEntityManager.ts Created manager for static entities and portal meshes
Comments suppressed due to low confidence (1)

src/app/game/StaticEntityManager.ts:81

  • [nitpick] The method name suggests it returns only IDs, but it returns the full Map of meshes. Consider renaming to getStaticEntities or returning an iterable of IDs.
public getStaticEntityIds(): Map<string, THREE.Mesh> {

// Load players, aliens, and static entities for the new map
await loadPlayers(spaceMapData.mapObject.players, component);
await loadAliens(spaceMapData.mapObject.aliens, component);
await loadStaticEntities(spaceMapData.mapObject.staticEntities, component);
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

The loadStaticEntities function is declared to accept StaticEntityDto[] but is being passed an array that may include PortalDto items. Consider updating the signature to accept the union type (StaticEntityDto | PortalDto)[] or filter out portal entries before calling.

Suggested change
await loadStaticEntities(spaceMapData.mapObject.staticEntities, component);
const filteredStaticEntities = spaceMapData.mapObject.staticEntities.filter(
(entity): entity is StaticEntityDto => 'staticEntitySpecificProperty' in entity
);
await loadStaticEntities(filteredStaticEntities, component);

Copilot uses AI. Check for mistakes.
await loadMapEnvironment(component, spaceMapData);

// Load players and aliens for the new map
// Load players, aliens, and static entities for the new map
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

Initial map loading uses loadStaticEntities only and does not create portal meshes, so portals won’t be available until the map is updated. Consider invoking portal creation logic on the first load or reusing updateSpacemap flow.

Copilot uses AI. Check for mistakes.
this.scene.add(mesh);
}

public createPortal(position: THREE.Vector3, destinationMap: string): THREE.Mesh {
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

Portals created here are not tracked in staticEntities, so removeAllStaticEntities or removeStaticEntity won't remove them. You may want to store portal meshes in the manager or provide a separate cleanup method.

Copilot uses AI. Check for mistakes.
}
}

public async removeAllStaticEntities(): Promise<void> {
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

This method is marked async but contains no await expressions. You can remove async and return void for clarity.

Suggested change
public async removeAllStaticEntities(): Promise<void> {
public removeAllStaticEntities(): void {

Copilot uses AI. Check for mistakes.
Comment on lines +12 to 14
private readonly TELEPORT_DISTANCE = 5; // Distance within which player can teleport

constructor(private hubService: HubService) {
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

[nitpick] The teleport distance is hardcoded as a magic number. Consider making this configurable (e.g., via constructor parameter or app settings) for greater flexibility.

Suggested change
private readonly TELEPORT_DISTANCE = 5; // Distance within which player can teleport
constructor(private hubService: HubService) {
private readonly TELEPORT_DISTANCE: number; // Distance within which player can teleport
constructor(private hubService: HubService, teleportDistance: number = 5) {
this.TELEPORT_DISTANCE = teleportDistance;

Copilot uses AI. Check for mistakes.
console.log('Teleportation successful:', message);
});

hubService.on('teleportFailed', (error: string) => {
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

You're registering teleport event listeners in ngOnInit but not removing them in ngOnDestroy. Add corresponding off calls to prevent potential memory leaks.

Copilot uses AI. Check for mistakes.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants