From cfd696608a714274e5f4aa46da52063e1bf6cfe5 Mon Sep 17 00:00:00 2001 From: kbengine Date: Tue, 26 May 2015 00:38:40 +0800 Subject: [PATCH] up --- Entity.cs | 7 +++++-- KBEngine.cs | 15 ++++++++++----- Property.cs | 20 ++++++++++++++++++++ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/Entity.cs b/Entity.cs index e41d107..7a75650 100644 --- a/Entity.cs +++ b/Entity.cs @@ -304,7 +304,8 @@ public virtual void set_position(object old) if(isPlayer()) KBEngineApp.app.entityServerPos(position); - Event.fireOut("set_position", new object[]{this}); + if(inWorld) + Event.fireOut("set_position", new object[]{this}); } public virtual void onUpdateVolatileData() @@ -322,7 +323,9 @@ public virtual void set_direction(object old) direction = v; //Dbg.DEBUG_MSG(className + "::set_direction: " + old + " => " + v); - Event.fireOut("set_direction", new object[]{this}); + + if(inWorld) + Event.fireOut("set_direction", new object[]{this}); } } diff --git a/KBEngine.cs b/KBEngine.cs index 43cb442..19f9dfe 100644 --- a/KBEngine.cs +++ b/KBEngine.cs @@ -83,7 +83,7 @@ public enum CLIENT_TYPE // 服务端与客户端的版本号以及协议MD5 public string serverVersion = ""; - public string clientVersion = "0.6.0"; + public string clientVersion = "0.6.1"; public string serverScriptVersion = ""; public string clientScriptVersion = "0.1.0"; public string serverProtocolMD5 = ""; @@ -807,6 +807,7 @@ public void onImportClientEntityDef(MemoryStream stream) propertysize--; UInt16 properUtype = stream.readUint16(); + UInt32 properFlags = stream.readUint32(); Int16 ialiasID = stream.readInt16(); string name = stream.readString(); string defaultValStr = stream.readString(); @@ -1502,7 +1503,8 @@ public void onUpdatePropertys_(Int32 eid, MemoryStream stream) entity.setDefinedProptertyByUType(utype, val); if(setmethod != null) { - setmethod.Invoke(entity, new object[]{oldval}); + if(propertydata.isBase() || entity.inWorld) + setmethod.Invoke(entity, new object[]{oldval}); } } } @@ -1629,11 +1631,11 @@ public void Client_onEntityEnterWorld(MemoryStream stream) _bufferedCreateEntityMessage.Remove(eid); entity.isOnGound = isOnGound > 0; - entity.__init__(); - entity.enterWorld(); - entity.set_direction(entity.getDefinedPropterty("direction")); entity.set_position(entity.getDefinedPropterty("position")); + + entity.__init__(); + entity.enterWorld(); } else { @@ -1651,6 +1653,9 @@ public void Client_onEntityEnterWorld(MemoryStream stream) entity.cellMailbox.className = entityType; entity.cellMailbox.type = Mailbox.MAILBOX_TYPE.MAILBOX_TYPE_CELL; + entity.set_direction(entity.getDefinedPropterty("direction")); + entity.set_position(entity.getDefinedPropterty("position")); + _entityServerPos = entity.position; entity.isOnGound = isOnGound > 0; entity.enterWorld(); diff --git a/Property.cs b/Property.cs index 2620367..a21b08f 100644 --- a/Property.cs +++ b/Property.cs @@ -9,9 +9,23 @@ */ public class Property { + public enum EntityDataFlags + { + ED_FLAG_UNKOWN = 0x00000000, // 未定义 + ED_FLAG_CELL_PUBLIC = 0x00000001, // 相关所有cell广播 + ED_FLAG_CELL_PRIVATE = 0x00000002, // 当前cell + ED_FLAG_ALL_CLIENTS = 0x00000004, // cell广播与所有客户端 + ED_FLAG_CELL_PUBLIC_AND_OWN = 0x00000008, // cell广播与自己的客户端 + ED_FLAG_OWN_CLIENT = 0x00000010, // 当前cell和客户端 + ED_FLAG_BASE_AND_CLIENT = 0x00000020, // base和客户端 + ED_FLAG_BASE = 0x00000040, // 当前base + ED_FLAG_OTHER_CLIENTS = 0x00000080, // cell广播和其他客户端 + }; + public string name = ""; public KBEDATATYPE_BASE utype = null; public UInt16 properUtype = 0; + public UInt32 properFlags = 0; public Int16 aliasID = -1; public string defaultValStr = ""; @@ -23,6 +37,12 @@ public Property() { } + + public bool isBase() + { + return properFlags == (UInt32)EntityDataFlags.ED_FLAG_BASE_AND_CLIENT || + properFlags == (UInt32)EntityDataFlags.ED_FLAG_BASE; + } } }