Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix null axis_multiplier_resource on subprojectile manager #107

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions addons/top_down/scenes/projectiles/projectile.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[gd_scene load_steps=13 format=3 uid="uid://beifde6xst23w"]
[gd_scene load_steps=14 format=3 uid="uid://beifde6xst23w"]

[ext_resource type="Script" path="res://addons/top_down/scripts/weapon_system/projectile/Projectile2D.gd" id="1_8ha7j"]
[ext_resource type="Resource" uid="uid://dedx0gi4fowby" path="res://addons/top_down/resources/GlobalResources/axis_multiplication_resource.tres" id="2_3gsbh"]
[ext_resource type="Texture2D" uid="uid://csfe20i4vc2bk" path="res://addons/top_down/assets/images/projectile/bullet_0.png" id="2_7x3e8"]
[ext_resource type="Script" path="res://addons/top_down/scripts/weapon_system/projectile/ProjectileSetup.gd" id="2_yrlmb"]
[ext_resource type="Script" path="res://addons/great_games_library/nodes/AreaTransmitter/AreaTransmitter2D.gd" id="3_e2gy5"]
Expand All @@ -18,7 +19,7 @@ size = Vector2(4, 2)
[node name="Projectile" type="Node2D"]
script = ExtResource("1_8ha7j")
speed = 120.0
axis_multiplier = Vector2(1, 0.5)
axis_multiplier_resource = ExtResource("2_3gsbh")

[node name="ProjectileSetup" type="Node" parent="." node_paths=PackedStringArray("projectile", "area_transmitter", "data_transmitter")]
script = ExtResource("2_yrlmb")
Expand Down
5 changes: 4 additions & 1 deletion addons/top_down/scenes/projectiles/sword_slash.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[gd_scene load_steps=18 format=3 uid="uid://c6ys2qs8aeu8n"]
[gd_scene load_steps=19 format=3 uid="uid://c6ys2qs8aeu8n"]

[ext_resource type="PackedScene" uid="uid://beifde6xst23w" path="res://addons/top_down/scenes/projectiles/projectile.tscn" id="1_lwexf"]
[ext_resource type="Texture2D" uid="uid://b3gj1j73p318" path="res://addons/top_down/assets/images/shadow.png" id="2_pfam2"]
[ext_resource type="PackedScene" uid="uid://djobi3eqlcjvo" path="res://addons/top_down/scenes/vfx/trail_particle.tscn" id="3_gx0bp"]
[ext_resource type="Texture2D" uid="uid://br6m3va43cuug" path="res://addons/top_down/assets/images/vfx/slash_3_strip4.png" id="4_u6vsr"]
[ext_resource type="Resource" uid="uid://dedx0gi4fowby" path="res://addons/top_down/resources/GlobalResources/axis_multiplication_resource.tres" id="6_gnksn"]
[ext_resource type="Script" path="res://addons/top_down/scripts/weapon_system/projectile/ProjectileSpawner.gd" id="6_whjok"]
[ext_resource type="Resource" uid="uid://d1ck1axrd4kd4" path="res://addons/top_down/resources/RoomResources/ysort_reference.tres" id="7_d1e47"]
[ext_resource type="Script" path="res://addons/top_down/scripts/weapon_system/projectile/SubProjectileManager.gd" id="7_n74ie"]
Expand Down Expand Up @@ -134,6 +135,7 @@ autoplay = "slash"

[node name="ProjectileSpawner" type="Node" parent="." index="5"]
script = ExtResource("6_whjok")
axis_multiplication_resource = ExtResource("6_gnksn")
initial_distance = 10.0
projectile_parent_reference = ExtResource("7_d1e47")

Expand All @@ -142,6 +144,7 @@ script = ExtResource("7_n74ie")
projectile = NodePath("..")
projectile_spawner = NodePath("../ProjectileSpawner")
start_projectile_scene = ExtResource("8_1el3x")
axis_multiplication_resource = ExtResource("6_gnksn")

[node name="HitLimit" parent="." index="8"]
hit_limit = -1
Expand Down
1 change: 0 additions & 1 deletion addons/top_down/scenes/weapons/sword.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ interval = 0.3
animation_name = &""

[node name="ProjectileSpawner" parent="." index="4"]
axis_multiplication = Vector2(1, 1)
initial_distance = 10.0
projectile_scene = ExtResource("2_x78ie")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ signal prepare_exit_event
## Direction to travel
@export var direction: = Vector2.RIGHT
## Used to fake angled perspective
@export var axis_multiplier:Vector2 = Vector2.ONE
@export var axis_multiplier_resource:Vector2Resource
## Each projectile contribute to the total damage value with multiply
@export var damage_multiply:float = 1.0
## Force pushing a damage receiver
Expand All @@ -25,10 +25,10 @@ func _ready()->void:
move_direction = to_local_direction(direction).normalized()

func to_local_direction(dir:Vector2)->Vector2:
return dir * (Vector2.ONE / axis_multiplier)
return dir * (Vector2.ONE / axis_multiplier_resource.value)

func _physics_process(delta:float)->void:
global_position += speed * delta * move_direction * axis_multiplier
global_position += speed * delta * move_direction * axis_multiplier_resource.value


func prepare_exit()->void:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ signal prepare_spawn


func spawn()->void:
if !enabled:
return
assert(projectile_scene != null, "no projectile scene assigned")
assert(projectile_parent_reference.node != null, "projectile parent reference isn't set")
assert(axis_multiplication_resource != null)

if !enabled:
return
prepare_spawn.emit()

var new_damage_resource:DamageResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ extends Node
## Scene created and the ready()
@export var start_projectile_scene:PackedScene
@export var exit_projectile_scene:PackedScene
## Used for extra calculation to simulate angled top-down perspective
@export var axis_multiplication_resource:Vector2Resource

var axis_compensation:Vector2

func _ready()->void:
# TODO: just a mockup. Need some kind per situation configurations
projectile_spawner.collision_mask = Bitwise.append_flags(projectile_spawner.collision_mask, projectile.collision_mask)
axis_compensation = Vector2.ONE / projectile.axis_multiplier
axis_compensation = Vector2.ONE / axis_multiplication_resource.value

if start_projectile_scene != null:
spawn(start_projectile_scene)
Expand Down