add boilerplate for mounts and fixtures
This commit is contained in:
parent
0ea163dfb7
commit
0a90b6b77a
15 changed files with 158 additions and 17 deletions
20
server/game/room/world/body/turret/blaster.js
Normal file
20
server/game/room/world/body/turret/blaster.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
|
||||
const Fixture = require('./fixture.js');
|
||||
const Laser = require('./shot/laser.js');
|
||||
|
||||
class Blaster extends Fixture {
|
||||
constructor(hardpoint, data) {
|
||||
super(hardpoint, data);
|
||||
}
|
||||
|
||||
fire() {
|
||||
wingbase.debug('pew pew');
|
||||
let data = {
|
||||
speed: 1
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Blaster;
|
34
server/game/room/world/body/turret/fixture.js
Normal file
34
server/game/room/world/body/turret/fixture.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
'use strict';
|
||||
|
||||
const traits = require('../../traits/turrets.json');
|
||||
|
||||
class Fixture {
|
||||
constructor(hardpoint, data) {
|
||||
this.hardpoint = hardpoint;
|
||||
|
||||
this.projectiles = new WeakSet();
|
||||
|
||||
let turretTraits = traits[data.type];
|
||||
|
||||
this.rof = turretTraits.rateOfFire;
|
||||
|
||||
this.traversal = this.hardpoint.traversal || false;
|
||||
this._angle = this.traversal ? this.traversal.cw : 0;
|
||||
}
|
||||
|
||||
destruct() {
|
||||
this.projectiles.forEach(p => p.world.removeBody(p));
|
||||
}
|
||||
|
||||
get angle() {
|
||||
return this._angle;
|
||||
}
|
||||
|
||||
set angle(angle) {
|
||||
// TODO: Check if within traversal limit if on mount.
|
||||
if (this.type == 'fixed') return;
|
||||
this._angle = angle;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Fixture;
|
24
server/game/room/world/body/turret/mount.js
Normal file
24
server/game/room/world/body/turret/mount.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
|
||||
const Blaster = require('./blaster.js');
|
||||
|
||||
class Mount {
|
||||
constructor(ship, data, fixture) {
|
||||
this.ship = ship;
|
||||
|
||||
this.type = data.type || 'turret';
|
||||
this.fixture = false; // TODO: Create fixture.
|
||||
|
||||
this.traversal = data.traversal ? {
|
||||
cw: data.bounds[0],
|
||||
ccw: data.bounds[1]
|
||||
} : false;
|
||||
}
|
||||
|
||||
destruct() {
|
||||
if (!this.fixture) return;
|
||||
this.fixture.destruct();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Mount;
|
11
server/game/room/world/body/turret/shot/beam.js
Normal file
11
server/game/room/world/body/turret/shot/beam.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
const Shot = require('./shot.js');
|
||||
|
||||
class Beam extends Shot {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Beam;
|
11
server/game/room/world/body/turret/shot/bullet.js
Normal file
11
server/game/room/world/body/turret/shot/bullet.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
const Shot = require('./shot.js');
|
||||
|
||||
class Bullet extends Shot {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Bullet;
|
11
server/game/room/world/body/turret/shot/laser.js
Normal file
11
server/game/room/world/body/turret/shot/laser.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
const Shot = require('./shot.js');
|
||||
|
||||
class Laser extends Shot {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Laser;
|
9
server/game/room/world/body/turret/shot/shot.js
Normal file
9
server/game/room/world/body/turret/shot/shot.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
class Shot {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Shot;
|
Loading…
Add table
Add a link
Reference in a new issue