feat: added configuration warnings to player body
This commit is contained in:
		
							parent
							
								
									4bec0ed5fc
								
							
						
					
					
						commit
						69daecea06
					
				| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue