Cannon.tscn 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. [gd_scene load_steps=9 format=3 uid="uid://fvhrbog40cpp"]
  2. [ext_resource type="Script" uid="uid://bxfr63s2j3ts7" path="res://Scripts/Classes/Entities/Objects/Cannon.gd" id="1_g2yj6"]
  3. [ext_resource type="Texture2D" uid="uid://x45kf055ej53" path="res://Assets/Sprites/Blocks/Cannon.png" id="2_yrqqx"]
  4. [ext_resource type="Script" uid="uid://ctfbuoxtnnl0q" path="res://Scripts/Classes/Components/EditorPropertyExposer.gd" id="3_yrqqx"]
  5. [ext_resource type="Script" uid="uid://cbal8ms2oe1ik" path="res://Scripts/Classes/Components/ResourceSetterNew.gd" id="3_ywjuo"]
  6. [ext_resource type="JSON" path="res://Assets/Sprites/Blocks/Cannon.json" id="4_1iyc0"]
  7. [sub_resource type="AtlasTexture" id="AtlasTexture_wj2h5"]
  8. atlas = ExtResource("2_yrqqx")
  9. region = Rect2(0, 0, 48, 16)
  10. [sub_resource type="RectangleShape2D" id="RectangleShape2D_ywjuo"]
  11. size = Vector2(16, 16)
  12. [sub_resource type="GDScript" id="GDScript_ywjuo"]
  13. script/source = "extends Node
  14. @onready var head: Sprite2D = $\"../Head\"
  15. @onready var mount: Sprite2D = $\"../Mount\"
  16. func _process(_delta: float) -> void:
  17. mount.global_rotation_degrees = owner.stand_angle * 90
  18. head.frame = int(int(owner.head_angle * 45) % 90 != 0)
  19. head.global_rotation_degrees = owner.head_angle * 45
  20. if head.frame == 1:
  21. head.global_rotation_degrees -= 45
  22. "
  23. [node name="Cannon" type="Node2D"]
  24. script = ExtResource("1_g2yj6")
  25. [node name="Head" type="Sprite2D" parent="."]
  26. physics_interpolation_mode = 2
  27. texture = SubResource("AtlasTexture_wj2h5")
  28. hframes = 2
  29. frame = 1
  30. region_enabled = true
  31. region_rect = Rect2(0, 0, 32, 16)
  32. region_filter_clip_enabled = true
  33. [node name="ResourceSetterNew" type="Node" parent="Head" node_paths=PackedStringArray("node_to_affect")]
  34. script = ExtResource("3_ywjuo")
  35. node_to_affect = NodePath("..")
  36. property_name = "texture"
  37. mode = 1
  38. resource_json = ExtResource("4_1iyc0")
  39. metadata/_custom_type_script = "uid://cbal8ms2oe1ik"
  40. [node name="Raycast" type="RayCast2D" parent="Head"]
  41. position = Vector2(0, -9)
  42. target_position = Vector2(0, -8)
  43. collision_mask = 6
  44. hit_from_inside = true
  45. [node name="Mount" type="Sprite2D" parent="."]
  46. physics_interpolation_mode = 2
  47. texture = SubResource("AtlasTexture_wj2h5")
  48. region_enabled = true
  49. region_rect = Rect2(32, 0, 16, 16)
  50. region_filter_clip_enabled = true
  51. [node name="ResourceSetterNew" type="Node" parent="Mount" node_paths=PackedStringArray("node_to_affect")]
  52. script = ExtResource("3_ywjuo")
  53. node_to_affect = NodePath("..")
  54. property_name = "texture"
  55. mode = 1
  56. resource_json = ExtResource("4_1iyc0")
  57. metadata/_custom_type_script = "uid://cbal8ms2oe1ik"
  58. [node name="StaticBody2D" type="StaticBody2D" parent="."]
  59. collision_layer = 2
  60. collision_mask = 0
  61. [node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
  62. shape = SubResource("RectangleShape2D_ywjuo")
  63. [node name="EditorPropertyExposer" type="Node" parent="."]
  64. script = ExtResource("3_yrqqx")
  65. properties = Array[String](["item", "head_angle", "stand_angle"])
  66. filters = Dictionary[String, String]({
  67. "item": "cannon_ammo"
  68. })
  69. metadata/_custom_type_script = "uid://ctfbuoxtnnl0q"
  70. [node name="Node" type="Node" parent="."]
  71. process_mode = 3
  72. script = SubResource("GDScript_ywjuo")
  73. [node name="Timer" type="Timer" parent="."]
  74. wait_time = 3.0
  75. [connection signal="timeout" from="Timer" to="." method="shoot"]