diff --git a/server/game/room/world/body/bay/bay.js b/server/game/room/world/body/bay/bay.js new file mode 100644 index 0000000..c35da9b --- /dev/null +++ b/server/game/room/world/body/bay/bay.js @@ -0,0 +1,9 @@ +'use strict'; + +class Bay { + constructor() { + + } +} + +module.exports = Bay; diff --git a/server/game/room/world/body/body.js b/server/game/room/world/body/body.js index aaabfd9..9d07587 100644 --- a/server/game/room/world/body/body.js +++ b/server/game/room/world/body/body.js @@ -2,7 +2,7 @@ const uuid = require('uuid'); -const Mount = require('./turret/mount.js'); +const Hardpoint = require('./hardpoint/hardpoint.js'); const b2Vec2 = require('box2d-html5').b2Vec2; @@ -21,12 +21,12 @@ class Body { this.r = data.r || 0; this.rvel = data.rvel || 0; - this.mounts = data.mounts || []; + this.hardpoints = data.hardpoints || []; this.fixtures = data.fixtures || []; this.health = data.health || 1; - this.mounts = this.mounts.map((m, i) => { + this.hardpoints = this.hardpoints.map((m, i) => { let fixture = this.fixtures[i]; - return new Mount(this, m, fixture); + return new Hardpoint(this, m, fixture); }); this.interface = { @@ -44,7 +44,7 @@ class Body { 'angle', 'state' ], - num: this.mounts.length + num: this.hardpoints.length } }; @@ -52,7 +52,7 @@ class Body { } destruct() { - this.mounts.forEach(mount => mount.destruct()); + this.hardpoints.forEach(hardpoint => hardpoint.destruct()); this.world.physics.remove(this); this.destructType(); @@ -113,7 +113,7 @@ class Body { if(pos.y < bounds.top) this.applyForce(0, 0.03); if(pos.y > bounds.bottom) this.applyForce(-0, -0.03); - this.mounts.forEach(m => m.tick()); + this.hardpoints.forEach(m => m.tick()); this.sleepTime++; @@ -129,7 +129,7 @@ class Body { let values = [this.id, pos.x, pos.y, vel.x, vel.y, pos.r, vel.r]; values = values.concat(this.packTypeDelta()); - this.mounts.forEach(m => [].push.apply(values, m.packDelta())); + this.hardpoints.forEach(m => [].push.apply(values, m.packDelta())); return values; } @@ -145,7 +145,7 @@ class Body { class: this.class, id: this.id, frame: this.frame, - fixtures: this.mounts.map(m => m.packFull()), + fixtures: this.hardpoints.map(m => m.packFull()), delta: this.packDelta(), interface: this.interface }; diff --git a/server/game/room/world/body/turret/blaster.js b/server/game/room/world/body/hardpoint/blaster.js similarity index 82% rename from server/game/room/world/body/turret/blaster.js rename to server/game/room/world/body/hardpoint/blaster.js index edec002..d724ea2 100644 --- a/server/game/room/world/body/turret/blaster.js +++ b/server/game/room/world/body/hardpoint/blaster.js @@ -1,7 +1,7 @@ 'use strict'; const Fixture = require('./fixture.js'); -const Laser = require('./discharge/laser.js'); +const Laser = require('../../particle/laser.js'); class Blaster extends Fixture { constructor(mount, data) { diff --git a/server/game/room/world/body/turret/fixture.js b/server/game/room/world/body/hardpoint/fixture.js similarity index 100% rename from server/game/room/world/body/turret/fixture.js rename to server/game/room/world/body/hardpoint/fixture.js diff --git a/server/game/room/world/body/turret/grapple.js b/server/game/room/world/body/hardpoint/grapple.js similarity index 100% rename from server/game/room/world/body/turret/grapple.js rename to server/game/room/world/body/hardpoint/grapple.js diff --git a/server/game/room/world/body/turret/mount.js b/server/game/room/world/body/hardpoint/hardpoint.js similarity index 96% rename from server/game/room/world/body/turret/mount.js rename to server/game/room/world/body/hardpoint/hardpoint.js index 6cf1be6..2c78233 100644 --- a/server/game/room/world/body/turret/mount.js +++ b/server/game/room/world/body/hardpoint/hardpoint.js @@ -5,7 +5,7 @@ const Grapple = require('./grapple.js'); const traits = require('../../traits/fixtures.json'); -class Mount { +class Hardpoint { constructor(body, data, fixture) { this.body = body; @@ -84,4 +84,4 @@ class Mount { } } -module.exports = Mount; +module.exports = Hardpoint; diff --git a/server/game/room/world/body/ship.js b/server/game/room/world/body/ship.js index 2aeaa06..395c719 100644 --- a/server/game/room/world/body/ship.js +++ b/server/game/room/world/body/ship.js @@ -62,7 +62,7 @@ class Ship extends Body { this.thrust.right = packet.thrust[2]; packet.fire.forEach((m, i) => { - m ? this.mounts[i].fire(m) : this.mounts[i].rest(); + m ? this.hardpoints[i].fire(m) : this.hardpoints[i].rest(); }); } diff --git a/server/game/room/world/body/turret/discharge/beam.js b/server/game/room/world/body/turret/discharge/beam.js deleted file mode 100644 index a34f982..0000000 --- a/server/game/room/world/body/turret/discharge/beam.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -const Discharge = require('./discharge.js'); - -class Beam extends Discharge { - constructor() { - super(); - } -} - -module.exports = Beam; diff --git a/server/game/room/world/body/turret/discharge/bullet.js b/server/game/room/world/body/turret/discharge/bullet.js deleted file mode 100644 index 789a7ab..0000000 --- a/server/game/room/world/body/turret/discharge/bullet.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -const Discharge = require('./discharge.js'); - -class Bullet extends Discharge { - constructor() { - super(); - } -} - -module.exports = Bullet; diff --git a/server/game/room/world/index.js b/server/game/room/world/index.js index f786ed9..7ddb6a2 100644 --- a/server/game/room/world/index.js +++ b/server/game/room/world/index.js @@ -11,7 +11,7 @@ class World { this.physics = new Physics(); this.spawner = new Spawner(this); this.bodies = new Set(); - this.discharges = new Set(); + this.particles = new Set(); this.asteroids = new Set(); this.copulae = new Set(); this.players = new Set(); @@ -66,9 +66,9 @@ class World { projectile.connect(); } - addDischarge(discharge) { - this.discharges.add(discharge); - this.room.broadcast('create', discharge.packFull()); + addParticle(particle) { + this.particles.add(particle); + this.room.broadcast('create', particle.packFull()); } addBody(body) { @@ -149,9 +149,9 @@ class World { this.room.broadcast('destroy', copula.id); } - removeDischarge(discharge) { - this.discharges.delete(discharge); - this.room.broadcast('destroy', discharge.id); + removeParticle(particle) { + this.particles.delete(particle); + this.room.broadcast('destroy', particle.id); } weld(bodyA, bodyB, point) { @@ -187,7 +187,7 @@ class World { tickBodies(this.asteroids, 1, 100); tickBodies(this.projectiles, 1); - this.discharges.forEach(d => d.tick()); + this.particles.forEach(d => d.tick()); if (Date.now() - this.tpsStart > 5000) { this.tps = this.tpsCount / 5 | 0; diff --git a/server/game/room/world/particle/beam.js b/server/game/room/world/particle/beam.js new file mode 100644 index 0000000..66452e4 --- /dev/null +++ b/server/game/room/world/particle/beam.js @@ -0,0 +1,11 @@ +'use strict'; + +const Particle = require('./particle.js'); + +class Beam extends Particle { + constructor() { + super(); + } +} + +module.exports = Beam; diff --git a/server/game/room/world/particle/bullet.js b/server/game/room/world/particle/bullet.js new file mode 100644 index 0000000..daa5dc9 --- /dev/null +++ b/server/game/room/world/particle/bullet.js @@ -0,0 +1,11 @@ +'use strict'; + +const Particle = require('./particle.js'); + +class Bullet extends Particle { + constructor() { + super(); + } +} + +module.exports = Bullet; diff --git a/server/game/room/world/body/turret/discharge/laser.js b/server/game/room/world/particle/laser.js similarity index 56% rename from server/game/room/world/body/turret/discharge/laser.js rename to server/game/room/world/particle/laser.js index 750adb5..64afdaf 100644 --- a/server/game/room/world/body/turret/discharge/laser.js +++ b/server/game/room/world/particle/laser.js @@ -1,8 +1,8 @@ 'use strict'; -const Discharge = require('./discharge.js'); +const Particle = require('./particle.js'); -class Laser extends Discharge { +class Laser extends Particle { constructor(fixture, data) { super(fixture, data); } diff --git a/server/game/room/world/body/turret/discharge/discharge.js b/server/game/room/world/particle/particle.js similarity index 78% rename from server/game/room/world/body/turret/discharge/discharge.js rename to server/game/room/world/particle/particle.js index 6c3ca16..5f47308 100644 --- a/server/game/room/world/body/turret/discharge/discharge.js +++ b/server/game/room/world/particle/particle.js @@ -1,6 +1,6 @@ 'use strict'; -class Discharge { +class Particle { constructor(fixture, data) { this.x = data.x; this.y = data.y; @@ -17,7 +17,7 @@ class Discharge { } destroy() { - this.world.removeDischarge(this); + this.world.removeParticle(this); } contact(body, point) { @@ -31,7 +31,7 @@ class Discharge { } packDelta() { - // TODO: Implement some sort of delta interface for discharges that is + // TODO: Implement some sort of delta interface for particles that is // derived from the fixture so it's efficient. return [this.id, this.x, this.y]; } @@ -40,7 +40,7 @@ class Discharge { // TODO: Create creation interface using fixture then send this as // an array. return { - form: 'discharge', + form: 'particle', id: this.id, x: this.x, y: this.y, @@ -52,28 +52,20 @@ class Discharge { } tick() { - let start = { - x: this.x, - y: this.y - }; + let start = { x: this.x, y: this.y }; this.x += this.xvel; this.y += this.yvel - let end = { - x: this.x, - y: this.y - }; - + let end = { x: this.x, y: this.y }; let contact = this.world.physics.raycast(start, end); - if (contact) { + if (contact) this.contact(contact.body, contact.point); - } if (this.lifetime-- <= 0) this.destroy(); } } -module.exports = Discharge; +module.exports = Particle; diff --git a/server/game/room/world/spawner.js b/server/game/room/world/spawner.js index 9bfda8c..9dffb9e 100644 --- a/server/game/room/world/spawner.js +++ b/server/game/room/world/spawner.js @@ -3,7 +3,7 @@ const Asteroid = require('./body/asteroid.js'); const Grapple = require('./body/projectile/grapple.js'); const Missile = require('./body/projectile/missile.js'); -const Laser = require('./body/turret/discharge/laser.js'); +const Laser = require('./particle/laser.js'); const Ship = require('./body/ship.js'); class Spawner { @@ -93,7 +93,7 @@ class Spawner { yvel: fixture.body.vel.y + vy }; let laser = new Laser(fixture, pos); - this.world.addDischarge(laser); + this.world.addParticle(laser); return laser; } } diff --git a/server/game/room/world/traits/ships.json b/server/game/room/world/traits/ships.json index bc899f6..dce036e 100644 --- a/server/game/room/world/traits/ships.json +++ b/server/game/room/world/traits/ships.json @@ -17,7 +17,7 @@ [3, 1] ] ], - "mounts": [ + "hardpoints": [ { "pos": [0.5625, 0.125], "type": "fixed",