fixed a wallhanging bug and explosion shader precompilation to alleviate stuttering
This commit is contained in:
36
scenes/explosion/Explosion.cs
Normal file
36
scenes/explosion/Explosion.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Movementtests.interfaces;
|
||||
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_projectile.png")]
|
||||
public partial class Explosion : Area3D, IDamageDealer
|
||||
{
|
||||
[Export] public RDamage RDamage { get; set;}
|
||||
[Export] public float Radius { get; set;}
|
||||
[Export] public float ExplosionTime { get; set; } = 0.2f;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
var sphereShape = GetNode<CollisionShape3D>("CollisionShape3D").Shape as SphereShape3D;
|
||||
sphereShape!.Radius = Radius;
|
||||
var sphereMesh = GetNode<MeshInstance3D>("MeshInstance3D").Mesh as SphereMesh;
|
||||
sphereMesh!.Radius = Radius;
|
||||
sphereMesh!.Height = Radius*2f;
|
||||
|
||||
GetTree().CreateTimer(ExplosionTime).Timeout += TriggerExplosion;
|
||||
}
|
||||
|
||||
public void TriggerExplosion()
|
||||
{
|
||||
var bodies = GetOverlappingBodies();
|
||||
foreach (var body in bodies)
|
||||
{
|
||||
if (body is IDamageable damageable)
|
||||
damageable.TakeDamage(new DamageRecord(GlobalPosition, RDamage));
|
||||
if (body is IStunnable stunnable)
|
||||
stunnable.Stun();
|
||||
}
|
||||
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
1
scenes/explosion/Explosion.cs.uid
Normal file
1
scenes/explosion/Explosion.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cnlu64l7oxvv3
|
||||
34
scenes/explosion/explosion.tscn
Normal file
34
scenes/explosion/explosion.tscn
Normal file
@@ -0,0 +1,34 @@
|
||||
[gd_scene format=3 uid="uid://duju3atqgltkg"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cnlu64l7oxvv3" path="res://scenes/explosion/Explosion.cs" id="1_82hkh"]
|
||||
[ext_resource type="Script" uid="uid://jitubgv6judn" path="res://components/damage/RDamage.cs" id="2_hys74"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ffdh3"]
|
||||
script = ExtResource("2_hys74")
|
||||
DamageDealt = 5.0
|
||||
DamageType = 3
|
||||
metadata/_custom_type_script = "uid://jitubgv6judn"
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_82hkh"]
|
||||
radius = 1.0
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_82hkh"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_hys74"]
|
||||
transparency = 1
|
||||
cull_mode = 2
|
||||
albedo_color = Color(0.9607843, 0.27058825, 0, 0.7176471)
|
||||
|
||||
[node name="Explosion" type="Area3D" unique_id=1876014452]
|
||||
collision_layer = 0
|
||||
collision_mask = 16
|
||||
monitorable = false
|
||||
script = ExtResource("1_82hkh")
|
||||
RDamage = SubResource("Resource_ffdh3")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1259903749]
|
||||
shape = SubResource("SphereShape3D_82hkh")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=1864409522]
|
||||
mesh = SubResource("SphereMesh_82hkh")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_hys74")
|
||||
Reference in New Issue
Block a user