start of tossing system
This commit is contained in:
parent
f5999da412
commit
dc2a1a78f3
12 changed files with 193 additions and 38 deletions
|
@ -22,6 +22,7 @@ var input_dir: float = 0.0
|
|||
var aim_back_arm: bool = false
|
||||
|
||||
var _was_on_floor: bool = true
|
||||
var _highlighted_pickup: Pickup = null
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -117,3 +118,17 @@ func _airborn_physics_process(delta: float) -> void:
|
|||
velocity += get_gravity() * delta
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
#region Collision Signals
|
||||
func _on_pickup_area_entered(area: Area2D) -> void:
|
||||
if not _highlighted_pickup:
|
||||
_highlighted_pickup = area.get_parent() as Pickup
|
||||
_highlighted_pickup.highlight = true
|
||||
|
||||
|
||||
func _on_pickup_area_exited(area: Area2D) -> void:
|
||||
if _highlighted_pickup == (area.get_parent() as Pickup):
|
||||
_highlighted_pickup.highlight = false
|
||||
_highlighted_pickup = null
|
||||
#endregion
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
[ext_resource type="Texture2D" uid="uid://d1qyuom3pxifj" path="res://textures/player/foot_front.png" id="12_dda5a"]
|
||||
[ext_resource type="Texture2D" uid="uid://cssnogcrn57xv" path="res://textures/player/skirt.png" id="13_qgkik"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_6roai"]
|
||||
resource_name = "stand"
|
||||
[sub_resource type="Animation" id="Animation_7ampj"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
|
@ -206,8 +206,8 @@ tracks/14/keys = {
|
|||
"values": [Vector2(1, 6)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_7ampj"]
|
||||
length = 0.001
|
||||
[sub_resource type="Animation" id="Animation_6roai"]
|
||||
resource_name = "stand"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
|
@ -637,6 +637,14 @@ position = Vector2(-0.5, -16)
|
|||
shape = SubResource("RectangleShape2D_wydm2")
|
||||
debug_color = Color(0.720957, 0.248475, 1, 0.42)
|
||||
|
||||
[node name="PickupDetector" type="Area2D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
collision_layer = 0
|
||||
collision_mask = 128
|
||||
monitorable = false
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
|
||||
[node name="Graphics" type="Node2D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
|
@ -872,8 +880,8 @@ delay_in_seconds = "0.0"
|
|||
editor_description = "Performs no movement."
|
||||
script = ExtResource("5_8e8ei")
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
|
||||
[connection signal="area_entered" from="PickupDetector" to="." method="_on_pickup_area_entered"]
|
||||
[connection signal="area_exited" from="PickupDetector" to="." method="_on_pickup_area_exited"]
|
||||
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Active" to="." method="_active_physics_process"]
|
||||
[connection signal="child_state_entered" from="StateChart/Root/Movement/Active/Grounded" to="." method="_grounded_child_state_entered"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Movement/Active/Grounded/Standing" to="." method="_standing_entered"]
|
||||
|
|
|
@ -1,18 +1,27 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://dlnu4b8eydxui"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://dlnu4b8eydxui"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://ccyfbp8cypnyy" path="res://objects/weapons/projectiles/throwable.tscn" id="1_4sas3"]
|
||||
[ext_resource type="PackedScene" uid="uid://ccyfbp8cypnyy" path="res://objects/weapons/projectiles/pickup.tscn" id="1_4sas3"]
|
||||
[ext_resource type="Texture2D" uid="uid://bd3mcp3gds2vg" path="res://textures/projectiles/brick.png" id="2_evkjl"]
|
||||
[ext_resource type="Shader" path="res://assets/shaders/outline.gdshader" id="2_irmt4"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gpkcl"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("2_irmt4")
|
||||
shader_parameter/outline_enabled = false
|
||||
shader_parameter/outline_color = Color(0.358343, 0.568333, 0.699081, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_7kw5j"]
|
||||
size = Vector2(6, 4)
|
||||
|
||||
[node name="Brick" instance=ExtResource("1_4sas3")]
|
||||
material = SubResource("ShaderMaterial_gpkcl")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="." index="0"]
|
||||
use_parent_material = true
|
||||
texture = ExtResource("2_evkjl")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"]
|
||||
shape = SubResource("RectangleShape2D_7kw5j")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Interactable" index="0"]
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Pickup" index="0"]
|
||||
shape = SubResource("RectangleShape2D_7kw5j")
|
||||
|
|
17
objects/weapons/projectiles/pickup.gd
Normal file
17
objects/weapons/projectiles/pickup.gd
Normal file
|
@ -0,0 +1,17 @@
|
|||
class_name Pickup
|
||||
extends RigidBody2D
|
||||
|
||||
|
||||
var highlight: bool:
|
||||
set(value):
|
||||
material.set_shader_parameter(&"outline_enabled", value)
|
||||
get():
|
||||
return material.get_shader_parameter(&"outline_enabled")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
|
||||
func pick_up() -> void:
|
||||
freeze = true
|
21
objects/weapons/projectiles/pickup.tscn
Normal file
21
objects/weapons/projectiles/pickup.tscn
Normal file
|
@ -0,0 +1,21 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://ccyfbp8cypnyy"]
|
||||
|
||||
[ext_resource type="Shader" path="res://assets/shaders/outline.gdshader" id="1_d8t6k"]
|
||||
[ext_resource type="Script" path="res://objects/weapons/projectiles/pickup.gd" id="2_wyw28"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ocln2"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("1_d8t6k")
|
||||
shader_parameter/outline_enabled = false
|
||||
shader_parameter/outline_color = Color(0.358343, 0.568333, 0.699081, 1)
|
||||
|
||||
[node name="Pickup" type="RigidBody2D"]
|
||||
material = SubResource("ShaderMaterial_ocln2")
|
||||
collision_layer = 8
|
||||
script = ExtResource("2_wyw28")
|
||||
|
||||
[node name="Pickup" type="Area2D" parent="."]
|
||||
collision_layer = 128
|
||||
collision_mask = 256
|
||||
input_pickable = false
|
||||
monitoring = false
|
|
@ -1,12 +0,0 @@
|
|||
class_name Throwable
|
||||
extends RigidBody2D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_interacted(user: Node) -> void:
|
||||
var player = user as Player
|
||||
if player:
|
||||
player.pick_up(self)
|
|
@ -1,16 +0,0 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://ccyfbp8cypnyy"]
|
||||
|
||||
[ext_resource type="Script" path="res://objects/weapons/projectiles/throwable.gd" id="1_dsh6j"]
|
||||
[ext_resource type="Script" path="res://objects/interactable.gd" id="2_b3de0"]
|
||||
|
||||
[node name="Throwable" type="RigidBody2D"]
|
||||
script = ExtResource("1_dsh6j")
|
||||
|
||||
[node name="Interactable" type="Area2D" parent="."]
|
||||
collision_layer = 64
|
||||
collision_mask = 0
|
||||
input_pickable = false
|
||||
monitoring = false
|
||||
script = ExtResource("2_b3de0")
|
||||
|
||||
[connection signal="interacted" from="Interactable" to="." method="_on_interacted"]
|
Reference in a new issue