Skip to content

Conversation

@RSamaium
Copy link
Owner

Purpose of the Added Code

The code introduced in this pull request adds a new ViteJS plugin whose main purpose is to ensure compatibility between RPGJS v4 and RPGJS v5.

RPGJS v4 relies on a specific project structure and build behavior that does not work the same way in Vite 5. Since RPGJS v5 is built on a different engine and workflow, some features and conventions from v4 are no longer supported out of the box.

The new plugin re-implements the expected v4-style project structure and behavior on top of the v5 architecture, allowing existing projects to migrate gradually or to maintain compatibility with both versions.

Below is an example of how the plugin is meant to be used:

import { defineConfig } from 'vite';
import { compatibilityV4Plugin, rpgjs } from '@rpgjs/vite';
import path from 'path';

export default defineConfig({
    plugins: [
        compatibilityV4Plugin(),
        ...rpgjs(),
    ],
    resolve: {
        alias: {
            '@': path.resolve(__dirname, './src')
        }
    },
    server: {
        port: 3000
    }
});

The plugin also supports Tiled by default.
However, for Tiled map files to be correctly detected, they must be placed inside a tiled directory at the root of the project.

RSamaium and others added 30 commits November 27, 2025 15:40
- Updated dependencies in `pnpm-lock.yaml` including Babel packages and added new packages like `@iarna/toml`, `fs-extra`, `glob`, `image-size`, and `xml2js`.
- Added `sample-v4-compatibility` to `pnpm-workspace.yaml` for improved project structure.
- Enhanced documentation for TiledMap configuration, detailing V4 compatibility mode and manual setup instructions.
- Refactored Vite plugin exports to include compatibility features and improved server module loading logic.

These changes improve project maintainability and enhance the TiledMap integration with Vite.
- Introduced a new `starter` package in `pnpm-lock.yaml` with dependencies for RPGJS and CanvasEngine.
- Updated `pnpm-workspace.yaml` to include the `starter` package for better project organization.
- Refactored Vite compatibility plugin to improve module loading and configuration handling, including support for global configuration.
- Enhanced utility functions to resolve paths relative to the project root, improving module import handling.

These changes streamline project setup and enhance the Vite integration for RPGJS, contributing to a more efficient development experience.
- Added new type definitions for `@types/fs-extra`, `@types/jsonfile`, and `@types/xml2js` in `pnpm-lock.yaml` to enhance type safety.
- Updated `package.json` to include the new type dependencies for better development experience.
- Refactored type annotations in `server-plugin.ts`, `require-transform.ts`, and `utils.ts` to improve code clarity and maintainability.
- Fixed a typo in the import statement of `vite-plugin-tsx-xml.ts`.

These changes enhance type safety and improve the overall quality of the Vite integration, contributing to a more robust development environment.
- Added a `setupCollisionDetection` method to handle collision events between players and dynamic events.
- Implemented logic to trigger the `onPlayerTouch` hook when a player collides with an event, enhancing interactivity.
- Introduced tracking for active collisions to prevent multiple triggers for the same interaction, improving performance and responsiveness.

These changes enhance gameplay by allowing players to interact with events through collisions, contributing to a more engaging experience.
- Introduced the ability to attach shapes to players using the new `attachShape` method, enhancing interaction with the physics engine.
- Implemented methods to retrieve attached shapes and shapes where the player is currently located, improving gameplay mechanics.
- Updated the `Player` and server files to integrate the new shape functionality, allowing for more dynamic player interactions.

These changes enhance the gameplay experience by enabling players to create and manage detection zones, contributing to more engaging interactions within the game world.
…gMap

- Introduced methods for creating, removing, and retrieving shapes on the map, allowing for dynamic hitbox management.
- Enhanced collision detection to trigger `onInShape` and `onOutShape` hooks for players and events interacting with shapes.
- Updated the `setupCollisionDetection` method to handle shape collisions alongside player-event interactions, improving gameplay interactivity.
- Added internal maps to manage shape entities, ensuring efficient collision handling and retrieval.

These changes significantly enhance the interaction mechanics within the game, enabling more complex gameplay scenarios and improved player engagement.
- Introduced new signals for managing player components at various positions (top, bottom, center, left, right) in the RpgCommonPlayer class.
- Implemented methods to set, merge, and remove components, allowing for dynamic UI elements around the player.
- Updated the RpgClientEngine to apply client-side prediction filtering and server reconciliation for scene updates.
- Enhanced the character component rendering logic to conditionally display player components based on available data.

These changes improve the flexibility and visual representation of player elements, contributing to a more engaging gameplay experience.
- Added a `soundResolver` function to the `RpgClient` interface for dynamically loading sounds when not found in the cache.
- Enhanced the `RpgClientEngine` to utilize the sound resolver for retrieving and playing sounds, including support for both synchronous and asynchronous loading.
- Introduced a `playSound` method in the `RpgPlayer` class to emit sound events to clients, allowing for targeted sound playback.
- Updated documentation to include comprehensive information on sound configuration and usage.

These changes significantly improve the audio experience in the game, enabling dynamic sound management and enhancing player immersion.
- Updated the `playSound` method in `RpgPlayer` to support optional volume and loop parameters, allowing for more customized sound playback for individual players.
- Introduced a new `playSound` method in `RpgMap` to play sounds for all players on the map, improving the management of environmental and event-based audio.
- Added a `stopSound` method in both `RpgPlayer` and `RpgMap` to allow for stopping sounds that were previously played, enhancing control over audio playback.
- Enhanced documentation to clarify sound configuration options and usage examples.

These changes significantly improve the audio experience, enabling more dynamic and immersive sound interactions in the game.
- Refactored the frame update logic in `RpgPlayer` to reduce unnecessary updates by grouping rapid changes, improving performance and responsiveness.
- Enhanced the `RpgClientEngine` to initialize sound functionality more efficiently by directly importing `RpgSound`, streamlining the sound loading process.
- Cleaned up the `RpgClientObject` to ensure proper handling of frame coordinates, improving the accuracy of player positioning.

These changes enhance the overall performance and audio experience in the game, contributing to smoother gameplay and better sound management.
- Updated dependencies in `pnpm-lock.yaml` including Babel packages and added new packages like `@iarna/toml`, `fs-extra`, `glob`, `image-size`, and `xml2js`.
- Added `sample-v4-compatibility` to `pnpm-workspace.yaml` for improved project structure.
- Enhanced documentation for TiledMap configuration, detailing V4 compatibility mode and manual setup instructions.
- Refactored Vite plugin exports to include compatibility features and improved server module loading logic.

These changes improve project maintainability and enhance the TiledMap integration with Vite.
- Introduced a new `starter` package in `pnpm-lock.yaml` with dependencies for RPGJS and CanvasEngine.
- Updated `pnpm-workspace.yaml` to include the `starter` package for better project organization.
- Refactored Vite compatibility plugin to improve module loading and configuration handling, including support for global configuration.
- Enhanced utility functions to resolve paths relative to the project root, improving module import handling.

These changes streamline project setup and enhance the Vite integration for RPGJS, contributing to a more efficient development experience.
- Added new type definitions for `@types/fs-extra`, `@types/jsonfile`, and `@types/xml2js` in `pnpm-lock.yaml` to enhance type safety.
- Updated `package.json` to include the new type dependencies for better development experience.
- Refactored type annotations in `server-plugin.ts`, `require-transform.ts`, and `utils.ts` to improve code clarity and maintainability.
- Fixed a typo in the import statement of `vite-plugin-tsx-xml.ts`.

These changes enhance type safety and improve the overall quality of the Vite integration, contributing to a more robust development environment.
- Upgraded `@signe` packages to version `2.5.1` in `client`, `common`, and `server` packages for improved functionality.
- Updated `@canvasengine/compiler` to version `2.0.0-beta.34` in relevant packages to ensure compatibility with the latest features.
- Increased `vite` version to `7.2.4` and `vitest` to `4.0.14` across all packages for enhanced performance and testing capabilities.
- Adjusted `vue` version to `3.5.25` in the `vue` package for the latest improvements and bug fixes.
- Updated `zod` to version `4.1.13` in the `server` package for better validation features.
- Ensured all package.json files reflect the latest dependency versions for consistency and stability.
- Introduced new item hooks for lifecycle events (onAdd, onUse, onRemove, onEquip) to allow for dynamic item behavior in the player's inventory.
- Updated the `addItem` method to support adding items as strings, classes, or objects, improving flexibility in item management.
- Enhanced the `RpgMap` class with methods to dynamically add and remove data from the map's database, allowing for more robust data handling.
- Added new properties to the `ItemData` interface, including `name`, `description`, and `price`, to standardize item attributes.
- Updated the `RpgClientEngine` to log player data during synchronization for better debugging and tracking.

These changes significantly improve the item management system, enabling more dynamic interactions and better data handling within the game.
…er component

- Removed console logging during synchronization in RpgClientEngine for cleaner output.
- Updated RpgClientObject to manage graphics signals more effectively, utilizing RxJS operators for better data flow.
- Modified character component rendering to iterate over graphics signals instead of graphic IDs, enhancing clarity and maintainability.
- Adjusted the sheet function to accept graphic objects, improving flexibility in sprite management.

These changes enhance the overall structure and performance of graphics handling within the game, contributing to a more efficient rendering process.
…eamline character rendering

- Introduced a new dynamic components system in RpgClientObject to manage and render components based on incoming data, enhancing flexibility in gameplay.
- Removed the player-components component to simplify the rendering process, directly integrating component handling within the character component.
- Updated character rendering logic to accommodate dynamic components, improving the overall structure and maintainability of the code.

These changes enhance the dynamic interaction capabilities of game objects, contributing to a more responsive and engaging player experience.
- Updated dependencies in `pnpm-lock.yaml` including Babel packages and added new packages like `@iarna/toml`, `fs-extra`, `glob`, `image-size`, and `xml2js`.
- Added `sample-v4-compatibility` to `pnpm-workspace.yaml` for improved project structure.
- Enhanced documentation for TiledMap configuration, detailing V4 compatibility mode and manual setup instructions.
- Refactored Vite plugin exports to include compatibility features and improved server module loading logic.

These changes improve project maintainability and enhance the TiledMap integration with Vite.
- Added new decorators for event and map handling to streamline event management within the game.
- Updated the RpgMap class to set event names dynamically, improving the clarity and functionality of event instances.
- Introduced a new CharaEvent class with enhanced initialization and action handling for better event interactions.

These changes improve the overall event system, enabling more dynamic gameplay experiences.
- Introduced the `attachToSprite` option in the GUI system, allowing GUIs to be rendered directly on sprites instead of as a global overlay.
- Updated the `RpgGui` class to manage the display state of attached GUIs based on server commands.
- Enhanced the character component to render attached GUIs conditionally, improving the visual interaction for tooltips and health bars.
- Added methods to control the visibility of attached GUIs from the server side, enhancing gameplay dynamics.

These changes provide a more immersive experience by integrating UI elements directly with game characters.
- Updated the technology stack in the getting started guide to reflect the latest versions of ViteJS (v7+) and NodeJS (v24+).
- Added resource management functionality by exporting the `Resource` module in the client index file and initializing it in the `RpgClientEngine`.
- Improved configuration in the sample project by including sound resources and ensuring proper handling of hitboxes.

These changes ensure compatibility with the latest technologies and enhance resource handling within the game.
- Added a new `setKeyboardControls` method in the `RpgClientEngine` to register a `KeyboardControls` instance in the dependency injection context.
- Updated the character component to automatically assign keyboard controls when a sprite is displayed, enhancing user interaction.
- Introduced a `Control` enum in the `Player` module to standardize control actions, improving code clarity and maintainability.
- Enhanced the `provideMmorpg` and `provideRpg` functions to include keyboard controls, ensuring they are available throughout the application.

These changes improve gameplay by providing a structured way to manage keyboard interactions, making the game more responsive to player inputs.
- Renamed the 'Quick Start' section to 'Guide' for better clarity.
- Added new items to the guide menu, including 'Spritesheets', 'World Maps', 'Items', 'Sounds', 'Synchronization', and 'Attach GUI'.
- Expanded the GUI menu with 'Dialog Box' and 'Vue Integration' options.
- Enhanced the advanced menu by including 'Latency Simulation' and 'Packet Loss Simulation'.

These changes improve the organization and comprehensiveness of the documentation, making it easier for users to navigate and find relevant information.
- Updated dependencies in `pnpm-lock.yaml` including Babel packages and added new packages like `@iarna/toml`, `fs-extra`, `glob`, `image-size`, and `xml2js`.
- Added `sample-v4-compatibility` to `pnpm-workspace.yaml` for improved project structure.
- Enhanced documentation for TiledMap configuration, detailing V4 compatibility mode and manual setup instructions.
- Refactored Vite plugin exports to include compatibility features and improved server module loading logic.

These changes improve project maintainability and enhance the TiledMap integration with Vite.
- Updated dependencies in `pnpm-lock.yaml` including Babel packages and added new packages like `@iarna/toml`, `fs-extra`, `glob`, `image-size`, and `xml2js`.
- Added `sample-v4-compatibility` to `pnpm-workspace.yaml` for improved project structure.
- Enhanced documentation for TiledMap configuration, detailing V4 compatibility mode and manual setup instructions.
- Refactored Vite plugin exports to include compatibility features and improved server module loading logic.

These changes improve project maintainability and enhance the TiledMap integration with Vite.
- Introduced a new `starter` package in `pnpm-lock.yaml` with dependencies for RPGJS and CanvasEngine.
- Updated `pnpm-workspace.yaml` to include the `starter` package for better project organization.
- Refactored Vite compatibility plugin to improve module loading and configuration handling, including support for global configuration.
- Enhanced utility functions to resolve paths relative to the project root, improving module import handling.

These changes streamline project setup and enhance the Vite integration for RPGJS, contributing to a more efficient development experience.
- Added new type definitions for `@types/fs-extra`, `@types/jsonfile`, and `@types/xml2js` in `pnpm-lock.yaml` to enhance type safety.
- Updated `package.json` to include the new type dependencies for better development experience.
- Refactored type annotations in `server-plugin.ts`, `require-transform.ts`, and `utils.ts` to improve code clarity and maintainability.
- Fixed a typo in the import statement of `vite-plugin-tsx-xml.ts`.

These changes enhance type safety and improve the overall quality of the Vite integration, contributing to a more robust development environment.
- Updated dependencies in `pnpm-lock.yaml` including Babel packages and added new packages like `@iarna/toml`, `fs-extra`, `glob`, `image-size`, and `xml2js`.
- Added `sample-v4-compatibility` to `pnpm-workspace.yaml` for improved project structure.
- Enhanced documentation for TiledMap configuration, detailing V4 compatibility mode and manual setup instructions.
- Refactored Vite plugin exports to include compatibility features and improved server module loading logic.

These changes improve project maintainability and enhance the TiledMap integration with Vite.
- Introduced a new `starter` package in `pnpm-lock.yaml` with dependencies for RPGJS and CanvasEngine.
- Updated `pnpm-workspace.yaml` to include the `starter` package for better project organization.
- Refactored Vite compatibility plugin to improve module loading and configuration handling, including support for global configuration.
- Enhanced utility functions to resolve paths relative to the project root, improving module import handling.

These changes streamline project setup and enhance the Vite integration for RPGJS, contributing to a more efficient development experience.
- Added new type definitions for `@types/fs-extra`, `@types/jsonfile`, and `@types/xml2js` in `pnpm-lock.yaml` to enhance type safety.
- Updated `package.json` to include the new type dependencies for better development experience.
- Refactored type annotations in `server-plugin.ts`, `require-transform.ts`, and `utils.ts` to improve code clarity and maintainability.
- Fixed a typo in the import statement of `vite-plugin-tsx-xml.ts`.

These changes enhance type safety and improve the overall quality of the Vite integration, contributing to a more robust development environment.
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