Basic projectile implementation (put sample version in FilthEaterModelView)
This commit is contained in:
35
Zennysoft.Game.Ma/src/system/Projectile.cs
Normal file
35
Zennysoft.Game.Ma/src/system/Projectile.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
using Zennysoft.Game.Ma;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Projectile : Node3D
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency] protected IPlayer _player => this.DependOn(() => GetParent().GetChildren().OfType<IPlayer>().Single());
|
||||
|
||||
[Node] public Area3D ProjectileHitbox { get; set; }
|
||||
|
||||
[Node] public AnimationPlayer AnimationPlayer { get; set; }
|
||||
|
||||
[Export] public AttackDataResource AttackData { get; set; }
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
ProjectileHitbox.AreaEntered += Hitbox_AreaEntered;
|
||||
}
|
||||
|
||||
public void Fire()
|
||||
{
|
||||
AnimationPlayer.Play("Fire");
|
||||
}
|
||||
|
||||
private void Hitbox_AreaEntered(Area3D area)
|
||||
{
|
||||
_player.TakeDamage(new AttackData(AttackData.Damage, AttackData.ElementType));
|
||||
}
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/system/Projectile.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/system/Projectile.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cqm6u7qa8japr
|
||||
438
Zennysoft.Game.Ma/src/system/SampleProjectile.tscn
Normal file
438
Zennysoft.Game.Ma/src/system/SampleProjectile.tscn
Normal file
@@ -0,0 +1,438 @@
|
||||
[gd_scene load_steps=50 format=3 uid="uid://36h8dl0tpmga"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cqm6u7qa8japr" path="res://src/system/Projectile.cs" id="1_0hjuy"]
|
||||
[ext_resource type="Texture2D" uid="uid://wqjql5n24h1l" path="res://src/vfx/Enemy/BLUE_FLAME.png" id="2_hwc8p"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xrn7e"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(1024, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8qeb2"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(1536, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_q8n6h"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(2048, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_brbcy"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(2560, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dftoy"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(3072, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8u0x2"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(3584, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fqqmc"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(4096, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_b1lif"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(4608, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_f7ayv"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(5120, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_2y7ln"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(5632, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_311ch"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(6144, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_60ajf"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(6656, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qcv8t"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(7168, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ym3vo"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(7680, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_5fqo7"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(8192, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_w2bwt"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(8704, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qm55s"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(9216, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_rdrim"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(9728, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kli1f"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(10240, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dif4r"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(10752, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4mwd1"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(11264, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_npl5k"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(11776, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_obbx1"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(12288, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4o8yi"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(12800, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kk4df"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(13312, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_a212s"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(13824, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ddop6"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(14336, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_bsamt"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(14848, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_lcs75"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(15360, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_sv0jq"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(15872, 0, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ap565"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(0, 502, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_x7xwk"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(512, 502, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gf7y0"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(1024, 502, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_n3cae"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(1536, 502, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_s3abf"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(2048, 502, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ldl6g"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(2560, 502, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ysnl1"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(3072, 502, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_l6jiv"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(3584, 502, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ra6k7"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(4096, 502, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_chxxr"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(4608, 502, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1cxo4"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(5120, 502, 512, 502)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_sx8e2"]
|
||||
atlas = ExtResource("2_hwc8p")
|
||||
region = Rect2(5632, 502, 512, 502)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_brsyt"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xrn7e")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_8qeb2")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_q8n6h")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_brbcy")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_dftoy")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_8u0x2")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fqqmc")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_b1lif")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_f7ayv")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_2y7ln")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_311ch")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_60ajf")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qcv8t")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ym3vo")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_5fqo7")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_w2bwt")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qm55s")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_rdrim")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_kli1f")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_dif4r")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_4mwd1")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_npl5k")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_obbx1")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_4o8yi")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_kk4df")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_a212s")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ddop6")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_bsamt")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_lcs75")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_sv0jq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ap565")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_x7xwk")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_gf7y0")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_n3cae")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_s3abf")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ldl6g")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ysnl1")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_l6jiv")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ra6k7")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_chxxr")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_1cxo4")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_sx8e2")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"default",
|
||||
"speed": 24.0
|
||||
}]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_kct8n"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_8qeb2"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("..:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 0, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("../ProjectileHitbox:monitoring")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [false]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath(".:visible")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [false]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_xrn7e"]
|
||||
resource_name = "fire"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("..:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 0, 0), Vector3(0, 0, 10)]
|
||||
}
|
||||
tracks/1/type = "audio"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("../AudioStreamPlayer3D")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"clips": [{
|
||||
"end_offset": 0.0,
|
||||
"start_offset": 0.0,
|
||||
"stream": null
|
||||
}],
|
||||
"times": PackedFloat32Array(0.0333333)
|
||||
}
|
||||
tracks/1/use_blend = true
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("../ProjectileHitbox:monitoring")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 0.0333333, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [false, true, false]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath(".:visible")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array(0, 0.0333333, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [false, true, false]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_q8n6h"]
|
||||
_data = {
|
||||
&"Fire": SubResource("Animation_xrn7e"),
|
||||
&"RESET": SubResource("Animation_8qeb2")
|
||||
}
|
||||
|
||||
[node name="Projectile" type="Node3D"]
|
||||
script = ExtResource("1_0hjuy")
|
||||
|
||||
[node name="Bullet" type="Node3D" parent="."]
|
||||
|
||||
[node name="AnimatedSprite3D" type="AnimatedSprite3D" parent="Bullet"]
|
||||
visible = false
|
||||
offset = Vector2(0, 150)
|
||||
billboard = 1
|
||||
sprite_frames = SubResource("SpriteFrames_brsyt")
|
||||
autoplay = "default"
|
||||
frame_progress = 0.79063
|
||||
|
||||
[node name="ProjectileHitbox" type="Area3D" parent="Bullet"]
|
||||
unique_name_in_owner = true
|
||||
collision_layer = 0
|
||||
collision_mask = 64
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Bullet/ProjectileHitbox"]
|
||||
shape = SubResource("SphereShape3D_kct8n")
|
||||
|
||||
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="Bullet"]
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="Bullet"]
|
||||
unique_name_in_owner = true
|
||||
root_node = NodePath("../AnimatedSprite3D")
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_q8n6h")
|
||||
}
|
||||
Reference in New Issue
Block a user