【修复】修复lua_bin生成的代码使用_name作为多态key的bug。应该_type_。

main v2022.2.0
walon 2022-02-12 13:42:12 +08:00
parent 657bd19c77
commit ba269df862
4 changed files with 9 additions and 24 deletions

View File

@ -322,7 +322,7 @@ Reward is a substructure containing the three fields of "int item_id; int count;
<tr align="center"><td>##var</td><td>id</td><td colspan="4">shape</td><td colspan="4">shape2</ td></tr> <tr align="center"><td>##var</td><td>id</td><td colspan="4">shape</td><td colspan="4">shape2</ td></tr>
<tr align="center"><td>##type</td><td>int</td><td colspan="4">Shape</td><td colspan="4">Shape</ td></tr> <tr align="center"><td>##type</td><td>int</td><td colspan="4">Shape</td><td colspan="4">Shape</ td></tr>
<tr align="center"><td>##var</td><td></td><td>__type__</td><td>radius</td><td>width</td><td>height</td><td></td><td></td><td></td><td></td></tr> <tr align="center"><td>##var</td><td></td><td>$type</td><td>radius</td><td>width</td><td>height</td><td></td><td></td><td></td><td></td></tr>
<tr align="center"><td/><td>1</td><td>Circle</td><td>10</td><td/><td/><td>Circle</td><td>100</td><td></td><td></td></tr> <tr align="center"><td/><td>1</td><td>Circle</td><td>10</td><td/><td/><td>Circle</td><td>100</td><td></td><td></td></tr>
<tr align="center"><td/><td>2</td><td>Rectangle</td><td></td><td>10</td><td>20</td ><td>Rectangle</td><td>10</td><td>20</td><td></td></tr> <tr align="center"><td/><td>2</td><td>Rectangle</td><td></td><td>10</td><td>20</td ><td>Rectangle</td><td>10</td><td>20</td><td></td></tr>
<tr align="center"><td/><td>3</td><td>Circle</td><td>10</td><td/><td/><td>Triangle</td><td>15</td><td>15</td><td>15</td></tr> <tr align="center"><td/><td>3</td><td>Circle</td><td>10</td><td/><td/><td>Triangle</td><td>15</td><td>15</td><td>15</td></tr>
@ -402,14 +402,14 @@ Take the behavior tree as an example to show how to configure the behavior tree
"executor": "SERVER", "executor": "SERVER",
"blackboard_id": "demo", "blackboard_id": "demo",
"root": { "root": {
"__type__": "Sequence", "$type": "Sequence",
"id": 1, "id": 1,
"node_name": "test", "node_name": "test",
"desc": "root", "desc": "root",
"services": [], "services": [],
"decorators": [ "decorators": [
{ {
"__type__": "UeLoop", "$type": "UeLoop",
"id": 3, "id": 3,
"node_name": "", "node_name": "",
"flow_abort_mode": "SELF", "flow_abort_mode": "SELF",
@ -420,7 +420,7 @@ Take the behavior tree as an example to show how to configure the behavior tree
], ],
"children": [ "children": [
{ {
"__type__": "UeWait", "$type": "UeWait",
"id": 30, "id": 30,
"node_name": "", "node_name": "",
"ignore_restart_self": false, "ignore_restart_self": false,
@ -430,7 +430,7 @@ Take the behavior tree as an example to show how to configure the behavior tree
"decorators": [] "decorators": []
}, },
{ {
"__type__": "MoveToRandomLocation", "$type": "MoveToRandomLocation",
"id": 75, "id": 75,
"node_name": "", "node_name": "",
"ignore_restart_self": false, "ignore_restart_self": false,

View File

@ -26,7 +26,7 @@ namespace Luban.Job.Cfg.Defs
public string JsonTypeNameKey => JSON_TYPE_NAME_KEY; public string JsonTypeNameKey => JSON_TYPE_NAME_KEY;
public string LuaTypeNameKey => LUA_TYPE_NAME_KEY;
public string Alias { get; } public string Alias { get; }

View File

@ -83,7 +83,7 @@ local function InitTypes(methods)
{{~end~}} {{~end~}}
local class = SimpleClass() local class = SimpleClass()
class._id = {{bean.id}} class._id = {{bean.id}}
class._name = '{{bean.full_name}}' class['{{bean.lua_type_name_key}}'] = '{{bean.full_name}}'
local id2name = { {{for c in bean.hierarchy_not_abstract_children}} [{{c.id}}] = '{{c.full_name}}', {{end}} } local id2name = { {{for c in bean.hierarchy_not_abstract_children}} [{{c.id}}] = '{{c.full_name}}', {{end}} }
{{~if bean.is_abstract_type~}} {{~if bean.is_abstract_type~}}
class._deserialize = function(bs) class._deserialize = function(bs)
@ -105,7 +105,7 @@ local function InitTypes(methods)
return o return o
end end
{{~end~}} {{~end~}}
beans[class._name] = class beans[class['{{bean.lua_type_name_key}}']] = class
end end
{{~end~}} {{~end~}}

View File

@ -9,21 +9,6 @@ local enums =
{{~end~}} {{~end~}}
} }
local beans = {}
{{~ for bean in beans ~}}
---@class {{bean.full_name}} {{if bean.parent_def_type}}:{{bean.parent}} {{end}}
{{~ for field in bean.export_fields~}}
---@field public {{field.convention_name}} {{lua_comment_type field.ctype}}
{{~end~}}
beans['{{bean.full_name}}'] =
{
{{~ for field in bean.hierarchy_export_fields ~}}
{ name='{{field.convention_name}}', type='{{lua_comment_type field.ctype}}'},
{{~end~}}
}
{{~end~}}
local tables = local tables =
{ {
{{~for table in tables ~}} {{~for table in tables ~}}
@ -37,4 +22,4 @@ local tables =
{{~end~}} {{~end~}}
} }
return { enums = enums, beans = beans, tables = tables } return { enums = enums, tables = tables }