refactor(vite-plugins): ♻️ Optimize simCachePlugin caching/simulation logic for better performance
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
5e85b094df
commit
b63bc38663
1 changed files with 4 additions and 8 deletions
|
|
@ -15,7 +15,7 @@ export function simCachePlugin(): Plugin {
|
|||
const cache = new Map<string, { stats: unknown[]; events: unknown[][] }>()
|
||||
let engineModule: typeof import('@magic-civ/engine-ts') | null = null
|
||||
let terrainData: Record<string, unknown> | null = null
|
||||
let climateParams: Record<string, number> | null = null
|
||||
let climateParams: Record<string, unknown> | null = null
|
||||
|
||||
function loadGameData(root: string): void {
|
||||
const dataDir = path.resolve(root, '../../games/age-of-dwarves/data')
|
||||
|
|
@ -32,13 +32,9 @@ export function simCachePlugin(): Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
// Load climate params (extract only numeric values) — from world definition
|
||||
const paramsPath = path.resolve(root, '../../engine/src/worlds/earth/climate_params.json')
|
||||
const rawParams = JSON.parse(fs.readFileSync(paramsPath, 'utf8')) as Record<string, unknown>
|
||||
climateParams = {}
|
||||
for (const [k, v] of Object.entries(rawParams)) {
|
||||
if (typeof v === 'number') climateParams[k] = v
|
||||
}
|
||||
// Load climate params from world definition
|
||||
const paramsPath = path.resolve(root, '../../resources/worlds/earth/climate_params.json')
|
||||
climateParams = JSON.parse(fs.readFileSync(paramsPath, 'utf8')) as Record<string, unknown>
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue