this is so easy to develop there must be a catch
Some checks failed
Create tag and build when new code gets to main / BumpTag (push) Successful in 26s
Create tag and build when new code gets to main / Export (push) Failing after 1m55s

This commit is contained in:
2026-01-25 00:16:16 +01:00
parent 92cc4f0264
commit cf7591b413
5 changed files with 60 additions and 14 deletions

View File

@@ -1,10 +1,12 @@
using System;
using Godot;
using GodotStateCharts;
using Movementtests.interfaces;
using Movementtests.systems.damage;
namespace Movementtests.systems;
public partial class WeaponSystem : RigidBody3D
public partial class WeaponSystem : RigidBody3D, IDamageDealer
{
[Signal]
public delegate void WeaponThrownEventHandler();
@@ -12,6 +14,8 @@ public partial class WeaponSystem : RigidBody3D
[Signal]
public delegate void WeaponRetrievedEventHandler();
[Export]
public RDamage RDamage { get; set; }
[Export(PropertyHint.Range, "0,100,1,or_greater")]
public float ThrowForce { get; set; } = 1f;
[Export(PropertyHint.Range, "0,0.2,0.01,or_greater")]
@@ -107,6 +111,17 @@ public partial class WeaponSystem : RigidBody3D
tween.Finished += ThrowWeaponOnCurve;
}
public void PlantInEnemy(Node3D enemy)
{
GetTree().GetRoot().CallDeferred(Node.MethodName.RemoveChild, this);
enemy.CallDeferred(Node.MethodName.AddChild, this);
if (enemy is IDamageable damageable)
{
damageable.TakeDamage(new DamageRecord(this, RDamage));
}
}
public void RethrowWeapon()
{
_weaponState.SendEvent("throw");
@@ -130,8 +145,7 @@ public partial class WeaponSystem : RigidBody3D
// WeaponLocationIndicatorMaterial.StencilColor = new Color(1f, 0.2f, 0.2f);
if (PlantObject is Node3D node)
{
GetTree().GetRoot().CallDeferred(Node.MethodName.RemoveChild, this);
node.CallDeferred(Node.MethodName.AddChild, this);
PlantInEnemy(node);
}
CallDeferred(Node3D.MethodName.SetGlobalPosition, PlantLocation);
CallDeferred(Node3D.MethodName.LookAt, GlobalTransform.Origin + PlantNormal, Vector3.Up, true);