GameObject.ts 657 B

12345678910111213141516171819202122232425262728
  1. abstract class GameObject{
  2. get clonableFields(){
  3. return Object.fromEntries(Object.entries(this).filter(([key,v])=>!key.startsWith("$")))
  4. }
  5. get ownData(){
  6. var ownData = {};
  7. Object.keys(this).forEach(function (pn) {
  8. if(typeof this[pn] !== "function" && !pn.startsWith("$")){
  9. ownData[pn] = clone(this[pn]);
  10. }
  11. }, this);
  12. return ownData;
  13. }
  14. _init(data: { [x: string]: any; }){
  15. Object.keys(data).forEach(function (pn) {
  16. this[pn] = clone(data[pn]);
  17. }, this);
  18. this._postInit();
  19. return this;
  20. }
  21. _postInit(){}
  22. }