Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
183dc04d
Commit
183dc04d
authored
Jun 18, 2020
by
Paul Joannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[mono] implement generics GetNodesInGroup
parent
4e0f31a6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
152 additions
and
0 deletions
+152
-0
SceneTreeExtensions.cs
...otSharp/GodotSharp/Core/Extensions/SceneTreeExtensions.cs
+17
-0
GodotSharp.csproj
modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj
+1
-0
glue_header.h
modules/mono/glue/glue_header.h
+2
-0
scene_tree_glue.cpp
modules/mono/glue/scene_tree_glue.cpp
+82
-0
scene_tree_glue.h
modules/mono/glue/scene_tree_glue.h
+50
-0
No files found.
modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/SceneTreeExtensions.cs
0 → 100644
View file @
183dc04d
using
System
;
using
System.Runtime.CompilerServices
;
using
Godot.Collections
;
namespace
Godot
{
public
partial
class
SceneTree
{
public
Array
<
T
>
GetNodesInGroup
<
T
>(
StringName
group
)
where
T
:
class
{
return
new
Array
<
T
>(
godot_icall_SceneTree_get_nodes_in_group_Generic
(
Object
.
GetPtr
(
this
),
StringName
.
GetPtr
(
group
),
typeof
(
T
)));
}
[
MethodImpl
(
MethodImplOptions
.
InternalCall
)]
internal
extern
static
IntPtr
godot_icall_SceneTree_get_nodes_in_group_Generic
(
IntPtr
obj
,
IntPtr
group
,
Type
elemType
);
}
}
modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj
View file @
183dc04d
...
...
@@ -53,6 +53,7 @@
<Compile
Include=
"Core\Extensions\NodeExtensions.cs"
/>
<Compile
Include=
"Core\Extensions\ObjectExtensions.cs"
/>
<Compile
Include=
"Core\Extensions\ResourceLoaderExtensions.cs"
/>
<Compile
Include=
"Core\Extensions\SceneTreeExtensions.cs"
/>
<Compile
Include=
"Core\GD.cs"
/>
<Compile
Include=
"Core\GodotSynchronizationContext.cs"
/>
<Compile
Include=
"Core\GodotTaskScheduler.cs"
/>
...
...
modules/mono/glue/glue_header.h
View file @
183dc04d
...
...
@@ -35,6 +35,7 @@
#include "gd_glue.h"
#include "nodepath_glue.h"
#include "rid_glue.h"
#include "scene_tree_glue.h"
#include "string_glue.h"
#include "string_name_glue.h"
...
...
@@ -50,6 +51,7 @@ void godot_register_glue_header_icalls() {
godot_register_object_icalls
();
godot_register_rid_icalls
();
godot_register_string_icalls
();
godot_register_scene_tree_icalls
();
}
// Used by the generated glue
...
...
modules/mono/glue/scene_tree_glue.cpp
0 → 100644
View file @
183dc04d
/*************************************************************************/
/* scene_tree_glue.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* 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 "scene_tree_glue.h"
#ifdef MONO_GLUE_ENABLED
#include "core/class_db.h"
#include "modules/mono/csharp_script.h"
#include "modules/mono/mono_gd/gd_mono_utils.h"
#include "scene/main/node.h"
Array
*
godot_icall_SceneTree_get_nodes_in_group_Generic
(
SceneTree
*
ptr
,
StringName
*
group
,
MonoReflectionType
*
refltype
)
{
List
<
Node
*>
nodes
;
Array
ret
;
// Retrieve all the nodes in the group
ptr
->
get_nodes_in_group
(
*
group
,
&
nodes
);
// No need to bother if the group is empty
if
(
!
nodes
.
empty
())
{
MonoType
*
elem_type
=
mono_reflection_type_get_type
(
refltype
);
MonoClass
*
mono_class
=
mono_class_from_mono_type
(
elem_type
);
GDMonoClass
*
klass
=
GDMono
::
get_singleton
()
->
get_class
(
mono_class
);
if
(
klass
==
GDMonoUtils
::
get_class_native_base
(
klass
))
{
// If we're trying to get native objects, just check the inheritance list
StringName
native_class_name
=
GDMonoUtils
::
get_native_godot_class_name
(
klass
);
for
(
int
i
=
0
;
i
<
nodes
.
size
();
++
i
)
{
if
(
ClassDB
::
is_parent_class
(
nodes
[
i
]
->
get_class
(),
native_class_name
))
ret
.
push_back
(
nodes
[
i
]);
}
}
else
{
// If we're trying to get csharpscript instances, get the mono object and compare the classes
for
(
int
i
=
0
;
i
<
nodes
.
size
();
++
i
)
{
CSharpInstance
*
si
=
CAST_CSHARP_INSTANCE
(
nodes
[
i
]
->
get_script_instance
());
if
(
si
!=
nullptr
)
{
MonoObject
*
obj
=
si
->
get_mono_object
();
if
(
obj
!=
nullptr
&&
mono_object_get_class
(
obj
)
==
mono_class
)
{
ret
.
push_back
(
nodes
[
i
]);
}
}
}
}
}
return
memnew
(
Array
(
ret
));
}
void
godot_register_scene_tree_icalls
()
{
mono_add_internal_call
(
"Godot.SceneTree::godot_icall_SceneTree_get_nodes_in_group_Generic"
,
(
void
*
)
godot_icall_SceneTree_get_nodes_in_group_Generic
);
}
#endif // MONO_GLUE_ENABLED
modules/mono/glue/scene_tree_glue.h
0 → 100644
View file @
183dc04d
/*************************************************************************/
/* scene_tree_glue.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* 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. */
/*************************************************************************/
#ifndef SCENE_TREE_GLUE_H
#define SCENE_TREE_GLUE_H
#ifdef MONO_GLUE_ENABLED
#include "core/array.h"
#include "core/string_name.h"
#include "scene/main/scene_tree.h"
#include "../mono_gd/gd_mono_marshal.h"
Array
*
godot_icall_SceneTree_get_nodes_in_group_Generic
(
SceneTree
*
ptr
,
StringName
*
group
,
MonoReflectionType
*
refltype
);
// Register internal calls
void
godot_register_scene_tree_icalls
();
#endif // MONO_GLUE_ENABLED
#endif // SCENE_TREE_GLUE_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment