From 69daecea06e510ab54fcc504c92d2f1954599d11 Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 25 Jul 2025 21:06:59 +0200 Subject: [PATCH] feat: added configuration warnings to player body --- modules/wave_survival/player_body.cpp | 14 ++++++++++++++ modules/wave_survival/player_body.h | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/wave_survival/player_body.cpp b/modules/wave_survival/player_body.cpp index c9a97e00..11394966 100644 --- a/modules/wave_survival/player_body.cpp +++ b/modules/wave_survival/player_body.cpp @@ -84,6 +84,20 @@ void PlayerBody::_notification(int what) { } } +PackedStringArray PlayerBody::get_configuration_warnings() const { + PackedStringArray warnings{ super_type::get_configuration_warnings() }; + if (find_children("*", HealthStatus::get_class_static()).is_empty()) { + warnings.push_back("This node has no health status and will cause crashes.\nConsider adding HealthStatus node as a child."); + } + if (find_children("*", PlayerInput::get_class_static()).is_empty()) { + warnings.push_back("This node has no input dispatcher and will cause crashes.\nConsider adding a PlayerInput node as a child."); + } + if (find_children("*", WeaponInventory::get_class_static()).is_empty()) { + warnings.push_back("This node has no inventory and will cause crashes.\nConsider adding a WeaponInventory node as a child."); + } + return warnings; +} + PlayerBody *PlayerBody::get_singleton() { return singleton_instance; } diff --git a/modules/wave_survival/player_body.h b/modules/wave_survival/player_body.h index ad528664..12ced770 100644 --- a/modules/wave_survival/player_body.h +++ b/modules/wave_survival/player_body.h @@ -20,6 +20,7 @@ class PlayerBody : public CharacterBody3D { protected: void _notification(int what); + virtual PackedStringArray get_configuration_warnings() const override; public: static PlayerBody *get_singleton(); @@ -33,7 +34,7 @@ private: float run_speed{ 8.f }; float acceleration{ 40.f }; float jump_strength{ 3.5f }; - Vector2 movement_input{}; + Vector2 movement_input{ 0, 0 }; WeaponInventory *weapons; HealthStatus *health{ nullptr };