本文整理汇总了C#中KBEngine.MemoryStream.readUint8方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryStream.readUint8方法的具体用法?C# MemoryStream.readUint8怎么用?C# MemoryStream.readUint8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KBEngine.MemoryStream
的用法示例。
在下文中一共展示了MemoryStream.readUint8方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: onUpdatePropertys_
public void onUpdatePropertys_(Int32 eid, MemoryStream stream)
{
Entity entity = null;
if(!entities.TryGetValue(eid, out entity))
{
MemoryStream entityMessage = null;
if(_bufferedCreateEntityMessage.TryGetValue(eid, out entityMessage))
{
Dbg.ERROR_MSG("KBEngine::Client_onUpdatePropertys: entity(" + eid + ") not found!");
return;
}
MemoryStream stream1 = new MemoryStream();
stream1.wpos = stream.wpos;
stream1.rpos = stream.rpos - 4;
Array.Copy(stream.data(), stream1.data(), stream.data().Length);
_bufferedCreateEntityMessage[eid] = stream1;
return;
}
ScriptModule sm = EntityDef.moduledefs[entity.className];
Dictionary<UInt16, Property> pdatas = sm.idpropertys;
while(stream.length() > 0)
{
UInt16 utype = 0;
if(sm.usePropertyDescrAlias)
{
utype = stream.readUint8();
}
else
{
utype = stream.readUint16();
}
Property propertydata = pdatas[utype];
utype = propertydata.properUtype;
System.Reflection.MethodInfo setmethod = propertydata.setmethod;
object val = propertydata.utype.createFromStream(stream);
object oldval = entity.getDefinedProptertyByUType(utype);
// Dbg.DEBUG_MSG("KBEngine::Client_onUpdatePropertys: " + entity.className + "(id=" + eid + " " +
// propertydata.name + "=" + val + "), hasSetMethod=" + setmethod + "!");
entity.setDefinedProptertyByUType(utype, val);
if(setmethod != null)
{
if(propertydata.isBase() || entity.inWorld)
setmethod.Invoke(entity, new object[]{oldval});
}
}
}
示例2: Client_onEntityEnterWorld
/*
服务端通知一个实体进入了世界(如果实体是当前玩家则玩家第一次在一个space中创建了, 如果是其他实体则是其他实体进入了玩家的AOI)
*/
public void Client_onEntityEnterWorld(MemoryStream stream)
{
Int32 eid = stream.readInt32();
if(entity_id > 0 && entity_id != eid)
_entityIDAliasIDList.Add(eid);
UInt16 uentityType;
if(EntityDef.idmoduledefs.Count > 255)
uentityType = stream.readUint16();
else
uentityType = stream.readUint8();
sbyte isOnGround = 1;
if(stream.length() > 0)
isOnGround = stream.readInt8();
string entityType = EntityDef.idmoduledefs[uentityType].name;
// Dbg.DEBUG_MSG("KBEngine::Client_onEntityEnterWorld: " + entityType + "(" + eid + "), spaceID(" + KBEngineApp.app.spaceID + ")!");
Entity entity = null;
if(!entities.TryGetValue(eid, out entity))
{
MemoryStream entityMessage = null;
if(!_bufferedCreateEntityMessage.TryGetValue(eid, out entityMessage))
{
Dbg.ERROR_MSG("KBEngine::Client_onEntityEnterWorld: entity(" + eid + ") not found!");
return;
}
ScriptModule module = null;
if(!EntityDef.moduledefs.TryGetValue(entityType, out module))
{
Dbg.ERROR_MSG("KBEngine::Client_onEntityEnterWorld: not found module(" + entityType + ")!");
}
Type runclass = module.script;
if(runclass == null)
return;
entity = (Entity)Activator.CreateInstance(runclass);
entity.id = eid;
entity.className = entityType;
entity.cellMailbox = new Mailbox();
entity.cellMailbox.id = eid;
entity.cellMailbox.className = entityType;
entity.cellMailbox.type = Mailbox.MAILBOX_TYPE.MAILBOX_TYPE_CELL;
entities[eid] = entity;
Client_onUpdatePropertys(entityMessage);
_bufferedCreateEntityMessage.Remove(eid);
entity.isOnGround = isOnGround > 0;
entity.set_direction(entity.getDefinedPropterty("direction"));
entity.set_position(entity.getDefinedPropterty("position"));
entity.__init__();
entity.enterWorld();
}
else
{
if(!entity.inWorld)
{
// 安全起见, 这里清空一下
// 如果服务端上使用giveClientTo切换控制权
// 之前的实体已经进入世界, 切换后的实体也进入世界, 这里可能会残留之前那个实体进入世界的信息
_entityIDAliasIDList.Clear();
clearEntities(false);
entities[entity.id] = entity;
entity.cellMailbox = new Mailbox();
entity.cellMailbox.id = eid;
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.isOnGround = isOnGround > 0;
entity.enterWorld();
}
}
}
示例3: onImportClientMessages
public void onImportClientMessages(MemoryStream stream)
{
UInt16 msgcount = stream.readUint16();
Dbg.DEBUG_MSG(string.Format("KBEngine::Client_onImportClientMessages: start currserver=" + currserver + "(msgsize={0})...", msgcount));
while(msgcount > 0)
{
msgcount--;
MessageID msgid = stream.readUint16();
Int16 msglen = stream.readInt16();
string msgname = stream.readString();
sbyte argstype = stream.readInt8();
Byte argsize = stream.readUint8();
List<Byte> argstypes = new List<Byte>();
for(Byte i=0; i<argsize; i++)
{
argstypes.Add(stream.readUint8());
}
System.Reflection.MethodInfo handler = null;
bool isClientMethod = msgname.Contains("Client_");
if(isClientMethod)
{
handler = typeof(KBEngineApp).GetMethod(msgname);
if(handler == null)
{
Dbg.WARNING_MSG(string.Format("KBEngine::onImportClientMessages[{0}]: interface({1}/{2}/{3}) no implement!",
currserver, msgname, msgid, msglen));
handler = null;
}
else
{
//Dbg.DEBUG_MSG(string.Format("KBEngine::onImportClientMessages: imported({0}/{1}/{2}) successfully!",
// msgname, msgid, msglen));
}
}
if(msgname.Length > 0)
{
Message.messages[msgname] = new Message(msgid, msgname, msglen, argstype, argstypes, handler);
//if(!isClientMethod)
// Dbg.DEBUG_MSG(string.Format("KBEngine::onImportClientMessages[{0}]: imported({1}/{2}/{3}) successfully!",
// currserver, msgname, msgid, msglen));
if(isClientMethod)
{
Message.clientMessages[msgid] = Message.messages[msgname];
}
else
{
if(currserver == "loginapp")
Message.loginappMessages[msgid] = Message.messages[msgname];
else
Message.baseappMessages[msgid] = Message.messages[msgname];
}
}
else
{
Message msg = new Message(msgid, msgname, msglen, argstype, argstypes, handler);
//if(!isClientMethod)
// Dbg.DEBUG_MSG(string.Format("KBEngine::onImportClientMessages[{0}]: imported({1}/{2}/{3}) successfully!",
// currserver, msgname, msgid, msglen));
if(currserver == "loginapp")
Message.loginappMessages[msgid] = msg;
else
Message.baseappMessages[msgid] = msg;
}
};
onImportClientMessagesCompleted();
}
示例4: onRemoteMethodCall_
public void onRemoteMethodCall_(Int32 eid, MemoryStream stream)
{
Entity entity = null;
if(!entities.TryGetValue(eid, out entity))
{
Dbg.ERROR_MSG("KBEngine::Client_onRemoteMethodCall: entity(" + eid + ") not found!");
return;
}
UInt16 methodUtype = 0;
if(EntityDef.moduledefs[entity.className].useMethodDescrAlias)
methodUtype = stream.readUint8();
else
methodUtype = stream.readUint16();
Method methoddata = EntityDef.moduledefs[entity.className].idmethods[methodUtype];
// Dbg.DEBUG_MSG("KBEngine::Client_onRemoteMethodCall: " + entity.className + "." + methoddata.name);
object[] args = new object[methoddata.args.Count];
for(int i=0; i<methoddata.args.Count; i++)
{
args[i] = methoddata.args[i].createFromStream(stream);
}
try
{
methoddata.handler.Invoke(entity, args);
}
catch (Exception e)
{
if(methoddata.handler != null)
{
Dbg.ERROR_MSG("KBEngine::Client_onRemoteMethodCall: " + entity.className + "(" + eid + "), callMethod(" + entity.className + "." + methoddata.name + ") is error!\nerror=" + e.ToString());
}
else
{
Dbg.ERROR_MSG("KBEngine::Client_onRemoteMethodCall: " + entity.className + "(" + eid + "), not found method(" + entity.className + "." + methoddata.name + ")!\nerror=" + e.ToString());
}
}
}
示例5: getAoiEntityIDFromStream
/*
通过流数据获得AOI实体的ID
*/
public Int32 getAoiEntityIDFromStream(MemoryStream stream)
{
if (!_args.useAliasEntityID)
return stream.readInt32();
Int32 id = 0;
if(_entityIDAliasIDList.Count > 255)
{
id = stream.readInt32();
// 如果为0且客户端上一步是重登陆或者重连操作并且服务端entity在断线期间一直处于在线状态
// 则可以忽略这个错误, 因为cellapp可能一直在向baseapp发送同步消息, 当客户端重连上时未等
// 服务端初始化步骤开始则收到同步信息, 此时这里就会出错。
if(_entityIDAliasIDList.Count == 0)
return 0;
}
else
{
byte aliasID = stream.readUint8();
// 如果为0且客户端上一步是重登陆或者重连操作并且服务端entity在断线期间一直处于在线状态
// 则可以忽略这个错误, 因为cellapp可能一直在向baseapp发送同步消息, 当客户端重连上时未等
// 服务端初始化步骤开始则收到同步信息, 此时这里就会出错。
if(_entityIDAliasIDList.Count == 0)
return 0;
id = _entityIDAliasIDList[aliasID];
}
return id;
}
示例6: onImportClientEntityDef
public void onImportClientEntityDef(MemoryStream stream)
{
createDataTypeFromStreams(stream, true);
while(stream.length() > 0)
{
string scriptmethod_name = stream.readString();
UInt16 scriptUtype = stream.readUint16();
UInt16 propertysize = stream.readUint16();
UInt16 methodsize = stream.readUint16();
UInt16 base_methodsize = stream.readUint16();
UInt16 cell_methodsize = stream.readUint16();
Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: import(" + scriptmethod_name + "), propertys(" + propertysize + "), " +
"clientMethods(" + methodsize + "), baseMethods(" + base_methodsize + "), cellMethods(" + cell_methodsize + ")!");
ScriptModule module = new ScriptModule(scriptmethod_name);
EntityDef.moduledefs[scriptmethod_name] = module;
EntityDef.idmoduledefs[scriptUtype] = module;
Type Class = module.script;
while(propertysize > 0)
{
propertysize--;
UInt16 properUtype = stream.readUint16();
UInt32 properFlags = stream.readUint32();
Int16 ialiasID = stream.readInt16();
string name = stream.readString();
string defaultValStr = stream.readString();
KBEDATATYPE_BASE utype = EntityDef.id2datatypes[stream.readUint16()];
System.Reflection.MethodInfo setmethod = null;
if(Class != null)
{
try{
setmethod = Class.GetMethod("set_" + name);
}
catch (Exception e)
{
string err = "KBEngine::Client_onImportClientEntityDef: " +
scriptmethod_name + ".set_" + name + ", error=" + e.ToString();
throw new Exception(err);
}
}
Property savedata = new Property();
savedata.name = name;
savedata.utype = utype;
savedata.properUtype = properUtype;
savedata.properFlags = properFlags;
savedata.aliasID = ialiasID;
savedata.defaultValStr = defaultValStr;
savedata.setmethod = setmethod;
savedata.val = savedata.utype.parseDefaultValStr(savedata.defaultValStr);
module.propertys[name] = savedata;
if(ialiasID >= 0)
{
module.usePropertyDescrAlias = true;
module.idpropertys[(UInt16)ialiasID] = savedata;
}
else
{
module.usePropertyDescrAlias = false;
module.idpropertys[properUtype] = savedata;
}
//Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: add(" + scriptmethod_name + "), property(" + name + "/" + properUtype + ").");
};
while(methodsize > 0)
{
methodsize--;
UInt16 methodUtype = stream.readUint16();
Int16 ialiasID = stream.readInt16();
string name = stream.readString();
Byte argssize = stream.readUint8();
List<KBEDATATYPE_BASE> args = new List<KBEDATATYPE_BASE>();
while(argssize > 0)
{
argssize--;
args.Add(EntityDef.id2datatypes[stream.readUint16()]);
};
Method savedata = new Method();
savedata.name = name;
savedata.methodUtype = methodUtype;
savedata.aliasID = ialiasID;
savedata.args = args;
if(Class != null)
{
try{
//.........这里部分代码省略.........
示例7: Client_onImportClientEntityDef
public void Client_onImportClientEntityDef(MemoryStream stream)
{
UInt16 aliassize = stream.readUint16();
Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: importAlias(size=" + aliassize + ")!");
while(aliassize > 0)
{
aliassize--;
createDataTypeFromStream(stream, true);
};
foreach(string datatype in EntityDef.datatypes.Keys)
{
if(EntityDef.datatypes[datatype] != null)
{
EntityDef.datatypes[datatype].bind();
}
}
while(stream.opsize() > 0)
{
string scriptmethod_name = stream.readString();
UInt16 scriptUtype = stream.readUint16();
UInt16 propertysize = stream.readUint16();
UInt16 methodsize = stream.readUint16();
UInt16 base_methodsize = stream.readUint16();
UInt16 cell_methodsize = stream.readUint16();
Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: import(" + scriptmethod_name + "), propertys(" + propertysize + "), " +
"clientMethods(" + methodsize + "), baseMethods(" + base_methodsize + "), cellMethods(" + cell_methodsize + ")!");
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)
{
propertysize--;
UInt16 properUtype = stream.readUint16();
string name = stream.readString();
string defaultValStr = stream.readString();
KBEDATATYPE_BASE utype = EntityDef.iddatatypes[stream.readUint16()];
System.Reflection.MethodInfo setmethod = null;
if(Class != null)
{
setmethod = Class.GetMethod("set_" + name);
}
Property savedata = new Property();
savedata.name = name;
savedata.properUtype = properUtype;
savedata.defaultValStr = defaultValStr;
savedata.utype = utype;
savedata.setmethod = setmethod;
module.propertys[name] = savedata;
module.idpropertys[properUtype] = savedata;
Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: add(" + scriptmethod_name + "), property(" + name + "/" + properUtype + ").");
};
while(methodsize > 0)
{
methodsize--;
UInt16 methodUtype = stream.readUint16();
string name = stream.readString();
Byte argssize = stream.readUint8();
List<KBEDATATYPE_BASE> args = new List<KBEDATATYPE_BASE>();
while(argssize > 0)
{
argssize--;
args.Add(EntityDef.iddatatypes[stream.readUint16()]);
};
Method savedata = new Method();
savedata.name = name;
savedata.methodUtype = methodUtype;
savedata.args = args;
if(Class != null)
savedata.handler = Class.GetMethod(name);
module.methods[name] = savedata;
module.idmethods[methodUtype] = savedata;
Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: add(" + scriptmethod_name + "), method(" + name + ").");
};
while(base_methodsize > 0)
{
base_methodsize--;
//.........这里部分代码省略.........
示例8: createDataTypeFromStream
public void createDataTypeFromStream(MemoryStream stream, bool canprint)
{
UInt16 utype = stream.readUint16();
string name = stream.readString();
string valname = stream.readString();
/* 有一些匿名类型,我们需要提供一个唯一名称放到datatypes中
如:
<onRemoveAvatar>
<Arg> ARRAY <of> INT8 </of> </Arg>
</onRemoveAvatar>
*/
if(valname.Length == 0)
valname = "Null_" + utype;
if(canprint)
Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: importAlias(" + name + ":" + valname + ":" + utype + ")!");
if(name == "FIXED_DICT")
{
KBEDATATYPE_FIXED_DICT datatype = new KBEDATATYPE_FIXED_DICT();
Byte keysize = stream.readUint8();
datatype.implementedBy = stream.readString();
while(keysize > 0)
{
keysize--;
string keyname = stream.readString();
UInt16 keyutype = stream.readUint16();
datatype.dicttype[keyname] = keyutype;
};
EntityDef.datatypes[valname] = datatype;
}
else if(name == "ARRAY")
{
UInt16 uitemtype = stream.readUint16();
KBEDATATYPE_ARRAY datatype = new KBEDATATYPE_ARRAY();
datatype.vtype = uitemtype;
EntityDef.datatypes[valname] = datatype;
}
else
{
KBEDATATYPE_BASE val = null;
EntityDef.datatypes.TryGetValue(name, out val);
EntityDef.datatypes[valname] = val;
}
EntityDef.id2datatypes[utype] = EntityDef.datatypes[valname];
// 将用户自定义的类型补充到映射表中
EntityDef.datatype2id[valname] = utype;
}
示例9: createDataTypeFromStream
public void createDataTypeFromStream(MemoryStream stream, bool canprint)
{
UInt16 utype = stream.readUint16();
string name = stream.readString();
string valname = stream.readString();
if(canprint)
Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: importAlias(" + name + ":" + valname + ")!");
if(valname == "FIXED_DICT")
{
KBEDATATYPE_FIXED_DICT datatype = new KBEDATATYPE_FIXED_DICT();
Byte keysize = stream.readUint8();
datatype.implementedBy = stream.readString();
while(keysize > 0)
{
keysize--;
string keyname = stream.readString();
UInt16 keyutype = stream.readUint16();
datatype.dicttype[keyname] = keyutype;
};
EntityDef.datatypes[name] = datatype;
}
else if(valname == "ARRAY")
{
UInt16 uitemtype = stream.readUint16();
KBEDATATYPE_ARRAY datatype = new KBEDATATYPE_ARRAY();
datatype.type = uitemtype;
EntityDef.datatypes[name] = datatype;
}
else
{
KBEDATATYPE_BASE val = null;
EntityDef.datatypes.TryGetValue(valname, out val);
EntityDef.datatypes[name] = val;
}
EntityDef.iddatatypes[utype] = EntityDef.datatypes[name];
EntityDef.datatype2id[name] = EntityDef.datatype2id[valname];
}
示例10: onRemoteMethodCall_
public void onRemoteMethodCall_(Int32 eid, MemoryStream stream)
{
Entity entity = null;
if(!entities.TryGetValue(eid, out entity))
{
Dbg.ERROR_MSG("KBEngine::Client_onRemoteMethodCall: entity(" + eid + ") not found!");
return;
}
UInt16 methodUtype = 0;
if(EntityDef.moduledefs[entity.classtype].useMethodDescrAlias)
methodUtype = stream.readUint8();
else
methodUtype = stream.readUint16();
Method methoddata = EntityDef.moduledefs[entity.classtype].idmethods[methodUtype];
Dbg.DEBUG_MSG("KBEngine::Client_onRemoteMethodCall: " + entity.classtype + "." + methoddata.name);
object[] args = new object[methoddata.args.Count];
for(int i=0; i<methoddata.args.Count; i++)
{
args[i] = methoddata.args[i].createFromStream(stream);
}
methoddata.handler.Invoke(entity, args);
}
示例11: getAoiEntityIDFromStream
public Int32 getAoiEntityIDFromStream(MemoryStream stream)
{
Int32 id = 0;
if(entityIDAliasIDList.Count > 255)
{
id = stream.readInt32();
}
else
{
byte aliasID = stream.readUint8();
id = entityIDAliasIDList[aliasID];
}
return id;
}
示例12: Client_onEntityEnterWorld
public void Client_onEntityEnterWorld(MemoryStream stream)
{
Int32 eid = stream.readInt32();
if(entity_id > 0 && entity_id != eid)
entityIDAliasIDList.Add(eid);
UInt16 uentityType;
if(EntityDef.idmoduledefs.Count > 255)
uentityType = stream.readUint16();
else
uentityType = stream.readUint8();
sbyte isOnGound = 1;
if(stream.opsize() > 0)
isOnGound = stream.readInt8();
string entityType = EntityDef.idmoduledefs[uentityType].name;
Dbg.DEBUG_MSG("KBEngine::Client_onEntityEnterWorld: " + entityType + "(" + eid + "), spaceID(" + KBEngineApp.app.spaceID + ")!");
Entity entity = null;
if(!entities.TryGetValue(eid, out entity))
{
MemoryStream entityMessage = null;
if(!bufferedCreateEntityMessage.TryGetValue(eid, out entityMessage))
{
Dbg.ERROR_MSG("KBEngine::Client_onEntityEnterWorld: entity(" + eid + ") not found!");
return;
}
Type runclass = EntityDef.moduledefs[entityType].script;
if(runclass == null)
return;
entity = (Entity)Activator.CreateInstance(runclass);
entity.id = eid;
entity.classtype = entityType;
entity.cellMailbox = new Mailbox();
entity.cellMailbox.id = eid;
entity.cellMailbox.classtype = entityType;
entity.cellMailbox.type = Mailbox.MAILBOX_TYPE.MAILBOX_TYPE_CELL;
entities[eid] = entity;
Client_onUpdatePropertys(entityMessage);
bufferedCreateEntityMessage.Remove(eid);
entity.isOnGound = isOnGound > 0;
entity.__init__();
entity.onEnterWorld();
Event.fireOut("set_direction", new object[]{entity});
Event.fireOut("set_position", new object[]{entity});
}
else
{
if(!entity.inWorld)
{
entity.cellMailbox = new Mailbox();
entity.cellMailbox.id = eid;
entity.cellMailbox.classtype = entityType;
entity.cellMailbox.type = Mailbox.MAILBOX_TYPE.MAILBOX_TYPE_CELL;
entityServerPos = entity.position;
entity.isOnGound = isOnGound > 0;
entity.onEnterWorld();
}
}
}
示例13: createFromStream
public override object createFromStream(MemoryStream stream)
{
return stream.readUint8();
}