Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
kbengine committed May 25, 2015
1 parent d861252 commit cfd6966
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
7 changes: 5 additions & 2 deletions Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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});
}
}

Expand Down
15 changes: 10 additions & 5 deletions KBEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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});
}
}
}
Expand Down Expand Up @@ -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
{
Expand All @@ -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();
Expand Down
20 changes: 20 additions & 0 deletions Property.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand All @@ -23,6 +37,12 @@ public Property()
{

}

public bool isBase()
{
return properFlags == (UInt32)EntityDataFlags.ED_FLAG_BASE_AND_CLIENT ||
properFlags == (UInt32)EntityDataFlags.ED_FLAG_BASE;
}
}

}

0 comments on commit cfd6966

Please sign in to comment.