43 lines
No EOL
756 B
Python
43 lines
No EOL
756 B
Python
class TimedAction:
|
|
|
|
def __init__(self, start_t, duration_t, nodes, program):
|
|
|
|
self.program = program
|
|
self.program.actions.append(self)
|
|
|
|
if not isinstance(nodes, list):
|
|
nodes = [nodes]
|
|
|
|
self.nodes = nodes # list of nodes
|
|
self.start_t = start_t
|
|
self.duration_t = duration_t
|
|
self.end_t = start_t + duration_t
|
|
|
|
def tick(self, t):
|
|
|
|
if t >= self.start_t and t <= self.end_t:
|
|
|
|
for node in self.nodes:
|
|
|
|
if t == self.start_t:
|
|
self.start(node)
|
|
|
|
elif t == self.end_t:
|
|
self.end(node)
|
|
|
|
else:
|
|
self.progress((t - self.start_t) / float(self.duration_t), node)
|
|
|
|
# REIMPLEMENT
|
|
|
|
def start(self, node):
|
|
|
|
pass
|
|
|
|
def end(self, node):
|
|
|
|
pass
|
|
|
|
def progress(self, prc, node):
|
|
|
|
pass |