diff --git a/SCsub b/SCsub index 252994a..287ed44 100644 --- a/SCsub +++ b/SCsub @@ -26,11 +26,11 @@ sources = [ "clutter/ground_clutter.cpp", "clutter/ground_clutter_foliage.cpp", - "prop_mesh_utils.cpp", - "prop_instance.cpp", "prop_ess_entity.cpp", "prop_instance_job.cpp", + + "singleton/prop_utils.cpp", ] if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes': diff --git a/prop_mesh_utils.cpp b/prop_mesh_utils.cpp deleted file mode 100644 index a5cc072..0000000 --- a/prop_mesh_utils.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "prop_mesh_utils.h" - -PropMeshUtils::PropMeshUtils() { -} -PropMeshUtils::~PropMeshUtils() { -} - -void PropMeshUtils::_bind_methods() { -} diff --git a/register_types.cpp b/register_types.cpp index a81fb83..f13f798 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -33,13 +33,16 @@ SOFTWARE. #include "clutter/ground_clutter.h" #include "clutter/ground_clutter_foliage.h" -#include "prop_mesh_utils.h" - #include "prop_ess_entity.h" #include "prop_instance.h" #include "prop_instance_job.h" +#include "core/engine.h" +#include "singleton/prop_utils.h" + +static PropUtils *prop_utils = NULL; + void register_props_types() { ClassDB::register_class(); ClassDB::register_class(); @@ -52,14 +55,19 @@ void register_props_types() { ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); + + prop_utils = memnew(PropUtils); + ClassDB::register_class(); + Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton())); } void unregister_props_types() { + if (prop_utils) { + memdelete(prop_utils); + } } diff --git a/singleton/prop_utils.cpp b/singleton/prop_utils.cpp new file mode 100644 index 0000000..48c46c7 --- /dev/null +++ b/singleton/prop_utils.cpp @@ -0,0 +1,40 @@ +/* +Copyright (c) 2019-2020 Péter Magyar + +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_utils.h" + +PropUtils *PropUtils::_instance; + +PropUtils *PropUtils::get_singleton() { + return _instance; +} + +PropUtils::PropUtils() { + _instance = this; +} + +PropUtils::~PropUtils() { + _instance = NULL; +} + +void PropUtils::_bind_methods() { +} diff --git a/prop_mesh_utils.h b/singleton/prop_utils.h similarity index 80% rename from prop_mesh_utils.h rename to singleton/prop_utils.h index 3ff2691..b770d1c 100644 --- a/prop_mesh_utils.h +++ b/singleton/prop_utils.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2020 Péter Magyar +Copyright (c) 2019-2020 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,22 +20,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_MESH_UTILS_H -#define PROP_MESH_UTILS_H +#ifndef PROP_UTILS_H +#define PROP_UTILS_H -#include "core/reference.h" +#include "core/object.h" -#include "core/math/vector3.h" - -class PropMeshUtils : public Reference { - GDCLASS(PropMeshUtils, Reference); +class PropUtils : public Object { + GDCLASS(PropUtils, Object); public: - PropMeshUtils(); - ~PropMeshUtils(); + static PropUtils *get_singleton(); + + PropUtils(); + ~PropUtils(); protected: static void _bind_methods(); + +private: + static PropUtils *_instance; }; #endif