Shaun преди 3 години
родител
ревизия
66363367d4
променени са 2 файла, в които са добавени 48 реда и са изтрити 0 реда
  1. +47
    -0
      src/server/components/syncer.js
  2. +1
    -0
      src/server/world/syncer.js

+ 47
- 0
src/server/components/syncer.js Целия файл

@@ -1,6 +1,9 @@
module.exports = {
type: 'syncer',

locked: false,
buffer: [],

o: {
components: []
},
@@ -16,6 +19,20 @@ module.exports = {
this.oSelf = {
components: []
};

this.locked = false;

this.buffer.forEach(q => {
const [ method, ...rest ] = q;

this[method].apply(this, rest);
});

this.buffer = [];
},

queue: function (args) {
this.buffer.push(args);
},

get: function (self) {
@@ -36,6 +53,12 @@ module.exports = {
},

set: function (self, cpnType, property, value) {
if (this.locked) {
this.queue(['set', self, cpnType, property, value]);

return;
}

let o = this.o;
if (self)
o = this.oSelf;
@@ -56,6 +79,12 @@ module.exports = {
},

setComponent: function (self, cpnType, cpn) {
if (this.locked) {
this.queue(['setComponent', self, cpnType, cpn]);

return;
}

let o = this.o;
if (self)
o = this.oSelf;
@@ -68,6 +97,12 @@ module.exports = {
},

setObject: function (self, cpnType, object, property, value) {
if (this.locked) {
this.queue(['setObject', self, cpnType, object, property, value]);

return;
}

let o = this.o;
if (self)
o = this.oSelf;
@@ -90,6 +125,12 @@ module.exports = {
},

setArray: function (self, cpnType, property, value, noDuplicate) {
if (this.locked) {
this.queue(['setArray', self, cpnType, property, value, noDuplicate]);

return;
}

let o = this.o;
if (self)
o = this.oSelf;
@@ -112,6 +153,12 @@ module.exports = {
},

setSelfArray: function (self, property, value) {
if (this.locked) {
this.queue(['setSelfArray', self, property, value]);

return;
}

let o = this.o;
if (self)
o = this.oSelf;


+ 1
- 0
src/server/world/syncer.js Целия файл

@@ -62,6 +62,7 @@ module.exports = {
if (!destroyed) {
sync = o.syncer.get();
syncSelf = o.syncer.get(true);
o.syncer.locked = true;
} else {
sync = {
id: o.id,


Зареждане…
Отказ
Запис