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.
 
 
 

73 lines
1.1 KiB

  1. define([
  2. 'js/misc/physics'
  3. ], function (
  4. physics
  5. ) {
  6. let bptParticles = {
  7. chance: 0.1,
  8. blueprint: {
  9. color: {
  10. start: 'f2f5f5'
  11. },
  12. alpha: {
  13. start: 0.75,
  14. end: 0.2
  15. },
  16. scale: {
  17. start: 6,
  18. end: 2
  19. },
  20. lifetime: {
  21. min: 1,
  22. max: 3
  23. },
  24. chance: 0.025
  25. }
  26. };
  27. return {
  28. type: 'resourceNode',
  29. init: function () {
  30. let x = this.obj.x;
  31. let y = this.obj.y;
  32. let w = this.obj.width || 1;
  33. let h = this.obj.height || 1;
  34. let isFish = (this.nodeType === 'fish');
  35. for (let i = x; i < x + w; i++) {
  36. for (let j = y; j < y + h; j++) {
  37. let bpt = $.extend(true, {}, bptParticles, {
  38. new: true
  39. });
  40. if (isFish) {
  41. if (!physics.isTileBlocking(i, j))
  42. continue;
  43. else if (Math.random() < 0.4)
  44. continue;
  45. $.extend(true, bpt, {
  46. blueprint: {
  47. color: {
  48. start: '48edff'
  49. },
  50. spawnType: 'rect',
  51. spawnRect: {
  52. x: 40 * (i - x),
  53. y: 40 * (j - y),
  54. w: 40,
  55. h: 40
  56. }
  57. }
  58. });
  59. }
  60. this.obj.addComponent('particles', bpt);
  61. }
  62. }
  63. }
  64. };
  65. });