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. dock = GD.Load<PackedScene>("res://addons/dungeonShooting_plugin/Automation.tscn").Instantiate<Control>();
  30. AddControlToDock(DockSlot.LeftUr, dock);
  31. }
  32.  
  33. public override void _ExitTree()
  34. {
  35. RemoveCustomType("ActivityObjectTemplate");
  36. RemoveCustomType("DungeonRoomTemplate");
  37. RemoveControlFromDocks(dock);
  38. dock.Free();
  39. }
  40.  
  41. /*public override bool Handles(Object @object)
  42. {
  43. if (@object is Node node)
  44. {
  45. node.
  46. GD.Print("node: " + (node.GetScript() == activityObjectTemplateScript));
  47. /*GD.Print("---------------------- 1: " + objectTemplate.Name);
  48. var sp = new Sprite2D();
  49. sp.Name = "Sprite2D";
  50. objectTemplate.AddChild(sp);
  51. sp.Owner = objectTemplate.Owner;#1#
  52. }
  53. return base.Handles(@object);
  54. }*/
  55. }
  56.  
  57. }
  58. #endif