PackageNode.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Collections.Generic;
  2. using Godot;
  3. namespace TBL.GodotSharp.Content
  4. {
  5. /// <summary>
  6. /// 资源包节点
  7. /// </summary>
  8. public abstract partial class PackageNode : Node
  9. {
  10. /// <summary>
  11. /// 自身信息
  12. /// </summary>
  13. public abstract Info SelfInfo { get; }
  14. /// <summary>
  15. /// 依赖项信息集
  16. /// </summary>
  17. public abstract IEnumerable<DependencyInfo> Dependencies { get; }
  18. public override void _Ready()
  19. {
  20. Name = SelfInfo.ToString();
  21. }
  22. public override void _EnterTree()
  23. {
  24. if (SelfFileSystem != null && GetParent() is PackageContainer packageContainer)
  25. {
  26. packageContainer.FileSystem.AddFileSystem(SelfFileSystem);
  27. }
  28. }
  29. public override void _ExitTree()
  30. {
  31. if (SelfFileSystem != null && GetParent() is PackageContainer packageContainer)
  32. {
  33. packageContainer.FileSystem.RemoveFileSystem(SelfFileSystem);
  34. SelfFileSystem.Dispose();
  35. }
  36. }
  37. }
  38. }