add robust fixture rendering
This commit is contained in:
parent
ef2d067b38
commit
cf4e8024af
13 changed files with 140 additions and 64 deletions
|
@ -1,36 +1,35 @@
|
|||
'use strict';
|
||||
|
||||
const traits = require('../../traits/fixtures.json');
|
||||
|
||||
class Fixture {
|
||||
constructor(mount, data) {
|
||||
this.type = data.type;
|
||||
this.id = data.id;
|
||||
this.rof = data.rateOfFire;
|
||||
|
||||
this.state = 0;
|
||||
this.projectiles = new Set();
|
||||
this._angle = mount.traversal ? mount.traversal.cw : 0;
|
||||
|
||||
this.mount = mount;
|
||||
|
||||
this.projectiles = new WeakSet();
|
||||
|
||||
let turretTraits = traits[data.type];
|
||||
|
||||
console.log(turretTraits);
|
||||
|
||||
this.rof = turretTraits.rateOfFire;
|
||||
|
||||
this.traversal = this.mount.traversal || false;
|
||||
this.fired = false;
|
||||
this._angle = this.traversal ? this.traversal.cw : 0;
|
||||
}
|
||||
|
||||
destruct() {
|
||||
this.projectiles.forEach(p => p.world.removeBody(p));
|
||||
}
|
||||
|
||||
fire() {
|
||||
|
||||
}
|
||||
|
||||
packFull() {
|
||||
return {
|
||||
traversal: this.traversal
|
||||
traversal: this.traversal,
|
||||
angle: this.angle
|
||||
}
|
||||
}
|
||||
|
||||
packDelta() {
|
||||
return [this.traversal];
|
||||
|
||||
}
|
||||
|
||||
get angle() {
|
||||
|
@ -39,7 +38,7 @@ class Fixture {
|
|||
|
||||
set angle(angle) {
|
||||
// TODO: Check if within traversal limit if on mount.
|
||||
if (this.type == 'fixed') return;
|
||||
if (this.mount.type == 'fixed') return;
|
||||
this._angle = angle;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue