From 9c3ac7c4f81c74e813adb77d5f850c10aaa99104 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 15 Apr 2025 10:03:21 +0200 Subject: [PATCH] Added prop support for ESSEntityWorldSpawner3DSingle. --- modules/entity_spell_system/SCsub | 6 +- modules/entity_spell_system/config.py | 1 + ...ata_ess_entity_world_spawner_3d_single.cpp | 144 ++++++++++++++++++ ..._data_ess_entity_world_spawner_3d_single.h | 79 ++++++++++ .../entity_spell_system/register_types.cpp | 14 +- 5 files changed, 240 insertions(+), 4 deletions(-) create mode 100644 modules/entity_spell_system/props/prop_data_ess_entity_world_spawner_3d_single.cpp create mode 100644 modules/entity_spell_system/props/prop_data_ess_entity_world_spawner_3d_single.h diff --git a/modules/entity_spell_system/SCsub b/modules/entity_spell_system/SCsub index b69ee3908..db607e7da 100644 --- a/modules/entity_spell_system/SCsub +++ b/modules/entity_spell_system/SCsub @@ -114,8 +114,6 @@ sources = [ "editor/ess_editor_plugin.cpp", - "props/prop_data_entity.cpp", - "material_cache/ess_material_cache.cpp", "world_spawners/ess_entity_world_spawner_2d.cpp", @@ -126,6 +124,10 @@ sources = [ if env["module_texture_packer_enabled"]: sources.append("material_cache/ess_material_cache_pcm.cpp") + +if env["module_props_enabled"]: + sources.append("props/prop_data_entity.cpp") + sources.append("props/prop_data_ess_entity_world_spawner_3d_single.cpp") if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes': # Shared lib compilation diff --git a/modules/entity_spell_system/config.py b/modules/entity_spell_system/config.py index 5bd45ec3a..139aa85bc 100644 --- a/modules/entity_spell_system/config.py +++ b/modules/entity_spell_system/config.py @@ -102,6 +102,7 @@ def get_doc_classes(): "ESSEntitySpawner", "PropDataEntity", + "PropDataESSEntityWorldSpawner3DSingle", "ESSMaterialCache", "ESSMaterialCachePCM", diff --git a/modules/entity_spell_system/props/prop_data_ess_entity_world_spawner_3d_single.cpp b/modules/entity_spell_system/props/prop_data_ess_entity_world_spawner_3d_single.cpp new file mode 100644 index 000000000..693ccb2be --- /dev/null +++ b/modules/entity_spell_system/props/prop_data_ess_entity_world_spawner_3d_single.cpp @@ -0,0 +1,144 @@ +/*************************************************************************/ +/* prop_data_ess_entity_world_spawner_3d_single.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* PANDEMONIUM ENGINE */ +/* https://github.com/Relintai/pandemonium_engine */ +/*************************************************************************/ +/* Copyright (c) 2022-present Péter Magyar. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "prop_data_ess_entity_world_spawner_3d_single.h" + +#include "../../props/props/prop_data.h" +#include "../entities/data/entity_data.h" +#include "../world_spawners/ess_entity_world_spawner_3d_single.h" + +String PropDataESSEntityWorldSpawner3DSingle::get_entity_name() const { + return _entity_name; +} +void PropDataESSEntityWorldSpawner3DSingle::set_entity_name(const String &p_name) { + _entity_name = p_name; +} + +Ref PropDataESSEntityWorldSpawner3DSingle::get_entity_data() const { + return _entity_data; +} +void PropDataESSEntityWorldSpawner3DSingle::set_entity_data(const Ref &p_data) { + _entity_data = p_data; +} + +int PropDataESSEntityWorldSpawner3DSingle::get_entity_level() const { + return _entity_level; +} +void PropDataESSEntityWorldSpawner3DSingle::set_entity_level(const int p_level) { + _entity_level = p_level; +} + +float PropDataESSEntityWorldSpawner3DSingle::get_respawn_time_min() const { + return _respawn_time_min; +} +void PropDataESSEntityWorldSpawner3DSingle::set_respawn_time_min(const float p_respawn_time) { + _respawn_time_min = p_respawn_time; +} + +float PropDataESSEntityWorldSpawner3DSingle::get_respawn_time_max() const { + return _respawn_time_max; +} +void PropDataESSEntityWorldSpawner3DSingle::set_respawn_time_max(const float p_respawn_time) { + _respawn_time_max = p_respawn_time; +} + +bool PropDataESSEntityWorldSpawner3DSingle::_processor_handles(Node *node) { + ESSEntityWorldSpawner3DSingle *i = Object::cast_to(node); + + return i; +} + +void PropDataESSEntityWorldSpawner3DSingle::_processor_process(Ref prop_data, Node *node, const Transform &transform) { + ESSEntityWorldSpawner3DSingle *i = Object::cast_to(node); + + ERR_FAIL_COND(!i); + + if (!i->get_entity_data().is_valid()) { + // skip + return; + } + + Ref l; + l.instance(); + + l->set_entity_name(i->get_entity_name()); + l->set_entity_data(i->get_entity_data()); + l->set_entity_level(i->get_entity_level()); + l->set_respawn_time_min(i->get_respawn_time_min()); + l->set_respawn_time_max(i->get_respawn_time_max()); + l->set_transform(transform * i->get_transform()); + + prop_data->add_prop(l); +} + +Node *PropDataESSEntityWorldSpawner3DSingle::_processor_get_node_for(const Transform &transform) { + ESSEntityWorldSpawner3DSingle *i = memnew(ESSEntityWorldSpawner3DSingle); + + i->set_entity_name(get_entity_name()); + i->set_entity_data(get_entity_data()); + i->set_entity_level(get_entity_level()); + i->set_respawn_time_min(get_respawn_time_min()); + i->set_respawn_time_max(get_respawn_time_max()); + i->set_transform(get_transform()); + + return i; +} + +PropDataESSEntityWorldSpawner3DSingle::PropDataESSEntityWorldSpawner3DSingle() { + _entity_level = 1; + _respawn_time_min = 0; + _respawn_time_max = 0; + _respawn_timer = 0; +} +PropDataESSEntityWorldSpawner3DSingle::~PropDataESSEntityWorldSpawner3DSingle() { +} + +void PropDataESSEntityWorldSpawner3DSingle::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_entity_name"), &PropDataESSEntityWorldSpawner3DSingle::get_entity_name); + ClassDB::bind_method(D_METHOD("set_entity_name", "value"), &PropDataESSEntityWorldSpawner3DSingle::set_entity_name); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "entity_name"), "set_entity_name", "get_entity_name"); + + ClassDB::bind_method(D_METHOD("get_entity_data"), &PropDataESSEntityWorldSpawner3DSingle::get_entity_data); + ClassDB::bind_method(D_METHOD("set_entity_data", "value"), &PropDataESSEntityWorldSpawner3DSingle::set_entity_data); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "entity_data", PROPERTY_HINT_RESOURCE_TYPE, "EntityData"), "set_entity_data", "get_entity_data"); + + ClassDB::bind_method(D_METHOD("get_entity_level"), &PropDataESSEntityWorldSpawner3DSingle::get_entity_level); + ClassDB::bind_method(D_METHOD("set_entity_level", "value"), &PropDataESSEntityWorldSpawner3DSingle::set_entity_level); + ADD_PROPERTY(PropertyInfo(Variant::INT, "entity_level"), "set_entity_level", "get_entity_level"); + + ClassDB::bind_method(D_METHOD("get_respawn_time_min"), &PropDataESSEntityWorldSpawner3DSingle::get_respawn_time_min); + ClassDB::bind_method(D_METHOD("set_respawn_time_min", "respawn_time"), &PropDataESSEntityWorldSpawner3DSingle::set_respawn_time_min); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "respawn_time_min"), "set_respawn_time_min", "get_respawn_time_min"); + + ClassDB::bind_method(D_METHOD("get_respawn_time_max"), &PropDataESSEntityWorldSpawner3DSingle::get_respawn_time_max); + ClassDB::bind_method(D_METHOD("set_respawn_time_max", "respawn_time"), &PropDataESSEntityWorldSpawner3DSingle::set_respawn_time_max); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "respawn_time_max"), "set_respawn_time_max", "get_respawn_time_max"); +} diff --git a/modules/entity_spell_system/props/prop_data_ess_entity_world_spawner_3d_single.h b/modules/entity_spell_system/props/prop_data_ess_entity_world_spawner_3d_single.h new file mode 100644 index 000000000..59f1534b3 --- /dev/null +++ b/modules/entity_spell_system/props/prop_data_ess_entity_world_spawner_3d_single.h @@ -0,0 +1,79 @@ +#ifndef PROP_DATA_ESS_ENTITY_WORLD_SPAWNER_3D_SINGLE_H +#define PROP_DATA_ESS_ENTITY_WORLD_SPAWNER_3D_SINGLE_H + +/*************************************************************************/ +/* prop_data_ess_entity_world_spawner_3d_single.h */ +/*************************************************************************/ +/* This file is part of: */ +/* PANDEMONIUM ENGINE */ +/* https://github.com/Relintai/pandemonium_engine */ +/*************************************************************************/ +/* Copyright (c) 2022-present Péter Magyar. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "../../props/props/prop_data_entry.h" + +class ESSEntityWorldSpawner3DSingle; +class EntityData; +class PropData; + +class PropDataESSEntityWorldSpawner3DSingle : public PropDataEntry { + GDCLASS(PropDataESSEntityWorldSpawner3DSingle, PropDataEntry); + +public: + String get_entity_name() const; + void set_entity_name(const String &p_name); + + Ref get_entity_data() const; + void set_entity_data(const Ref &p_data); + + int get_entity_level() const; + void set_entity_level(const int p_level); + + float get_respawn_time_min() const; + void set_respawn_time_min(const float p_respawn_time); + + float get_respawn_time_max() const; + void set_respawn_time_max(const float p_respawn_time); + + bool _processor_handles(Node *node); + void _processor_process(Ref prop_data, Node *node, const Transform &transform); + Node *_processor_get_node_for(const Transform &transform); + + PropDataESSEntityWorldSpawner3DSingle(); + ~PropDataESSEntityWorldSpawner3DSingle(); + +protected: + static void _bind_methods(); + +private: + String _entity_name; + Ref _entity_data; + int _entity_level; + float _respawn_time_min; + float _respawn_time_max; + real_t _respawn_timer; +}; + +#endif diff --git a/modules/entity_spell_system/register_types.cpp b/modules/entity_spell_system/register_types.cpp index 903b1d44b..10b4af151 100644 --- a/modules/entity_spell_system/register_types.cpp +++ b/modules/entity_spell_system/register_types.cpp @@ -150,13 +150,15 @@ #endif #ifdef MODULE_PROPS_ENABLED +#include "modules/props/singleton/prop_utils.h" #include "props/prop_data_entity.h" +#include "props/prop_data_ess_entity_world_spawner_3d_single.h" #endif #include "world_spawners/ess_entity_world_spawner_2d.cpp" -#include "world_spawners/ess_entity_world_spawner_3d_single.cpp" -#include "world_spawners/ess_entity_world_spawner_3d_area.h" #include "world_spawners/ess_entity_world_spawner_3d.cpp" +#include "world_spawners/ess_entity_world_spawner_3d_area.h" +#include "world_spawners/ess_entity_world_spawner_3d_single.cpp" static ESS *entity_data_manager = NULL; static ProfileManager *profile_manager = NULL; @@ -175,6 +177,7 @@ void register_entity_spell_system_types(ModuleRegistrationLevel p_level) { if (p_level == MODULE_REGISTRATION_LEVEL_SCENE) { #ifdef MODULE_PROPS_ENABLED ClassDB::register_class(); + ClassDB::register_class(); #endif ClassDB::register_class(); @@ -307,6 +310,13 @@ void register_entity_spell_system_types(ModuleRegistrationLevel p_level) { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); + +#ifdef MODULE_PROPS_ENABLED + // TODO update and register ClassDB::register_class(); too + + Ref world_spawner_single_processor = Ref(memnew(PropDataESSEntityWorldSpawner3DSingle)); + PropUtils::add_processor(world_spawner_single_processor); +#endif } #ifdef TOOLS_ENABLED