Skip to content

Commit 4a4e280

Browse files
committed
Merge pull request #6 from klights/master
删除Entity冗余属性
2 parents 33cbf82 + 9c4a14b commit 4a4e280

File tree

2 files changed

+9
-32
lines changed

2 files changed

+9
-32
lines changed

Entity.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ public class Entity
2626

2727
public bool inWorld = false;
2828

29-
public static Dictionary<string, Dictionary<string, Property>> alldefpropertys =
30-
new Dictionary<string, Dictionary<string, Property>>();
31-
3229
// entityDef属性,服务端同步过来后存储在这里
3330
private Dictionary<string, Property> defpropertys_ =
3431
new Dictionary<string, Property>();
@@ -38,19 +35,20 @@ public class Entity
3835

3936
public static void clear()
4037
{
41-
alldefpropertys.Clear();
4238
}
4339

4440
public Entity()
4541
{
46-
foreach(Property e in alldefpropertys[GetType().Name].Values)
42+
foreach(Property e in EntityDef.moduledefs[GetType().Name].propertys.Values)
4743
{
4844
Property newp = new Property();
4945
newp.name = e.name;
50-
newp.properUtype = e.properUtype;
5146
newp.utype = e.utype;
52-
newp.val = e.val;
47+
newp.properUtype = e.properUtype;
48+
newp.aliasID = e.aliasID;
49+
newp.defaultValStr = e.defaultValStr;
5350
newp.setmethod = e.setmethod;
51+
newp.val = newp.utype.parseDefaultValStr(newp.defaultValStr);
5452
defpropertys_.Add(e.name, newp);
5553
iddefpropertys_.Add(e.properUtype, newp);
5654
}

KBEngine.cs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -799,10 +799,7 @@ public void onImportClientEntityDef(MemoryStream stream)
799799
ScriptModule module = new ScriptModule(scriptmethod_name);
800800
EntityDef.moduledefs[scriptmethod_name] = module;
801801
EntityDef.idmoduledefs[scriptUtype] = module;
802-
803-
Dictionary<string, Property> defpropertys = new Dictionary<string, Property>();
804-
Entity.alldefpropertys.Add(scriptmethod_name, defpropertys);
805-
802+
806803
Type Class = module.script;
807804

808805
while(propertysize > 0)
@@ -833,11 +830,12 @@ public void onImportClientEntityDef(MemoryStream stream)
833830

834831
Property savedata = new Property();
835832
savedata.name = name;
833+
savedata.utype = utype;
836834
savedata.properUtype = properUtype;
837835
savedata.aliasID = ialiasID;
838836
savedata.defaultValStr = defaultValStr;
839-
savedata.utype = utype;
840837
savedata.setmethod = setmethod;
838+
savedata.val = savedata.utype.parseDefaultValStr(savedata.defaultValStr);
841839

842840
module.propertys[name] = savedata;
843841

@@ -964,26 +962,7 @@ public void onImportClientEntityDef(MemoryStream stream)
964962
{
965963
Dbg.ERROR_MSG("KBEngine::Client_onImportClientEntityDef: module(" + scriptmethod_name + ") not found!");
966964
}
967-
968-
foreach(string name in module.propertys.Keys)
969-
{
970-
Property infos = module.propertys[name];
971-
972-
Property newp = new Property();
973-
newp.name = infos.name;
974-
newp.properUtype = infos.properUtype;
975-
newp.aliasID = infos.aliasID;
976-
newp.utype = infos.utype;
977-
newp.val = infos.utype.parseDefaultValStr(infos.defaultValStr);
978-
newp.setmethod = infos.setmethod;
979-
980-
defpropertys.Add(infos.name, newp);
981-
if(module.script != null && module.script.GetMember(name) == null)
982-
{
983-
Dbg.ERROR_MSG(scriptmethod_name + "(" + module.script + "):: property(" + name + ") no defined!");
984-
}
985-
};
986-
965+
987966
foreach(string name in module.methods.Keys)
988967
{
989968
// Method infos = module.methods[name];

0 commit comments

Comments
 (0)