Throw item
This commit is contained in:
30
src/items/throwable/ThrowableItem.cs
Normal file
30
src/items/throwable/ThrowableItem.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
|
||||
public interface IThrowableItem : INode3D
|
||||
{
|
||||
public IAnimationPlayer AnimationPlayer { get; set; }
|
||||
}
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class ThrowableItem : Node3D, IThrowableItem
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Node] public IAnimationPlayer AnimationPlayer { get; set; } = default!;
|
||||
|
||||
[Node] public IHitbox Hitbox { get; set; } = default!;
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
AnimationPlayer.AnimationFinished += OnAnimationFinished;
|
||||
Hitbox.Damage = 5;
|
||||
}
|
||||
|
||||
private void OnAnimationFinished(StringName animName)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
69
src/items/throwable/ThrowableItem.tscn
Normal file
69
src/items/throwable/ThrowableItem.tscn
Normal file
@@ -0,0 +1,69 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://1fl6s352e2ej"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/items/throwable/ThrowableItem.cs" id="1_nac2l"]
|
||||
[ext_resource type="Texture2D" uid="uid://dr8mjn3wahdvp" path="res://src/inventory_menu/cursor.png" id="2_mojlk"]
|
||||
[ext_resource type="Script" path="res://src/hitbox/Hitbox.cs" id="3_qpunu"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_qihtb"]
|
||||
size = Vector3(0.371643, 0.289612, 0.286743)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_7gvmx"]
|
||||
resource_name = "throw"
|
||||
length = 2.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Hitbox:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 2),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 1, 0), Vector3(0, 1, -15)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_d22ed"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Hitbox:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_qfght"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_d22ed"),
|
||||
"throw": SubResource("Animation_7gvmx")
|
||||
}
|
||||
|
||||
[node name="ThrowableItem" type="Node3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.535839)
|
||||
script = ExtResource("1_nac2l")
|
||||
|
||||
[node name="Hitbox" type="Area3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
collision_layer = 16
|
||||
collision_mask = 16
|
||||
script = ExtResource("3_qpunu")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="Hitbox"]
|
||||
billboard = 2
|
||||
texture = ExtResource("2_mojlk")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Hitbox"]
|
||||
shape = SubResource("BoxShape3D_qihtb")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_qfght")
|
||||
}
|
||||
Reference in New Issue
Block a user