@@ -4,7 +4,7 @@ import { seed } from "../util/random.ts"
44import { floorN , modulo } from "../util/math.ts"
55import { loadImage } from "../util/load.ts"
66import type { Dir , IBox } from "./types.ts"
7- import type { ItemType , LoadOptions , PropType as PropType } from "./types.ts"
7+ import type { LoadOptions } from "./types.ts"
88import {
99 ActorDefinition ,
1010 Catalog ,
@@ -33,7 +33,6 @@ export class ItemSpawn implements IBox {
3333 readonly id : string
3434 readonly i : number
3535 readonly j : number
36- readonly type : ItemType
3736 readonly def : ItemDefinition
3837 readonly x : number
3938 readonly y : number
@@ -42,28 +41,26 @@ export class ItemSpawn implements IBox {
4241 constructor (
4342 i : number ,
4443 j : number ,
45- type : ItemType ,
4644 def : ItemDefinition ,
4745 ) {
48- this . id = `${ i } .${ j } .${ type } ` // Unique ID for the spawn
46+ this . id = `${ i } .${ j } .${ def . type } ` // Unique ID for the spawn
4947 this . i = i
5048 this . j = j
51- this . type = type
5249 this . def = def
5350 this . x = i * CELL_SIZE
5451 this . y = j * CELL_SIZE
5552 }
5653
5754 equals ( other : ItemSpawn ) : boolean {
5855 return this . i === other . i && this . j === other . j &&
59- this . type === other . type
56+ this . def . type === other . def . type
6057 }
6158
6259 toJSON ( ) : BlockMapSource [ "items" ] [ number ] {
6360 return {
6461 i : this . i ,
6562 j : this . j ,
66- type : this . type ,
63+ type : this . def . type ,
6764 }
6865 }
6966}
@@ -73,7 +70,6 @@ export class PropSpawn implements IBox {
7370 readonly id : string
7471 readonly i : number
7572 readonly j : number
76- readonly type : PropType
7773 readonly def : PropDefinition
7874 readonly x : number
7975 readonly y : number
@@ -83,14 +79,12 @@ export class PropSpawn implements IBox {
8379 constructor (
8480 i : number ,
8581 j : number ,
86- type : PropType ,
8782 def : PropDefinition ,
8883 data : unknown ,
8984 ) {
90- this . id = `${ i } .${ j } .${ type } ` // Unique ID for the spawn
85+ this . id = `${ i } .${ j } .${ def . type } ` // Unique ID for the spawn
9186 this . i = i
9287 this . j = j
93- this . type = type
9488 this . data = data
9589 this . def = def
9690 this . x = i * CELL_SIZE
@@ -99,14 +93,14 @@ export class PropSpawn implements IBox {
9993
10094 equals ( other : PropSpawn ) : boolean {
10195 return this . i === other . i && this . j === other . j &&
102- this . type === other . type
96+ this . def . type === other . def . type
10397 }
10498
10599 toJSON ( ) : BlockMapSource [ "props" ] [ number ] {
106100 const json : BlockMapSource [ "props" ] [ number ] = {
107101 i : this . i ,
108102 j : this . j ,
109- type : this . type ,
103+ type : this . def . type ,
110104 }
111105 if ( this . data !== undefined ) {
112106 json . data = this . data
@@ -329,15 +323,13 @@ export class BlockMap {
329323 new ItemSpawn (
330324 item . i ,
331325 item . j ,
332- item . type as ItemType ,
333326 catalog . items [ item . type ] ! ,
334327 )
335328 )
336329 this . props = ( source . props ?? [ ] ) . map ( ( prop ) =>
337330 new PropSpawn (
338331 prop . i ,
339332 prop . j ,
340- prop . type as PropType ,
341333 catalog . props [ prop . type ] ! ,
342334 prop . data ,
343335 )
0 commit comments