-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlevel.js
More file actions
100 lines (95 loc) · 2.44 KB
/
Copy pathlevel.js
File metadata and controls
100 lines (95 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
class Level
{
name;
lumps;
rootNode;
linedefs;
sidedefs;
vertexes;
segs;
subsectors;
nodes;
sectors;
things;
constructor(name)
{
this.name = name;
this.initializeLumps();
this.rootNode = new Node(this.lumps,this);
var j = Math.floor(this.lumps.things.lumpLength / 10);
for(var i = 0; i < j; i++)
{
this.getThing(i);
}
}
getNode(i)
{
if(!this.nodes) this.nodes = [];
if(!this.nodes[i]) this.nodes[i] = new Node(this.lumps, this, i);
return this.nodes[i];
}
getSubsector(i)
{
if(!this.subsectors) this.subsectors = [];
if(!this.subsectors[i]) this.subsectors[i] = new Subsector(this.lumps, this, i);
return this.subsectors[i];
}
getSeg(i)
{
if(!this.segs) this.segs = [];
if(!this.segs[i]) this.segs[i] = new Seg(this.lumps, this, i);
return this.segs[i];
}
getVertex(i)
{
if(!this.vertexes) this.vertexes = [];
if(!this.vertexes[i]) this.vertexes[i] = new Vertex(this.lumps, this, i);
return this.vertexes[i];
}
getLinedef(i)
{
if(!this.linedefs) this.linedefs = [];
if(!this.linedefs[i]) this.linedefs[i] = new Linedef(this.lumps, this, i);
return this.linedefs[i];
}
getSidedef(i)
{
if(!this.sidedefs) this.sidedefs = [];
if(!this.sidedefs[i]) this.sidedefs[i] = new Sidedef(this.lumps, this, i);
return this.sidedefs[i];
}
getSector(i)
{
if(!this.sectors) this.sectors = [];
if(!this.sectors[i]) this.sectors[i] = new Sector(this.lumps, this, i);
return this.sectors[i];
}
getThing(i)
{
if(!this.things) this.things = [];
if(!this.things[i]) this.things[i] = new Thing(this.lumps, this, i);
return this.things[i];
}
getFirstThing(type)
{
for(var i = 0; i < this.things.length; i++)
{
var t = this.getThing(i);
if(t && t.type == type) return t;
}
}
initializeLumps()
{
this.lumps = {};
this.lumps.things = wad.getFirstLumpAfter("THINGS", this.name);
this.lumps.linedefs = wad.getFirstLumpAfter("LINEDEFS", this.name);
this.lumps.sidedefs = wad.getFirstLumpAfter("SIDEDEFS", this.name);
this.lumps.vertexes = wad.getFirstLumpAfter("VERTEXES", this.name);
this.lumps.segs = wad.getFirstLumpAfter("SEGS", this.name);
this.lumps.ssectors = wad.getFirstLumpAfter("SSECTORS", this.name);
this.lumps.nodes = wad.getFirstLumpAfter("NODES", this.name);
this.lumps.sectors = wad.getFirstLumpAfter("SECTORS", this.name);
this.lumps.reject = wad.getFirstLumpAfter("REJECT", this.name);
this.lumps.blockmap = wad.getFirstLumpAfter("BLOCKMAP", this.name);
}
}