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.
 
 
 

84 lines
1.0 KiB

  1. define([
  2. ], function (
  3. ) {
  4. let colors = [
  5. '929398',
  6. '3fa7dd',
  7. 'faac45',
  8. 'a24eff',
  9. 'ffeb38'
  10. ];
  11. let chances = [
  12. 0.0075,
  13. 0.02,
  14. 0.04,
  15. 0.08,
  16. 0.095
  17. ];
  18. let indices = {
  19. 50: 0,
  20. 51: 1,
  21. 128: 2,
  22. 52: 3,
  23. 53: 4
  24. };
  25. return {
  26. type: 'chest',
  27. ownerId: null,
  28. init: function (blueprint) {
  29. if (this.ownerId != -1) {
  30. if (!window.player) {
  31. this.hideSprite();
  32. return;
  33. }
  34. if (this.ownerId != window.player.serverId) {
  35. this.hideSprite();
  36. return;
  37. }
  38. }
  39. let index = indices[this.obj.cell];
  40. let color = colors[index];
  41. this.obj.addComponent('particles', {
  42. chance: chances[index],
  43. blueprint: {
  44. color: {
  45. start: colors[index]
  46. },
  47. alpha: {
  48. start: 0.75,
  49. end: 0.2
  50. },
  51. lifetime: {
  52. min: 1,
  53. max: 4
  54. },
  55. chance: chances[index],
  56. spawnType: 'rect',
  57. spawnRect: {
  58. x: -4,
  59. y: -4,
  60. w: 8,
  61. h: 8
  62. }
  63. }
  64. });
  65. },
  66. hideSprite: function () {
  67. if (this.obj.sprite)
  68. this.obj.sprite.visible = false;
  69. }
  70. };
  71. });