chore:首次提交
This commit is contained in:
+57
@@ -0,0 +1,57 @@
|
||||
import { gameManager } from './core/GameManager';
|
||||
import { GameScene } from './scenes/GameScene';
|
||||
import { injectGlobalTheme } from './ui/theme';
|
||||
import './ui/UIManager';
|
||||
import { modManager } from './mods/ModManager';
|
||||
import { dataRegistry } from './data/DataRegistry';
|
||||
|
||||
injectGlobalTheme();
|
||||
|
||||
async function initGame(): Promise<void> {
|
||||
modManager.loadConfig();
|
||||
|
||||
await loadExampleMods();
|
||||
await dataRegistry.loadAll();
|
||||
|
||||
gameManager.init(
|
||||
{
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
parent: 'game-container',
|
||||
},
|
||||
[GameScene]
|
||||
);
|
||||
|
||||
// Handle resize
|
||||
window.addEventListener('resize', () => {
|
||||
const game = gameManager.getGame();
|
||||
if (game) {
|
||||
game.scale.resize(window.innerWidth, window.innerHeight);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('OES-WEB initialized');
|
||||
}
|
||||
|
||||
async function loadExampleMods(): Promise<void> {
|
||||
const mods = [
|
||||
'/data/mods/example-weapons-mod.json',
|
||||
'/data/mods/example-quest-mod.json',
|
||||
'/data/mods/base-scripts-mod.json',
|
||||
];
|
||||
|
||||
for (const url of mods) {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
if (response.ok) {
|
||||
const mod = await response.json();
|
||||
await modManager.installMod(mod.manifest, mod.data, mod.scripts);
|
||||
console.log(`Loaded mod: ${mod.manifest.id}`);
|
||||
}
|
||||
} catch {
|
||||
console.log(`Mod not found: ${url}, skipping`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initGame();
|
||||
Reference in New Issue
Block a user