fixed a wallhanging bug and explosion shader precompilation to alleviate stuttering

This commit is contained in:
2026-02-04 10:32:44 +01:00
parent 0e412c2a42
commit 15ab9edab1
6 changed files with 8 additions and 2 deletions

View 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();
}
}