private void CreateRobot(GameCmd.t_MapNpcDataPos npcdata, uint job) { Profiler.BeginSample("CreateRobot"); IEntitySystem es = ClientGlobal.Instance().GetEntitySystem(); if (es == null) { Engine.Utility.Log.Error("严重错误:EntitySystem is null!"); return; } Vector3 pos = new Vector3(npcdata.cur_pos.x * 0.01f, 0, -npcdata.cur_pos.y * 0.01f); // 服务器到客户端坐标转换 npcdata.mapnpcdata.npcdata.job = job; EntityCreateData data = RoleUtil.BuildCreateEntityData(EntityType.EntityTYpe_Robot, npcdata, 0); IRobot robot = es.FindRobot(npcdata.mapnpcdata.npcdata.dwTempID); if (robot != null) { robot.UpdateProp(data); } else { robot = es.CreateEntity(EntityType.EntityTYpe_Robot, data, !m_bDelayLoad) as IRobot; // 发送事件 CreateEntity if (robot != null) { PlayAni anim_param = new PlayAni(); anim_param.strAcionName = EntityAction.Stand; anim_param.fSpeed = 1; anim_param.nStartFrame = 0; anim_param.nLoop = -1; anim_param.fBlendTime = 0.2f; robot.SendMessage(EntityMessage.EntityCommand_PlayAni, anim_param); if (!string.IsNullOrEmpty(npcdata.mapnpcdata.npcdata.name) && !Application.isEditor) { robot.SendMessage(EntityMessage.EntityCommond_SetName, npcdata.mapnpcdata.npcdata.name); } else { string strName = string.Format("{0}(AI)", npcdata.mapnpcdata.npcdata.name); robot.SendMessage(EntityMessage.EntityCommond_SetName, npcdata.mapnpcdata.npcdata.name); } } } Engine.Utility.Log.Info("创建机器人 {0} pos {1}", robot.GetID(), pos); robot.SendMessage(EntityMessage.EntityCommand_SetPos, (object)pos); Vector3 rot = GameUtil.S2CDirection(npcdata.mapnpcdata.npcdata.byDirect); robot.SendMessage(EntityMessage.EntityCommand_SetRotate, (object)rot); Profiler.EndSample(); }