2021-05-23 14:33:05 +02:00
|
|
|
from functools import partial
|
|
|
|
|
|
|
|
|
2021-05-21 20:14:00 +02:00
|
|
|
class OnCollisionComponent:
|
2021-05-23 14:33:05 +02:00
|
|
|
def __init__(self, callbacks=None):
|
|
|
|
if callbacks is None:
|
|
|
|
callbacks = []
|
2021-05-21 20:14:00 +02:00
|
|
|
self.callbacks = callbacks
|
|
|
|
|
2021-06-19 00:04:34 +02:00
|
|
|
def call_all(self):
|
2021-05-21 20:14:00 +02:00
|
|
|
for func in self.callbacks:
|
|
|
|
func()
|
|
|
|
|
2021-06-19 00:04:34 +02:00
|
|
|
def add_callback(self, fn, **kwargs):
|
2021-05-23 14:33:05 +02:00
|
|
|
self.callbacks.append(partial(fn, **kwargs))
|