add boilerplate for mounts and fixtures

This commit is contained in:
Asraelite 2016-03-27 15:08:49 +01:00
parent 0ea163dfb7
commit 0a90b6b77a
15 changed files with 158 additions and 17 deletions

View 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;

View 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;

View 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;

View file

@ -0,0 +1,11 @@
'use strict';
const Shot = require('./shot.js');
class Beam extends Shot {
constructor() {
super();
}
}
module.exports = Beam;

View file

@ -0,0 +1,11 @@
'use strict';
const Shot = require('./shot.js');
class Bullet extends Shot {
constructor() {
super();
}
}
module.exports = Bullet;

View file

@ -0,0 +1,11 @@
'use strict';
const Shot = require('./shot.js');
class Laser extends Shot {
constructor() {
super();
}
}
module.exports = Laser;

View file

@ -0,0 +1,9 @@
'use strict';
class Shot {
constructor() {
}
}
module.exports = Shot;