You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

48 rivejä
747 B

  1. define([
  2. ], function(
  3. ) {
  4. return {
  5. configs: null,
  6. init: function(instance) {
  7. this.instance = instance;
  8. var configs = null;
  9. try {
  10. configs = require('../config/maps/' + this.instance.map.name + '/events');
  11. }
  12. catch (e) {}
  13. if (!configs)
  14. return;
  15. this.configs = extend(true, [], configs);
  16. this.configs.forEach(c => (c.ttl = 10));
  17. },
  18. update: function() {
  19. var configs = this.configs;
  20. if (!configs)
  21. return;
  22. var cLen = configs.length;
  23. for (var i = 0; i < cLen; i++) {
  24. var c = configs[i];
  25. if (c.event)
  26. continue;
  27. else if (c.ttl > 0) {
  28. c.ttl--;
  29. continue;
  30. }
  31. c.event = this.startEvent(c);
  32. }
  33. },
  34. startEvent: function(config) {
  35. return {};
  36. }
  37. };
  38. });