Fix CS
This commit is contained in:
parent
2484e4f1df
commit
d48d5b0285
@ -19,7 +19,7 @@ export class MapController {
|
||||
// Returns a map mapping map name to file name of the map
|
||||
getStartMap() {
|
||||
this.App.get("/start-map", (req: Request, res: Response) => {
|
||||
let url = req.headers.host?.replace('api.', 'maps.') + URL_ROOM_STARTED;
|
||||
const url = req.headers.host?.replace('api.', 'maps.') + URL_ROOM_STARTED;
|
||||
res.status(OK).send({
|
||||
mapUrlStart: url,
|
||||
startInstance: "global"
|
||||
|
@ -252,11 +252,11 @@ export class GameScene extends Phaser.Scene {
|
||||
})
|
||||
|
||||
// Scan the object layers for objects to load and load them.
|
||||
let objects = new Map<string, ITiledMapObject[]>();
|
||||
const objects = new Map<string, ITiledMapObject[]>();
|
||||
|
||||
for (let layer of this.mapFile.layers) {
|
||||
for (const layer of this.mapFile.layers) {
|
||||
if (layer.type === 'objectgroup') {
|
||||
for (let object of layer.objects) {
|
||||
for (const object of layer.objects) {
|
||||
let objectsOfType: ITiledMapObject[]|undefined;
|
||||
if (!objects.has(object.type)) {
|
||||
objectsOfType = new Array<ITiledMapObject>();
|
||||
@ -272,16 +272,17 @@ export class GameScene extends Phaser.Scene {
|
||||
}
|
||||
}
|
||||
|
||||
for (let [itemType, objectsOfType] of objects) {
|
||||
for (const [itemType, objectsOfType] of objects) {
|
||||
// FIXME: we would ideally need for the loader to WAIT for the import to be performed, which means writing our own loader plugin.
|
||||
|
||||
let itemFactory: ItemFactoryInterface;
|
||||
|
||||
switch (itemType) {
|
||||
case 'computer':
|
||||
let module = await import('../Items/Computer/computer');
|
||||
itemFactory = module.default as ItemFactoryInterface;
|
||||
case 'computer': {
|
||||
const module = await import('../Items/Computer/computer');
|
||||
itemFactory = module.default;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new Error('Unsupported object type: "'+ itemType +'"');
|
||||
}
|
||||
@ -295,9 +296,9 @@ export class GameScene extends Phaser.Scene {
|
||||
this.createPromise.then(() => {
|
||||
itemFactory.create(this);
|
||||
|
||||
for (let object of objectsOfType) {
|
||||
for (const object of objectsOfType) {
|
||||
// TODO: we should pass here a factory to create sprites (maybe?)
|
||||
let actionableItem = itemFactory.factory(this, object);
|
||||
const actionableItem = itemFactory.factory(this, object);
|
||||
this.actionableItems.push(actionableItem);
|
||||
}
|
||||
});
|
||||
@ -675,8 +676,8 @@ export class GameScene extends Phaser.Scene {
|
||||
|
||||
let shortestDistance: number = Infinity;
|
||||
let selectedItem: ActionableItem|null = null;
|
||||
for (let item of this.actionableItems) {
|
||||
let distance = item.actionableDistance(x, y);
|
||||
for (const item of this.actionableItems) {
|
||||
const distance = item.actionableDistance(x, y);
|
||||
if (distance !== null && distance < shortestDistance) {
|
||||
shortestDistance = distance;
|
||||
selectedItem = item;
|
||||
|
@ -18,7 +18,7 @@ export class ActionableItem {
|
||||
* OR null if we are out of range.
|
||||
*/
|
||||
public actionableDistance(x: number, y: number): number|null {
|
||||
let distanceSquared = (x - this.sprite.x)*(x - this.sprite.x) + (y - this.sprite.y)*(y - this.sprite.y);
|
||||
const distanceSquared = (x - this.sprite.x)*(x - this.sprite.x) + (y - this.sprite.y)*(y - this.sprite.y);
|
||||
if (distanceSquared < this.activationRadiusSquared) {
|
||||
return distanceSquared;
|
||||
} else {
|
||||
|
@ -15,7 +15,7 @@ export default {
|
||||
},
|
||||
factory: (scene: GameScene, object: ITiledMapObject): ActionableItem => {
|
||||
// Idée: ESSAYER WebPack? https://paultavares.wordpress.com/2018/07/02/webpack-how-to-generate-an-es-module-bundle/
|
||||
let foo = new Sprite(scene, object.x, object.y, 'computer');
|
||||
const foo = new Sprite(scene, object.x, object.y, 'computer');
|
||||
scene.add.existing(foo);
|
||||
|
||||
return new ActionableItem(foo, 32);
|
||||
|
@ -27,7 +27,7 @@ const config: GameConfig = {
|
||||
callbacks: {
|
||||
postBoot: game => {
|
||||
// FIXME: we should fore WebGL in the config.
|
||||
let renderer = game.renderer as WebGLRenderer;
|
||||
const renderer = game.renderer as WebGLRenderer;
|
||||
renderer.addPipeline(OutlinePipeline.KEY, new OutlinePipeline(game));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user