GetEntityById() private method

private GetEntityById ( int id ) : EntityInfo
id int
return EntityInfo
        internal static void Execute(object msg, User user)
        {
            Msg_CR_Skill use_skill = msg as Msg_CR_Skill;

            if (null == use_skill)
            {
                return;
            }
            EntityInfo userObj = user.Info;

            if (null == userObj)
            {
                LogSys.Log(LOG_TYPE.DEBUG, "UseSkillHandler, charactor {0}({1},{2},{3}) not exist", user.RoleId, user.GetKey(), user.Guid, user.Name);
                return;
            }
            Scene scene = user.OwnRoom.ActiveScene;

            if (null != scene)
            {
                EntityInfo obj = scene.GetEntityById(use_skill.role_id);
                if (null != obj)
                {
                    AiStateInfo aiInfo = obj.GetAiStateInfo();
                    if (use_skill.target_id > 0)
                    {
                        aiInfo.Target = use_skill.target_id;
                    }
                    else if (use_skill.target_dir > 0)
                    {
                        float dir = ProtoHelper.DecodeFloat(use_skill.target_dir);
                        obj.GetMovementStateInfo().SetFaceDir(dir);
                        aiInfo.Target = 0;
                    }
                    if (aiInfo.AiLogic == (int)AiStateLogicId.Entity_Leader)
                    {
                        AiData_Leader data = aiInfo.AiDatas.GetData <AiData_Leader>();
                        if (null == data)
                        {
                            data = new AiData_Leader();
                            aiInfo.AiDatas.AddData(data);
                        }
                        data.ManualSkillId = use_skill.skill_id;
                    }
                    else
                    {
                        AiData_General data = aiInfo.AiDatas.GetData <AiData_General>();
                        if (null == data)
                        {
                            data = new AiData_General();
                            aiInfo.AiDatas.AddData(data);
                        }
                        data.ManualSkillId = use_skill.skill_id;
                    }
                    aiInfo.ChangeToState((int)AiStateId.SkillCommand);
                }
            }
        }
Exemplo n.º 2
0
        public static void Execute(object msg, User user)
        {
            Msg_CR_Skill use_skill = msg as Msg_CR_Skill;

            if (null == use_skill)
            {
                return;
            }
            EntityInfo userObj = user.Info;

            if (null == userObj)
            {
                LogSys.Log(LOG_TYPE.DEBUG, "UseSkillHandler, charactor {0}({1},{2},{3}) not exist", user.RoleId, user.GetKey(), user.Guid, user.Name);
                return;
            }
            Scene scene = user.OwnRoomUserManager.ActiveScene;

            if (null != scene)
            {
                EntityInfo obj = scene.GetEntityById(use_skill.role_id);
                if (null != obj)
                {
                    AiStateInfo aiInfo = obj.GetAiStateInfo();
                    if (use_skill.target_id > 0)
                    {
                        aiInfo.Target = use_skill.target_id;
                    }
                    else if (use_skill.target_dir > 0)
                    {
                        float dir = use_skill.target_dir;
                        obj.GetMovementStateInfo().SetFaceDir(dir);
                        aiInfo.Target = 0;
                    }
                    Msg_RC_NpcSkill retMsg = DataSyncUtility.BuildNpcSkillMessage(obj, use_skill.skill_id);
                    scene.NotifyAllUser(RoomMessageDefine.Msg_RC_NpcSkill, retMsg);
                }
            }
        }