initial
This commit is contained in:
		
							parent
							
								
									2d7050a065
								
							
						
					
					
						commit
						f89d2ccf53
					
				
							
								
								
									
										
											BIN
										
									
								
								.cache/clangd/index/actor_body.cpp.3DBD3D1A5C1819D9.idx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.cache/clangd/index/actor_body.cpp.3DBD3D1A5C1819D9.idx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.cache/clangd/index/actor_body.h.E6B5DA66D5128F55.idx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.cache/clangd/index/actor_body.h.E6B5DA66D5128F55.idx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.cache/clangd/index/equipment.cpp.0DAD3B9F041D4E8F.idx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.cache/clangd/index/equipment.cpp.0DAD3B9F041D4E8F.idx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.cache/clangd/index/equipment.h.87F30A43991E43C4.idx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.cache/clangd/index/equipment.h.87F30A43991E43C4.idx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.cache/clangd/index/macros.h.2ABF5D78F9EC4C2D.idx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.cache/clangd/index/macros.h.2ABF5D78F9EC4C2D.idx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.cache/clangd/index/register_types.cpp.C2CF44F1B437E8E2.idx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.cache/clangd/index/register_types.cpp.C2CF44F1B437E8E2.idx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								.cache/clangd/index/register_types.h.1B701265B4D42B11.idx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.cache/clangd/index/register_types.h.1B701265B4D42B11.idx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							|  | @ -8,7 +8,7 @@ config.log | |||
| 
 | ||||
| engine/.github | ||||
| project/.godot | ||||
| build/PROJECT.pck | ||||
| build/PROJECT.x86_64 | ||||
| build/PROJECT.exe | ||||
| build/tabtargeting.pck | ||||
| build/tabtargeting.x86_64 | ||||
| build/tabtargeting.exe | ||||
| build.zip | ||||
|  |  | |||
							
								
								
									
										1
									
								
								compile_commands.json
									
									
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								compile_commands.json
									
									
									
									
									
										Symbolic link
									
								
							|  | @ -0,0 +1 @@ | |||
| engine/compile_commands.json | ||||
|  | @ -1,15 +0,0 @@ | |||
| #include "register_types.h" | ||||
| 
 | ||||
| #include "core/object/class_db.h" | ||||
| 
 | ||||
| void initialize_PROJECT_module(ModuleInitializationLevel p_level) { | ||||
| 	if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { | ||||
| 		return; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void uninitialize_PROJECT_module(ModuleInitializationLevel p_level) { | ||||
| 	if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { | ||||
| 		return; | ||||
| 	} | ||||
| } | ||||
|  | @ -1,9 +0,0 @@ | |||
| #ifndef PROJECT_REGISTER_TYPES_H | ||||
| #define PROJECT_REGISTER_TYPES_H | ||||
| 
 | ||||
| #include "modules/register_module_types.h" | ||||
| 
 | ||||
| void initialize_PROJECT_module(ModuleInitializationLevel p_level); | ||||
| void uninitialize_PROJECT_module(ModuleInitializationLevel p_level); | ||||
| 
 | ||||
| #endif // !PROJECT_REGISTER_TYPES_H
 | ||||
							
								
								
									
										
											BIN
										
									
								
								modules/tabtargeting/__pycache__/config.cpython-313.pyc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								modules/tabtargeting/__pycache__/config.cpython-313.pyc
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										10
									
								
								modules/tabtargeting/actor_body.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								modules/tabtargeting/actor_body.cpp
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,10 @@ | |||
| #include "actor_body.h" | ||||
| #include "core/string/print_string.h" | ||||
| 
 | ||||
| void ActorBody::_bind_methods() { | ||||
| } | ||||
| 
 | ||||
| void ActorBody::receive_damage(DamageEvent event) { | ||||
| 	this->health -= event.compound_damage; | ||||
| 	print_line(vformat("Damage dealth (%d to %s, %d remaining", event.compound_damage, this->get_name(), this->health)); | ||||
| } | ||||
							
								
								
									
										20
									
								
								modules/tabtargeting/actor_body.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								modules/tabtargeting/actor_body.h
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,20 @@ | |||
| #ifndef ACTOR_BODY_H | ||||
| #define ACTOR_BODY_H | ||||
| 
 | ||||
| #include "scene/3d/physics/character_body_3d.h" | ||||
| #include "equipment.h" | ||||
| class ActorBody; | ||||
| 
 | ||||
| class ActorBody : public CharacterBody3D { | ||||
| 	GDCLASS(ActorBody, CharacterBody3D); | ||||
| 	static void _bind_methods(); | ||||
| public: | ||||
| 	void receive_damage(DamageEvent event); | ||||
| 	void send_damage(int amount, ActorBody *target); | ||||
| private: | ||||
| 	int health{10}; | ||||
| 	int max_health{10}; | ||||
| 
 | ||||
| 	class Equipment *equipment{nullptr}; | ||||
| }; | ||||
| #endif // !ACTOR_BODY_H
 | ||||
							
								
								
									
										13
									
								
								modules/tabtargeting/actor_state_machine.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								modules/tabtargeting/actor_state_machine.h
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| #ifndef ACTOR_STATE_MACHINE_H | ||||
| #define ACTOR_STATE_MACHINE_H | ||||
| 
 | ||||
| #include "scene/main/node.h" | ||||
| 
 | ||||
| class ActorStateMachine : public Node { | ||||
| 	GDCLASS(ActorStateMachine, Node); | ||||
| 	static void _bind_methods(); | ||||
| public: | ||||
| private: | ||||
| }; | ||||
| 
 | ||||
| #endif // !ACTOR_STATE_MACHINE_H
 | ||||
							
								
								
									
										138
									
								
								modules/tabtargeting/equipment.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										138
									
								
								modules/tabtargeting/equipment.cpp
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,138 @@ | |||
| #include "equipment.h" | ||||
| #include "macros.h" | ||||
| #include "tabtargeting/actor_body.h" | ||||
| 
 | ||||
| DamageEvent::DamageEvent(int damage, ActorBody *source) | ||||
| : compound_damage{damage} | ||||
| , initial_damage{damage} | ||||
| , source{source} | ||||
| {} | ||||
| 
 | ||||
| void DamageStats::_bind_methods() { | ||||
| 	BIND_PROPERTY(Variant::INT, damage_add); | ||||
| 	BIND_PROPERTY(Variant::INT, damage_mul); | ||||
| 	BIND_PROPERTY(Variant::INT, defend_add); | ||||
| 	BIND_PROPERTY(Variant::INT, defend_mul); | ||||
| } | ||||
| 
 | ||||
| DamageEvent DamageStats::apply(DamageEvent event, ActorBody *owner) { | ||||
| 	if(owner == event.get_source()) { | ||||
| 		event.compound_damage *= this->damage_mul; | ||||
| 		event.compound_damage += this->damage_add; | ||||
| 	} else { | ||||
| 		event.compound_damage *= this->defend_mul; | ||||
| 		event.compound_damage += this->defend_add; | ||||
| 	} | ||||
| 	return event; | ||||
| } | ||||
| 
 | ||||
| void DamageStats::set_damage_add(int val) { | ||||
| 	this->damage_add = val; | ||||
| } | ||||
| int DamageStats::get_damage_add() const { | ||||
| 	return this->damage_add; | ||||
| } | ||||
| void DamageStats::set_damage_mul(float val) { | ||||
| 	this->damage_mul = val; | ||||
| } | ||||
| float DamageStats::get_damage_mul() const { | ||||
| 	return this->damage_mul; | ||||
| } | ||||
| void DamageStats::set_defend_add(int val) { | ||||
| 	this->defend_add = val; | ||||
| } | ||||
| int DamageStats::get_defend_add() const { | ||||
| 	return this->defend_add; | ||||
| } | ||||
| void DamageStats::set_defend_mul(float val) { | ||||
| 	this->defend_mul = val; | ||||
| } | ||||
| float DamageStats::get_defend_mul() const { | ||||
| 	return this->defend_mul; | ||||
| } | ||||
| 
 | ||||
| void EquipItem::_bind_methods() { | ||||
| 	BIND_HPROPERTY(Variant::OBJECT, stats, PROPERTY_HINT_RESOURCE_TYPE, "DamageStats"); | ||||
| } | ||||
| 
 | ||||
| DamageEvent EquipItem::apply(DamageEvent event, ActorBody *owner)  { | ||||
| 	return this->stats->apply(event, owner); | ||||
| } | ||||
| 
 | ||||
| void EquipItem::set_stats(Ref<DamageStats> stats) { | ||||
| 	this->stats = stats; | ||||
| } | ||||
| 
 | ||||
| Ref<DamageStats> EquipItem::get_stats() const { | ||||
| 	return this->stats; | ||||
| } | ||||
| 
 | ||||
| void Weapon::_bind_methods() { | ||||
| 	BIND_PROPERTY(Variant::INT, base_damage); | ||||
| } | ||||
| 
 | ||||
| void Weapon::set_base_damage(int amount) { | ||||
| 	this->base_damage = amount; | ||||
| } | ||||
| 
 | ||||
| int Weapon::get_base_damage() const { | ||||
| 	return this->base_damage; | ||||
| } | ||||
| 
 | ||||
| DamageEvent Weapon::create_base_damage_event(ActorBody *source) { | ||||
| 	return DamageEvent(this->base_damage, source); | ||||
| } | ||||
| 
 | ||||
| void Armor::_bind_methods() { | ||||
| 	BIND_HPROPERTY(Variant::INT, armor_type, PROPERTY_HINT_ENUM, "Helmet, Chest, Legs"); | ||||
| } | ||||
| void Armor::set_armor_type(int type) { | ||||
| 	this->type = ArmorType(type); | ||||
| } | ||||
| int Armor::get_armor_type() const { | ||||
| 	return this->type; | ||||
| } | ||||
| 
 | ||||
| void Equipment::_bind_methods() { | ||||
| 	BIND_HPROPERTY(Variant::OBJECT, weapon, PROPERTY_HINT_RESOURCE_TYPE, "Weapon"); | ||||
| 	BIND_HPROPERTY(Variant::OBJECT, helmet, PROPERTY_HINT_RESOURCE_TYPE, "Armor"); | ||||
| 	BIND_HPROPERTY(Variant::OBJECT, chest, PROPERTY_HINT_RESOURCE_TYPE, "Armor"); | ||||
| 	BIND_HPROPERTY(Variant::OBJECT, legs, PROPERTY_HINT_RESOURCE_TYPE, "Armor"); | ||||
| } | ||||
| 
 | ||||
| DamageEvent Equipment::apply(DamageEvent event, ActorBody *target) { | ||||
| 	 | ||||
| } | ||||
| 
 | ||||
| void Equipment::set_weapon(Ref<Weapon> weapon) { | ||||
| 	this->weapon = weapon; | ||||
| } | ||||
| 
 | ||||
| Ref<Weapon> Equipment::get_weapon() const { | ||||
| 	return this->weapon; | ||||
| } | ||||
| 
 | ||||
| void Equipment::set_helmet(Ref<Armor> helmet) { | ||||
| 	this->helmet = helmet; | ||||
| } | ||||
| 
 | ||||
| Ref<Armor> Equipment::get_helmet() const { | ||||
| 	return this->helmet; | ||||
| } | ||||
| 
 | ||||
| void Equipment::set_chest(Ref<Armor> chest) { | ||||
| 	this->chest = chest; | ||||
| } | ||||
| 
 | ||||
| Ref<Armor> Equipment::get_chest() const { | ||||
| 	return this->chest; | ||||
| } | ||||
| 
 | ||||
| void Equipment::set_legs(Ref<Armor> legs) { | ||||
| 	this->legs = legs; | ||||
| } | ||||
| 
 | ||||
| Ref<Armor> Equipment::get_legs() const { | ||||
| 	return this->legs; | ||||
| } | ||||
| 
 | ||||
							
								
								
									
										104
									
								
								modules/tabtargeting/equipment.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								modules/tabtargeting/equipment.h
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,104 @@ | |||
| #ifndef EQUIPMENT_H | ||||
| #define EQUIPMENT_H | ||||
| 
 | ||||
| #include "core/io/resource.h" | ||||
| #include "core/templates/vector.h" | ||||
| #include "scene/main/node.h" | ||||
| class ActorBody; | ||||
| 
 | ||||
| struct DamageEvent { | ||||
| 	DamageEvent(int damage, ActorBody *source); | ||||
| 	int compound_damage{1}; | ||||
| 	int get_initial_damage() const; | ||||
| 	ActorBody *get_source() const; | ||||
| private: | ||||
| 	int initial_damage{1}; | ||||
| 	ActorBody *source{nullptr}; | ||||
| }; | ||||
| 
 | ||||
| class DamageModifier { | ||||
| public: | ||||
| 	virtual DamageEvent apply(DamageEvent event, ActorBody *target) = 0; | ||||
| }; | ||||
| 
 | ||||
| class DamageStats : public Resource, | ||||
| 					public DamageModifier { | ||||
| 	GDCLASS(DamageStats, Resource); | ||||
| 	static void _bind_methods(); | ||||
| public: | ||||
| 	virtual DamageEvent apply(DamageEvent event, ActorBody *target) override; | ||||
| 	void set_damage_add(int val); | ||||
| 	int get_damage_add() const; | ||||
| 	void set_damage_mul(float val); | ||||
| 	float get_damage_mul() const; | ||||
| 	void set_defend_add(int val); | ||||
| 	int get_defend_add() const; | ||||
| 	void set_defend_mul(float val); | ||||
| 	float get_defend_mul() const; | ||||
| public: | ||||
| 	int damage_add{0}; | ||||
| 	float damage_mul{1.f}; | ||||
| 	int defend_add{0}; | ||||
| 	float defend_mul{1.f}; | ||||
| }; | ||||
| 
 | ||||
| class EquipItem : public Resource, | ||||
| 				  public DamageModifier { | ||||
| 	GDCLASS(EquipItem, Resource); | ||||
| 	static void _bind_methods(); | ||||
| public: | ||||
| 	virtual DamageEvent apply(DamageEvent event, ActorBody *target) override; | ||||
| 	void set_stats(Ref<DamageStats> stats); | ||||
| 	Ref<DamageStats> get_stats() const; | ||||
| private: | ||||
| 	Ref<DamageStats> stats{}; | ||||
| }; | ||||
| 
 | ||||
| class Weapon : public EquipItem { | ||||
| 	GDCLASS(Weapon, EquipItem); | ||||
| 	static void _bind_methods(); | ||||
| public: | ||||
| 	void set_base_damage(int amount); | ||||
| 	int get_base_damage() const; | ||||
| 
 | ||||
| 	DamageEvent create_base_damage_event(ActorBody *source); | ||||
| private: | ||||
| 	int base_damage{1}; | ||||
| }; | ||||
| 
 | ||||
| enum ArmorType { | ||||
| 	Helmet, Chest, Legs | ||||
| }; | ||||
| 
 | ||||
| class Armor : public EquipItem { | ||||
| 	GDCLASS(Armor, EquipItem); | ||||
| 	static void _bind_methods(); | ||||
| public: | ||||
| 	void set_armor_type(int type); | ||||
| 	int get_armor_type() const; | ||||
| private: | ||||
| 	ArmorType type{}; | ||||
| }; | ||||
| 
 | ||||
| class Equipment : public Node, | ||||
| 				  public DamageModifier { | ||||
| 	GDCLASS(Equipment, Node); | ||||
| 	static void _bind_methods(); | ||||
| public: | ||||
| 	virtual DamageEvent apply(DamageEvent event, ActorBody *target) override; | ||||
| 	void set_weapon(Ref<Weapon> weapon); | ||||
| 	Ref<Weapon> get_weapon() const; | ||||
| 	void set_helmet(Ref<Armor> helmet); | ||||
| 	Ref<Armor> get_helmet() const; | ||||
| 	void set_chest(Ref<Armor> chest); | ||||
| 	Ref<Armor> get_chest() const; | ||||
| 	void set_legs(Ref<Armor> legs); | ||||
| 	Ref<Armor> get_legs() const; | ||||
| private: | ||||
| 	Ref<Weapon> weapon{}; | ||||
| 	Ref<Armor> helmet{}; | ||||
| 	Ref<Armor> chest{}; | ||||
| 	Ref<Armor> legs{}; | ||||
| }; | ||||
| 
 | ||||
| #endif // !EQUIPMENT_H
 | ||||
							
								
								
									
										23
									
								
								modules/tabtargeting/register_types.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								modules/tabtargeting/register_types.cpp
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,23 @@ | |||
| #include "register_types.h" | ||||
| 
 | ||||
| #include "core/object/class_db.h" | ||||
| #include "tabtargeting/equipment.h" | ||||
| #include "tabtargeting/actor_body.h" | ||||
| 
 | ||||
| void initialize_tabtargeting_module(ModuleInitializationLevel p_level) { | ||||
| 	if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { | ||||
| 		return; | ||||
| 	} | ||||
| 	ClassDB::register_class<ActorBody>(); | ||||
| 	ClassDB::register_class<DamageStats>(); | ||||
| 	ClassDB::register_class<EquipItem>(); | ||||
| 	ClassDB::register_class<Weapon>(); | ||||
| 	ClassDB::register_class<Armor>(); | ||||
| 	ClassDB::register_class<Equipment>(); | ||||
| } | ||||
| 
 | ||||
| void uninitialize_tabtargeting_module(ModuleInitializationLevel p_level) { | ||||
| 	if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { | ||||
| 		return; | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										9
									
								
								modules/tabtargeting/register_types.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								modules/tabtargeting/register_types.h
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,9 @@ | |||
| #ifndef tabtargeting_REGISTER_TYPES_H | ||||
| #define tabtargeting_REGISTER_TYPES_H | ||||
| 
 | ||||
| #include "modules/register_module_types.h" | ||||
| 
 | ||||
| void initialize_tabtargeting_module(ModuleInitializationLevel p_level); | ||||
| void uninitialize_tabtargeting_module(ModuleInitializationLevel p_level); | ||||
| 
 | ||||
| #endif // !tabtargeting_REGISTER_TYPES_H
 | ||||
|  | @ -9,7 +9,7 @@ custom_features="" | |||
| export_filter="all_resources" | ||||
| include_filter="" | ||||
| exclude_filter="" | ||||
| export_path="../build/PROJECT.x86_64" | ||||
| export_path="../build/tabtargeting.x86_64" | ||||
| patches=PackedStringArray() | ||||
| encryption_include_filters="" | ||||
| encryption_exclude_filters="" | ||||
|  | @ -51,7 +51,7 @@ custom_features="" | |||
| export_filter="all_resources" | ||||
| include_filter="" | ||||
| exclude_filter="" | ||||
| export_path="../build/PROJECT.exe" | ||||
| export_path="../build/tabtargeting.exe" | ||||
| patches=PackedStringArray() | ||||
| encryption_include_filters="" | ||||
| encryption_exclude_filters="" | ||||
|  |  | |||
|  | @ -10,6 +10,6 @@ config_version=5 | |||
| 
 | ||||
| [application] | ||||
| 
 | ||||
| config/name="PROJECT" | ||||
| config/name="tabtargeting" | ||||
| config/features=PackedStringArray("4.4", "Forward Plus") | ||||
| config/icon="res://icon.svg" | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Sara
						Sara