Skip to content

[codex] Add shared time manager module#317

Draft
RSamaium wants to merge 4 commits into
v5from
feature/time-manager
Draft

[codex] Add shared time manager module#317
RSamaium wants to merge 4 commits into
v5from
feature/time-manager

Conversation

@RSamaium

@RSamaium RSamaium commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

This PR proposes a shared Time Manager design that can be registered through the existing module providers instead of adding more public methods to RpgMap.

The intended DX is:

provideServerModules([
  withTimeManager({ start: '0001-01-01 08:00', scale: 10 })
])

provideClientModules([
  withTimeManager()
])

Design

  • Adds withTimeManager() in @rpgjs/common as a shared module factory.
  • Adds TimeManager in @rpgjs/server for authoritative server-side time control.
  • Adds ClientTimeManager in @rpgjs/client for local display projection.
  • Stores the synchronized map snapshot in an internal namespaced field, __rpgjsTime.
  • Keeps the client non-authoritative: it infers display time from elapsedMinutes, scale, paused, and serverTimestamp.
  • Keeps RpgMap public API unchanged.
  • Supports calendars, pause/resume, scale changes, manual time setting, time advancement, and optional lighting integration through existing lighting APIs.

Developer Impact

Game code can register one shared module on both client and server while using focused services for behavior:

const time = inject(TimeManager)
time.set({ hour: 22, minute: 30 })
time.pause()
time.resume()
const time = inject(ClientTimeManager)
const now = time.state()

Documentation

Adds docs/guide/time-manager.md and links it near the existing lighting/weather guides.

Validation

  • pnpm vitest run packages/server/tests/time-manager.spec.ts
  • pnpm vitest run packages/server/tests/lighting.spec.ts packages/client/src/i18n.spec.ts packages/server/tests/module.spec.ts
  • pnpm --dir packages/common build
  • pnpm --dir packages/server build
  • pnpm --dir packages/client build

@mintlify

mintlify Bot commented Jul 2, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
rpgjs 🟢 Ready View Preview Jul 2, 2026, 12:18 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

RSamaium added 3 commits July 2, 2026 15:04
- Added client entry point with game configuration and server integration.
- Created map component with grid lines, HUD elements, and event layer.
- Implemented time HUD component displaying current time, date, and weather.
- Configured client settings including keyboard controls and map loading.
- Defined main module for client and server interactions.
- Developed server module with player hooks and weather pedestal event.
- Introduced time management module with calendar and lighting settings.
- Set up server entry point for game execution.
- Configured Vite for development with RPG.js integration.
- Added TypeScript definitions for custom file extensions.
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.

1 participant