Browse Source

Create damage texts from client-side effects

tags/v0.10.6^2
kckckc 2 years ago
parent
commit
b43f208d0e
3 changed files with 26 additions and 19 deletions
  1. +22
    -7
      src/server/clientComponents/effects.js
  2. +4
    -0
      src/server/clientComponents/effects/auras.js
  3. +0
    -12
      src/server/components/effects.js

+ 22
- 7
src/server/clientComponents/effects.js View File

@@ -1,17 +1,31 @@
define([
'js/rendering/numbers'
], function (
numbers
) {
const effectBase = {
init: function () {
this.defaultDamageText(false);
},

destroy: function () {
this.defaultDamageText(true);
},

defaultDamageText: function (removing) {
numbers.onGetDamage({
id: this.obj.id,
event: true,
text: (removing ? '-' : '+') + this.type
});
}
};

return {
type: 'effects',

effects: [],

effectBase: {

},

templates: {
},
@@ -29,8 +43,9 @@ define([
let template = this.templates[data.type] || {};

let effect = $.extend(true, {}, this.effectBase, template, data);
let effect = $.extend(true, {}, effectBase, template, data);

effect.self = !!this.obj.self;
effect.obj = this.obj;

if (effect.init)


+ 4
- 0
src/server/clientComponents/effects/auras.js View File

@@ -39,6 +39,8 @@ define([
h: scale * 3,
cell: cell
});

this.defaultDamageText();
},

getAlpha: function () {
@@ -93,6 +95,8 @@ define([
layerName: 'effects',
sprite: this.sprite
});

this.defaultDamageText(true);
},

setVisible: function (visible) {


+ 0
- 12
src/server/components/effects.js View File

@@ -195,12 +195,6 @@ module.exports = {
id: builtEffect.id
}, [this.obj.serverId]);

this.obj.instance.syncer.queue('onGetDamage', {
id: this.obj.id,
event: true,
text: '+' + options.type
}, -1);

this.obj.syncer.setArray(false, 'effects', 'addEffects', builtEffect.simplify());
}

@@ -238,12 +232,6 @@ module.exports = {
id: id
}, [this.obj.serverId]);

this.obj.instance.syncer.queue('onGetDamage', {
id: this.obj.id,
event: true,
text: '-' + type
}, -1);

this.obj.syncer.setArray(false, 'effects', 'removeEffects', id);
},



Loading…
Cancel
Save