예제 #1
0
def build_my_hive(i, ex, args):
    ex.events = EventManager()

    # Create instantiator, but don't add events by leader
    ex.instantiator = Instantiator(forward_events='all')

    # Create args dict
    i.hive_class = Variable("class", start_value=SomeHive)
    hive.connect(i.hive_class, ex.instantiator.hive_class)
예제 #2
0
def build_some_instance(i, ex, args):
    i.some_var = hive.attribute("str")
    ex.on_tick = dragonfly.event.OnTick()
    i.mod = hive.modifier(lambda self: print(self, self._some_var))
    hive.connect(ex.on_tick, i.mod)

    def on_stopped():
        print("I am closed!")

    ex.on_closed = hive.plugin(on_stopped, "on_stopped")
예제 #3
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)
예제 #4
0
def build_house(cls, i, ex, args):
    ex.some_plugin = hive.plugin(cls.get_current_hive, identifier="get.house", data_type="float")

    # Auto connect
    i.filler = FillerHive()
    ex.filler = hive.hook(i.filler)

    # Manual connect
    i.fido = DogHive(name="Main", import_namespace=False)
    ex.fido = hive.hook(i.fido)

    hive.connect(ex.some_plugin, i.fido.some_socket)
예제 #5
0
파일: server.py 프로젝트: agoose77/hive2
def build_server(cls, i, ex, args):
    i.local_address = hive.property(cls, "local_address", "tuple")
    i.push_bind_address = hive.push_in(i.local_address)
    ex.bind_to = hive.antenna(i.push_bind_address)

    i.do_bind = hive.triggerable(cls.do_bind)
    hive.trigger(i.push_bind_address, i.do_bind)

    # Receiving connection
    i.connected_address = hive.property(cls, "connected_address", "tuple")
    i.push_connected_address = hive.push_out(i.connected_address)
    ex.on_client_connected = hive.output(i.push_connected_address)

    # Receiving connection
    i.disconnected_address = hive.property(cls, "disconnected_address",
                                           "tuple")
    i.push_disconnected_address = hive.push_out(i.disconnected_address)
    ex.on_client_disconnected = hive.output(i.push_disconnected_address)

    # Receiving
    i.from_address = hive.property(cls, "from_address", "tuple")
    i.pull_from_address = hive.pull_out(i.from_address)
    ex.from_address = hive.output(i.pull_from_address)

    i.received_data = hive.property(cls, "received_data", "bytes")
    i.push_received = hive.push_out(i.received_data)
    ex.on_received = hive.output(i.push_received)

    # Hive callbacks
    i.on_disconnected = hive.triggerfunc()
    i.on_connected = hive.triggerfunc()
    i.on_received = hive.triggerfunc()

    hive.trigger(i.on_received, i.push_received)
    hive.trigger(i.on_connected, i.push_connected_address)
    hive.trigger(i.on_disconnected, i.push_disconnected_address)

    # Sending
    i.to_address = hive.property(cls, "to_address", "tuple")
    i.pull_to_address = hive.pull_in(i.to_address)
    ex.to_address = hive.antenna(i.pull_to_address)

    i.outgoing_data = hive.property(cls, "outgoing_data", "bytes")
    i.push_outgoing_data = hive.push_in(i.outgoing_data)
    ex.send = hive.antenna(i.push_outgoing_data)

    i.do_send_data = hive.triggerable(cls.do_send)
    hive.trigger(i.push_outgoing_data, i.pull_to_address, pretrigger=True)
    hive.trigger(i.push_outgoing_data, i.do_send_data)

    i.synchronise_data = hive.triggerable(cls.synchronise)
    i.on_tick = OnTick()
    hive.connect(i.on_tick.on_tick, i.synchronise_data)
예제 #6
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")
예제 #7
0
파일: test-sca.py 프로젝트: agoose77/hive2
def build_some_hive(i, ex, args):
    ex.keyboard = Keyboard(import_namespace=True)
    ex.and_ = AND()
    ex.debug = Debug()

    hive.connect(ex.keyboard.positive, ex.and_.a)
    hive.connect(ex.keyboard.positive, ex.and_.b)
    hive.connect(ex.keyboard.trig_out, ex.and_.trig_in)
    hive.connect(ex.and_.trig_out, ex.debug.trig_in)
예제 #8
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)
예제 #9
0
def build_dog(cls, i, ex, args):
    i.call = hive.triggerfunc(cls.call)
    i.woof = hive.triggerable(cls.woof)
    hive.connect(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)
예제 #10
0
파일: client.py 프로젝트: agoose77/hive2
def build_server(cls, i, ex, args):
    i.connect_address = hive.property(cls, "server_address", "tuple")
    i.push_connect = hive.push_in(i.connect_address)
    ex.connect_to = hive.antenna(i.push_connect)

    i.do_connect = hive.triggerable(cls.do_connect)
    hive.trigger(i.push_connect, i.do_connect)

    # Hive callbacks
    i.on_disconnected = hive.triggerfunc()
    i.on_connected = hive.triggerfunc()
    i.on_received = hive.triggerfunc()

    # Receiving connection
    ex.on_connected = hive.hook(i.on_connected)

    # Lost connection
    ex.on_disconnected = hive.hook(i.on_disconnected)

    # Receiving
    i.received_data = hive.property(cls, "received_data", "bytes")
    i.push_received = hive.push_out(i.received_data)
    ex.on_received = hive.output(i.push_received)

    hive.trigger(i.on_received, i.push_received)

    # Sending
    i.outgoing_data = hive.property(cls, "outgoing_data", "bytes")
    i.push_outgoing_data = hive.push_in(i.outgoing_data)
    ex.send = hive.antenna(i.push_outgoing_data)

    i.do_send_data = hive.triggerable(cls.do_send)
    hive.trigger(i.push_outgoing_data, i.do_send_data)

    i.synchronise_data = hive.triggerable(cls.synchronise)
    i.on_tick = OnTick()
    hive.connect(i.on_tick.on_tick, i.synchronise_data)
예제 #11
0
def build_kennel(i, ex, args):
    i.brutus = dog("Brutus")
    i.fifi = dog("Fifi")
    #h.trigger(i.fifi.call, i.brutus.woof)
    #h.trigger(i.fifi.call, i.brutus)
    h.connect(i.fifi.call, i.brutus)
예제 #12
0
    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)


dog = h.hive("dog", build_dog, Dog)

spot = dog("Spot")
spike = dog("Spike")

print(3)
print(spot.name)  #=> Spot
spot.call()  #=> CALL Spot WOOF Spot 1
h.connect(spot.call, spot._woof2)
spot.call()  #=> CALL Spot WOOF Spot 2 WOOF2 Spot 1
print("SPOT WOOFS", spot.woofs, spot.woofs2)  #=> SPOT WOOFS 2 1
print(4)
spot.bark()  #=> WOOF Spot 3
print(5)
spike.call()  #=> CALL Spike WOOF Spike 1
spike.call()  #=> CALL Spike WOOF Spike 2
print(6)
spike.bark()  #=> WOOF Spike 3


class House(object):
    def dog_comes(self):
        print("A dog comes")
예제 #13
0
def my_hive_builder(cls, i, ex, args):
    ex.some_socket = hive.socket(cls.get_handler)
    hive.connect(ex.add_handler, ex.some_socket)
예제 #14
0
    taskMgr.step()


pandarender = h.triggerable(pandarender)
c = chessboard()

mainloop = dragonfly.mainloop(1000)  #maximum 1000 frames/sec

#h.connect(mainloop, pandarender)
h.trigger(mainloop, pandarender)

commandline = dragonfly.Commandline()
h.trigger(mainloop, commandline.flush)

c.do_make_move("e2-e4")
"""
##############
#1. plugin-socket connection
h.connect(c.p_make_move, commandline.listen)
#send over the socket
commandline.send_command("e7-e5")
##############
"""

##############
#2. antenna-output connection
h.connect(commandline.command, c.make_move)

#send over the antenna
commandline.prop_command = "e7-e5"
commandline._push_command()