def __init__(self, protocol, team, x, y):
self.protocol = protocol
self.team = team
self.x = x
self.y = y
if self.random_colors:
self.color = choice(self.random_colors)
elif self.team_color:
self.color = make_color(*team.color)
self.blocks = set()
base_lines, base_points = self.lines, self.points
self.lines, self.points = [], []
for line in base_lines:
self.make_line(*line)
for point in base_points:
self.make_block(*point)
# find markers we're colliding with
has_timer = self.duration is not None
collisions = []
current_time = seconds()
worst_time = current_time + self.duration if has_timer else None
for marker in protocol.markers:
intersect = marker.blocks & self.blocks
if intersect:
self.blocks -= intersect
collisions.append(marker)
if has_timer and marker.expire_call:
worst_time = min(worst_time, marker.expire_call.getTime())
# forward expiration time so that colliding markers vanish all at once
if has_timer:
delay = worst_time - current_time
self.expire_call = callLater(delay, self.expire)
self.build()
team.marker_count[self.__class__] += 1
protocol.markers.append(self)
if self.background_class:
self.background = self.background_class(protocol, team, x, y)
评论列表
文章目录