Compare commits

...

13 Commits

Author SHA1 Message Date
9690280cd7 better spawning
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 20s
Create tag and build when new code gets to main / Export (push) Successful in 10m36s
2026-01-18 10:27:21 +01:00
65538495c4 spawning
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 19s
Create tag and build when new code gets to main / Export (push) Successful in 9m59s
2026-01-17 23:18:06 +01:00
561e026834 ok so this should be the way to go
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 20s
Create tag and build when new code gets to main / Export (push) Successful in 10m24s
2026-01-17 21:51:57 +01:00
7c74b8b5e5 removing broken ABC and refactoring enemy movement
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 19s
Create tag and build when new code gets to main / Export (push) Successful in 10m2s
2026-01-17 19:55:51 +01:00
f7705a6d57 moving files around
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 18s
Create tag and build when new code gets to main / Export (push) Successful in 10m3s
2026-01-17 17:58:23 +01:00
0dcf4a3f99 fixed damage composition issue 2026-01-17 17:47:14 +01:00
4ccdbc0ee6 broken composition and signals 2026-01-17 17:02:31 +01:00
0436053c62 broken composition and signals 2026-01-17 17:02:16 +01:00
6b97c226f1 setup damage types and modifiers as resources
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 19s
Create tag and build when new code gets to main / Export (push) Successful in 10m48s
2026-01-17 14:32:48 +01:00
b1e78df6c7 some damage interfacing 2026-01-17 11:02:17 +01:00
5908494977 two enemy types, ready to refactor 2026-01-17 10:10:14 +01:00
63529a11ae removed tool script stuff
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 20s
Create tag and build when new code gets to main / Export (push) Successful in 9m57s
2026-01-16 18:36:36 +01:00
255b87f991 basic interface and no success trying to use them in a Tool script 2026-01-16 18:35:58 +01:00
62 changed files with 995 additions and 144 deletions

View File

@@ -1,4 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAction_00601_002Ecs_002Fl_003AC_0021_003FUsers_003FMinimata_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F7c0f83388bfc4d2c9d09befcec9dd79bc90908_003Fb8_003F4d300c4d_003FAction_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANode_002Ecs_002Fl_003AC_0021_003FUsers_003FMinimata_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003Fdf73a4db74df89d59655c5fb6326406f47fbfa9af1fa81518fe0a07c49d34133_003FNode_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASceneTree_002Ecs_002Fl_003AC_0021_003FUsers_003FMinimata_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003F8d6960554e939a669841b1ece03d27df4ab42f92bb80be3767eaec8cdaccf84b_003FSceneTree_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=floorplane/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@@ -0,0 +1,9 @@
using Godot;
namespace Movementtests.interfaces;
public interface IDamageMaker
{
[Export]
RDamage RDamage { get; set; }
}

View File

@@ -0,0 +1 @@
uid://wdqo51131g5

View File

@@ -0,0 +1,9 @@
using System;
namespace Movementtests.interfaces;
public interface IDamageable
{
event Action<IDamageable, float> DamageTaken;
float TakeDamage(RDamage damage);
}

View File

@@ -0,0 +1 @@
uid://cf56b2ep3bu3j

16
interfaces/IHealthable.cs Normal file
View File

@@ -0,0 +1,16 @@
using System;
using Godot;
namespace Movementtests.interfaces;
public interface IHealthable
{
event Action<IHealthable, float> HealthChanged;
event Action<IHealthable> HealthDepleted;
[Export] RHealth RHealth { get; set; }
float CurrentHealth { get; set; }
void ReduceHealth(IDamageable source, float amount);
}

View File

@@ -0,0 +1 @@
uid://bea2kvnu3kuhu

6
interfaces/IKillable.cs Normal file
View File

@@ -0,0 +1,6 @@
namespace Movementtests.interfaces;
public interface IKillable
{
void Kill(IHealthable source);
}

View File

@@ -0,0 +1 @@
uid://dqpjr2d01sk1a

View File

@@ -0,0 +1,6 @@
namespace Movementtests.interfaces;
public interface IKnockbackable
{
}

View File

@@ -0,0 +1 @@
uid://bh06s1yefucf7

16
interfaces/IMoveable.cs Normal file
View File

@@ -0,0 +1,16 @@
using Godot;
namespace Movementtests.interfaces;
public record MovementInputs(
Vector3 Velocity = default,
Vector3 TargetLocation = default,
bool isOnFloor = false,
Vector3 gravity = default,
double delta = 0);
public interface IMoveable
{
[Export] RMovement RMovement { get; set; }
Vector3 ComputeVelocity(MovementInputs inputs);
}

View File

@@ -0,0 +1 @@
uid://dp6v42a2iwlbs

7
interfaces/ISpawnable.cs Normal file
View File

@@ -0,0 +1,7 @@
using Godot;
interface ISpawnable
{
void Initialize();
}

View File

@@ -0,0 +1 @@
uid://bethuw2c1at8o

View File

@@ -0,0 +1,16 @@
using Godot;
using System.Linq;
namespace Movementtests.interfaces;
public static class NodeExtensions
{
public static IDamageable[] ToIDamageables(this GodotObject[] nodes)
{
return nodes == null ? System.Array.Empty<IDamageable>() : nodes.OfType<IDamageable>().ToArray();
}
public static IKillable[] ToIKillables(this GodotObject[] nodes)
{
return nodes == null ? System.Array.Empty<IKillable>() : nodes.OfType<IKillable>().ToArray();
}
}

View File

@@ -0,0 +1 @@
uid://bgnncty7axdwd

View File

@@ -1,9 +1,23 @@
[gd_scene load_steps=11 format=3 uid="uid://q7uc1h2jpbd2"]
[gd_scene load_steps=20 format=3 uid="uid://q7uc1h2jpbd2"]
[ext_resource type="PackedScene" uid="uid://bei4nhkf8lwdo" path="res://player_controller/PlayerController.tscn" id="1_62kkh"]
[ext_resource type="Material" uid="uid://31aulub2nqov" path="res://assets/greybox/m_greybox.tres" id="2_3uydm"]
[ext_resource type="PackedScene" uid="uid://dxt0e2ugmttqq" path="res://scenes/enemies/first_enemy.tscn" id="3_3uydm"]
[ext_resource type="Script" uid="uid://b2vdwkiqauhk3" path="res://scenes/enemies/EnemyInitInputs.cs" id="4_nd7vd"]
[ext_resource type="Script" uid="uid://jitubgv6judn" path="res://resource_definitions/RDamage.cs" id="2_sysok"]
[ext_resource type="PackedScene" uid="uid://dxt0e2ugmttqq" path="res://scenes/enemies/grounded_enemy/grounded_enemy.tscn" id="3_3uydm"]
[ext_resource type="Script" uid="uid://b4cwruitopcee" path="res://resource_definitions/RDeathEffect.cs" id="5_7m3bq"]
[ext_resource type="PackedScene" uid="uid://cmlud1hwkd6sv" path="res://scenes/enemies/flying_enemy/flying_enemy.tscn" id="5_8fd2t"]
[ext_resource type="PackedScene" uid="uid://c305mfrtumcyq" path="res://scenes/spawners/spawner.tscn" id="6_7m3bq"]
[ext_resource type="Resource" uid="uid://bqq6uukbdfysr" path="res://scenes/enemies/grounded_enemy/grounded_enemy_movement.tres" id="7_caohq"]
[ext_resource type="Script" uid="uid://baiapod3csndf" path="res://resource_definitions/RHealth.cs" id="9_2e4ci"]
[ext_resource type="Resource" uid="uid://otfc2snh8umc" path="res://scenes/enemies/grounded_enemy/grounded_enemy_damage.tres" id="9_dmw1t"]
[ext_resource type="Resource" uid="uid://dgo65k2ceqfvy" path="res://scenes/enemies/flying_enemy/flying_enemy_damage.tres" id="9_gp7s3"]
[ext_resource type="Resource" uid="uid://bwqjaom4k7rc3" path="res://scenes/enemies/flying_enemy/flying_enemy_movement.tres" id="10_spw1u"]
[ext_resource type="Resource" uid="uid://dg1xbjhyhgnnk" path="res://scenes/enemies/flying_enemy/flying_enemy_health.tres" id="11_2e4ci"]
[sub_resource type="Resource" id="Resource_2e4ci"]
script = ExtResource("2_sysok")
DamageDealt = 10.0
metadata/_custom_type_script = "uid://jitubgv6judn"
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_0xm2m"]
sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
@@ -27,26 +41,21 @@ ssil_radius = 8.4
sdfgi_use_occlusion = true
glow_enabled = true
[sub_resource type="Resource" id="Resource_8fd2t"]
script = ExtResource("4_nd7vd")
Speed = 3.2
metadata/_custom_type_script = "uid://b2vdwkiqauhk3"
[sub_resource type="Resource" id="Resource_7m3bq"]
script = ExtResource("4_nd7vd")
Speed = 2.8
metadata/_custom_type_script = "uid://b2vdwkiqauhk3"
[sub_resource type="Resource" id="Resource_sysok"]
script = ExtResource("4_nd7vd")
Speed = 6.4
metadata/_custom_type_script = "uid://b2vdwkiqauhk3"
script = ExtResource("5_7m3bq")
metadata/_custom_type_script = "uid://b4cwruitopcee"
[sub_resource type="Resource" id="Resource_ybosk"]
script = ExtResource("9_2e4ci")
StartingHealth = 1.0
metadata/_custom_type_script = "uid://baiapod3csndf"
[node name="Main" type="Node3D"]
[node name="Player" parent="." instance=ExtResource("1_62kkh")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 7.5)
TutorialDone = true
RDamage = SubResource("Resource_2e4ci")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_1bvp3")
@@ -111,14 +120,36 @@ material = ExtResource("2_3uydm")
[node name="Enemy" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("3_3uydm")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -16.83681)
Target = NodePath("../Player")
Inputs = SubResource("Resource_8fd2t")
DeathEffects = Array[Object]([SubResource("Resource_sysok")])
[node name="Enemy2" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("3_3uydm")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, -16.83681)
Target = NodePath("../Player")
Inputs = SubResource("Resource_7m3bq")
[node name="Enemy3" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("3_3uydm")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.5, 0, -16.83681)
Target = NodePath("../Player")
Inputs = SubResource("Resource_sysok")
[node name="FlyingEnemy" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("5_8fd2t")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8, 7, -16)
Target = NodePath("../Player")
[node name="FlyingEnemy2" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("5_8fd2t")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 10, 7, -16)
Target = NodePath("../Player")
[node name="GroundedSpawner" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("6_7m3bq")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12, 2.5, -15)
EnemyToSpawn = ExtResource("3_3uydm")
MovementInputs = ExtResource("7_caohq")
HealthInputs = SubResource("Resource_ybosk")
DamageInputs = ExtResource("9_dmw1t")
Target = NodePath("../Player")
[node name="FlyingSpawner" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("6_7m3bq")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 18, 11, -14)
EnemyToSpawn = ExtResource("5_8fd2t")
MovementInputs = ExtResource("10_spw1u")
HealthInputs = ExtResource("11_2e4ci")
DamageInputs = ExtResource("9_gp7s3")
Target = NodePath("../Player")

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=40 format=3 uid="uid://dmkw8cmalm5k"]
[gd_scene load_steps=45 format=3 uid="uid://dmkw8cmalm5k"]
[ext_resource type="PackedScene" uid="uid://bei4nhkf8lwdo" path="res://player_controller/PlayerController.tscn" id="1_2vsi6"]
[ext_resource type="Script" uid="uid://blenis2y55fmg" path="res://tools/city_helpers.gd" id="1_qwuk2"]
@@ -23,6 +23,10 @@
[ext_resource type="Texture2D" uid="uid://cjh5cnvdbq5ku" path="res://assets/ui/input-prompts/Xbox Series/Vector/xbox_button_b_outline.svg" id="19_efsse"]
[ext_resource type="Texture2D" uid="uid://nrhxjdpuje3f" path="res://assets/ui/input-prompts/Xbox Series/Vector/xbox_lt_outline.svg" id="20_crf87"]
[ext_resource type="Texture2D" uid="uid://dyjvbsvbriii4" path="res://assets/ui/input-prompts/Xbox Series/Vector/xbox_rb_outline.svg" id="23_p287n"]
[ext_resource type="PackedScene" uid="uid://c305mfrtumcyq" path="res://scenes/spawners/spawner.tscn" id="24_qwuk2"]
[ext_resource type="PackedScene" uid="uid://dxt0e2ugmttqq" path="res://scenes/enemies/grounded_enemy/grounded_enemy.tscn" id="25_nrosh"]
[ext_resource type="PackedScene" uid="uid://cmlud1hwkd6sv" path="res://scenes/enemies/flying_enemy/flying_enemy.tscn" id="25_x7fl1"]
[ext_resource type="Script" uid="uid://dtpxijlnb2c5" path="res://resource_definitions/RMovement.cs" id="26_lu3yt"]
[sub_resource type="LabelSettings" id="LabelSettings_2k3fr"]
font_size = 30
@@ -89,6 +93,12 @@ adjustment_enabled = true
[sub_resource type="BoxMesh" id="BoxMesh_p287n"]
[sub_resource type="Resource" id="Resource_pxspk"]
script = ExtResource("26_lu3yt")
Speed = 7.0
TargetHeight = 15.0
metadata/_custom_type_script = "uid://dtpxijlnb2c5"
[node name="Main" type="Node3D"]
script = ExtResource("1_qwuk2")
@@ -436,6 +446,17 @@ spot_range = 47.233
spot_angle = 18.85
spot_angle_attenuation = 10.556052
[node name="Spawner" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("24_qwuk2")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 19, 43, -111.5)
EnemyToSpawn = ExtResource("25_x7fl1")
MovementInputs = SubResource("Resource_pxspk")
Target = NodePath("../Player")
[node name="Spawner2" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("24_qwuk2")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 31, 7.5, -88)
EnemyToSpawn = ExtResource("25_nrosh")
Target = NodePath("../Player")
[connection signal="timeout" from="TutorialController/WaitToShowBlockingTuto" to="TutorialController" method="_show_weapon_tutorial"]
[connection signal="body_exited" from="TutoTriggers/TriggerTutoMove" to="TutorialController" method="hide_tutorials"]
[connection signal="body_entered" from="TutoTriggers/TriggerTutoMantle" to="TutorialController" method="_on_tuto_mantle_body_entered"]

View File

@@ -1,10 +1,12 @@
[gd_scene load_steps=50 format=3 uid="uid://bei4nhkf8lwdo"]
[gd_scene load_steps=54 format=3 uid="uid://bei4nhkf8lwdo"]
[ext_resource type="Script" uid="uid://bbbrf5ckydfna" path="res://player_controller/Scripts/PlayerController.cs" id="1_poq2x"]
[ext_resource type="PackedScene" uid="uid://cf3rrgr1imvv4" path="res://scenes/path/path.tscn" id="2_6lejt"]
[ext_resource type="Resource" uid="uid://bl5crtu1gkrtr" path="res://systems/inputs/base_mode/base_mode.tres" id="3_cresl"]
[ext_resource type="Script" uid="uid://b0u23nkpaimyc" path="res://scenes/damage/CDamageable.cs" id="4_q7bng"]
[ext_resource type="Resource" uid="uid://cpdaw41ah5gic" path="res://systems/inputs/base_mode/rotate_y.tres" id="4_rxwoh"]
[ext_resource type="Resource" uid="uid://ccrb5xsnphc8" path="res://systems/inputs/base_mode/rotate_floorplane.tres" id="5_4u7i3"]
[ext_resource type="Script" uid="uid://b6y3ugfydvch0" path="res://resource_definitions/RDamageModifier.cs" id="5_q7bng"]
[ext_resource type="Resource" uid="uid://f3vs6l4m623s" path="res://systems/inputs/base_mode/move_left.tres" id="5_q14ux"]
[ext_resource type="Resource" uid="uid://t612lts1wi1s" path="res://systems/inputs/base_mode/move_right.tres" id="6_q7bng"]
[ext_resource type="Script" uid="uid://cwbvxlfvmocc1" path="res://player_controller/Scripts/StairsSystem.cs" id="7_bmt5a"]
@@ -43,12 +45,20 @@
[ext_resource type="Texture2D" uid="uid://chvt6g0xn5c2m" path="res://systems/dash/light-ring.jpg" id="32_lgpc8"]
[ext_resource type="Script" uid="uid://b4dwolbvt8our" path="res://addons/godot_state_charts/history_state.gd" id="41_ruloh"]
[sub_resource type="Resource" id="Resource_jb43f"]
script = ExtResource("5_q7bng")
Modifier = 3.0
metadata/_custom_type_script = "uid://b6y3ugfydvch0"
[sub_resource type="CapsuleMesh" id="CapsuleMesh_xc2g5"]
height = 1.7
[sub_resource type="SphereShape3D" id="SphereShape3D_6lejt"]
radius = 0.45
[sub_resource type="SphereShape3D" id="SphereShape3D_q14ux"]
radius = 1.0
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nodcl"]
transparency = 1
albedo_color = Color(0, 0.627451, 0.6313726, 0.49019608)
@@ -69,9 +79,10 @@ radius = 0.4
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_2q0ik"]
blend_mode = 1
[node name="Player" type="CharacterBody3D"]
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("CDamage")]
collision_mask = 272
script = ExtResource("1_poq2x")
CDamage = NodePath("CDamageable")
WalkSpeed = 7.5
AccelerationFloor = 4.0
DecelerationFloor = 3.0
@@ -109,6 +120,11 @@ WallHugGravityLesseningFactor = 15.0
WallHugDownwardMaxSpeed = 4.0
WallHugHorizontalDeceleration = 1.0
[node name="CDamageable" type="Node" parent="."]
script = ExtResource("4_q7bng")
DamageModifiers = Array[Object]([SubResource("Resource_jb43f")])
metadata/_custom_type_script = "uid://b0u23nkpaimyc"
[node name="WallRunSnapper" type="RayCast3D" parent="."]
unique_name_in_owner = true
transform = Transform3D(0.99999994, 0, 0, 0, 1, 0, 0, 0, 0.99999994, 0, 0, 0)
@@ -164,6 +180,17 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.6, 0)
MantleEndLocationDistanceFromWall = 0.3
MantleHeightCastStart = 2.5
[node name="WeaponHitbox" type="Area3D" parent="HeadSystem"]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.6, 0)
collision_layer = 0
collision_mask = 16
monitorable = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="HeadSystem/WeaponHitbox"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -1.5)
shape = SubResource("SphereShape3D_q14ux")
[node name="StairsSystem" type="Node3D" parent="."]
script = ExtResource("7_bmt5a")
@@ -301,6 +328,7 @@ offset_left = 1524.0
offset_top = 1.0
offset_right = -8.0
offset_bottom = 1.0
enabled = false
initial_node_to_watch = NodePath("../StateChart")
[node name="UI" type="Control" parent="."]

View File

@@ -2,11 +2,12 @@ using System;
using Godot;
using GodotStateCharts;
using Movementtests.addons.godot_state_charts.csharp;
using Movementtests.interfaces;
using Movementtests.systems;
using Movementtests.player_controller.Scripts;
using RustyOptions;
public partial class PlayerController : CharacterBody3D
public partial class PlayerController : CharacterBody3D, IDamageable, IKnockbackable, IDamageMaker
{
// Enums
public enum AllowedInputs
@@ -28,6 +29,12 @@ public partial class PlayerController : CharacterBody3D
}
private BufferedActions _bufferedAction = BufferedActions.None;
///////////////////////////
// Signals and events //
///////////////////////////
public event Action<IDamageable, float> DamageTaken;
///////////////////////////
// Public stuff //
///////////////////////////
@@ -52,11 +59,19 @@ public partial class PlayerController : CharacterBody3D
public ShapeCast3D GroundDetector;
public ShapeCast3D CeilingDetector;
public RayCast3D DirectGroundDetector;
public Area3D WeaponHitbox;
// Inspector stuff
[Export] public Marker3D TutorialWeaponTarget;
[Export] public bool TutorialDone { get; set; }
[ExportCategory("Combat")]
[ExportGroup("Damage")]
[Export]
public RDamage RDamage { get; set; }
[Export]
public CDamageable CDamage { get; set; }
[ExportCategory("Movement")]
[ExportGroup("Ground")]
[Export(PropertyHint.Range, "0,20,0.1,or_greater")]
@@ -353,6 +368,8 @@ public partial class PlayerController : CharacterBody3D
var playerShape = StandingCollider.GetShape() as CapsuleShape3D;
_playerHeight = playerShape!.Height;
_playerRadius = playerShape.Radius;
WeaponHitbox = GetNode<Area3D>("%WeaponHitbox");
// State management
_playerState = StateChart.Of(GetNode("StateChart"));
@@ -1567,17 +1584,6 @@ public partial class PlayerController : CharacterBody3D
DashIndicatorMesh.Visible = false;
}
///////////////////////////
// Hit Management ///////
///////////////////////////
public void OnInputHitPressed()
{
if (_aiming.Active)
{
ThrowWeapon();
}
}
///////////////////////////
// Parry Management ///////
///////////////////////////
@@ -1728,4 +1734,30 @@ public partial class PlayerController : CharacterBody3D
DashIndicatorNode.LookAt(WeaponSystem.GlobalPosition);
}
}
public float TakeDamage(RDamage damage)
{
var finalDamage = CDamage.TakeDamage(damage);
DamageTaken?.Invoke(this, finalDamage);
return finalDamage;
}
///////////////////////////
// Hit Management ///////
///////////////////////////
public void OnInputHitPressed()
{
if (_aiming.Active && WeaponSystem.InHandState.Active)
{
ThrowWeapon();
}
if (!WeaponSystem.InHandState.Active) return;
var bodies = WeaponHitbox.GetOverlappingBodies();
foreach (var body in bodies)
{
if(body is IDamageable spawnable)
spawnable.TakeDamage(RDamage);
}
}
}

View File

@@ -0,0 +1,24 @@
using Godot;
using System;
using Movementtests.systems.damage;
[GlobalClass]
public partial class RDamage : Resource
{
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
public float DamageDealt = 1.0f;
[Export]
public EDamageTypes DamageType = EDamageTypes.Normal;
public RDamage()
{
DamageDealt = 1.0f;
DamageType = EDamageTypes.Normal;
}
public RDamage(float damageDealt, EDamageTypes damageType)
{
DamageDealt = damageDealt;
DamageType = damageType;
}
}

View File

@@ -0,0 +1 @@
uid://jitubgv6judn

View File

@@ -0,0 +1,34 @@
using Godot;
using System;
using Movementtests.interfaces;
using Movementtests.systems.damage;
[GlobalClass]
public partial class RDamageModifier : Resource, IDamageable
{
public event Action<IDamageable, float> DamageTaken;
[Export]
public EDamageTypes DamageType = EDamageTypes.Normal;
[Export]
public float Modifier = 1.0f;
public RDamageModifier()
{
Modifier = 1.0f;
DamageType = EDamageTypes.Normal;
}
public RDamageModifier(EDamageTypes damageType, float modifier)
{
Modifier = modifier;
DamageType = damageType;
}
public float TakeDamage(RDamage damage)
{
if (damage.DamageType != DamageType) return 0;
var finalDamage = damage.DamageDealt * Modifier;
DamageTaken?.Invoke(this, finalDamage);
return finalDamage;
}
}

View File

@@ -0,0 +1 @@
uid://b6y3ugfydvch0

View File

@@ -0,0 +1,12 @@
using Godot;
using System;
using Movementtests.interfaces;
[GlobalClass]
public partial class RDeathEffect : Resource, IKillable
{
public void Kill(IHealthable source)
{
GD.Print($"Death Effect triggered on {source}");
}
}

View File

@@ -0,0 +1 @@
uid://b4cwruitopcee

View File

@@ -0,0 +1,20 @@
using Godot;
using System;
using Movementtests.interfaces;
[GlobalClass]
public partial class RHealth : Resource
{
[Export]
public float StartingHealth = 100.0f;
public RHealth()
{
StartingHealth = 100.0f;
}
public RHealth(float startingHealth)
{
StartingHealth = startingHealth;
}
}

View File

@@ -0,0 +1 @@
uid://baiapod3csndf

View File

@@ -0,0 +1,23 @@
using Godot;
using System;
[GlobalClass]
public partial class RMovement : Resource
{
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
public float Speed;
[Export(PropertyHint.Range, "0,20,1,or_greater")]
public float TargetHeight;
public RMovement()
{
Speed = 3.0f;
TargetHeight = 10.0f;
}
public RMovement(float speed, float targetHeight)
{
Speed = speed;
TargetHeight = targetHeight;
}
}

View File

@@ -0,0 +1 @@
uid://dtpxijlnb2c5

View File

@@ -0,0 +1,22 @@
using Godot;
using System;
using Movementtests.interfaces;
[GlobalClass]
public partial class CDamageable : Node, IDamageable
{
public event Action<IDamageable, float> DamageTaken;
[Export]
public RDamageModifier[] DamageModifiers { get; set; }
public float TakeDamage(RDamage damage)
{
var finalDamage = 0f;
foreach (var damageable in DamageModifiers.ToIDamageables())
finalDamage += damageable.TakeDamage(damage);
DamageTaken?.Invoke(this, finalDamage);
return finalDamage;
}
}

View File

@@ -0,0 +1 @@
uid://b0u23nkpaimyc

View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://hpsg4fqwrx1u"]
[ext_resource type="Script" uid="uid://b0u23nkpaimyc" path="res://scenes/damage/CDamageable.cs" id="1_qp8bd"]
[node name="CDamageable" type="Node"]
script = ExtResource("1_qp8bd")

117
scenes/enemies/Enemy.cs Normal file
View File

@@ -0,0 +1,117 @@
using System;
using Godot;
using Movementtests.interfaces;
[GlobalClass]
public partial class Enemy : CharacterBody3D, IDamageable, IDamageMaker, IHealthable, IKillable, IMoveable, ISpawnable
{
public event Action<IDamageable, float> DamageTaken;
public event Action<IHealthable, float> HealthChanged;
public event Action<IHealthable> HealthDepleted;
[Export]
public Node3D Target { get; set; }
[Export]
public Node CHealth { get; set; }
[Export]
public RHealth RHealth { get; set; }
public float CurrentHealth { get; set; }
[Export]
public Node CDamage { get; set; }
[Export]
public RDamage RDamage { get; set; }
[Export]
public Node CMovement { get; set; }
[Export]
public RMovement RMovement { get; set; }
[Export]
public RDeathEffect[] DeathEffects { get; set; }
private Area3D _damageBox;
public override void _Ready()
{
Initialize();
SetupSignals();
}
public void Initialize()
{
_damageBox = GetNode<Area3D>("DamageBox");
if (CMovement is IMoveable moveable && RMovement != null) moveable.RMovement = RMovement;
if (CHealth is IHealthable healthable && RHealth != null)
{
healthable.RHealth = RHealth;
healthable.CurrentHealth = RHealth.StartingHealth;
}
}
public void SetupSignals()
{
_damageBox.BodyEntered += OnDamageBoxTriggered;
if (CDamage is IDamageable damageable) damageable.DamageTaken += ReduceHealth;
if (CHealth is IHealthable healthable) healthable.HealthDepleted += Kill;
}
public override void _PhysicsProcess(double delta)
{
var targetPlanar = new Vector3(Target.GlobalPosition.X, GlobalPosition.Y, Target.GlobalPosition.Z);
LookAt(targetPlanar);
var inputs = new MovementInputs(
Velocity: Velocity,
TargetLocation: Target.GlobalPosition,
isOnFloor: IsOnFloor(),
gravity: GetGravity(),
delta: delta
);
Velocity = ComputeVelocity(inputs);
MoveAndSlide();
}
public Vector3 ComputeVelocity(MovementInputs inputs)
{
if (CMovement is not IMoveable movement) return Vector3.Zero;
return movement!.ComputeVelocity(inputs);
}
public void OnDamageBoxTriggered(Node3D body)
{
GD.Print("Take this!");
if (body is not IDamageable damageable) return;
damageable.TakeDamage(RDamage);
}
public float TakeDamage(RDamage damage)
{
GD.Print("Ouch!");
if (CDamage is not IDamageable damageable) return 0;
var finalDamage = damageable.TakeDamage(damage);
DamageTaken?.Invoke(this, damage.DamageDealt);
return finalDamage;
}
public void ReduceHealth(IDamageable source, float amount)
{
if (CHealth is not IHealthable healthable) return;
healthable.ReduceHealth(source, amount);
}
public void Kill(IHealthable source)
{
foreach (var killable in DeathEffects.ToIKillables())
{
killable.Kill(source);
}
QueueFree();
}
}

View File

@@ -1,18 +0,0 @@
using Godot;
using System;
[GlobalClass]
public partial class EnemyInitInputs : Resource
{
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
public float Speed = 5.0f;
public EnemyInitInputs()
{
Speed = 5.0f;
}
public EnemyInitInputs(float speed)
{
Speed = speed;
}
}

View File

@@ -1 +0,0 @@
uid://b2vdwkiqauhk3

View File

@@ -1,40 +0,0 @@
using Godot;
using System;
using Movementtests.player_controller.Scripts;
public partial class FirstEnemy : CharacterBody3D
{
[Export]
public Node3D Target { get; set; }
[Export]
public EnemyInitInputs Inputs;
private RayCast3D _wallInFrontRayCast;
public override void _Ready()
{
_wallInFrontRayCast = GetNode<RayCast3D>("WallInFrontRayCast");
}
public override void _PhysicsProcess(double delta)
{
var target = Target.GlobalPosition;
var direction = (target - GlobalPosition).Normalized();
var targetPlane = new Vector3(target.X, GlobalPosition.Y, target.Z);
LookAt(targetPlane);
var velocity = Velocity;
velocity.X = direction.X * Inputs.Speed;
velocity.Z = direction.Z * Inputs.Speed;
if (_wallInFrontRayCast.IsColliding())
velocity.Y = Inputs.Speed;
else if (!IsOnFloor())
velocity += GetGravity() * (float)delta;
Velocity = velocity;
MoveAndSlide();
}
}

View File

@@ -1,51 +0,0 @@
[gd_scene load_steps=6 format=3 uid="uid://dxt0e2ugmttqq"]
[ext_resource type="Script" uid="uid://bn7sc6id7n166" path="res://scenes/enemies/FirstEnemy.cs" id="1_4yfjf"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_62kkh"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_3uydm"]
[sub_resource type="SphereMesh" id="SphereMesh_4yfjf"]
radius = 0.05
height = 0.1
radial_segments = 4
rings = 4
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_4yfjf"]
albedo_color = Color(0.06469653, 0.06469653, 0.06469653, 1)
[node name="CharacterBody3D" type="CharacterBody3D"]
collision_layer = 16
collision_mask = 273
script = ExtResource("1_4yfjf")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = SubResource("CapsuleShape3D_62kkh")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
layers = 33
mesh = SubResource("CapsuleMesh_3uydm")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.2, 1.5, -0.5)
layers = 33
cast_shadow = 0
ignore_occlusion_culling = true
mesh = SubResource("SphereMesh_4yfjf")
surface_material_override/0 = SubResource("StandardMaterial3D_4yfjf")
[node name="MeshInstance3D3" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, 1.5, -0.5)
layers = 33
cast_shadow = 0
ignore_occlusion_culling = true
mesh = SubResource("SphereMesh_4yfjf")
surface_material_override/0 = SubResource("StandardMaterial3D_4yfjf")
[node name="WallInFrontRayCast" type="RayCast3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0)
target_position = Vector3(0, 0, -1.5)
collision_mask = 272

View File

@@ -0,0 +1,104 @@
[gd_scene load_steps=18 format=3 uid="uid://cmlud1hwkd6sv"]
[ext_resource type="Script" uid="uid://bn7sc6id7n166" path="res://scenes/enemies/Enemy.cs" id="1_q8l7o"]
[ext_resource type="Script" uid="uid://b6y3ugfydvch0" path="res://resource_definitions/RDamageModifier.cs" id="2_1bsgx"]
[ext_resource type="Resource" uid="uid://dg1xbjhyhgnnk" path="res://scenes/enemies/flying_enemy/flying_enemy_health.tres" id="2_ma2bq"]
[ext_resource type="Resource" uid="uid://dgo65k2ceqfvy" path="res://scenes/enemies/flying_enemy/flying_enemy_damage.tres" id="2_on7rt"]
[ext_resource type="Resource" uid="uid://bwqjaom4k7rc3" path="res://scenes/enemies/flying_enemy/flying_enemy_movement.tres" id="4_dejyg"]
[ext_resource type="Script" uid="uid://bjwrpv3jpsc1e" path="res://scenes/health/CHealth.cs" id="4_ys4jv"]
[ext_resource type="PackedScene" uid="uid://dmw5ibwrb483f" path="res://scenes/movement/CFlyingMovement.tscn" id="7_vaeds"]
[ext_resource type="Script" uid="uid://dtpxijlnb2c5" path="res://resource_definitions/RMovement.cs" id="8_on7rt"]
[ext_resource type="Script" uid="uid://b0u23nkpaimyc" path="res://scenes/damage/CDamageable.cs" id="8_uotso"]
[sub_resource type="Resource" id="Resource_jnv07"]
script = ExtResource("2_1bsgx")
metadata/_custom_type_script = "uid://b6y3ugfydvch0"
[sub_resource type="Resource" id="Resource_53j1c"]
script = ExtResource("2_1bsgx")
DamageType = 1
metadata/_custom_type_script = "uid://b6y3ugfydvch0"
[sub_resource type="Resource" id="Resource_on7rt"]
script = ExtResource("8_on7rt")
Speed = 3.0
TargetHeight = 10.0
metadata/_custom_type_script = "uid://dtpxijlnb2c5"
[sub_resource type="SphereShape3D" id="SphereShape3D_b46rq"]
[sub_resource type="SphereMesh" id="SphereMesh_1bsgx"]
[sub_resource type="SphereMesh" id="SphereMesh_4yfjf"]
radius = 0.05
height = 0.1
radial_segments = 4
rings = 4
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_4yfjf"]
albedo_color = Color(0.06469653, 0.06469653, 0.06469653, 1)
[sub_resource type="BoxShape3D" id="BoxShape3D_4yfjf"]
size = Vector3(1, 1, 1.5)
[node name="FlyingEnemy" type="CharacterBody3D" node_paths=PackedStringArray("CHealth", "CDamage", "CMovement")]
collision_layer = 16
collision_mask = 273
motion_mode = 1
script = ExtResource("1_q8l7o")
CHealth = NodePath("CHealth")
RHealth = ExtResource("2_ma2bq")
CDamage = NodePath("CDamageable")
RDamage = ExtResource("2_on7rt")
CMovement = NodePath("CFlyingMovement")
RMovement = ExtResource("4_dejyg")
DeathEffects = Array[Object]([])
[node name="CHealth" type="Node" parent="."]
script = ExtResource("4_ys4jv")
RHealth = ExtResource("2_ma2bq")
metadata/_custom_type_script = "uid://bjwrpv3jpsc1e"
[node name="CDamageable" type="Node" parent="."]
script = ExtResource("8_uotso")
DamageModifiers = Array[Object]([SubResource("Resource_jnv07"), SubResource("Resource_53j1c")])
metadata/_custom_type_script = "uid://b0u23nkpaimyc"
[node name="CFlyingMovement" parent="." instance=ExtResource("7_vaeds")]
RMovement = SubResource("Resource_on7rt")
TerrainCollision = 256
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_b46rq")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
layers = 33
mesh = SubResource("SphereMesh_1bsgx")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.2, 0, -0.5)
layers = 33
cast_shadow = 0
ignore_occlusion_culling = true
mesh = SubResource("SphereMesh_4yfjf")
surface_material_override/0 = SubResource("StandardMaterial3D_4yfjf")
[node name="MeshInstance3D3" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, 0, -0.5)
layers = 33
cast_shadow = 0
ignore_occlusion_culling = true
mesh = SubResource("SphereMesh_4yfjf")
surface_material_override/0 = SubResource("StandardMaterial3D_4yfjf")
[node name="GroundDistance" type="RayCast3D" parent="."]
target_position = Vector3(0, 0, 0)
collision_mask = 272
[node name="DamageBox" type="Area3D" parent="."]
collision_layer = 0
monitorable = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="DamageBox"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.75)
shape = SubResource("BoxShape3D_4yfjf")

View File

@@ -0,0 +1,8 @@
[gd_resource type="Resource" script_class="RDamage" load_steps=2 format=3 uid="uid://dgo65k2ceqfvy"]
[ext_resource type="Script" uid="uid://jitubgv6judn" path="res://resource_definitions/RDamage.cs" id="1_h6law"]
[resource]
script = ExtResource("1_h6law")
DamageType = 3
metadata/_custom_type_script = "uid://jitubgv6judn"

View File

@@ -0,0 +1,8 @@
[gd_resource type="Resource" script_class="RHealth" load_steps=2 format=3 uid="uid://dg1xbjhyhgnnk"]
[ext_resource type="Script" uid="uid://baiapod3csndf" path="res://resource_definitions/RHealth.cs" id="1_jht15"]
[resource]
script = ExtResource("1_jht15")
StartingHealth = 50.0
metadata/_custom_type_script = "uid://baiapod3csndf"

View File

@@ -0,0 +1,9 @@
[gd_resource type="Resource" script_class="RMovement" load_steps=2 format=3 uid="uid://bwqjaom4k7rc3"]
[ext_resource type="Script" uid="uid://dtpxijlnb2c5" path="res://resource_definitions/RMovement.cs" id="1_3yq0a"]
[resource]
script = ExtResource("1_3yq0a")
Speed = 3.0
TargetHeight = 10.0
metadata/_custom_type_script = "uid://dtpxijlnb2c5"

View File

@@ -0,0 +1,100 @@
[gd_scene load_steps=17 format=3 uid="uid://dxt0e2ugmttqq"]
[ext_resource type="Script" uid="uid://bn7sc6id7n166" path="res://scenes/enemies/Enemy.cs" id="1_r6506"]
[ext_resource type="Resource" uid="uid://otfc2snh8umc" path="res://scenes/enemies/grounded_enemy/grounded_enemy_damage.tres" id="2_bn56u"]
[ext_resource type="Script" uid="uid://bjwrpv3jpsc1e" path="res://scenes/health/CHealth.cs" id="2_gsmti"]
[ext_resource type="Script" uid="uid://b6y3ugfydvch0" path="res://resource_definitions/RDamageModifier.cs" id="2_r3cnf"]
[ext_resource type="Resource" uid="uid://bohbojc68j7y1" path="res://scenes/enemies/grounded_enemy/grounded_enemy_health.tres" id="2_w4lm8"]
[ext_resource type="Resource" uid="uid://bqq6uukbdfysr" path="res://scenes/enemies/grounded_enemy/grounded_enemy_movement.tres" id="4_na24f"]
[ext_resource type="Script" uid="uid://b0u23nkpaimyc" path="res://scenes/damage/CDamageable.cs" id="7_1tw73"]
[ext_resource type="PackedScene" uid="uid://dbr7ioio158ew" path="res://scenes/movement/CGroundedMovement.tscn" id="7_qyswd"]
[ext_resource type="Script" uid="uid://dtpxijlnb2c5" path="res://resource_definitions/RMovement.cs" id="8_6d4gl"]
[sub_resource type="Resource" id="Resource_qj0ob"]
script = ExtResource("2_r3cnf")
metadata/_custom_type_script = "uid://b6y3ugfydvch0"
[sub_resource type="Resource" id="Resource_6d4gl"]
script = ExtResource("8_6d4gl")
Speed = 5.0
metadata/_custom_type_script = "uid://dtpxijlnb2c5"
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_62kkh"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_3uydm"]
[sub_resource type="SphereMesh" id="SphereMesh_4yfjf"]
radius = 0.05
height = 0.1
radial_segments = 4
rings = 4
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_4yfjf"]
albedo_color = Color(0.06469653, 0.06469653, 0.06469653, 1)
[sub_resource type="BoxShape3D" id="BoxShape3D_4yfjf"]
size = Vector3(1, 2, 2)
[node name="GroundedEnemy" type="CharacterBody3D" node_paths=PackedStringArray("CHealth", "CDamage", "CMovement")]
collision_layer = 16
collision_mask = 273
script = ExtResource("1_r6506")
CHealth = NodePath("CHealth")
RHealth = ExtResource("2_w4lm8")
CDamage = NodePath("CDamageable")
RDamage = ExtResource("2_bn56u")
CMovement = NodePath("CGroundedMovement")
RMovement = ExtResource("4_na24f")
DeathEffects = Array[Object]([])
[node name="CHealth" type="Node" parent="."]
script = ExtResource("2_gsmti")
RHealth = ExtResource("2_w4lm8")
metadata/_custom_type_script = "uid://bjwrpv3jpsc1e"
[node name="CDamageable" type="Node" parent="."]
script = ExtResource("7_1tw73")
DamageModifiers = Array[Object]([SubResource("Resource_qj0ob")])
metadata/_custom_type_script = "uid://b0u23nkpaimyc"
[node name="CGroundedMovement" parent="." node_paths=PackedStringArray("WallInFrontRayCast") instance=ExtResource("7_qyswd")]
RMovement = SubResource("Resource_6d4gl")
WallInFrontRayCast = NodePath("../WallInFrontRayCast")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = SubResource("CapsuleShape3D_62kkh")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
layers = 33
mesh = SubResource("CapsuleMesh_3uydm")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.2, 1.5, -0.5)
layers = 33
cast_shadow = 0
ignore_occlusion_culling = true
mesh = SubResource("SphereMesh_4yfjf")
surface_material_override/0 = SubResource("StandardMaterial3D_4yfjf")
[node name="MeshInstance3D3" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, 1.5, -0.5)
layers = 33
cast_shadow = 0
ignore_occlusion_culling = true
mesh = SubResource("SphereMesh_4yfjf")
surface_material_override/0 = SubResource("StandardMaterial3D_4yfjf")
[node name="WallInFrontRayCast" type="RayCast3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0)
target_position = Vector3(0, 0, -1.5)
collision_mask = 272
[node name="DamageBox" type="Area3D" parent="."]
collision_layer = 0
monitorable = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="DamageBox"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -0.5)
shape = SubResource("BoxShape3D_4yfjf")

View File

@@ -0,0 +1,8 @@
[gd_resource type="Resource" script_class="RDamage" load_steps=2 format=3 uid="uid://otfc2snh8umc"]
[ext_resource type="Script" uid="uid://jitubgv6judn" path="res://resource_definitions/RDamage.cs" id="1_y415a"]
[resource]
script = ExtResource("1_y415a")
DamageDealt = 2.0
metadata/_custom_type_script = "uid://jitubgv6judn"

View File

@@ -0,0 +1,7 @@
[gd_resource type="Resource" script_class="RHealth" load_steps=2 format=3 uid="uid://bohbojc68j7y1"]
[ext_resource type="Script" uid="uid://baiapod3csndf" path="res://resource_definitions/RHealth.cs" id="1_h6jgd"]
[resource]
script = ExtResource("1_h6jgd")
metadata/_custom_type_script = "uid://baiapod3csndf"

View File

@@ -0,0 +1,8 @@
[gd_resource type="Resource" script_class="RMovement" load_steps=2 format=3 uid="uid://bqq6uukbdfysr"]
[ext_resource type="Script" uid="uid://dtpxijlnb2c5" path="res://resource_definitions/RMovement.cs" id="1_hsy8g"]
[resource]
script = ExtResource("1_hsy8g")
Speed = 5.0
metadata/_custom_type_script = "uid://dtpxijlnb2c5"

33
scenes/health/CHealth.cs Normal file
View File

@@ -0,0 +1,33 @@
using Godot;
using System;
using Movementtests.interfaces;
[GlobalClass]
public partial class CHealth : Node, IHealthable
{
public event Action<IHealthable, float> HealthChanged;
public event Action<IHealthable> HealthDepleted;
[Export]
public RHealth RHealth { get; set; }
public float CurrentHealth { get; set; }
public override void _Ready()
{
CurrentHealth = RHealth.StartingHealth;
}
public void ReduceHealth(IDamageable source, float amount)
{
GD.Print(CurrentHealth);
CurrentHealth -= amount;
HealthChanged?.Invoke(this, CurrentHealth);
if (CurrentHealth <= 0)
{
CurrentHealth = 0;
HealthDepleted?.Invoke(this);
}
}
}

View File

@@ -0,0 +1 @@
uid://bjwrpv3jpsc1e

View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://c4ikbhojckpnc"]
[ext_resource type="Script" uid="uid://bjwrpv3jpsc1e" path="res://scenes/health/CHealth.cs" id="1_75uyt"]
[node name="CHealth" type="Node"]
script = ExtResource("1_75uyt")

View File

@@ -0,0 +1,61 @@
using Godot;
using Movementtests.interfaces;
namespace Movementtests.scenes.movement;
public partial class CFlyingMovement : Node3D, IMoveable
{
[Export] public RMovement RMovement { get; set; }
[Export(PropertyHint.Layers3DPhysics)]
public uint TerrainCollision { get; set; } = 1;
private bool _movingToDesiredHeight = true;
private Vector3 _randomDirection;
public override void _Ready()
{
_randomDirection = new Vector3(GD.RandRange(-1, 1), 1, GD.RandRange(-1, 1)).Normalized();
}
public Vector3 ComputeVelocity(MovementInputs inputs)
{
var velocity = inputs.Velocity;
var spaceState = GetWorld3D().DirectSpaceState;
var target = inputs.TargetLocation;
var direction = (target - GlobalPosition).Normalized();
// Check if we have a direct line of sight to the player
if (!_movingToDesiredHeight)
{
velocity = direction * RMovement.Speed;
var query = PhysicsRayQueryParameters3D.Create(GlobalPosition, target, TerrainCollision);
var result = spaceState.IntersectRay(query);
if (result.Count > 0)
{
_movingToDesiredHeight = true;
_randomDirection = new Vector3(GD.RandRange(-1, 1), 1, GD.RandRange(-1, 1)).Normalized();
}
}
else
{
velocity = _randomDirection * RMovement.Speed;
var groundQuery = PhysicsRayQueryParameters3D.Create(GlobalPosition, GlobalPosition+Vector3.Down*RMovement.TargetHeight, TerrainCollision);
var groundResult = spaceState.IntersectRay(groundQuery);
if (groundResult.Count == 0)
{
velocity.Y = 0;
var query = PhysicsRayQueryParameters3D.Create(GlobalPosition, target, TerrainCollision);
var result = spaceState.IntersectRay(query);
if (result.Count == 0)
{
_movingToDesiredHeight = false;
}
}
}
return velocity;
}
}

View File

@@ -0,0 +1 @@
uid://cps1rbkxs3nvq

View File

@@ -0,0 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://dmw5ibwrb483f"]
[ext_resource type="Script" uid="uid://cps1rbkxs3nvq" path="res://scenes/movement/CFlyingMovement.cs" id="1_i26q2"]
[node name="CFlyingMovement" type="Node3D"]
script = ExtResource("1_i26q2")
CollisionMask = 256

View File

@@ -0,0 +1,33 @@
using Godot;
using Movementtests.interfaces;
namespace Movementtests.scenes.movement;
public partial class CGroundedMovement : Node3D, IMoveable
{
[Export] public RMovement RMovement { get; set; }
[Export]
public RayCast3D WallInFrontRayCast { get; set; }
public Vector3 ComputeVelocity(MovementInputs inputs)
{
var velocity = inputs.Velocity;
var target = inputs.TargetLocation;
var direction = (target - GlobalPosition).Normalized();
var targetPlane = new Vector3(target.X, GlobalPosition.Y, target.Z);
LookAt(targetPlane);
velocity.X = direction.X * RMovement.Speed;
velocity.Z = direction.Z * RMovement.Speed;
if (WallInFrontRayCast.IsColliding())
velocity.Y = RMovement.Speed;
else if (!inputs.isOnFloor)
velocity += inputs.gravity * (float)inputs.delta;
return velocity;
}
}

View File

@@ -0,0 +1 @@
uid://bdag2eeixw2lt

View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://dbr7ioio158ew"]
[ext_resource type="Script" uid="uid://bdag2eeixw2lt" path="res://scenes/movement/CGroundedMovement.cs" id="1_e0agf"]
[node name="CGroundedMovement" type="Node3D"]
script = ExtResource("1_e0agf")

View File

@@ -0,0 +1,69 @@
using Godot;
using System;
public partial class Spawner : Node3D
{
[Export(PropertyHint.NodeType)]
public PackedScene EnemyToSpawn { get; set; }
[Export]
public RMovement MovementInputs { get; set; }
[Export]
public RHealth HealthInputs { get; set; }
[Export]
public RDamage DamageInputs { get; set; }
[Export]
public Node3D Target { get; set; }
[Export(PropertyHint.Range, "0.1, 100, 0.1, or_greater")]
public float SpawnInterval { get; set; } = 1.0f;
[Export]
public bool IsActiveOnStart { get; set; } = true;
private float _spawnTimer;
private bool _isActive;
public override void _Ready()
{
_isActive = IsActiveOnStart;
_spawnTimer = SpawnInterval;
}
public override void _Process(double delta)
{
if (!_isActive) return;
_spawnTimer -= (float) delta;
if (_spawnTimer <= 0) Spawn();
}
public void Spawn()
{
if (EnemyToSpawn == null || !EnemyToSpawn.CanInstantiate()) return;
if (EnemyToSpawn.Instantiate() is not Enemy spawnedInstance) return;
spawnedInstance.Target = Target;
spawnedInstance.RMovement = MovementInputs;
spawnedInstance.RDamage = DamageInputs;
spawnedInstance.RHealth = HealthInputs;
spawnedInstance.Initialize();
GetTree().GetCurrentScene().AddChild(spawnedInstance);
spawnedInstance.GlobalPosition = GlobalPosition;
_spawnTimer = SpawnInterval;
}
public void StartSpawning()
{
_isActive = true;
_spawnTimer = SpawnInterval;
}
public void StopSpawning()
{
_isActive = false;
}
}

View File

@@ -0,0 +1 @@
uid://djyspwixi01j5

View File

@@ -0,0 +1,10 @@
[gd_scene load_steps=3 format=3 uid="uid://c305mfrtumcyq"]
[ext_resource type="Script" uid="uid://djyspwixi01j5" path="res://scenes/spawners/Spawner.cs" id="1_2otbo"]
[ext_resource type="PackedScene" uid="uid://dxt0e2ugmttqq" path="res://scenes/enemies/grounded_enemy/grounded_enemy.tscn" id="2_2otbo"]
[node name="Spawner" type="Node3D"]
script = ExtResource("1_2otbo")
SceneToSpawn = ExtResource("2_2otbo")
[node name="Marker3D" type="Marker3D" parent="."]

View File

@@ -0,0 +1,9 @@
namespace Movementtests.systems.damage;
public enum EDamageTypes
{
Normal,
Fire,
Ice,
Explosion,
}

View File

@@ -0,0 +1 @@
uid://dubmiwfuunxmu