update
parent
a9077781fe
commit
dc4c2714eb
|
@ -57,27 +57,27 @@ static func example():
|
|||
|
||||
func _has(key:String)->bool:
|
||||
return _all_events.has(key)
|
||||
func _get(key) -> Variant:
|
||||
func _get_actions(key:String) -> Variant:
|
||||
return _all_events[key]
|
||||
|
||||
|
||||
func add(key:String,action:Callable):
|
||||
if !_has(key):
|
||||
var empty : Array[Callable] = []
|
||||
_all_events[key] = empty
|
||||
_all_events[key].append(action)
|
||||
_get_actions(key).append(action)
|
||||
|
||||
func erase(key:String, action:Callable):
|
||||
if _has(key):
|
||||
_get(key).erase(action)
|
||||
_get_actions(key).erase(action)
|
||||
|
||||
func trigger(event_key:String):
|
||||
if _has(event_key):
|
||||
for event in _all_events[event_key]:
|
||||
for event in _get_actions(event_key):
|
||||
event.call()
|
||||
|
||||
func trigger_data(event_key:String, data):
|
||||
if _has(event_key):
|
||||
for event in _all_events[event_key]:
|
||||
for event in _get_actions(event_key):
|
||||
event.call(data)
|
||||
```
|
||||
推荐使用样例
|
||||
|
|
Loading…
Reference in New Issue