def testtimerCallback(self, dic): plug2 = Plugin.GetPlugin("Test2") plug2.Invoke("TestSharedFunction", dic["first"], dic["second"]) Debug.Log(dic["first"]) Debug.Log(dic["second"]) Plugin.DumpObjToFile("testtimerCallback.dict", dic, 3, 20, True, True) Plugin.KillTimers()
def init(self): import options from UnityEngine import Debug L = lambda s: Debug.Log("PyWrap: " + s) L("init") self.events = [] # should set them options.no_update options.show_hidden_mode options.freeplay = False if options.no_update: import autoupdate autoupdate.Autoupdate = autoupdate.DummyAutoupdate L("before gevent") from gevent import monkey monkey.patch_socket() monkey.patch_os() monkey.patch_select() L("after gevent") from game import autoenv autoenv.init('Client') import thb.ui.ui_meta # noqa, init ui_meta from client.core.executive import Executive self.executive = ExecutiveWrapper(Executive, self)
def inject_static_linked_extensions(): try: import gevent_ares import gevent_core import gevent_semaphore import msgpack_packer import msgpack_unpacker sys.modules['gevent.ares'] = gevent_ares # sys.modules['gevent.core'] = gevent_core sys.modules['gevent._semaphore'] = gevent_semaphore sys.modules['msgpack._packer'] = msgpack_packer sys.modules['msgpack._unpacker'] = msgpack_unpacker import gevent import msgpack gevent.ares = gevent_ares gevent.core = gevent_core gevent._semaphore = gevent_semaphore msgpack._packer = msgpack_packer msgpack._unpacker = msgpack_unpacker except Exception: from UnityEngine import Debug from traceback import format_exc Debug.Log('Inject static extension failed.\n\n' + format_exc())
def _dbgprint(ins): s = [ 'NOP', 'DUP', 'GET', 'CREATE', 'MOVE', 'FADE', 'GRAY', 'UNGRAY', 'FATETELL', 'AREA_HAND', 'AREA_DECK', 'AREA_DROP', 'AREA_PORT0', 'AREA_PORT1', 'AREA_PORT2', 'AREA_PORT3', 'AREA_PORT4', 'AREA_PORT5', 'AREA_PORT6', 'AREA_PORT7', 'AREA_PORT8', 'AREA_PORT9', ] rst = [] for i in ins: if isinstance(i, int): rst.append(s[i]) else: rst.append(repr(i)) from UnityEngine import Debug Debug.Log(repr(rst))
def connect_server(self, host, port): from UnityEngine import Debug Debug.Log(repr((host, port))) @gevent.spawn def do(): Q = self.warpgate.queue_system_event Q('connect', self.executive.connect_server((host, port), Q))
def init(self): import options from UnityEngine import Debug L = lambda s: Debug.Log("PyWrap: " + s) L("init") self.events = [] # should set them options.no_update options.no_crashreport options.show_hidden_mode options.freeplay = False if options.no_update: import autoupdate autoupdate.Autoupdate = autoupdate.DummyAutoupdate L("before gevent") from gevent import monkey monkey.patch_socket() monkey.patch_os() monkey.patch_select() L("after gevent") from game import autoenv autoenv.init('Client') import gamepack.thb.ui.ui_meta # noqa, init ui_meta # For debug @gevent.spawn def beat(): while True: gevent.sleep(1) # self.events.append(("tick",)) from client.core.executive import Executive self.executive = ExecutiveWrapper(Executive, self)
def write(self, data): from UnityEngine import Debug Debug.Log(data)
def On_ServerShutdown(self): Debug.Log("On_ServerShutdown hooked from Python")
def On_PluginInit(self): Debug.Log("On_PluginInit hooked from Python")
def On_ServerInit(self): Debug.Log("On_ServerInit hooked from Python") dic = Plugin.CreateDict() dic.Add("first", "timer is:") dic.Add("second", "working") Plugin.CreateTimer("testtimer", 5000, dic).Start()
def On_AllPluginsLoaded(self): Debug.Log("The knights who say NI!")