Browse Source

work

1993-leagues
Shaun 10 months ago
parent
commit
9fd4406051
6 changed files with 51 additions and 16 deletions
  1. +8
    -8
      src/server/clientComponents/serverActions.js
  2. +7
    -0
      src/server/components/notice.js
  3. +19
    -2
      src/server/events/events.js
  4. +10
    -0
      src/server/objects/objBase.js
  5. +4
    -6
      src/server/world/map.js
  6. +3
    -0
      src/server/world/physics.js

+ 8
- 8
src/server/clientComponents/serverActions.js View File

@@ -38,27 +38,27 @@ define([

extend: function (blueprint) {
if (blueprint.addActions) {
blueprint.addActions.forEach(function (a) {
blueprint.addActions.forEach(a => {
this.actions.spliceWhere(f => f.key === a.key);

let exists = this.actions.some(function (ta) {
return ((ta.targetId === a.targetId) && (ta.cpn === a.cpn) && (ta.method === a.method));
let exists = this.actions.some(ta => {
return (ta.action.data.targetId === a.action.data.targetId && ta.action.cpn === a.action.cpn && ta.action.method === a.action.method);
});
if (exists)
return;

this.actions.push(a);
}, this);
});

delete blueprint.addActions;
}

if (blueprint.removeActions) {
blueprint.removeActions.forEach(function (a) {
this.actions.spliceWhere(function (ta) {
return ((ta.targetId === a.targetId) && (ta.cpn === a.cpn) && (ta.method === a.method));
blueprint.removeActions.forEach(a => {
this.actions.spliceWhere(ta => {
return (ta.action.data.targetId === a.action.data.targetId && ta.action.cpn === a.action.cpn && ta.action.method === a.action.method);
});
}, this);
});

delete blueprint.removeActions;
}


+ 7
- 0
src/server/components/notice.js View File

@@ -85,6 +85,13 @@ module.exports = {
}, [obj.serverId]);
},

collisionStay: function (obj) {
if (!obj.player)
return;

this.callAction(obj, 'stay');
},

collisionExit: function (obj, force) {
if (!force) {
if (!obj.player)


+ 19
- 2
src/server/events/events.js View File

@@ -5,6 +5,12 @@ const fs = require('fs');
const phaseTemplate = require('./phases/phaseTemplate');
const { mapList } = require('../world/mapManager');

//Internals
const phasePaths = [{
type: 'end',
path: './phases/phaseEnd'
}];

//Helpers
const applyVariablesToDescription = (desc, variables) => {
if (!variables)
@@ -26,6 +32,10 @@ module.exports = {
init: function (instance) {
this.instance = instance;

this.instance.eventEmitter.emit('beforeGetEventPhasePaths', {
phasePaths
});

const zoneName = this.instance.map.name;
const zonePath = mapList.find(z => z.name === zoneName).path;
const zoneEventPath = zonePath + '/' + zoneName + '/events';
@@ -430,8 +440,15 @@ module.exports = {

let phase = event.phases[i];
if (!phase) {
let phaseFile = 'phase' + p.type[0].toUpperCase() + p.type.substr(1);
let typeTemplate = require('./phases/' + phaseFile);
let typeTemplate;

const phasePathEntry = phasePaths.find(f => f.type === p.type);
if (!phasePathEntry) {
const phaseFile = 'phase' + p.type[0].toUpperCase() + p.type.substr(1);
typeTemplate = require('./phases/' + phaseFile);
} else
typeTemplate = require(`../${phasePathEntry.path}`);

phase = extend({
instance: this.instance,
event: event


+ 10
- 0
src/server/objects/objBase.js View File

@@ -337,6 +337,16 @@ module.exports = {
}
},

collisionStay: function (obj) {
let cpns = this.components;
let cLen = cpns.length;
for (let i = 0; i < cLen; i++) {
let c = cpns[i];
if (c.collisionStay)
c.collisionStay(obj);
}
},

collisionExit: function (obj) {
let cpns = this.components;
let cLen = cpns.length;


+ 4
- 6
src/server/world/map.js View File

@@ -456,12 +456,10 @@ module.exports = {
if (objZoneName !== name)
blueprint.objZoneName = objZoneName;

if (this.zoneConfig) {
if ((this.zoneConfig.objects) && (this.zoneConfig.objects[objZoneName.toLowerCase()]))
extend(blueprint, this.zoneConfig.objects[objZoneName.toLowerCase()]);
else if ((this.zoneConfig.objects) && (this.zoneConfig.mobs[objZoneName.toLowerCase()]))
extend(blueprint, this.zoneConfig.mobs[objZoneName.toLowerCase()]);
}
if (this.zoneConfig?.objects?.[objZoneName.toLowerCase()])
extend(blueprint, this.zoneConfig.objects[objZoneName.toLowerCase()]);
else if (this.zoneConfig?.mobs?.[objZoneName.toLowerCase()])
extend(blueprint, this.zoneConfig.objects[objZoneName.toLowerCase()]);

if (blueprint.blocking)
this.collisionMap[blueprint.x][blueprint.y] = 1;


+ 3
- 0
src/server/world/physics.js View File

@@ -112,6 +112,9 @@ module.exports = {
} else if ((fromX < c.x) || (fromY < c.y) || (fromX >= c.x + c.width) || (fromY >= c.y + c.height)) {
c.collisionEnter(obj);
obj.collisionEnter(c);
} else if ((fromX >= c.x) && (fromY >= c.y) && (fromX < c.x + c.width) && (fromY < c.y + c.height)) {
c.collisionStay(obj);
obj.collisionStay(c);
}
} else {
//If a callback returns true, it means we collide


Loading…
Cancel
Save