import { ILocation , IWorld } from "./location" ; import { ITime , ITimeStorage , Time } from "./time" ; let game = { } ; export function InitGAME ( ) { game = { } ; } export function GAME ( ) { return game ; } export interface IGameCache { name ? : string ; version ? : number ; time ? : ITimeStorage ; flags ? : { [ index ] : number ; } ; } let gameCache = { } ; export function SetGameCache ( c ) { gameCache = c ; } export function GameCache ( ) { return gameCache ; } const world = { SaveSpots : { } , } ; export function WORLD ( ) { return world ; } let worldTime ; export function InitWorldTime ( time ) { worldTime = time ; } export function WorldTime ( ) { return worldTime ; } export function MoveToLocation ( location , timestep ? , preventClear ? ) { const oldLocation = game . party . location ; game . party . location = location ; timestep = timestep || new Time ( ) ; TimeStep ( timestep ) ; location . onEntry ( preventClear , oldLocation ) ; } export function TimeStep ( step ) { worldTime . Inc ( step ) ; for ( const ent of entityStorage ) { if ( ent . Update ) { ent . Update ( step ) ; } } } export function StepToHour ( hour , minute = 0 ) { const step = worldTime . TimeToHour ( hour , minute ) ; TimeStep ( step ) ; return step ; } let entityStorage = new Array ( ) ; export function EntityStorage ( ) { return entityStorage ; } export function InitEntityStorage ( ) { entityStorage = new Array ( ) ; } let cavalcade ; export function SetCavalcade ( c ) { cavalcade = c ; } export function GetCavalcade ( ) { return cavalcade ; } const nav = { } ; export function NAV ( ) { return nav ; }