reorganizing stuff
This commit is contained in:
25
components/knockback/CKnockback.cs
Normal file
25
components/knockback/CKnockback.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Movementtests.interfaces;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class CKnockback : Node3D, IKnockbackable
|
||||
{
|
||||
[Export] public RKnockback RKnockback { get; set;}
|
||||
|
||||
private DamageRecord _damageRecord = null;
|
||||
|
||||
public void RegisterKnockback(IDamageable source, DamageRecord damageRecord)
|
||||
{
|
||||
_damageRecord = damageRecord;
|
||||
}
|
||||
|
||||
public Vector3 ComputeKnockback()
|
||||
{
|
||||
if (_damageRecord == null) return Vector3.Zero;
|
||||
|
||||
var knockbackDirection = GlobalPosition - _damageRecord.Source.GlobalPosition;
|
||||
_damageRecord = null;
|
||||
return knockbackDirection.Normalized() * RKnockback.Modifier;
|
||||
}
|
||||
}
|
||||
1
components/knockback/CKnockback.cs.uid
Normal file
1
components/knockback/CKnockback.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b8dprpcjeac7e
|
||||
12
components/knockback/CKnockback.tscn
Normal file
12
components/knockback/CKnockback.tscn
Normal file
@@ -0,0 +1,12 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://bctpe34ddamg5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b8dprpcjeac7e" path="res://components/knockback/CKnockback.cs" id="1_ix2yg"]
|
||||
[ext_resource type="Script" uid="uid://b44cse62qru7j" path="res://components/knockback/RKnockback.cs" id="2_uqiml"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_gbu2d"]
|
||||
script = ExtResource("2_uqiml")
|
||||
metadata/_custom_type_script = "uid://b44cse62qru7j"
|
||||
|
||||
[node name="CKnockback" type="Node3D"]
|
||||
script = ExtResource("1_ix2yg")
|
||||
RKnockback = SubResource("Resource_gbu2d")
|
||||
19
components/knockback/RKnockback.cs
Normal file
19
components/knockback/RKnockback.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Movementtests.interfaces;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class RKnockback : Resource
|
||||
{
|
||||
[Export]
|
||||
public float Modifier = 1.0f;
|
||||
|
||||
public RKnockback()
|
||||
{
|
||||
Modifier = 1.0f;
|
||||
}
|
||||
public RKnockback(float modifier)
|
||||
{
|
||||
Modifier = modifier;
|
||||
}
|
||||
}
|
||||
1
components/knockback/RKnockback.cs.uid
Normal file
1
components/knockback/RKnockback.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b44cse62qru7j
|
||||
Reference in New Issue
Block a user