forked from y3-editor/y3-lualib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
175 lines (152 loc) · 5.78 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
---@type table<string, string>
local arg = GameAPI.lua_get_start_args()
pcall(function ()
if arg['lua_multi_mode'] == 'true' then
local id = GameAPI.get_client_role():get_role_id_num()
local debug_me
for i in arg['lua_multi_debug_players']:gmatch('%d+') do
if tonumber(i) == id then
debug_me = true
break
end
end
if not debug_me then
return
end
local port = 12399 - id
LDBG = require "y3.debugger":start("127.0.0.1:" .. tostring(port))
else
LDBG = require "y3.debugger":start "127.0.0.1:12399"
end
if LDBG then LDBG:event('autoUpdate', false) end
if arg['lua_wait_debugger'] == 'true'
or arg['lua_multi_wait_debugger'] == 'true' then
if LDBG then LDBG:event 'wait' end
end
end)
-- 全局方法类,提供各种全局方法
---@class Y3
y3 = {}
y3.version = 241015
y3.proxy = require 'y3.tools.proxy'
y3.class = require 'y3.tools.class'
y3.util = require 'y3.tools.utility'
y3.json = require 'y3.tools.json'
y3.inspect = require 'y3.tools.inspect'
y3.await = require 'y3.tools.await'
pcall(function ()
y3.doctor = require 'y3.tools.doctor'
end)
Class = y3.class.declare
New = y3.class.new
---@deprecated
---@diagnostic disable-next-line: deprecated
Super = y3.class.super
Extends = y3.class.extends
Delete = y3.class.delete
IsValid = y3.class.isValid
Type = y3.class.type
IsInstanceOf = y3.class.isInstanceOf
require 'y3.util.log'
y3.reload = require 'y3.tools.reload'
y3.sandbox = require 'y3.tools.sandbox'
y3.hash = require 'y3.tools.SDBMHash'
y3.linkedTable = require 'y3.tools.linked-table'
---@diagnostic disable-next-line: lowercase-global
include = y3.reload.include
require 'y3.tools.pool'
require 'y3.tools.gc'
require 'y3.tools.synthesis'
require 'y3.util.patch'
require 'y3.util.eca_function'
y3.trigger = require 'y3.util.trigger'
require 'y3.util.event'
require 'y3.util.event_manager'
require 'y3.util.custom_event'
require 'y3.util.ref'
require 'y3.util.storage'
require 'y3.util.gc_buffer'
y3.ctimer = require 'y3.util.client_timer'
y3.const = require 'y3.game.const'
y3.math = require 'y3.game.math'
y3.game = require 'y3.game.game'
y3.py_converter = require 'y3.game.py_converter'
y3.py_event_sub = require 'y3.game.py_event_subscribe'
y3.helper = require 'y3.game.helper'
y3.ground = require 'y3.game.ground'
y3.config = require 'y3.game.config'
y3.kv = require 'y3.game.kv'
y3.timer = require 'y3.object.runtime_object.timer'
y3.py_proxy = require 'y3.util.py_proxy'
y3.ltimer = require 'y3.util.local_timer'
y3.unit = require 'y3.object.editable_object.unit'
y3.ability = require 'y3.object.editable_object.ability'
y3.destructible = require 'y3.object.editable_object.destructible'
y3.item = require 'y3.object.editable_object.item'
y3.buff = require 'y3.object.editable_object.buff'
y3.projectile = require 'y3.object.editable_object.projectile'
y3.technology = require 'y3.object.editable_object.technology'
y3.beam = require 'y3.object.runtime_object.beam'
y3.item_group = require 'y3.object.runtime_object.item_group'
y3.mover = require 'y3.object.runtime_object.mover'
y3.particle = require 'y3.object.runtime_object.particle'
y3.player = require 'y3.object.runtime_object.player'
y3.player_group = require 'y3.object.runtime_object.player_group'
y3.unit_group = require 'y3.object.runtime_object.unit_group'
y3.projectile_group = require 'y3.object.runtime_object.projectile_group'
y3.selector = require 'y3.object.runtime_object.selector'
y3.cast = require 'y3.object.runtime_object.cast'
y3.damage_instance = require 'y3.object.runtime_object.damage_instance'
y3.heal_instance = require 'y3.object.runtime_object.heal_instance'
y3.sound = require 'y3.object.runtime_object.sound'
require 'y3.object.runtime_object.local_player'
require 'y3.object.runtime_object.current_select'
y3.area = require 'y3.object.scene_object.area'
y3.camera = require 'y3.object.scene_object.camera'
y3.light = require 'y3.object.scene_object.light'
y3.road = require 'y3.object.scene_object.road'
y3.point = require 'y3.object.scene_object.point'
y3.scene_ui = require 'y3.object.scene_object.scene_ui'
y3.ui = require 'y3.object.scene_object.ui'
y3.ui_prefab = require 'y3.object.scene_object.ui_prefab'
y3.shape = require 'y3.object.scene_object.shape'
y3.object = require 'y3.util.object'
y3.save_data = require 'y3.util.save_data'
y3.dump = require 'y3.util.dump'
y3.sync = require 'y3.util.sync'
y3.network = require 'y3.util.network'
y3.eca = require 'y3.util.eca_helper'
y3.base64 = require 'y3.util.base64'
y3.aes = require 'y3.util.aes'
y3.local_ui = require 'y3.util.local_ui'
y3.fs = require 'y3.util.fs'
pcall(function ()
require 'y3-helper.meta'
end)
y3.develop = {}
y3.develop.command = include 'y3.develop.command'
y3.develop.code = require 'y3.develop.code'
y3.develop.console = include 'y3.develop.console'
y3.develop.helper = require 'y3.develop.helper'
--对await进行一些配置
y3.await.setErrorHandler(log.error)
y3.await.setSleepWaker(y3.ltimer.wait)
log.info('LuaLib版本:', y3.version)
y3.game:event_dispatch('$Y3-初始化')
if LDBG then
y3.ltimer.loop_frame(1, function ()
LDBG:event 'update'
end)
end
if arg['lua_tracy'] == 'true' then
y3.ltimer.wait_frame(0, function ()
enable_lua_profile(true)
end)
end
--自己控制GC
GlobalAPI.api_stop_luagc_control()
-- collectgarbage('generational')
-- collectgarbage('incremental')
-- collectgarbage('restart')
local collector = require 'y3.tools.collector'
collector.start()