-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathutils.gd
More file actions
29 lines (27 loc) · 803 Bytes
/
utils.gd
File metadata and controls
29 lines (27 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 常用工具模块
tool
# Check does an object has all of script methods of target class
# - - - - - - - - - -
# *Parameters*
# * [obj:Object] The object to check
# * [interface:GDScript] The interface to check with
# - - - - - - - - - -
# *Returns* bool
static func implements(obj: Object, interface:GDScript) -> bool:
if obj == null or interface == null:
return false
if typeof(obj) != TYPE_OBJECT:
return false
if obj is interface:
return true
var interface_obj = interface.new()
var required_methods = []
for m in interface_obj.get_method_list():
if m.flags & METHOD_FLAG_FROM_SCRIPT:
required_methods.append(m.name)
if not interface_obj is Reference:
interface_obj.free()
for mid in required_methods:
if not obj.has_method(mid):
return false
return true