本文整理汇总了C#中KBEngine.MemoryStream.opsize方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryStream.opsize方法的具体用法?C# MemoryStream.opsize怎么用?C# MemoryStream.opsize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KBEngine.MemoryStream
的用法示例。
在下文中一共展示了MemoryStream.opsize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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--;
//.........这里部分代码省略.........
示例2: Client_initSpaceData
public void Client_initSpaceData(MemoryStream stream)
{
spacedatas.Clear();
UInt32 spaceID = stream.readUint32();
while(stream.opsize() > 0)
{
string key = stream.readString();
string val = stream.readString();
Client_setSpaceData(spaceID, key, val);
}
Dbg.DEBUG_MSG("KBEngine::Client_initSpaceData: spaceID(" + spaceID + "), size(" + spacedatas.Count + ")!");
}
示例3: 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();
}
}
}
示例4: Client_onUpdatePropertys
public void Client_onUpdatePropertys(MemoryStream stream)
{
Int32 eid = stream.readInt32();
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;
}
Dictionary<UInt16, Property> pdatas = EntityDef.moduledefs[entity.classtype].idpropertys;
while(stream.opsize() > 0)
{
UInt16 utype = stream.readUint16();
Property propertydata = pdatas[utype];
System.Reflection.MethodInfo setmethod = propertydata.setmethod;
object val = propertydata.utype.createFromStream(stream);
object oldval = entity.getDefinedProptertyByUType(utype);
Dbg.DEBUG_MSG("KBEngine::Client_onUpdatePropertys: " + entity.classtype + "(id=" + eid + " " + propertydata.name + "=" + val + "), hasSetMethod=" + setmethod + "!");
entity.setDefinedProptertyByUType(utype, val);
if(setmethod != null)
{
setmethod.Invoke(entity, new object[]{oldval});
}
}
}
示例5: Client_onEntityEnterSpace
public void Client_onEntityEnterSpace(MemoryStream stream)
{
Int32 eid = stream.readInt32();
sbyte isOnGound = 1;
if(stream.opsize() > 0)
isOnGound = stream.readInt8();
Entity entity = null;
if(!entities.TryGetValue(eid, out entity))
{
Dbg.ERROR_MSG("KBEngine::Client_onEntityEnterSpace: entity(" + eid + ") not found!");
return;
}
entity.isOnGound = isOnGound > 0;
entityServerPos = entity.position;
entity.onEnterSpace();
}