本文整理汇总了C#中KBEngine.MemoryStream.readInt32方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryStream.readInt32方法的具体用法?C# MemoryStream.readInt32怎么用?C# MemoryStream.readInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KBEngine.MemoryStream
的用法示例。
在下文中一共展示了MemoryStream.readInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Client_onEntityEnterSpace
/*
服务端通知当前玩家进入了一个新的space
*/
public void Client_onEntityEnterSpace(MemoryStream stream)
{
Int32 eid = stream.readInt32();
spaceID = stream.readUint32();
sbyte isOnGround = 1;
if(stream.length() > 0)
isOnGround = stream.readInt8();
Entity entity = null;
if(!entities.TryGetValue(eid, out entity))
{
Dbg.ERROR_MSG("KBEngine::Client_onEntityEnterSpace: entity(" + eid + ") not found!");
return;
}
entity.isOnGround = isOnGround > 0;
_entityServerPos = entity.position;
entity.enterSpace();
}
示例2: Client_onUpdatePropertys
/*
服务端更新实体属性数据
*/
public void Client_onUpdatePropertys(MemoryStream stream)
{
Int32 eid = stream.readInt32();
onUpdatePropertys_(eid, stream);
}
示例3: 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;
}
示例4: Client_onUpdateData_xyz_yr
public void Client_onUpdateData_xyz_yr(MemoryStream stream)
{
Int32 eid = stream.readInt32();
Vector2 xz = stream.readPackXZ();
float y = stream.readPackY();
SByte yaw = stream.readInt8();
SByte r = stream.readInt8();
_updateVolatileData(eid, xz[0], y, xz[1], yaw, KBE_FLT_MAX, r);
}
示例5: Client_onUpdateData_xz_yp
public void Client_onUpdateData_xz_yp(MemoryStream stream)
{
Int32 eid = stream.readInt32();
Vector2 xz = stream.readPackXZ();
SByte y = stream.readInt8();
SByte p = stream.readInt8();
_updateVolatileData(eid, xz[0], 0.0f, xz[1], y, p, KBE_FLT_MAX);
}
示例6: Client_onRemoteMethodCall
/*
服务端调用实体方法
*/
public void Client_onRemoteMethodCall(MemoryStream stream)
{
Int32 eid = stream.readInt32();
onRemoteMethodCall_(eid, stream);
}
示例7: 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();
}
}
}
示例8: Client_onRemoteMethodCall
public void Client_onRemoteMethodCall(MemoryStream stream)
{
Int32 eid = stream.readInt32();
Entity entity = null;
if(!entities.TryGetValue(eid, out entity))
{
Dbg.ERROR_MSG("KBEngine::Client_onRemoteMethodCall: entity(" + eid + ") not found!");
return;
}
UInt16 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);
}
示例9: Client_onSetEntityPosAndDir
public void Client_onSetEntityPosAndDir(MemoryStream stream)
{
Int32 eid = stream.readInt32();
Entity entity = null;
if(!entities.TryGetValue(eid, out entity))
{
Dbg.ERROR_MSG("KBEngine::Client_onSetEntityPosAndDir: entity(" + eid + ") not found!");
return;
}
entity.position.x = stream.readFloat();
entity.position.y = stream.readFloat();
entity.position.z = stream.readFloat();
entity.direction.z = KBEMath.int82angle((SByte)stream.readFloat(), false) * 360 / ((float)System.Math.PI * 2);
entity.direction.y = KBEMath.int82angle((SByte)stream.readFloat(), false) * 360 / ((float)System.Math.PI * 2);
entity.direction.x = KBEMath.int82angle((SByte)stream.readFloat(), false) * 360 / ((float)System.Math.PI * 2);
Vector3 position = (Vector3)entity.getDefinedPropterty("position");
Vector3 direction = (Vector3)entity.getDefinedPropterty("direction");
position.x = entity.position.x;
position.y = entity.position.y;
position.z = entity.position.z;
direction.x = entity.direction.x;
direction.y = entity.direction.y;
direction.z = entity.direction.z;
Event.fire("set_direction", new object[]{entity});
Event.fire("set_position", new object[]{entity});
}
示例10: 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});
}
}
}
示例11: Client_onHelloCB
public void Client_onHelloCB(MemoryStream stream)
{
serverVersion_ = stream.readString();
Int32 ctype = stream.readInt32();
Dbg.DEBUG_MSG("KBEngine::Client_onHelloCB: verInfo(" + serverVersion_ + "), ctype(" + ctype + ")!");
}
示例12: Client_onUpdateData_ypr
public void Client_onUpdateData_ypr(MemoryStream stream)
{
Int32 eid = stream.readInt32();
SByte y = stream.readInt8();
SByte p = stream.readInt8();
SByte r = stream.readInt8();
_updateVolatileData(eid, 0.0f, 0.0f, 0.0f, y, p, r);
}
示例13: Client_onUpdateData_y
public void Client_onUpdateData_y(MemoryStream stream)
{
Int32 eid = stream.readInt32();
float y = stream.readPackY();
_updateVolatileData(eid, 0.0f, 0.0f, 0.0f, y, KBE_FLT_MAX, KBE_FLT_MAX);
}
示例14: 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;
}
示例15: 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();
}
}
}