1
0

serializableObject.ts 623 B

12345678910111213141516171819202122232425262728
  1. class Example{
  2. //#region SYSTEM
  3. constructor(){}
  4. _init(playerCharacter: { [x: string]: any; }){
  5. Object.keys(playerCharacter).forEach(function (pn) {
  6. this[pn] = clone(playerCharacter[pn]);
  7. }, this);
  8. return this;
  9. }
  10. clone = function () {
  11. return (new setup.Example())._init(this);
  12. };
  13. toJSON = function () {
  14. var ownData = {};
  15. Object.keys(this).forEach(function (pn) {
  16. if(typeof this[pn] !== "function")
  17. ownData[pn] = clone(this[pn]);
  18. }, this);
  19. return JSON.reviveWrapper('(new setup.Example())._init($ReviveData$)', ownData);
  20. };
  21. //#endregion
  22. }
  23. setup.Example = Example;