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);
}
}
}
}