AI-Project/survival/components/on_collision_component.py
2021-06-19 00:04:34 +02:00

16 lines
368 B
Python

from functools import partial
class OnCollisionComponent:
def __init__(self, callbacks=None):
if callbacks is None:
callbacks = []
self.callbacks = callbacks
def call_all(self):
for func in self.callbacks:
func()
def add_callback(self, fn, **kwargs):
self.callbacks.append(partial(fn, **kwargs))