Skip to content

Commit

Permalink
General branch fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GsLogiMaker committed Dec 4, 2024
1 parent 6797002 commit 5eebef8
Show file tree
Hide file tree
Showing 29 changed files with 124 additions and 101 deletions.
18 changes: 2 additions & 16 deletions cpp/src/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

using namespace godot;

GFComponent::GFComponent() {
}
GFComponent::~GFComponent() {
}

Expand All @@ -36,10 +34,7 @@ Ref<GFComponent> GFComponent::from_id(ecs_entity_t comp, ecs_entity_t entity, GF
" Entity ", world->id_to_text(comp), " is not a component"
);
}
Ref<GFComponent> comp_ref = Ref(memnew(GFComponent));
comp_ref->source_entity_id = entity;
comp_ref->set_id(comp);
comp_ref->set_world(world);
Ref<GFComponent> comp_ref = memnew(GFComponent(entity, comp, world));
return setup_template<GFComponent>(comp_ref);
}

Expand All @@ -51,10 +46,7 @@ Ref<GFComponent> GFComponent::from_id_no_source(ecs_entity_t comp, GFWorld* worl
" Entity ", world->id_to_text(comp), " is not a component"
);
}
Ref<GFComponent> comp_ref = Ref(memnew(GFComponent));
comp_ref->source_entity_id = 0;
comp_ref->set_id(comp);
comp_ref->set_world(world);
Ref<GFComponent> comp_ref = Ref(memnew(GFComponent(0, comp, world)));
comp_ref->update_script();
return comp_ref;
}
Expand Down Expand Up @@ -373,10 +365,6 @@ void GFComponent::set_source_id(ecs_entity_t id) {
source_entity_id = id;
}

Ref<GFRegisterableEntity> GFComponent::new_internal() {
return Ref(memnew(GFComponent));
}

void GFComponent::_bind_methods() {
GDVIRTUAL_BIND(_build, "b");
godot::ClassDB::bind_method(D_METHOD("_register_internal"), &GFComponent::_register_internal);
Expand All @@ -393,6 +381,4 @@ void GFComponent::_bind_methods() {
godot::ClassDB::bind_method(D_METHOD("get_data_alignment"), &GFComponent::get_data_alignment);
godot::ClassDB::bind_method(D_METHOD("is_alive"), &GFComponent::is_alive);
godot::ClassDB::bind_method(D_METHOD("_to_string"), &GFComponent::to_string);

godot::ClassDB::bind_static_method(get_class_static(), D_METHOD("_new_internal"), &GFComponent::new_internal);
}
17 changes: 9 additions & 8 deletions cpp/src/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ namespace godot {
GDCLASS(GFComponent, GFRegisterableEntity)

public:
GFComponent();
GFComponent(ecs_entity_t component, GFWorld* world):
GFRegisterableEntity(component, world) {
update_script();
}
GFRegisterableEntity(component, world),
source_entity_id(0)
{}
GFComponent(ecs_entity_t entity, ecs_entity_t component, GFWorld* world):
source_entity_id(entity),
GFRegisterableEntity(component, world) {
update_script();
}
GFRegisterableEntity(component, world)
{}
GFComponent():
source_entity_id(0),
GFRegisterableEntity(0, GFWorld::singleton())
{}
~GFComponent();

// --------------------------------------
Expand Down Expand Up @@ -63,7 +65,6 @@ namespace godot {
static const EcsStruct* get_struct_ptr(GFWorld*, ecs_entity_t);
void set_source_id(ecs_entity_t id);

static Ref<GFRegisterableEntity> new_internal();

protected:
static void _bind_methods();
Expand Down
9 changes: 8 additions & 1 deletion cpp/src/component_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ namespace godot {
GDCLASS(GFComponentBuilder, RefCounted)

public:
GFComponentBuilder(GFWorld* world): world(world) {}
GFComponentBuilder(GFWorld* world):
component_desc({0}),
struct_desc({0}),
name(""),
member_names(Array()),
world(world),
built(false)
{}
GFComponentBuilder():
GFComponentBuilder(GFWorld::singleton())
{}
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/doc_classes/GFWorld.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GFWorld" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
<class name="GFWorld" inherits="Object"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
<brief_description>
An entity component system world.
</brief_description>
Expand Down Expand Up @@ -51,7 +52,6 @@
[/codeblock]
</description>
</method>
</method>
<method name="pair">
<return type="GFPair" />
<param index="0" name="first" type="Variant" />
Expand Down
5 changes: 4 additions & 1 deletion cpp/src/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ namespace godot {
// New entity in specific world
GFEntity(GFWorld* world) ;
// Reference an entity
GFEntity(ecs_entity_t id_, GFWorld* world_): id(id_), world_instance_id(world_->get_instance_id()) {}
GFEntity(ecs_entity_t id_, GFWorld* world_):
id(id_),
world_instance_id(world_->get_instance_id())
{}
// Copy an entity reference
GFEntity(GFEntity& ett): GFEntity(ett.get_id(), ett.get_world()) {}
~GFEntity();
Expand Down
4 changes: 0 additions & 4 deletions cpp/src/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ void GFModule::_register_user() {
GFRegisterableEntity::_register_user();
}

Ref<GFRegisterableEntity> GFModule::new_internal() {
return Ref(memnew(GFModule));
}

void GFModule::_bind_methods() {
godot::ClassDB::bind_static_method(get_class_static(), D_METHOD("new_in_world", "world"), &GFModule::new_named_in_world);
Expand All @@ -140,5 +137,4 @@ void GFModule::_bind_methods() {
godot::ClassDB::bind_static_method(get_class_static(), D_METHOD("from_id", "module_id", "world"), &GFModule::from_id, nullptr);
godot::ClassDB::bind_method(D_METHOD("_register_internal"), &GFModule::_register_internal);
godot::ClassDB::bind_method(D_METHOD("_register_user"), &GFModule::_register_user);
godot::ClassDB::bind_static_method(get_class_static(), D_METHOD("_new_internal"), GFModule::new_internal);
}
2 changes: 0 additions & 2 deletions cpp/src/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ namespace godot {
static Ref<GFModule> from(Variant module, GFWorld*);
static Ref<GFModule> from_id(ecs_entity_t, GFWorld*);

static Ref<GFRegisterableEntity> new_internal();

// --------------------------------------
// --- Unexposed
// --------------------------------------
Expand Down
9 changes: 7 additions & 2 deletions cpp/src/observer_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ namespace godot {
GDCLASS(GFObserverBuilder, GFQuerylikeBuilder)

public:
GFObserverBuilder(GFWorld* world): GFQuerylikeBuilder(world) {}
GFObserverBuilder(): GFObserverBuilder(GFWorld::singleton()) {}
GFObserverBuilder(GFWorld* world):
GFQuerylikeBuilder(world),
events(0)
{}
GFObserverBuilder():
GFObserverBuilder(GFWorld::singleton())
{}
~GFObserverBuilder();

// **************************************
Expand Down
2 changes: 0 additions & 2 deletions cpp/src/pair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

using namespace godot;

GFPair::GFPair() {
}
GFPair::~GFPair() {
}

Expand Down
8 changes: 5 additions & 3 deletions cpp/src/pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ namespace godot {
GDCLASS(GFPair, GFEntity)

public:
GFPair();
GFPair(ecs_entity_t first, ecs_entity_t second, GFWorld* world):
GFEntity(ecs_make_pair(first, second), world)
{}
{}
GFPair(ecs_entity_t pair_id, GFWorld* world):
GFEntity(pair_id, world)
{}
{}
GFPair():
GFPair(0, nullptr)
{}
~GFPair();

// --------------------------------------
Expand Down
3 changes: 0 additions & 3 deletions cpp/src/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

using namespace godot;

GFQuery::GFQuery() {

}
GFQuery::~GFQuery() {
ecs_query_fini(query);
}
Expand Down
9 changes: 7 additions & 2 deletions cpp/src/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ namespace godot {
GDCLASS(GFQuery, RefCounted)

public:
GFQuery();
GFQuery(GFWorld* world, ecs_query_t* query): world(world), query(query) {}
GFQuery(GFWorld* world, ecs_query_t* query):
world(world),
query(query)
{}
GFQuery():
GFQuery(nullptr, nullptr)
{}
~GFQuery();

// --------------------------------------
Expand Down
8 changes: 6 additions & 2 deletions cpp/src/query_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ namespace godot {
GDCLASS(GFQueryBuilder, GFQuerylikeBuilder)

public:
GFQueryBuilder(GFWorld* world): GFQuerylikeBuilder(world) {}
GFQueryBuilder(): GFQueryBuilder(GFWorld::singleton()) {}
GFQueryBuilder(GFWorld* world):
GFQuerylikeBuilder(world)
{}
GFQueryBuilder():
GFQueryBuilder(GFWorld::singleton())
{}
~GFQueryBuilder();

// **************************************
Expand Down
3 changes: 0 additions & 3 deletions cpp/src/query_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

using namespace godot;

GFQueryIterator::GFQueryIterator() {
}

GFQueryIterator::~GFQueryIterator() {
if (!is_done()) {
ecs_iter_fini(&iterator);
Expand Down
6 changes: 4 additions & 2 deletions cpp/src/query_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ namespace godot {
GDCLASS(GFQueryIterator, RefCounted)

public:
GFQueryIterator();
GFQueryIterator():
GFQueryIterator(nullptr, {0})
{}
GFQueryIterator(Ref<GFQuery> query, ecs_iter_t iterator):
query(query),
iterator(iterator)
{}
{}
~GFQueryIterator();

// --------------------------------------
Expand Down
3 changes: 0 additions & 3 deletions cpp/src/querylike_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "querylike_builder.h"
#include "component.h"
#include "godot_cpp/variant/callable.hpp"
#include "godot_cpp/variant/utility_functions.hpp"
#include "godot_cpp/variant/variant.hpp"
#include "utils.h"
#include "world.h"
Expand All @@ -13,8 +12,6 @@

using namespace godot;

GFQuerylikeBuilder::GFQuerylikeBuilder() {
}
GFQuerylikeBuilder::~GFQuerylikeBuilder() {
}

Expand Down
11 changes: 9 additions & 2 deletions cpp/src/querylike_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ namespace godot {
friend QueryIterationContext;

public:
GFQuerylikeBuilder();
GFQuerylikeBuilder(GFWorld* world): world(world) {}
GFQuerylikeBuilder():
GFQuerylikeBuilder(nullptr)
{}
GFQuerylikeBuilder(GFWorld* world):
query_desc(0),
built(false),
term_count(0),
world(world)
{}
~GFQuerylikeBuilder();

// **************************************
Expand Down
6 changes: 1 addition & 5 deletions cpp/src/registerable_entity.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include "registerable_entity.h"
#include "godot_cpp/classes/wrapped.hpp"
#include "world.h"

#include <flecs.h>
#include <godot_cpp/core/class_db.hpp>
Expand Down Expand Up @@ -71,14 +72,9 @@ void GFRegisterableEntity::_register_user() {
GDVIRTUAL_CALL(_register, get_world());
}

Ref<GFRegisterableEntity> GFRegisterableEntity::new_internal() {
return Ref(memnew(GFRegisterableEntity));
}

void GFRegisterableEntity::_bind_methods() {
GDVIRTUAL_BIND(_register, "world");
godot::ClassDB::bind_static_method(GFRegisterableEntity::get_class_static(), D_METHOD("new_in_world", "world"), &GFRegisterableEntity::new_in_world);
godot::ClassDB::bind_method(D_METHOD("_register_internal"), &GFRegisterableEntity::_register_internal);
godot::ClassDB::bind_method(D_METHOD("_register_user"), &GFRegisterableEntity::_register_user);
godot::ClassDB::bind_static_method(get_class_static(), D_METHOD("_new_internal"), &GFRegisterableEntity::new_internal);
}
12 changes: 8 additions & 4 deletions cpp/src/registerable_entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ namespace godot {
GDCLASS(GFRegisterableEntity, GFEntity)

public:
GFRegisterableEntity(): GFEntity() {}
GFRegisterableEntity(GFWorld* world): GFEntity(world) {}
GFRegisterableEntity():
GFRegisterableEntity(GFWorld::singleton())
{}
GFRegisterableEntity(GFWorld* world):
GFEntity(world)
{}
GFRegisterableEntity(ecs_entity_t id, GFWorld* world):
GFEntity(id, world) {}
GFEntity(id, world)
{}
~GFRegisterableEntity();

// --------------------------------------------------------
// --- Exposed ---
// --------------------------------------------------------

GDVIRTUAL1(_register, GFWorld*)
static Ref<GFRegisterableEntity> new_internal();

static Ref<GFRegisterableEntity> new_in_world(GFWorld*);
static Ref<GFRegisterableEntity> from_id(ecs_entity_t id, GFWorld* world);
Expand Down
9 changes: 7 additions & 2 deletions cpp/src/system_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ namespace godot {
GDCLASS(GFSystemBuilder, GFQuerylikeBuilder)

public:
GFSystemBuilder(GFWorld* world): GFQuerylikeBuilder(world) {}
GFSystemBuilder(): GFSystemBuilder(GFWorld::singleton()) {}
GFSystemBuilder(GFWorld* world):
GFQuerylikeBuilder(world),
callable(Callable())
{}
GFSystemBuilder():
GFSystemBuilder(GFWorld::singleton())
{}
~GFSystemBuilder();

// **************************************
Expand Down
Loading

0 comments on commit 5eebef8

Please sign in to comment.