public bool GetAIEnable(int objID) { EntityInfo character = GetEntityById(objID); if (character != null) { return(character.GetAIEnable()); } return(false); }
internal static void Execute(object msg, User user) { Msg_CR_UserMoveToPos move_msg = msg as Msg_CR_UserMoveToPos; if (move_msg == null) { return; } EntityInfo charactor = user.Info; if (charactor == null) { LogSys.Log(LOG_TYPE.DEBUG, "charactor {0}({1},{2},{3}) not exist", user.RoleId, user.GetKey(), user.Guid, user.Name); return; } /// if (charactor.GetAIEnable()) { float tx, tz; ProtoHelper.DecodePosition2D(move_msg.target_pos, out tx, out tz); ScriptRuntime.Vector3 pos = new ScriptRuntime.Vector3(tx, 0, tz); MovementStateInfo msi = charactor.GetMovementStateInfo(); msi.IsMoving = true; msi.TargetPosition = pos; float dir = Geometry.GetYRadian(msi.GetPosition3D(), pos); msi.SetFaceDir(dir); msi.SetMoveDir(dir); Msg_RC_NpcMove npcMoveBuilder = DataSyncUtility.BuildNpcMoveMessage(charactor); if (null != npcMoveBuilder) { Scene scene = user.OwnRoom.ActiveScene; if (null != scene) { scene.NotifyAllUser(RoomMessageDefine.Msg_RC_NpcMove, npcMoveBuilder); } } } }
public void Execute(EntityInfo entity, long deltaTime) { if (entity.IsUnderControl()) { return; } if (entity.GetAIEnable()) { AiStateInfo npcAi = entity.GetAiStateInfo(); if (!npcAi.IsInited) { OnStateLogicInit(entity, deltaTime); npcAi.IsInited = true; } int curState = npcAi.CurState; if (curState > (int)AiStateId.Invalid && curState < (int)AiStateId.MaxNum) { AiStateHandler handler; if (m_Handlers.TryGetValue(curState, out handler)) { if (OnStateLogicCheck(entity, deltaTime) && null != handler) { handler(entity, deltaTime); } } else { LogSystem.Error("Illegal ai state: " + curState + " entity:" + entity.GetId()); } } else { ChangeToState(entity, (int)AiStateId.Idle); } } }