Source code for yracing.weapon.bonus.event

from yyagl.gameobject import EventColleague


[docs]class BonusEvent(EventColleague): def __init__(self, mediator): EventColleague.__init__(self, mediator) self.eng.attach_obs(self.on_collision)
[docs] def on_collision(self, obj, tgt_obj): # define "filtered" notification, so a receiver can define a filter for # its message (like a precondition for receiving them) is_bon = tgt_obj.get_name() == 'Bonus' if is_bon and obj in self.mediator.phys.ghost.getOverlappingNodes(): self.notify('on_bonus_collected', self.mediator) self.mediator.destroy()
[docs] def destroy(self): self.eng.detach_obs(self.on_collision) EventColleague.destroy(self)