Newer
Older
DungeonShooting / DungeonShooting_Godot / addons / dungeonShooting_plugin / Plugin.cs
  1. #if TOOLS
  2. using Godot;
  3.  
  4. namespace Plugin
  5. {
  6. [Tool]
  7. public partial class Plugin : EditorPlugin
  8. {
  9. public static Plugin Instance => _instance;
  10. private static Plugin _instance;
  11.  
  12. private Control dock;
  13.  
  14. public override void _Process(double delta)
  15. {
  16. _instance = this;
  17. }
  18.  
  19. public override void _EnterTree()
  20. {
  21. _instance = this;
  22. var script = GD.Load<Script>("res://src/framework/activity/ActivityObjectTemplate.cs");
  23. var texture = GD.Load<Texture2D>("res://addons/dungeonShooting_plugin/ActivityObject.svg");
  24. AddCustomType("ActivityObjectTemplate", "Node", script, texture);
  25.  
  26. var script2 = GD.Load<Script>("res://src/framework/map/DungeonRoomTemplate.cs");
  27. var texture2 = GD.Load<Texture2D>("res://addons/dungeonShooting_plugin/Map.svg");
  28. AddCustomType("DungeonRoomTemplate", "TileMap", script2, texture2);
  29. var script3 = GD.Load<Script>("res://src/framework/map/mark/ActivityMark.cs");
  30. var texture3 = GD.Load<Texture2D>("res://addons/dungeonShooting_plugin/Mark.svg");
  31. AddCustomType("ActivityMark", "Node2D", script3, texture3);
  32. dock = GD.Load<PackedScene>("res://addons/dungeonShooting_plugin/Automation.tscn").Instantiate<Control>();
  33. AddControlToDock(DockSlot.LeftUr, dock);
  34. }
  35.  
  36. public override void _ExitTree()
  37. {
  38. RemoveCustomType("ActivityObjectTemplate");
  39. RemoveCustomType("DungeonRoomTemplate");
  40. if (dock != null)
  41. {
  42. RemoveControlFromDocks(dock);
  43. dock.Free();
  44. }
  45. }
  46.  
  47. /*public override bool Handles(Object @object)
  48. {
  49. if (@object is Node node)
  50. {
  51. node.
  52. GD.Print("node: " + (node.GetScript() == activityObjectTemplateScript));
  53. /*GD.Print("---------------------- 1: " + objectTemplate.Name);
  54. var sp = new Sprite2D();
  55. sp.Name = "Sprite2D";
  56. objectTemplate.AddChild(sp);
  57. sp.Owner = objectTemplate.Owner;#1#
  58. }
  59. return base.Handles(@object);
  60. }*/
  61. }
  62.  
  63. }
  64. #endif