Esempio n. 1
0
    void ReceviceCommandMsg(T cmd, params object[] objs)
    {
        if (m_world.IsStart)
        {
            //Debug.Log("ReceviceCommandMsg " + cmd.frame + " world " + m_world.FrameCount);
            PlayerCommandRecordComponent pcrc = m_world.GetEntity(cmd.id).GetComp <PlayerCommandRecordComponent>();

            //判断帧数
            if (m_world.FrameCount >= cmd.frame)
            {
                PlayerCommandBase input = null;

                if (m_world.FrameCount == cmd.frame)
                {
                    input = pcrc.m_forecastInput;
                }
                else
                {
                    input = pcrc.GetInputCahae(cmd.frame);
                }

                //替换原来的记录
                pcrc.ReplaceCommand(cmd);

                //与本地预测做判断,如果不一致则需要重新演算
                if (!cmd.EqualsCmd(input))
                {
                    Recalc(cmd.frame);
                }
                else
                {
                    //清除以前的记录
                    m_world.ClearBefore(cmd.frame - 1);
                }
            }
            //存入缓存
            else
            {
                //Debug.Log("存入缓存");
                pcrc.m_serverCache.Add(cmd);
            }
        }
        else
        {
            //存入未执行命令列表
            GameDataCacheComponent gdcc = m_world.GetSingletonComp <GameDataCacheComponent>();
            gdcc.m_noExecuteCommandList.Add(cmd);
        }
    }