Skip to content

Commit

Permalink
Merge pull request #6 from klights/master
Browse files Browse the repository at this point in the history
删除Entity冗余属性
  • Loading branch information
kbengine committed Apr 15, 2015
2 parents 33cbf82 + 9c4a14b commit 4a4e280
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 32 deletions.
12 changes: 5 additions & 7 deletions Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public class Entity

public bool inWorld = false;

public static Dictionary<string, Dictionary<string, Property>> alldefpropertys =
new Dictionary<string, Dictionary<string, Property>>();

// entityDef属性,服务端同步过来后存储在这里
private Dictionary<string, Property> defpropertys_ =
new Dictionary<string, Property>();
Expand All @@ -38,19 +35,20 @@ public class Entity

public static void clear()
{
alldefpropertys.Clear();
}

public Entity()
{
foreach(Property e in alldefpropertys[GetType().Name].Values)
foreach(Property e in EntityDef.moduledefs[GetType().Name].propertys.Values)
{
Property newp = new Property();
newp.name = e.name;
newp.properUtype = e.properUtype;
newp.utype = e.utype;
newp.val = e.val;
newp.properUtype = e.properUtype;
newp.aliasID = e.aliasID;
newp.defaultValStr = e.defaultValStr;
newp.setmethod = e.setmethod;
newp.val = newp.utype.parseDefaultValStr(newp.defaultValStr);
defpropertys_.Add(e.name, newp);
iddefpropertys_.Add(e.properUtype, newp);
}
Expand Down
29 changes: 4 additions & 25 deletions KBEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -799,10 +799,7 @@ public void onImportClientEntityDef(MemoryStream stream)
ScriptModule module = new ScriptModule(scriptmethod_name);
EntityDef.moduledefs[scriptmethod_name] = module;
EntityDef.idmoduledefs[scriptUtype] = module;

Dictionary<string, Property> defpropertys = new Dictionary<string, Property>();
Entity.alldefpropertys.Add(scriptmethod_name, defpropertys);


Type Class = module.script;

while(propertysize > 0)
Expand Down Expand Up @@ -833,11 +830,12 @@ public void onImportClientEntityDef(MemoryStream stream)

Property savedata = new Property();
savedata.name = name;
savedata.utype = utype;
savedata.properUtype = properUtype;
savedata.aliasID = ialiasID;
savedata.defaultValStr = defaultValStr;
savedata.utype = utype;
savedata.setmethod = setmethod;
savedata.val = savedata.utype.parseDefaultValStr(savedata.defaultValStr);

module.propertys[name] = savedata;

Expand Down Expand Up @@ -964,26 +962,7 @@ public void onImportClientEntityDef(MemoryStream stream)
{
Dbg.ERROR_MSG("KBEngine::Client_onImportClientEntityDef: module(" + scriptmethod_name + ") not found!");
}

foreach(string name in module.propertys.Keys)
{
Property infos = module.propertys[name];

Property newp = new Property();
newp.name = infos.name;
newp.properUtype = infos.properUtype;
newp.aliasID = infos.aliasID;
newp.utype = infos.utype;
newp.val = infos.utype.parseDefaultValStr(infos.defaultValStr);
newp.setmethod = infos.setmethod;

defpropertys.Add(infos.name, newp);
if(module.script != null && module.script.GetMember(name) == null)
{
Dbg.ERROR_MSG(scriptmethod_name + "(" + module.script + "):: property(" + name + ") no defined!");
}
};


foreach(string name in module.methods.Keys)
{
// Method infos = module.methods[name];
Expand Down

0 comments on commit 4a4e280

Please sign in to comment.