Exemplo n.º 1
0
def build_buffer(i, ex, args, meta_args):
    """Store the input value and output saved value.

    In pull mode, the trigger is used to update the internal value.
    In push mode, the trigger is used to output the internal value.

    Can be used to cache changing values
    """
    args.start_value = hive.parameter(meta_args.data_type, None)
    i.cached_value = hive.attribute(meta_args.data_type, args.start_value)

    if meta_args.mode == "push":
        i.push_value = hive.push_in(i.cached_value)
        ex.value = hive.antenna(i.push_value)

        i.push_cached_value = hive.push_out(i.cached_value)
        ex.cached_value = hive.output(i.push_cached_value)

        ex.output = hive.entry(i.push_cached_value)

    elif meta_args.mode == "pull":
        i.pull_value = hive.pull_in(i.cached_value)
        ex.value = hive.antenna(i.pull_value)

        i.pull_cached_value = hive.pull_out(i.cached_value)
        ex.cached_value = hive.output(i.pull_cached_value)

        ex.update_cache = hive.entry(i.pull_value)
Exemplo n.º 2
0
def build_foreach(i, ex, args, meta_args):
    """Iterate over iterable object"""
    # Set iterable
    i.iterable = hive.variable("$iterable[int]")
    i.pull_iterable = hive.pull_in(i.iterable)
    ex.iterable = hive.antenna(i.pull_iterable)

    i.do_trig = hive.triggerfunc()
    i.trig_in = hive.triggerable(i.do_trig)
    ex.start = hive.entry(i.trig_in)

    i.break_ = hive.variable('bool', False)

    i.item = hive.variable(meta_args.data_type)
    i.push_item = hive.push_out(i.item)
    ex.item = hive.output(i.push_item)

    i.index = hive.variable('int', 0)
    i.pull_index = hive.pull_out(i.index)
    ex.index = hive.output(i.pull_index)

    i.finished = hive.triggerfunc()

    i.do_break = hive.modifier(do_break)
    ex.break_ = hive.entry(i.do_break)
    ex.finished = hive.hook(i.finished)

    i.iter = hive.modifier(do_iter)
    hive.trigger(i.do_trig, i.pull_iterable)
    hive.trigger(i.do_trig, i.iter)
Exemplo n.º 3
0
def build_tick(cls, i, ex, args):
    """Tick event sensor, trigger on_tick every tick"""
    i.on_tick = hive.triggerfunc()
    ex.on_tick = hive.hook(i.on_tick)

    ex.get_add_handler = hive.socket(cls.set_add_handler, "event.add_handler", policy=hive.SingleRequired)
    ex.get_remove_handler = hive.socket(cls.set_remove_handler, "event.remove_handler", policy=hive.SingleRequired)

    i.enable = hive.triggerable(cls.enable)
    ex.enable = hive.entry(i.enable)

    i.disable = hive.triggerable(cls.disable)
    ex.disable = hive.entry(i.disable)
Exemplo n.º 4
0
def build_count(i, ex, args):
    """Simple integer counter"""
    args.start_value = hive.parameter("int", 0)
    ex.count = hive.attribute("int", args.start_value)

    i.do_count_up = hive.modifier(do_count_up)
    ex.increment = hive.entry(i.do_count_up)

    i.do_count_down = hive.modifier(do_count_down)
    ex.decrement = hive.entry(i.do_count_down)

    i.count_out = hive.push_out(ex.count)
    ex.count_out = hive.output(i.count_out)
Exemplo n.º 5
0
def build_process(cls, i, ex, args):
    # Startup / End callback
    ex.get_on_started = hive.socket(cls.add_on_started,
                                    identifier="on_started",
                                    policy=hive.MultipleOptional)
    ex.get_on_stopped = hive.socket(cls.add_on_stopped,
                                    identifier="on_stopped",
                                    policy=hive.MultipleOptional)

    i.on_started = hive.triggerable(cls.start)
    i.on_stopped = hive.triggerable(cls.stop)

    ex.on_started = hive.entry(i.on_started)
    ex.on_stopped = hive.entry(i.on_stopped)
Exemplo n.º 6
0
def build_commandline(cls, i, ex, args):
    i.start = h.triggerable(cls.start)
    i.stop = h.triggerable(cls.stop)
    i.flush = h.triggerable(cls.flush)
    prop_command = h.property(cls, "command", "str")
    i.push_command = h.push_out(prop_command)

    ex.prop_command = prop_command
    ex.command = h.output(i.push_command)
    ex.send_command = cls.send_command
    ex.start = h.entry(i.start)
    ex.flush = h.entry(i.flush)
    ex.stop = h.entry(i.stop)
    ex.listen = h.socket(cls.add_listener)
Exemplo n.º 7
0
def build_debug(i, ex, args):
    def on_call(h):
        print(h.message)

    ex.message = hive.attribute(("str", ), "Triggered!")
    i.trig_in = hive.modifier(on_call)
    ex.trig_in = hive.entry(i.trig_in)
Exemplo n.º 8
0
def build_and(i, ex, args):
    ex.a_value = hive.attribute(("bool", ), False)
    ex.b_value = hive.attribute(("bool", ), False)

    i.a = hive.pull_in(ex.a_value)
    i.b = hive.pull_in(ex.b_value)

    ex.a = hive.antenna(i.a)
    ex.b = hive.antenna(i.b)

    def on_and(h):
        h._pull_inputs()

        if h.a_value and h.b_value:
            h.trig_out()

    i.trig_out = hive.triggerfunc()
    i.trig_in = hive.modifier(on_and)

    # Update attributes before calling modifier
    i.pull_inputs = hive.triggerfunc()
    hive.trigger(i.pull_inputs, i.a, pretrigger=True)
    hive.trigger(i.pull_inputs, i.b, pretrigger=True)

    ex.trig_out = hive.hook(i.trig_out)
    ex.trig_in = hive.entry(i.trig_in)
Exemplo n.º 9
0
def build_input_handler(cls, i, ex, args):
    i.update = hive.triggerable(cls.update)
    ex.update = hive.entry(i.update)

    i.event = hive.property(cls, "event", "tuple")
    i.push_event = hive.push_out(i.event)
    ex.event = hive.output(i.push_event)
Exemplo n.º 10
0
def build_instantiator(cls, i, ex, args, meta_args):
    """Instantiates a Hive class at runtime"""
    # If this is built now, then it won't perform matchmaking, so use meta hive
    bind_meta_class = hive.meta_hive("BindEnvironment", build_bind_environment, declare_build_environment,
                                     builder_cls=BindEnvironmentClass)
    #assert bind_meta_class._hive_object_class
    i.bind_meta_class = hive.property(cls, "bind_meta_class", "class", bind_meta_class)

    i.trig_instantiate = hive.triggerfunc(cls.instantiate)
    i.do_instantiate = hive.triggerable(i.trig_instantiate)

    i.hive_class = hive.property(cls, "hive_class", "class")
    i.pull_hive_class = hive.pull_in(i.hive_class)
    ex.hive_class = hive.antenna(i.pull_hive_class)

    ex.create = hive.entry(i.do_instantiate)

    hive.trigger(i.trig_instantiate, i.pull_hive_class, pretrigger=True)

    ex.process_id = hive.property(cls, "last_created_process_id", "int.process_id")
    i.pull_process_id = hive.pull_out(ex.process_id)
    ex.last_process_id = hive.output(i.pull_process_id)

    i.push_stop_process = hive.push_in(cls.stop_hive)
    ex.stop_process = hive.antenna(i.push_stop_process)

    # Bind class plugin
    ex.bind_on_created = hive.socket(cls.add_on_created, identifier="bind.on_created", policy=hive.MultipleOptional)
    ex.add_get_plugins = hive.socket(cls.add_get_plugins, identifier="bind.get_plugins", policy=hive.MultipleOptional)
    ex.add_get_config = hive.socket(cls.add_get_config, identifier="bind.get_config", policy=hive.MultipleOptional)

    # Bind instantiator
    if meta_args.bind_process == 'child':
        # Add startup and stop callbacks
        ex.on_stopped = hive.plugin(cls.stop_all_processes, identifier="on_stopped")
Exemplo n.º 11
0
def build_dog(cls, i, ex, args):
    i.call = hive.triggerfunc(cls.call)
    i.woof = hive.triggerable(cls.woof)
    hive.trigger(i.call, i.woof)

    i.bark = hive.triggerfunc()
    hive.trigger(i.bark, i.woof)

    i.woof_only = hive.triggerable(cls.woof)
    i.woofed = hive.triggerfunc()

    ex.woofs = hive.property(cls, "woofs")
    ex.woof = hive.entry(i.woof)
    ex.woof_only = hive.entry(i.woof_only)
    ex.woofed = hive.hook(i.woofed)
    ex.bark = hive.hook(i.bark)
    ex.call = hive.hook(i.call)
Exemplo n.º 12
0
def build_bind_environment(cls, i, ex, args, meta_args):
    """Provides plugins to new embedded hive instance"""
    ex.hive = meta_args.hive_class()

    # Startup / End callback
    ex.get_on_started = hive.socket(cls.add_on_started, identifier="on_started", policy=hive.MultipleOptional)
    ex.get_on_stopped = hive.socket(cls.add_on_stopped, identifier="on_stopped", policy=hive.MultipleOptional)

    i.on_started = hive.triggerable(cls.start)
    i.on_stopped = hive.triggerable(cls.stop)

    ex.on_started = hive.entry(i.on_started)
    ex.on_stopped = hive.entry(i.on_stopped)

    i.state = hive.property(cls, 'state', 'str')
    i.pull_state = hive.pull_out(i.state)
    ex.state = hive.output(i.pull_state)
Exemplo n.º 13
0
def build_mainloop(cls, i, ex, args):
    """Blocking fixed-timestep trigger generator"""
    i.tick = hive.triggerfunc()
    i.stop = hive.triggerable(cls.stop)
    i.run = hive.triggerable(cls.run)

    ex.tick = hive.hook(i.tick)
    ex.run = hive.entry(i.run)
    ex.stop = hive.entry(i.stop)

    i.tick_rate = hive.property(cls, "tick_rate", 'int')
    i.pull_tick_rate = hive.pull_out(i.tick_rate)
    ex.tick_rate = hive.output(i.pull_tick_rate)

    ex.get_tick_rate = hive.plugin(cls.get_tick_rate,
                                   identifier="app.get_tick_rate")
    ex.quit = hive.plugin(cls.stop, identifier="app.quit")
Exemplo n.º 14
0
def build_dispatch(cls, i, ex, args):
    i.event = hive.property(cls, "event", "tuple.event")
    i.pull_event = hive.pull_in(i.event)
    ex.event = hive.antenna(i.pull_event)

    ex.get_read_event = hive.socket(cls.set_read_event, identifier="event.process")

    i.dispatch = hive.triggerable(cls.dispatch)
    ex.trig = hive.entry(i.dispatch)
Exemplo n.º 15
0
def build_animation(cls, i, ex, args, meta_args):
    """Play animation for actor"""
    i.do_start = hive.triggerable(cls.start)
    i.do_stop = hive.triggerable(cls.stop)

    ex.start = hive.entry(i.do_start)
    ex.stop = hive.entry(i.do_stop)

    i.current_frame = hive.property(cls, "current_frame", "int")
    i.end_frame = hive.property(cls, "end_frame", "int")
    i.start_frame = hive.property(cls, "start_frame", "int")

    i.pull_current_frame = hive.pull_out(i.current_frame)
    i.pull_end_frame = hive.pull_in(i.end_frame)
    i.pull_start_frame = hive.pull_in(i.start_frame)

    ex.current_frame = hive.output(i.pull_current_frame)
    ex.start_frame = hive.antenna(i.pull_start_frame)
    ex.end_frame = hive.antenna(i.pull_end_frame)
Exemplo n.º 16
0
def build_spawn(cls, i, ex, args, meta_args):
    """Spawn an entity into the scene"""
    ex.get_spawn_entity = hive.socket(cls.set_spawn_entity, "entity.spawn")

    # Associate entity with this hive so it is safely destroyed
    ex.get_register_destructor = hive.socket(cls.set_register_destructor,
                                             "entity.register_destructor")
    ex.on_entity_process_instantiated = hive.plugin(
        cls.on_entity_process_created, "bind.on_created")

    i.entity_class_id = hive.property(cls, "entity_class_id",
                                      "str.entity_class_id")
    i.pull_class_id = hive.pull_in(i.entity_class_id)
    ex.entity_class_id = hive.antenna(i.pull_class_id)

    i.entity_last_created_id = hive.property(cls, "entity_last_created_id",
                                             "int.entity_id")

    if meta_args.spawn_hive:
        i.pull_entity_id = hive.pull_out(i.entity_last_created_id)
        ex.entity_last_created_id = hive.output(i.pull_entity_id)

    else:
        i.push_entity_id = hive.push_out(i.entity_last_created_id)
        ex.created_entity_id = hive.output(i.push_entity_id)

    i.do_spawn = hive.triggerable(cls.do_spawn_entity)
    i.trigger = hive.triggerfunc(i.do_spawn)
    i.on_triggered = hive.triggerable(i.trigger)

    hive.trigger(i.trigger, i.pull_class_id, pretrigger=True)

    # Process instantiator
    if meta_args.spawn_hive:
        i.instantiator = Instantiator(forward_events='all',
                                      bind_process='child')

        # Pull entity to instantiator
        hive.connect(i.pull_entity_id, i.instantiator.entity_id)

        # Get last created
        ex.hive_class = hive.antenna(i.instantiator.hive_class)
        ex.last_process_id = hive.output(i.instantiator.last_process_id)
        ex.stop_process = hive.antenna(i.instantiator.stop_process)
        ex.pause_events = hive.antenna(i.instantiator.pause_events)
        ex.resume_events = hive.antenna(i.instantiator.resume_events)

        # Instantiate
        hive.trigger(i.trigger, i.instantiator.create)

    else:
        # Finally push out entity
        hive.trigger(i.trigger, i.push_entity_id)

    ex.spawn = hive.entry(i.on_triggered)
Exemplo n.º 17
0
def build_dog(cls, i, ex, args, meta_args):

    print(meta_args)
    print("Invoked Builder")
    args.name = hive.parameter("str")
    ex.name = hive.property(cls, "name", "str", args.name)

    for ix in range(meta_args.puppies):
        mod = hive.modifier(lambda h: print("Puppy {} barked".format(h.name)))
        setattr(i, "mod_{}".format(ix), mod)
        setattr(ex, "bark_{}".format(ix), hive.entry(mod))
Exemplo n.º 18
0
def build_event_environment(cls, i, ex, args, meta_args):
    """Runtime event environment for instantiated hive.

    Provides appropriate sockets and plugins for event interface
    """
    ex.add_handler = hive.plugin(cls.add_handler,
                                 identifier="event.add_handler")
    ex.remove_handler = hive.plugin(cls.remove_handler,
                                    identifier="event.remove_handler")
    ex.read_event = hive.plugin(cls.handle_event, identifier="event.process")

    ex.event_on_stopped = hive.plugin(cls.on_closed,
                                      identifier="on_stopped",
                                      policy=hive.SingleOptional)

    i.pause_events = hive.triggerable(cls.pause)
    ex.pause_events = hive.entry(i.pause_events)

    i.resume_events = hive.triggerable(cls.resume)
    ex.resume_events = hive.entry(i.resume_events)
Exemplo n.º 19
0
def build_while(i, ex, args):
    """Trigger output while condition is True"""
    ex.condition = hive.attribute()
    i.condition_in = hive.pull_in(ex.condition)
    ex.condition_in = hive.antenna(i.condition_in)

    i.trig = hive.triggerfunc()
    ex.trig_out = hive.hook(i.trig)

    i.trig_in = hive.modifier(do_while)
    ex.trig_in = hive.entry(i.trig_in)
Exemplo n.º 20
0
def build_transistor(i, ex, args, meta_args):
    """Convert a pull output into a push output, using a trigger input"""
    i.value = hive.variable(meta_args.data_type)
    i.pull_value = hive.pull_in(i.value)
    ex.value = hive.antenna(i.pull_value)

    i.push_value = hive.push_out(i.value)
    ex.result = hive.output(i.push_value)

    ex.trigger = hive.entry(i.pull_value)

    hive.trigger(i.pull_value, i.push_value)
Exemplo n.º 21
0
def build_toggle(i, ex, args):
    """Toggle between two triggers"""
    args.start_value = hive.parameter('bool', False)
    i.toggle = hive.attribute("bool", args.start_value)

    i.modifier = hive.modifier(evaluate_toggle)
    ex.trig_in = hive.entry(i.modifier)

    i.trig_a = hive.triggerfunc()
    i.trig_b = hive.triggerfunc()

    ex.trig_a = hive.hook(i.trig_a)
    ex.trig_b = hive.hook(i.trig_b)
Exemplo n.º 22
0
def build_func(i, ex, args, meta_args):
    """Define callable object from expression"""
    # Get AST and parse ags
    ast_node = ast.parse(meta_args.definition, mode='exec')
    assert isinstance(ast_node, ast.Module)
    assert len(ast_node.body) == 1
    func_def_ast = ast_node.body[0]
    assert isinstance(func_def_ast, ast.FunctionDef)

    visitor = FunctionDefinitionVisitor()
    visitor.visit(ast_node)

    # Build the function itself
    user_namespace = {}
    exec(meta_args.definition, user_namespace)
    user_func = user_namespace[func_def_ast.name]

    has_return = visitor.output_type_name is not function_no_return

    # Define modifier source code (here, we will lookup the "user_func" name later)
    function_call_str = "user_func({})".format(", ".join(
        ["self._{}".format(a) for a in visitor.antennae]))
    result_body = result_str if has_return else ""
    modifier_decl = modifier_str.format(function_call_str=function_call_str,
                                        result_body=result_body)

    # Build modifier function
    namespace = {'user_func': user_func}
    exec(modifier_decl, namespace)
    modifier_func = namespace['modifier']

    # Create modifier bees
    i.modifier = hive.modifier(modifier_func)
    ex.trigger = hive.entry(i.modifier)

    i.pull_all_inputs = hive.triggerfunc()

    # Create IO pins
    for arg, (type_name, default) in visitor.antennae.items():
        attr = hive.variable(type_name, start_value=default)
        setattr(i, arg, attr)
        pull_in = hive.pull_in(attr)
        setattr(ex, arg, hive.antenna(pull_in))
        hive.trigger(i.pull_all_inputs, pull_in, pretrigger=True)

    if has_return:
        result_name = 'result'
        attr = hive.variable(visitor.output_type_name)
        setattr(i, result_name, attr)
        push_out = hive.push_out(attr)
        setattr(ex, result_name, hive.output(push_out))
Exemplo n.º 23
0
def build_house(cls, i, ex, args):
    i.brutus_ = DogHive("Brutus")
    i.fifi = DogHive("Fifi")

    i.dog_appeared = hive.triggerable(cls.dog_appeared)
    hive.trigger(i.brutus_.call, i.dog_appeared)

    i.mail_arrived = hive.triggerfunc(cls.mail_arrived)
    hive.trigger(i.mail_arrived, i.fifi.woof)

    ex.brutus = i.brutus_
    ex.fifi = i.fifi
    ex.mail_arrived = hive.hook(i.mail_arrived)
    ex.dog_appeared = hive.entry(i.dog_appeared)
Exemplo n.º 24
0
def build_house(cls, i, ex, args):
    i.brutus = dog("Brutus")
    i.fifi = dog("Fifi")

    i.dog_comes = h.triggerable(cls.dog_comes)
    h.trigger(i.brutus.call, i.dog_comes)

    i.mail = h.triggerfunc(cls.mail)
    h.trigger(i.mail, i.fifi.woof)

    ex.brutus = i.brutus
    ex.fifi = i.fifi
    ex.mail = h.hook(i.mail)
    ex.dog_comes = h.entry(i.dog_comes)
Exemplo n.º 25
0
def build_always(i, ex, args):
    ex.name = hive.variable(("str", ), "<Sensor>")
    ex.is_positive = hive.variable(("bool", ), True)

    i.positive = hive.pull_out(ex.is_positive)
    ex.positive = hive.output(i.positive)

    def trigger(h):
        h.trig_out()

    i.trig_in = hive.modifier(trigger)
    ex.trig_in = hive.entry(i.trig_in)

    i.trig_out = hive.triggerfunc()
    ex.trig_out = hive.hook(i.trig_out)
Exemplo n.º 26
0
def build_move(cls, i, ex, args, meta_args):
    """Apply a position delta to an entity"""
    coordinate_system = meta_args.coordinate_system

    i.displacement = hive.property(cls, "displacement", "vector")
    i.pull_displacement = hive.pull_in(i.displacement)
    ex.displacement = hive.antenna(i.pull_displacement)

    if meta_args.bound:
        ex.get_bound = hive.socket(cls.set_get_entity_id,
                                   identifier="entity.get_bound")
        i.do_get_entity_id = hive.triggerable(cls.do_get_entity_id)

        hive.trigger(i.pull_displacement, i.do_get_entity_id)

    else:
        i.entity_id = hive.property(cls, "entity_id", "int.entity_id")
        i.pull_entity_id = hive.pull_in(i.entity_id)
        ex.entity_id = hive.antenna(i.pull_entity_id)

        hive.trigger(i.pull_displacement, i.pull_entity_id)

    if coordinate_system == 'absolute':
        ex.get_set_position = hive.socket(
            cls.set_set_position, identifier="entity.position.set.absolute")
        ex.get_get_position = hive.socket(
            cls.set_get_position, identifier="entity.position.get.absolute")

        i.do_set_position = hive.triggerable(cls.do_move_absolute)

    else:
        i.other_entity_id = hive.property(cls, "other_entity_id",
                                          "int.entity_id")
        i.pull_other_entity_id = hive.pull_in(i.other_entity_id)
        ex.other_entity_id = hive.antenna(i.pull_other_entity_id)

        hive.trigger(i.pull_displacement, i.pull_other_entity_id)

        ex.get_set_position = hive.socket(
            cls.set_set_position, identifier="entity.position.set.relative")
        ex.get_get_position = hive.socket(
            cls.set_get_position, identifier="entity.position.get.relative")

        i.do_set_position = hive.triggerable(cls.do_move_relative)

    hive.trigger(i.pull_displacement, i.do_set_position)

    ex.trig = hive.entry(i.pull_displacement)
Exemplo n.º 27
0
def build_set(i, ex, args, meta_args):
    """Perform set operation on single sets"""

    i.set_ = hive.attribute('set', set())
    i.pull_set_ = hive.pull_out(i.set_)
    ex.set_out = hive.output(i.pull_set_)

    i.push_set_ = hive.push_in(i.set_)
    ex.set_ = hive.antenna(i.push_set_)

    # Pop item
    i.popped_item = hive.attribute(meta_args.data_type)
    i.pull_pop = hive.pull_out(i.popped_item)
    ex.pop = hive.output(i.pull_pop)

    def do_pop(self):
        self._popped_item = self._set_.pop()

    i.do_pop = hive.modifier(do_pop)
    hive.trigger(i.pull_pop, i.do_pop, pretrigger=True)

    # Add item
    i.to_add = hive.attribute(meta_args.data_type)
    i.push_to_add = hive.push_in(i.to_add)
    ex.add = hive.antenna(i.push_to_add)

    def to_add(self):
        self._set_.add(self._to_add)

    i.do_add = hive.modifier(to_add)
    hive.trigger(i.push_to_add, i.do_add)

    # Remove item
    i.to_remove = hive.attribute(meta_args.data_type)
    i.push_to_remove = hive.push_in(i.to_remove)
    ex.remove = hive.antenna(i.push_to_remove)

    def do_remove(self):
        self._set_.remove(self._to_remove)

    i.do_remove = hive.modifier(do_remove)
    hive.trigger(i.push_to_remove, i.do_remove)

    def do_clear(self):
        self._set_.clear()

    i.do_clear = hive.modifier(do_clear)
    ex.clear = hive.entry(i.do_clear)
Exemplo n.º 28
0
def build_dog(cls, i, ex, args):
    i.call = h.triggerfunc(cls.call)
    i.woof = h.triggerable(cls.woof)
    #h.trigger(i.call, i.woof)
    h.connect(i.call, i.woof)
    i.woof2 = h.modifier(woof2)
    i.bark = h.triggerfunc()
    h.trigger(i.bark, i.woof)
    i.woofed = h.triggerfunc()

    ex.woofs = h.property(cls, "woofs")
    ex.name = h.property(cls, "name")
    ex.woofs2 = h.variable(data_type="int", start_value=0)
    ex.woof = h.entry(i.woof)
    ex.woofed = h.hook(i.woofed)
    ex.bark = h.hook(i.bark)
    ex.call = h.hook(i.call)
Exemplo n.º 29
0
def build_switch(i, ex, args, meta_args):
    """Redirect input trigger to true / false outputs according to boolean evaluation of switch value"""
    ex.switch = hive.attribute(meta_args.data_type)

    i.input = hive.pull_in(ex.switch)
    ex.input = hive.antenna(i.input)

    i.true = hive.triggerfunc()
    ex.true = hive.hook(i.true)

    i.false = hive.triggerfunc()
    ex.false = hive.hook(i.false)

    i.do_evaluate = hive.modifier(evaluate_switch)
    i.do_trigger = hive.triggerfunc(i.do_evaluate)
    hive.trigger(i.do_trigger, i.input, pretrigger=True)

    i.on_trigger = hive.triggerable(i.do_trigger)
    ex.trigger = hive.entry(i.on_trigger)
Exemplo n.º 30
0
def build_physics_manager(cls, i, ex, args):
    i.tick_rate = hive.property(cls, "tick_rate", 'int')
    i.pull_tick_rate = hive.pull_in(i.tick_rate)
    ex.tick_rate = hive.antenna(i.pull_tick_rate)

    i.do_update = hive.triggerfunc(cls.update)
    hive.trigger(i.do_update, i.pull_tick_rate, pretrigger=True)

    i.on_tick = hive.triggerable(i.do_update)
    ex.tick = hive.entry(i.on_tick)

    ex.on_entity_destroyed = hive.plugin(cls.on_entity_destroyed, "entity.on_destroyed", policy=hive.SingleRequired)
    ex.on_entity_created = hive.plugin(cls.on_entity_created, "entity.on_created", policy=hive.SingleRequired)

    ex.get_angular_velocity = hive.plugin(cls.get_angular_velocity, "entity.angular_velocity.get",
                                          export_to_parent=True)
    ex.set_angular_velocity = hive.plugin(cls.set_angular_velocity, "entity.angular_velocity.set",
                                          export_to_parent=True)

    ex.get_linear_velocity = hive.plugin(cls.get_linear_velocity, "entity.angular_velocity.get", export_to_parent=True)
    ex.set_linear_velocity = hive.plugin(cls.set_linear_velocity, "entity.angular_velocity.set", export_to_parent=True)