mirror of
https://github.com/Terncode/pixel.horse.git
synced 2026-09-25 06:05:52 +02:00
29 lines
663 B
TypeScript
29 lines
663 B
TypeScript
import { Controller, ServerEntity, ServerMap } from '../serverInterfaces';
|
|
import { timingStart, timingEnd } from '../timing';
|
|
|
|
export class UpdateController implements Controller {
|
|
private updatables: ServerEntity[] = [];
|
|
constructor(private map: ServerMap) {
|
|
}
|
|
initialize() {
|
|
this.updatables = [];
|
|
|
|
for (const region of this.map.regions) {
|
|
for (const entity of region.entities) {
|
|
if (entity.serverUpdate) {
|
|
this.updatables.push(entity);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
update(delta: number, now: number) {
|
|
timingStart('TorchController.update()');
|
|
|
|
for (const entity of this.updatables) {
|
|
entity.serverUpdate!(delta, now);
|
|
}
|
|
|
|
timingEnd();
|
|
}
|
|
}
|