development #8
@ -12,7 +12,8 @@ class CollisionSystem(esper.Processor):
|
|||||||
self.map = game_map
|
self.map = game_map
|
||||||
|
|
||||||
def process(self, dt):
|
def process(self, dt):
|
||||||
for ent, (pos, moving, onCol) in self.world.get_components(PositionComponent, MovingComponent, OnCollisionComponent):
|
for ent, (pos, moving, onCol) in self.world.get_components(PositionComponent, MovingComponent,
|
||||||
|
OnCollisionComponent):
|
||||||
if moving.target is not None:
|
if moving.target is not None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -24,8 +25,8 @@ class CollisionSystem(esper.Processor):
|
|||||||
if self.check_collision(moving.target):
|
if self.check_collision(moving.target):
|
||||||
self.world.remove_component(ent, MovingComponent)
|
self.world.remove_component(ent, MovingComponent)
|
||||||
onCol.callAll()
|
onCol.callAll()
|
||||||
colliding_object : int = self.map.get_entity(moving.target)
|
colliding_object: int = self.map.get_entity(moving.target)
|
||||||
if self.world.has_component(colliding_object, OnCollisionComponent):
|
if colliding_object is not None and self.world.has_component(colliding_object, OnCollisionComponent):
|
||||||
self.world.component_for_entity(colliding_object, OnCollisionComponent).callAll()
|
self.world.component_for_entity(colliding_object, OnCollisionComponent).callAll()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user