diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObject.svg b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObject.svg new file mode 100644 index 0000000..f791a9b --- /dev/null +++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObject.svg @@ -0,0 +1 @@ + Basketball \ No newline at end of file diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObject.svg.import b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObject.svg.import new file mode 100644 index 0000000..6ad57a1 --- /dev/null +++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObject.svg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/ActivityObject.svg-991005c73263a96e250ef83836b7394e.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/dungeonShooting_plugin/ActivityObject.svg" +dest_files=[ "res://.import/ActivityObject.svg-991005c73263a96e250ef83836b7394e.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectTemplate.cs b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectTemplate.cs new file mode 100644 index 0000000..2647504 --- /dev/null +++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectTemplate.cs @@ -0,0 +1,77 @@ +using Godot; + +namespace Plugin +{ + /// + /// ActivityObject 节点模板对象 + /// + [Tool] + public class ActivityObjectTemplate : Node + { + /// + /// 当前物体所属物理层 + /// + [Export(PropertyHint.Layers2dPhysics)] + public uint CollisionLayer; + + /// + /// 当前物体扫描的物理层 + /// + [Export(PropertyHint.Layers2dPhysics)] + public uint CollisionMask; + + public override void _Ready() + { + // 在工具模式下创建的 template 节点自动创建对应的必要子节点 + if (Engine.EditorHint) + { + var parent = GetParent(); + if (parent != null) + { + //寻找 owner + Node owner; + if (parent.Owner != null) + { + owner = parent.Owner; + } + else if (Plugin.Instance.GetEditorInterface().GetEditedSceneRoot() == this) + { + owner = this; + } + else + { + owner = parent; + } + + //创建 Sprite + if (GetNodeOrNull("AnimatedSprite") == null) + { + var sp = new AnimatedSprite(); + sp.Name = "AnimatedSprite"; + AddChild(sp); + sp.Owner = owner; + } + + //创建Shadow + if (GetNodeOrNull("ShadowSprite") == null) + { + var sd = new Sprite(); + sd.Name = "ShadowSprite"; + sd.Material = ResourceManager.ShadowMaterial; + AddChild(sd); + sd.Owner = owner; + } + + //创建Collision + if (GetNodeOrNull("Collision") == null) + { + var co = new CollisionShape2D(); + co.Name = "Collision"; + AddChild(co); + co.Owner = owner; + } + } + } + } + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/Plugin.cs b/DungeonShooting_Godot/addons/dungeonShooting_plugin/Plugin.cs new file mode 100644 index 0000000..b8132c8 --- /dev/null +++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/Plugin.cs @@ -0,0 +1,47 @@ +#if TOOLS +using Godot; + +namespace Plugin +{ + [Tool] + public class Plugin : EditorPlugin + { + public static Plugin Instance => _instance; + private static Plugin _instance; + + public override void _Process(float delta) + { + _instance = this; + } + + public override void _EnterTree() + { + _instance = this; + var script = GD.Load