base/asset/Asset.js

  1. /*
  2. * Copyright 2020 WICKLETS LLC
  3. *
  4. * This file is part of Wick Engine.
  5. *
  6. * Wick Engine is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Wick Engine is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Wick Engine. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. Wick.Asset = class extends Wick.Base {
  20. /**
  21. * Creates a new Wick Asset.
  22. * @param {string} name - the name of the asset
  23. */
  24. constructor(args) {
  25. if (!args) args = {};
  26. super(args);
  27. this.name = args.name;
  28. }
  29. _serialize(args) {
  30. var data = super._serialize(args);
  31. data.name = this.name;
  32. return data;
  33. }
  34. _deserialize(data) {
  35. super._deserialize(data);
  36. this.name = data.name;
  37. }
  38. /**
  39. * A list of all objects using this asset.
  40. */
  41. getInstances() {
  42. // Implemented by subclasses
  43. }
  44. /**
  45. * Check if there are any objects in the project that use this asset.
  46. * @returns {boolean}
  47. */
  48. hasInstances() {
  49. // Implemented by sublasses
  50. }
  51. /**
  52. * Remove all instances of this asset from the project. (Implemented by ClipAsset, ImageAsset, and SoundAsset)
  53. */
  54. removeAllInstances() {
  55. // Implemented by sublasses
  56. }
  57. get classname() {
  58. return 'Asset';
  59. }
  60. }