Browse Source

more work

tags/v0.9.0^2
Shaun 3 years ago
parent
commit
860808308a
4 changed files with 30 additions and 19 deletions
  1. +1
    -0
      src/client/js/components/pather.js
  2. +14
    -13
      src/server/components/portal.js
  3. +7
    -4
      src/server/objects/objBase.js
  4. +8
    -2
      src/server/world/physics.js

+ 1
- 0
src/client/js/components/pather.js View File

@@ -27,6 +27,7 @@ define([
lastY: 0,

init: function () {
events.on('onRespawn', this.onDeath.bind(this));
events.on('onDeath', this.onDeath.bind(this));
events.on('onClearQueue', this.onDeath.bind(this));



+ 14
- 13
src/server/components/portal.js View File

@@ -17,7 +17,9 @@ module.exports = {
},

collisionEnter: async function (obj) {
if (!obj.player)
const { player, syncer, instance: { physics, syncer: globalSyncer } } = obj;

if (!player)
return;
else if (this.patronLevel) {
if (!roles.isRoleLevel(obj, this.patronLevel, 'enter this area'))
@@ -25,21 +27,20 @@ module.exports = {
}

if (obj.zoneName === this.toZone) {
physics.removeObject(obj, obj.x, obj.y);

obj.x = this.toPos.x;
obj.y = this.toPos.y;

const syncO = this.obj.syncer.o;
syncO.x = obj.x;
syncO.y = obj.y;

process.send({
method: 'rezone',
id: obj.serverId,
args: {
obj: simpleObj,
newZone: this.toZone
}
});
syncer.set(false, null, 'x', obj.x);
syncer.set(false, null, 'y', obj.y);

physics.addObject(obj, obj.x, obj.y);

globalSyncer.queue('onRespawn', {
x: obj.x,
y: obj.y
}, [obj.serverId]);

return;
}


+ 7
- 4
src/server/objects/objBase.js View File

@@ -317,10 +317,13 @@ module.exports = {
} else
return false;
} else {
physics.removeObject(this, this.x, this.y, data.x, data.y);
physics.addObject(this, data.x, data.y, this.x, this.y);
this.x = data.x;
this.y = data.y;
const { x: xOld, y: yOld } = this;
const { x: xNew, y: yNew } = data;

physics.removeObject(this, xOld, yOld, xNew, yNew);
this.x = xNew;
this.y = yNew;
physics.addObject(this, xNew, yNew, xOld, yOld);
}

let syncer = this.syncer;


+ 8
- 2
src/server/world/physics.js View File

@@ -114,14 +114,20 @@ module.exports = {
obj.collisionEnter(c);
}
} else {
//If a callback returns true, it means we collide
//If a callback returns true, it means we collide
if (c.collisionEnter(obj))
return;
obj.collisionEnter(c);
}
}

cell.push(obj);
//Perhaps a collisionEvent caused us to move somewhere else, in which case, we don't push to the cell
// as we assume that the collisionEvent handled it for us
if (x === obj.x && y === obj.y)
cell.push(obj);
else
console.log('nopers');
return true;
},



Loading…
Cancel
Save