Skip to content

Commit 7b4e9fd

Browse files
authored
Merge pull request #126 from GsLogiMaker/feature/entity-get-default
[Fix] Merge add and add_pair in builders
2 parents 0afe162 + c096b06 commit 7b4e9fd

9 files changed

Lines changed: 15 additions & 77 deletions

cpp/src/doc_classes/GFComponentBuilder.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<method name="add">
2020
<return type="GFComponentBuilder" />
2121
<param index="0" name="entity" type="Variant" />
22+
<param index="1" name="second" type="Variant" />
2223
<description>
2324
Overrides [GFEntityBuilder.add].
2425
</description>
@@ -32,14 +33,6 @@
3233
TODO: Add code examples.
3334
</description>
3435
</method>
35-
<method name="add_pair">
36-
<return type="GFComponentBuilder" />
37-
<param index="0" name="first" type="Variant" />
38-
<param index="1" name="second" type="Variant" />
39-
<description>
40-
Overrides [method GFEntityBuilder.add_pair].
41-
</description>
42-
</method>
4336
<method name="build">
4437
<return type="GFEntity" />
4538
<description>

cpp/src/doc_classes/GFEntity.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
Adds a child entity.
3232
Equivalent to the following:
3333
[codeblock]
34-
entity.add_pair("flecs/core/ChildOf", self)
34+
entity.add("flecs/core/ChildOf", self)
3535
[/codeblock]
3636
Example:
3737
[codeblock]
@@ -440,7 +440,7 @@
440440
Set this entity as a child of [param entity].
441441
Equivalent to the following:
442442
[codeblock]
443-
self.add_pair("flecs/core/ChildOf", entity)
443+
self.add("flecs/core/ChildOf", entity)
444444
[/codeblock]
445445
Example:
446446
[codeblock]
@@ -465,7 +465,7 @@
465465
var entity:= GFEntity.new()
466466
# Pair will be added if it is not already.
467467
entity.set_pair(start, GFPosition2D, Vector2(10, 10))
468-
entity.get_pair(start, GFPosition2D).get_vec() == Vector2(10, 10) # true
468+
entity.get(start, GFPosition2D).get_vec() == Vector2(10, 10) # true
469469
[/codeblock]
470470
This method returns [code]self[/code] for chaining.
471471
</description>
@@ -482,8 +482,8 @@
482482
var start:= GFEntity.new().set_name("Start")
483483
var entity:= GFEntity.new()
484484
# Pair will be added if it is not already.
485-
entity.set_pairv(start, GFPosition2D, [Vector2(10, 10)])
486-
entity.get_pair(start, GFPosition2D).get_vec() == Vector2(10, 10) # true
485+
entity.setpv(start, GFPosition2D, [Vector2(10, 10)])
486+
entity.get(start, GFPosition2D).get_vec() == Vector2(10, 10) # true
487487
[/codeblock]
488488
This method returns [code]self[/code] for chaining.
489489
</description>

cpp/src/doc_classes/GFEntityBuilder.xml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,9 @@
1010
<method name="add">
1111
<return type="GFEntityBuilder" />
1212
<param index="0" name="entity" type="Variant" />
13-
<description>
14-
Adds a new entity to the builder. The built entity have [param entity] added to it.
15-
TODO: Add code examples.
16-
</description>
17-
</method>
18-
<method name="add_pair">
19-
<return type="GFEntityBuilder" />
20-
<param index="0" name="first" type="Variant" />
2113
<param index="1" name="second" type="Variant" />
2214
<description>
23-
Adds a pair to the builder. The built entity will have the pair of [param first] and [param second] added to it.
15+
Adds a new entity to the builder. The built entity have [param entity] added to it.
2416
TODO: Add code examples.
2517
</description>
2618
</method>

cpp/src/doc_classes/GFObserverBuilder.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,9 @@
3232
<method name="add">
3333
<return type="GFObserverBuilder" />
3434
<param index="0" name="entity" type="Variant" />
35-
<description>
36-
Overrides [method GFEntityBuilder.add].
37-
</description>
38-
</method>
39-
<method name="add_pair">
40-
<return type="GFObserverBuilder" />
41-
<param index="0" name="first" type="Variant" />
4235
<param index="1" name="second" type="Variant" />
4336
<description>
44-
Overrides [method GFEntityBuilder.add_pair].
37+
Overrides [method GFEntityBuilder.add].
4538
</description>
4639
</method>
4740
<method name="cascade">

cpp/src/doc_classes/GFQueryBuilder.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,9 @@
1919
<method name="add">
2020
<return type="GFQueryBuilder" />
2121
<param index="0" name="entity" type="Variant" />
22-
<description>
23-
Overrides [method GFEntityBuilder.add].
24-
</description>
25-
</method>
26-
<method name="add_pair">
27-
<return type="GFQueryBuilder" />
28-
<param index="0" name="first" type="Variant" />
2922
<param index="1" name="second" type="Variant" />
3023
<description>
31-
Overrides [method GFEntityBuilder.add_pair].
24+
Overrides [method GFEntityBuilder.add].
3225
</description>
3326
</method>
3427
<method name="build">

cpp/src/doc_classes/GFQuerylikeBuilder.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,9 @@
1212
<method name="add">
1313
<return type="GFQuerylikeBuilder" />
1414
<param index="0" name="entity" type="Variant" />
15-
<description>
16-
Overrides [GFEntity.add].
17-
</description>
18-
</method>
19-
<method name="add_pair">
20-
<return type="GFQuerylikeBuilder" />
21-
<param index="0" name="first" type="Variant" />
2215
<param index="1" name="second" type="Variant" />
2316
<description>
24-
Overrides [GFEntity.add_pair].
17+
Overrides [GFEntity.add].
2518
</description>
2619
</method>
2720
<method name="cascade">

cpp/src/doc_classes/GFSystemBuilder.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,9 @@
2121
<method name="add">
2222
<return type="GFSystemBuilder" />
2323
<param index="0" name="entity" type="Variant" />
24-
<description>
25-
Overrides [method GFEntityBuilder.add_entity].
26-
</description>
27-
</method>
28-
<method name="add_pair">
29-
<return type="GFSystemBuilder" />
30-
<param index="0" name="first" type="Variant" />
3124
<param index="1" name="second" type="Variant" />
3225
<description>
33-
Overrides [method GFEntityBuilder.add_pair].
26+
Overrides [method GFEntityBuilder.add_entity].
3427
</description>
3528
</method>
3629
<method name="cascade">

cpp/src/entity_builder.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Ref<GFEntityBuilder> GFEntityBuilder::new_in_world(GFWorld* world) {
2424
return Ref(memnew(GFEntityBuilder(world)));
2525
}
2626

27-
Ref<GFEntityBuilder> GFEntityBuilder::add(const Variant entity) {
27+
Ref<GFEntityBuilder> GFEntityBuilder::add(const Variant entity, const Variant second) {
2828
GFWorld* w = get_world();
2929
ecs_entity_t id = w->coerce_id(entity);
3030
CHECK_ENTITY_ALIVE(id, w, this,
@@ -35,22 +35,6 @@ Ref<GFEntityBuilder> GFEntityBuilder::add(const Variant entity) {
3535
return this;
3636
}
3737

38-
Ref<GFEntityBuilder> GFEntityBuilder::add_pair(const Variant first, const Variant second) {
39-
GFWorld* w = get_world();
40-
ecs_entity_t first_id = w->coerce_id(first);
41-
CHECK_ENTITY_ALIVE(first_id, w, this,
42-
"Failed to add first of pair in builder\n"
43-
);
44-
ecs_entity_t second_id = w->coerce_id(second);
45-
CHECK_ENTITY_ALIVE(second_id, w, this,
46-
"Failed to add second of pair in builder\n"
47-
);
48-
49-
ids.append(ecs_pair(first_id, second_id));
50-
51-
return this;
52-
}
53-
5438
Ref<GFEntity> GFEntityBuilder::build() {
5539
GFWorld* w = get_world();
5640
return GFEntity::from_id(GFEntityBuilder::build_id(), w);

cpp/src/entity_builder.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@
1212
#include <godot_cpp/variant/string.hpp>
1313

1414
#define OVERRIDE_ENTITY_BUILDER_SELF_METHODS(Self) \
15-
Ref<Self> add(const Variant v0) { return GFEntityBuilder::add(v0); } \
16-
Ref<Self> add_pair(const Variant v0, const Variant v1) { return GFEntityBuilder::add_pair(v0, v1); } \
15+
Ref<Self> add(const Variant v0, const Variant v1) { return GFEntityBuilder::add(v0, v1); } \
1716
Ref<Self> set_target_entity(const Variant v0) { return GFEntityBuilder::set_target_entity(v0); } \
1817
Ref<Self> set_name(const Variant v0) { return GFEntityBuilder::set_name(v0); } \
1918
Ref<Self> set_parent(const Variant v0) { return GFEntityBuilder::set_parent(v0); } \
2019
;
2120

2221
#define REGISTER_ENTITY_BUILDER_SELF_METHODS(Self) \
23-
godot::ClassDB::bind_method(D_METHOD("add", "entity"), &Self::add); \
24-
godot::ClassDB::bind_method(D_METHOD("add_pair", "first", "second"), &Self::add_pair); \
22+
godot::ClassDB::bind_method(D_METHOD("add", "entity", "second"), &Self::add); \
2523
godot::ClassDB::bind_method(D_METHOD("set_target_entity", "entity"), &Self::set_target_entity); \
2624
godot::ClassDB::bind_method(D_METHOD("set_name", "name"), &Self::set_name); \
2725
godot::ClassDB::bind_method(D_METHOD("set_parent", "entity"), &Self::set_parent, 0); \
@@ -54,8 +52,7 @@ namespace godot {
5452

5553
static Ref<GFEntityBuilder> new_in_world(GFWorld*);
5654

57-
Ref<GFEntityBuilder> add(const Variant entity);
58-
Ref<GFEntityBuilder> add_pair(const Variant first, const Variant second);
55+
Ref<GFEntityBuilder> add(const Variant entity, const Variant second);
5956
Ref<GFEntityBuilder> set_target_entity(const Variant entity);
6057
Ref<GFEntityBuilder> set_name(const String);
6158
Ref<GFEntityBuilder> set_parent(const Variant entity);

0 commit comments

Comments
 (0)