예제 #1
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")
예제 #2
0
파일: keyboard.py 프로젝트: agoose77/hive2
def build_keyboard(cls, i, ex, args, meta_args):
    """Listen for keyboard event"""
    if meta_args.mode == 'single key':
        ex.on_event = hive.socket(cls.add_single_listener, identifier="event.add_handler")

        args.key = hive.parameter("str.keycode", "w")
        i.key = hive.property(cls, "key", "str.keycode", args.key)

        i.push_key = hive.push_in(i.key)
        ex.key = hive.antenna(i.push_key)

        i.on_key_changed = hive.triggerable(cls.change_listener_keys)
        hive.trigger(i.push_key, i.on_key_changed)

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

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

        i.is_pressed = hive.property(cls, "is_pressed", "bool")
        i.pull_is_pressed = hive.pull_out(i.is_pressed)
        ex.is_pressed = hive.output(i.pull_is_pressed)

    else:
        ex.on_event = hive.socket(cls.add_any_listener, identifier="event.add_handler")

        i.key_pressed = hive.property(cls, 'key_pressed', data_type='str.keycode')
        i.pull_key_pressed = hive.push_out(i.key_pressed)
        ex.key_pressed = hive.output(i.pull_key_pressed)

        i.key_released = hive.property(cls, 'key_released', data_type='str.keycode')
        i.pull_key_released = hive.push_out(i.key_released)
        ex.key_released = hive.output(i.pull_key_released)
예제 #3
0
def build_mainloop(cls, i, ex, args):
    i.event_manager = EventManager(export_namespace=True)
    i.input_manager = InputHandler(export_namespace=True)
    i.entity_manager = EntityManager(export_namespace=True)
    i.transform_manager = TransformManager(export_namespace=True)
    i.physics_manager = PhysicsManager(export_namespace=True)

    # Connect input manager
    hive.connect(i.tick, i.input_manager.update)
    hive.connect(i.input_manager.event, i.event_manager.event_in)

    # Connect physics
    hive.connect(i.tick, i.physics_manager.tick)
    hive.connect(i.pull_tick_rate, i.physics_manager.tick_rate)

    # Send tick event and step Panda
    i.on_tick = hive.triggerable(cls.on_tick)
    hive.trigger(i.tick, i.on_tick)

    # Get read event
    ex.get_dispatcher = hive.socket(cls.set_event_dispatcher, "event.process")
    ex.get_add_handler = hive.socket(cls.set_add_handler, "event.add_handler")

    # Add startup and stop callbacks
    ex.main_on_started = hive.plugin(cls.on_started, identifier="on_started")
예제 #4
0
def build_entity(cls, i, ex, args):
    ex.set_tag = hive.plugin(cls.set_tag,
                             identifier="entity.tag.set",
                             export_to_parent=True)
    ex.get_tag = hive.plugin(cls.get_tag,
                             identifier="entity.tag.get",
                             export_to_parent=True)
    ex.set_visibility = hive.plugin(cls.set_visibility,
                                    identifier="entity.visibility.set",
                                    export_to_parent=True)
    ex.get_visibility = hive.plugin(cls.get_visibility,
                                    identifier="entity.visibility.get",
                                    export_to_parent=True)
    ex.spawn_entity = hive.plugin(cls.spawn_entity,
                                  identifier="entity.spawn",
                                  export_to_parent=True)
    ex.destroy_entity = hive.plugin(cls.destroy_entity,
                                    identifier="entity.destroy",
                                    export_to_parent=True)
    ex.register_entity_factory = hive.plugin(cls.register_entity_factory,
                                             "entity.register_factory",
                                             export_to_parent=True)
    ex.register_hive_destructor = hive.plugin(cls.register_hive_destructor,
                                              "entity.register_destructor",
                                              export_to_parent=True)

    # Push out entity destroyed
    ex.on_entity_destroyed = hive.socket(cls.on_entity_destroyed,
                                         "entity.on_destroyed",
                                         policy=hive.MultipleOptional,
                                         export_to_parent=True)
    ex.on_entity_created = hive.socket(cls.on_entity_created,
                                       "entity.on_created",
                                       policy=hive.MultipleOptional,
                                       export_to_parent=True)
예제 #5
0
파일: spawn.py 프로젝트: agoose77/hive2
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)
예제 #6
0
def build_chessboard(cls, i, ex, args):
    prop_move = h.property(cls, "prop_move", "str")  # TODO: make buffer
    i.make_move = h.push_in(prop_move)
    i.trig_make_move = h.triggerable(cls.trig_make_move)  # TODO: make modifier
    h.trigger(i.make_move, i.trig_make_move)

    ex.make_move = h.antenna(i.make_move)
    ex.do_make_move = cls.make_move
    ex.p_make_move = h.plugin(cls.make_move)
    ex.prop_move = prop_move
    ex.set_turn = h.socket(cls.set_turn)
    ex.add_moveprocessor = h.socket(cls.add_moveprocessor)
예제 #7
0
파일: time.py 프로젝트: agoose77/hive2
def time_builder(cls, i, ex, args):
    """Access to Python time module"""
    i.elapsed = hive.property(cls, 'elapsed', 'float')
    i.elapsed_out = hive.pull_out(i.elapsed)
    ex.elapsed_out = hive.output(i.elapsed_out)

    ex.get_add_handler = hive.socket(cls.set_add_handler, "event.add_handler")
    ex.on_started = hive.plugin(cls.on_started,
                                "on_started",
                                policy=hive.SingleRequired)
    ex.get_get_tick_rate = hive.socket(cls.set_get_tick_rate,
                                       "app.get_tick_rate")
예제 #8
0
파일: tick.py 프로젝트: agoose77/hive2
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)
예제 #9
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)
예제 #10
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)
예제 #11
0
def build_watch(cls, i, ex, args, meta_args):
    """Watch value and indicate when it is changed.

    Uses a tick callback.
    """
    args.start_value = hive.parameter(meta_args.data_type, None)
    i.value = hive.property(cls, "current_value", meta_args.data_type, args.start_value)

    if meta_args.mode == 'pull':
        i.value_in = hive.pull_in(i.value)

    else:
        i.value_in = hive.push_in(i.value)

    ex.value = hive.antenna(i.value_in)

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

    if meta_args.mode == 'pull':
        ex.get_add_handler = hive.socket(cls.set_add_handler, identifier="event.add_handler")

    else:
        i.compare_values = hive.triggerable(cls.compare_values)
        hive.trigger(i.value_in, i.compare_values)
예제 #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)
예제 #13
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)
예제 #14
0
def build_this(cls, i, ex, args):
    """Access to current bound entity"""
    ex.get_bound_entity = hive.socket(cls.set_get_entity_id, identifier="entity.get_bound")

    i.entity_id = hive.property(cls, "entity_id", "int.entity_id")
    i.pull_entity_id = hive.pull_out(i.entity_id)
    ex.entity_id = hive.output(i.pull_entity_id)

    i.do_get_entity_id = hive.triggerable(cls.get_entity_id)
    hive.trigger(i.pull_entity_id, i.do_get_entity_id, pretrigger=True)
예제 #15
0
def build_listener(cls, i, ex, args, meta_args):
    """Tick event sensor, trigger on_tick every tick"""
    i.on_event = hive.triggerfunc()
    ex.on_event = hive.hook(i.on_event)

    ex.get_add_handler = hive.socket(cls.set_add_handler, "event.add_handler")

    if meta_args.mode == 'leader':
        i.after_leader = hive.property(cls, 'after_leader', 'tuple')
        i.pull_after_leader = hive.pull_out(i.after_leader)
        ex.after_leader = hive.output(i.pull_after_leader)
예제 #16
0
파일: tag.py 프로젝트: agoose77/hive2
def build_tag(cls, i, ex, args, meta_args):
    """Access to entity tag API"""
    if meta_args.bound:
        ex.get_bound = hive.socket(cls.set_get_entity_id, identifier="entity.get_bound")
        i.do_get_bound_entity_id = hive.triggerable(cls.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)
        i.do_get_bound_entity_id = hive.triggerable(i.pull_entity_id)

    i.tag_name = hive.property(cls, "tag_name", "str")
    i.tag_value = hive.property(cls, "tag_value", meta_args.data_type)

    i.pull_tag_name = hive.pull_in(i.tag_name)
    ex.name = hive.antenna(i.pull_tag_name)

    if meta_args.mode == 'get':
        ex.get_get_tag = hive.socket(cls.set_get_tag, identifier="entity.tag.get")

        i.pull_tag_value = hive.pull_out(i.tag_value)
        ex.value = hive.output(i.pull_tag_value)

        i.do_get_tag = hive.triggerable(cls.get_tag)

        hive.trigger(i.pull_tag_value, i.do_get_bound_entity_id)
        hive.trigger(i.pull_tag_value, i.pull_tag_name)
        hive.trigger(i.pull_tag_value, i.do_get_tag)

    else:
        ex.get_set_tag = hive.socket(cls.set_set_tag, identifier="entity.tag.set")

        i.push_tag_value = hive.push_in(i.tag_value)
        ex.value = hive.antenna(i.push_tag_value)

        i.do_get_tag = hive.triggerable(cls.get_tag)

        hive.trigger(i.push_tag_value, i.do_get_bound_entity_id)
        hive.trigger(i.push_tag_value, i.pull_tag_name)
        hive.trigger(i.push_tag_value, i.do_get_tag)
예제 #17
0
파일: destroy.py 프로젝트: agoose77/hive2
def build_destroy(cls, i, ex, args, meta_args):
    """Destroy an entity"""
    i.trig_destroy = hive.triggerfunc(cls.destroy)
    i.do_destroy = hive.triggerable(i.trig_destroy)
    ex.destroy = hive.entry(i.do_destroy)

    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.trig_destroy, i.do_get_entity_id, pretrigger=True)

    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.trig_destroy, i.pull_entity_id, pretrigger=True)

    ex.get_destroy_entity = hive.socket(cls.set_destroy_entity,
                                        identifier="entity.destroy")
예제 #18
0
def build_delay(cls, i, ex, args):
    """Delay input trigger by X ticks, where X is the value of delay_in (greater than zero)"""
    i.on_elapsed = hive.triggerfunc()
    ex.on_elapsed = hive.hook(i.on_elapsed)

    i.trigger = hive.triggerfunc(cls.on_triggered)
    i.do_trig = hive.triggerable(i.trigger)
    ex.trig_in = hive.entry(i.do_trig)

    ex.delay = hive.property(cls, "delay", "float")
    i.delay_in = hive.pull_in(ex.delay)
    ex.delay_in = hive.antenna(i.delay_in)

    i.elapsed = hive.pull_out(cls.elapsed)
    ex.elapsed = hive.output(i.elapsed)

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

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

    ex.get_get_tick_rate = hive.socket(cls.set_get_tick_rate, "app.get_tick_rate")
예제 #19
0
def build_collision(cls, i, ex, args):
    """Interface to collision events for bound hive"""
    i.hit_entity = hive.property(cls, "hit_entity_id", "int.entity_id")
    i.hit_position = hive.property(cls, "hit_position", "vector")
    i.hit_normal = hive.property(cls, "hit_normal", "vector")
    i.hit_impulse = hive.property(cls, "hit_impulse", "vector")

    i.pull_hit_entity = hive.pull_out(i.hit_entity)
    i.pull_hit_position = hive.pull_out(i.hit_position)
    i.pull_hit_normal = hive.pull_out(i.hit_normal)
    i.pull_hit_impulse = hive.pull_out(i.hit_impulse)

    ex.hit_entity = hive.output(i.pull_hit_entity)
    ex.hit_position = hive.output(i.pull_hit_position)
    ex.hit_normal = hive.output(i.pull_hit_normal)
    ex.hit_impulse = hive.output(i.pull_hit_impulse)

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

    ex.get_get_entity_id = hive.socket(cls.set_get_entity_id,
                                       "entity.get_bound")
    ex.get_add_handler = hive.socket(cls.set_add_handler, "event.add_handler")
예제 #20
0
def build_keyboard(cls, i, ex, args):
    ex.on_event = hive.socket(cls.add_single_listener,
                              identifier="event.add_handler")
    i.on_tick = hive.triggerfunc()

    ex.name = hive.variable(("str", ), "<Sensor>")
    ex.key = hive.property(cls, "key", "str")
    ex.is_positive = hive.variable(("bool", ), False)

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

    i.trig_out = hive.triggerfunc()
    ex.trig_out = hive.hook(i.trig_out)
예제 #21
0
def build_visibility(cls, i, ex, args, meta_args):
    """Set/Get entity visibility"""

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

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

    if meta_args.mode == 'get':
        ex.get_get_visibility = hive.socket(cls.set_get_visibility, identifier="entity.visibility.get")
        i.pull_visibility = hive.pull_out(cls.get_visibility)
        ex.visibility = hive.output(i.pull_visibility)
        hive.trigger(i.pull_visibility, i.do_get_entity_id, pretrigger=True)

    else:
        ex.get_set_visibility = hive.socket(cls.set_set_visibility, identifier="entity.visibility.set")
        i.push_in_visibility = hive.push_in(cls.set_visibility)
        ex.visibility = hive.antenna(i.push_in_visibility)
        hive.trigger(i.push_in_visibility, i.do_get_entity_id, pretrigger=True)
예제 #22
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)
예제 #23
0
파일: parent.py 프로젝트: agoose77/hive2
def build_parent(cls, i, ex, args, meta_args):
    """Set/Get entity parent"""
    ex.get_get_parent = hive.socket(cls.set_get_parent,
                                    identifier="entity.parent.get")
    ex.get_set_parent = hive.socket(cls.set_set_parent,
                                    identifier="entity.parent.set")

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

    if meta_args.bound:
        ex.get_bound = hive.socket(cls.set_get_entity_id,
                                   identifier="entity.get_bound")
        i.do_get_bound_entity_id = hive.triggerable(cls.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)
        i.do_get_bound_entity_id = hive.triggerable(i.pull_entity_id)

    if meta_args.mode == "get":
        i.pull_parent_id = hive.pull_out(i.parent_id)
        ex.parent_id = hive.output(i.pull_parent_id)

        i.get_parent_id = hive.triggerable(cls.get_parent_id)
        hive.trigger(i.pull_parent_id,
                     i.do_get_bound_entity_id,
                     pretrigger=True)
        hive.trigger(i.pull_parent_id, i.get_parent_id, pretrigger=True)

    else:
        i.push_parent_id = hive.push_in(i.parent_id_id)
        ex.parent_id = hive.antenna(i.push_parent_id)

        i.set_parent = hive.triggerable(cls.set_parent)
        hive.trigger(i.push_parent_id, i.do_get_bound_entity_id)
        hive.trigger(i.push_parent_id, i.set_parent)
예제 #24
0
def build_h(cls, i, ex, args, meta_args):
    print("Build hive", meta_args.i)

    is_root = meta_args.root

    if is_root:
        print("IS ROOT")
        ex.plug = hive.plugin(cls.print_name, identifier="some_api.func")

    if meta_args.i:
        setattr(ex, "h_{}".format(meta_args.i - 1),
                SomeHive(i=meta_args.i - 1, root=False, name="<internal>"))

    else:
        ex.sock = hive.socket(cls.get_plug, identifier="some_api.func")
예제 #25
0
    def external_builder(self, cls, i, ex, args, meta_args):
        """Adds bind-plugin sockets to ex wrapper if conditions allow."""
        meta_args_dict = meta_args.to_ordered_dict()

        for attr_name, plugin_entry in self._plugins.items():
            for condition in plugin_entry.condition_stack:
                if not condition(meta_args_dict):
                    break

            else:
                method = getattr(cls, attr_name)
                socket = hive.socket(method, plugin_entry.identifier, policy=plugin_entry.socket_policy)
                setattr(ex, attr_name, socket)

        get_plugins_plugin = hive.plugin(cls.get_plugins, identifier="bind.get_plugins")
        get_config_plugin = hive.plugin(cls.get_config, identifier="bind.get_config")

        setattr(ex, '{}_get_plugins'.format(self._name), get_plugins_plugin)
        setattr(ex, '{}_get_config'.format(self._name), get_config_plugin)
예제 #26
0
파일: mouse.py 프로젝트: agoose77/hive2
def build_mouse(cls, i, ex, args):
    ex.on_event = hive.socket(cls.set_add_handler,
                              identifier="event.add_handler")
    i.on_tick = hive.triggerfunc()

    args.button = hive.parameter("str",
                                 "left",
                                 options={"left", "middle", "right"})
    i.button = hive.property(cls, "button", "str", args.button)

    i.push_button = hive.push_in(i.button)
    ex.button = hive.antenna(i.push_button)

    i.on_button_changed = hive.triggerable(cls.change_listener_buttons)
    hive.trigger(i.push_button, i.on_button_changed)

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

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

    i.pos_x = hive.property(cls, "pos_x", "float")
    i.pull_x = hive.pull_out(i.pos_x)
    ex.x = hive.output(i.pull_x)

    i.pos_y = hive.property(cls, "pos_y", "float")
    i.pull_y = hive.pull_out(i.pos_y)
    ex.y = hive.output(i.pull_y)

    i.dx = hive.property(cls, "dx", "float")
    i.pull_dx = hive.pull_out(i.dx)
    ex.dx = hive.output(i.pull_dx)

    i.dy = hive.property(cls, "dy", "float")
    i.pull_dy = hive.pull_out(i.dy)
    ex.dy = hive.output(i.pull_dy)

    i.is_pressed = hive.property(cls, "is_pressed", "bool")
    i.pull_is_pressed = hive.pull_out(i.is_pressed)
    ex.is_pressed = hive.output(i.pull_is_pressed)
예제 #27
0
def build_on_stop(cls, i, ex, args):
    """Listen for quit event"""
    ex.get_add_handler = hive.socket(cls.set_add_handler, "event.add_handler")

    i.on_stop = hive.triggerfunc()
    ex.on_stop = hive.hook(i.on_stop)
예제 #28
0
def build_dog(cls, i, ex, args):
    i.print_house = hive.triggerable(cls.print_house)
    ex.print_house = hive.entry(i.print_house)
    ex.some_socket = hive.socket(cls.set_get_house, identifier="get.house", data_type="float")
예제 #29
0
파일: position.py 프로젝트: agoose77/hive2
def build_position(cls, i, ex, args, meta_args):
    """Access to entity position API"""
    coordinate_system = meta_args.coordinate_system

    i.position = hive.property(cls, "position", "vector")

    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)

    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)

    if coordinate_system == 'relative':
        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)

    if meta_args.mode == "get":
        i.pull_position = hive.pull_out(i.position)
        ex.position = hive.output(i.pull_position)

    else:
        i.push_position = hive.push_in(i.position)
        ex.position = hive.antenna(i.push_position)

    if meta_args.mode == "get":
        if coordinate_system == 'absolute':
            ex.get_get_position = hive.socket(
                cls.set_get_position,
                identifier="entity.position.get.absolute")
            i.do_get_position = hive.triggerable(cls.do_get_position)

        else:
            ex.get_get_position = hive.socket(
                cls.set_get_position,
                identifier="entity.position.get.relative")
            i.do_get_position = hive.triggerable(cls.do_get_relative_position)
            hive.trigger(i.pull_position,
                         i.pull_other_entity_id,
                         pretrigger=True)

        if meta_args.bound:
            hive.trigger(i.pull_position, i.do_get_entity_id, pretrigger=True)

        else:
            hive.trigger(i.pull_position, i.pull_entity_id, pretrigger=True)

        hive.trigger(i.pull_position, i.do_get_position, pretrigger=True)

    else:
        if coordinate_system == 'absolute':
            ex.get_set_position = hive.socket(
                cls.set_set_position,
                identifier="entity.position.set.absolute")
            i.do_set_position = hive.triggerable(cls.do_set_position)

        else:
            ex.get_set_position = hive.socket(
                cls.set_set_position,
                identifier="entity.position.set.relative")
            i.do_set_position = hive.triggerable(cls.do_set_relative_position)
            hive.trigger(i.push_position, i.pull_other_entity_id)

        if meta_args.bound:
            hive.trigger(i.push_position, i.do_get_entity_id)

        else:
            hive.trigger(i.push_position, i.pull_entity_id)

        hive.trigger(i.push_position, i.do_set_position)
예제 #30
0
def build_velocity(cls, i, ex, args, meta_args):
    """Access to entity velocity API"""
    coordinate_system = meta_args.coordinate_system

    i.velocity = hive.property(cls, "velocity", "vector")

    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)

    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)

    if coordinate_system == 'relative':
        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)

    if meta_args.mode == "get":
        i.pull_velocity = hive.pull_out(i.velocity)
        ex.velocity = hive.output(i.pull_velocity)

    else:
        i.push_velocity = hive.push_in(i.velocity)
        ex.velocity = hive.antenna(i.push_velocity)

    if meta_args.mode == "get":
        if coordinate_system == 'absolute':
            ex.get_get_velocity = hive.socket(cls.set_get_velocity, identifier="entity.linear_velocity.get")
            i.do_get_velocity = hive.triggerable(cls.do_get_velocity)

        else:
            ex.get_get_velocity = hive.socket(cls.set_get_velocity, identifier="entity.linear_velocity.get")
            i.do_get_velocity = hive.triggerable(cls.do_get_relative_velocity)
            hive.trigger(i.pull_velocity, i.pull_other_entity_id, pretrigger=True)

        if meta_args.bound:
            hive.trigger(i.pull_velocity, i.do_get_entity_id, pretrigger=True)

        else:
            hive.trigger(i.pull_velocity, i.pull_entity_id, pretrigger=True)

        hive.trigger(i.pull_velocity, i.do_get_velocity, pretrigger=True)

    else:
        if coordinate_system == 'absolute':
            ex.get_set_velocity = hive.socket(cls.set_set_velocity, identifier="entity.linear_velocity.set")
            i.do_set_velocity = hive.triggerable(cls.do_set_velocity)

        else:
            ex.get_set_velocity = hive.socket(cls.set_set_velocity, identifier="entity.linear_velocity.set")
            i.do_set_velocity = hive.triggerable(cls.do_set_relative_velocity)
            hive.trigger(i.push_velocity, i.pull_other_entity_id)

        if meta_args.bound:
            hive.trigger(i.push_velocity, i.do_get_entity_id)

        else:
            hive.trigger(i.push_velocity, i.pull_entity_id)

        hive.trigger(i.push_velocity, i.do_set_velocity)