public static void ProcessHitBoxCommands(DebugCommand message)
 {
     if (message.Command == DebugCommands.ShowDrawHitBoxOnBullet)
     {
         DebugConfig.DrawHitBoxOnBullet = true;
     }
     else if (message.Command == DebugCommands.HideDrawHitBoxOnBullet)
     {
         DebugConfig.DrawHitBoxOnBullet = false;
     }
     else if (message.Command == DebugCommands.ShowDrawHitBoxOnFrame)
     {
         DebugConfig.DrawHitBoxOnFrame = true;
     }
     else if (message.Command == DebugCommands.HideDrawHitBoxOnFrame)
     {
         DebugConfig.DrawHitBoxOnFrame = false;
     }
     else if (message.Command == DebugCommands.EnableDrawBullet)
     {
         DebugConfig.DrawBulletLine = true;
     }
     else if (message.Command == DebugCommands.DisableDrawBullet)
     {
         DebugConfig.DrawBulletLine = false;
     }
 }
        public static void ProcessMapObjectCommand(DebugCommand message, MapObjectContext context,
                                                   IMapObjectEntityFactory mapObjectEntityFactory, PlayerEntity player)
        {
            switch (message.Command)
            {
            case DebugCommands.ClearSceneObject:
                context.DestroyAllEntities();
                break;

            case DebugCommands.ListDoorEntity:
                var mapEntities = context.GetEntities();
                for (int i = 0; i < mapEntities.Length; ++i)
                {
                    var mapEntity = mapEntities[i];
                    if (mapEntity.hasDoorData && mapEntity.hasRawGameObject)
                    {
                        var obj = mapEntity.rawGameObject.Value;

                        string path = "/" + obj.name;
                        while (obj.transform.parent != null)
                        {
                            obj  = obj.transform.parent.gameObject;
                            path = "/" + obj.name + path;
                        }

                        Logger.InfoFormat("DoorEntity {0} {1}", mapEntity, path);
                    }
                }
                break;
            }
        }
        public static void ProcessSceneObjectCommand(DebugCommand message, SceneObjectContext context,
                                                     ISceneObjectEntityFactory sceneObjectEntityFactory, PlayerEntity player)
        {
            switch (message.Command)
            {
            case DebugCommands.CreateSceneObject:
                int category;
                int id;
                if (int.TryParse(message.Args[0], out category) && int.TryParse(message.Args[1], out id))
                {
                    sceneObjectEntityFactory.CreateSimpleObjectEntity((Assets.XmlConfig.ECategory)category, id,
                                                                      1, player.position.Value);
                }
                break;

            case DebugCommands.ClearSceneObject:
                context.DestroyAllEntities();
                break;
            }
        }
        public static string ProcessCommands(DebugCommand cmd, Contexts contexts, PlayerEntity player)
        {
            var type       = Type.GetType(cmd.Command);
            var fieldInfos = new Queue <FieldInfo>();

            if (null != type)
            {
                var instance = Activator.CreateInstance(type);
                var i        = 1;
                while (i < 100)
                {
                    var arg = type.GetField("arg" + i);
                    if (null == arg)
                    {
                        break;
                    }
                    fieldInfos.Enqueue(arg);
                    i++;
                }
                var abstractDebugCommand = instance as AbstractDebugCommand;
                return(abstractDebugCommand.Process(contexts, player, cmd.Args, fieldInfos));
            }
            return("");
        }
 public static void ProcessVehicleCommand(DebugCommand message, VehicleContext vehicleContext, PlayerEntity player)
 {
     if (message.Command == DebugCommands.ShowExplosionRange)
     {
         VehicleDebugUtility.ShowExplosionRange(vehicleContext, player, true, float.Parse(message.Args[0]));
     }
     else if (message.Command == DebugCommands.HideExplosionRange)
     {
         VehicleDebugUtility.ShowExplosionRange(vehicleContext, player, false, 1.0f);
     }
     else if (message.Command == DebugCommands.DragCar)
     {
         VehicleDebugUtility.DragCar(vehicleContext, player);
     }
     else if (message.Command == DebugCommands.ShowVehicleDebugInfo)
     {
         VehicleDebugUtility.ToggleVehicleDebugInfo();
     }
     else if (message.Command == DebugCommands.SetVehicleHp)
     {
         VehicleDebugUtility.SetVehicleHp(vehicleContext, int.Parse(message.Args[0]), int.Parse(message.Args[1]));
     }
     else if (message.Command == DebugCommands.SetVehicleFuel)
     {
         VehicleDebugUtility.SetVehicleFuel(vehicleContext, int.Parse(message.Args[0]), int.Parse(message.Args[1]));
     }
     else if (message.Command == DebugCommands.SetVehicleInput)
     {
         VehicleDebugUtility.SetVehicleInput(vehicleContext, message.Args);
     }
     else if (message.Command == DebugCommands.EnableVehicleCollisionDamage)
     {
         VehicleDebugUtility.EnableVehicleCollisionDamage(int.Parse(message.Args[0]) != 0);
     }
     else if (message.Command == DebugCommands.EnableVehicleCollisionDebug)
     {
         VehicleDebugUtility.EnableVehicleCollisionDebug(int.Parse(message.Args[0]) != 0);
     }
     else if (message.Command == DebugCommands.SetVehicleDynamicPrediction)
     {
         VehicleDebugUtility.SetVehicleDynamicPrediction(vehicleContext, int.Parse(message.Args[0]) != 0);
     }
     else if (message.Command == DebugCommands.ShowClientVehicle)
     {
         VehicleDebugUtility.ShowVehicles(vehicleContext, false);
     }
     else if (message.Command == DebugCommands.ShowServerVehicle)
     {
         VehicleDebugUtility.ShowVehicles(vehicleContext, true);
     }
     else if (message.Command == DebugCommands.ResetVehicle)
     {
         VehicleDebugUtility.ResetVehicle(vehicleContext, int.Parse(message.Args[0]));
     }
     else if (message.Command == DebugCommands.TestFrame)
     {
         SharedConfig.runTestRame = string.Join(",", message.Args);
     }
     else if (message.Command == DebugCommands.EnableVehicleCull)
     {
         VehicleDebugUtility.EnableVehicleCull(int.Parse(message.Args[0]) != 0, int.Parse(message.Args[1]) != 0);
     }
     else if (message.Command == DebugCommands.SetVehicleActiveUpdateRate)
     {
         VehicleDebugUtility.SetVehicleActiveUpdateRate(int.Parse(message.Args[0]) != 0, int.Parse(message.Args[1]));
     }
     else if (message.Command == DebugCommands.CreateVehicle)
     {
         VehicleDebugUtility.CreateVehicleOffline(player, message.Args.Length > 0 ?  int.Parse(message.Args[0])  : 0, message.Args.Length > 1? int.Parse(message.Args[1]) : 1);
     }
 }
        public static string ProcessDebugCommand(DebugCommand message, Contexts context)
        {
            var result = string.Empty;

            switch (message.Command)
            {
            case DebugCommands.ListTriggerObj:
                result = ListTriggerObj(context.mapObject, message.Args);
                break;

            case DebugCommands.ListDoorEntity:
                break;

            case DebugCommands.ShowConfig:
                var config = message.Args[0] as string;
                switch (config)
                {
                case "camera":
                    result = SingletonManager.Get <CameraConfigManager>().XMLContent;
                    break;
                }
                break;

            case DebugCommands.EnableRecordProfiler:
            {
                var isClient = true;
                var enabled  = false;
                if (message.Args.Length == 1)
                {
                    enabled = int.Parse(message.Args[0]) != 0;
                }
                else if (message.Args.Length == 2)
                {
                    isClient = message.Args[0].ToLower().Equals("c");
                    enabled  = int.Parse(message.Args[1]) != 0;
                }

                if (isClient && !SharedConfig.IsServer ||
                    !isClient && SharedConfig.IsServer)
                {
                    if (enabled)
                    {
                        SingletonManager.Get <MyProfilerManager>().EnableProfiler();
                    }
                    else
                    {
                        SingletonManager.Get <MyProfilerManager>().DisableProfiler();
                    }
                }

                break;
            }

            case DebugCommands.EnableProfiler:
            {
                var cmdargs  = CmdParser.ParseCommandLine(message.Args, "-");
                var isClient = false;
                var isServer = false;
                var value    = 0;
                isClient = TryGetArgs <int>(cmdargs, "c", out value);
                if (!isClient)
                {
                    isServer = TryGetArgs <int>(cmdargs, "s", out value);
                }
                var enabled = value != 0;

                var isProfilePhysics = TryGetArgs <int>(cmdargs, "p", out value);
                var profilePhysics   = value != 0;

                var isProfileGpu = TryGetArgs <int>(cmdargs, "g", out value);
                var profileGpu   = value != 0;
                //profilegpu is only valid on client
                profileGpu = !SharedConfig.IsServer && profileGpu;

                var isLog     = TryGetArgs <int>(cmdargs, "l", out value);
                var enableLog = !isLog || value != 0;

                if (isProfilePhysics)
                {
#if PHYSICS_PROFILER_STATISTICS
                    UnityEngine.Profiling.Profiler.profilePhysics = profilePhysics;
#endif
                    result = "ok";
                }

                if (isClient && !SharedConfig.IsServer ||
                    isServer && SharedConfig.IsServer)
                {
                    if (enabled)
                    {
                        UnityProfiler.EnableProfiler(profileGpu, enableLog);
                        result = String.Format("ok, start {0}", SharedConfig.IsServer ? "server" : "client");
                    }
                    else
                    {
                        UnityProfiler.DisableProfiler();
                        result = "ok, stop profiler";
                    }
                }
                else if (isProfileGpu)
                {
                    UnityProfiler.EnableProfileGpu(profileGpu);
                }


                result = String.Format("{0} profile gpu {1} profile physics {2}",
                                       result,
                                       profileGpu ? "enabled" : "disabled",
                                       profilePhysics ? "enabled" : "disabled");

                if (isServer && isProfileGpu)
                {
                    result = "GPU Profile is not supported on Server!.";
                }

                break;
            }
            }
            return(result);
        }
        public static string ProcessGameSettingCommnands(DebugCommand message, SessionStateMachine stateMachine)
        {
            if (message.Command == DebugCommands.SetFrameRate)
            {
                string target    = message.Args[0].ToLower();
                var    frameRate = int.Parse(message.Args[1]);
                if (frameRate == -1)
                {
                    QualitySettings.vSyncCount = 1;
                    return("ok");
                }
                QualitySettings.vSyncCount = 0;
                GameSettingUtility.SetFrameRate(target, frameRate);
                return("ok");
            }
            else if (message.Command == DebugCommands.GetUnityQuality)
            {
                var qualityName = GameSettingUtility.GetQualityName();
                message.Args    = new string[1];
                message.Args[0] = qualityName;
                return(qualityName);
            }
            else if (message.Command == DebugCommands.GetQualityList)
            {
                message.Args = GameSettingUtility.GetQualityNameList();
                return("ok");
            }
            else if (message.Command == DebugCommands.GetQuality)
            {
                var qualityName = SettingManager.GetInstance().GetQuality();
                return(qualityName.ToString());
            }
            else if (message.Command == DebugCommands.SetQuality)
            {
                int levelIndex = int.Parse(message.Args[0]);
                GameSettingUtility.SetQuality(levelIndex);
                return("ok");
            }
            else if (message.Command == DebugCommands.Quality)
            {
                int levelIndex = int.Parse(message.Args[0]);
                SettingManager.GetInstance().SetQuality((QualityLevel)levelIndex);
                return("ok");
            }
            else if (message.Command == DebugCommands.VideoSetting)
            {
                int id = int.Parse(message.Args[0]);

                return(GameQualitySettingManager.GetVideoValue((EVideoSettingId)id));
            }

            else if (message.Command == DebugCommands.LodBias)
            {
                if (message.Args.Length > 0)
                {
                    float val;
                    if (float.TryParse(message.Args[0], out val))
                    {
                        QualitySettings.lodBias = val;
                    }
                    else
                    {
                        return("参数不合法,需要能转为float类型");
                    }
                }
                else
                {
                    return(QualitySettings.lodBias.ToString());
                }

                return("ok");
            }
            else if (message.Command == DebugCommands.TreeDistance)
            {
                if (message.Args.Length > 1)
                {
                    float val;
                    if (float.TryParse(message.Args[0], out val))
                    {
                        SingletonManager.Get <DynamicScenesController>().SetTreeDistance(val);
                    }
                    else
                    {
                        return("参数不合法,需要能转为float类型");
                    }
                    if (float.TryParse(message.Args[1], out val))
                    {
                        SingletonManager.Get <DynamicScenesController>().SetGrassDensity(val);
                    }
                    else
                    {
                        return("参数不合法,需要能转为float类型");
                    }
                }
                else if (message.Args.Length > 0)
                {
                    float val;
                    if (float.TryParse(message.Args[0], out val))
                    {
                        SingletonManager.Get <DynamicScenesController>().SetTreeDistance(val);
                    }
                    else
                    {
                        return("参数不合法,需要能转为float类型");
                    }
                }
                else
                {
                    return(string.Format("tree {0}, grass {1}", SingletonManager.Get <DynamicScenesController>().GetTreeDistance(),
                                         SingletonManager.Get <DynamicScenesController>().GetGrassDensity()));
                }

                return("ok");
            }
            else if (message.Command == DebugCommands.PermitSystem)
            {
                if (stateMachine.PermitSystem(message.Args[0]))
                {
                    return("ok");
                }
                return("wrong path");
            }
            else if (message.Command == DebugCommands.ForbidSystem)
            {
                if (stateMachine.ForbidSystems(message.Args[0]))
                {
                    return("ok");
                }
                return("wrong path");
            }
            else if (message.Command == DebugCommands.ShowSystem)
            {
                var treeNode = stateMachine.GetUpdateSystemTree();
                return(TransSystemTreeToString(treeNode));
            }
            return(String.Empty);
        }
        public static string ProcessPlayerCommands(DebugCommand message, Contexts contexts, PlayerEntity player, ICommonSessionObjects sessionObjects, ICurrentTime currentTime)
        {
            var result = "";

            switch (message.Command)
            {
            case DebugCommands.ClientMove:
                var pos = new Vector3(0, 1000, 0).ShiftedPosition();
                var yaw = 0f;
                switch (message.Args.Length)
                {
                case 2:
                    break;

                case 3:
                    break;

                case 4:
                    break;
                }
                if (message.Args.Length > 0)
                {
                    float x;
                    if (float.TryParse(message.Args[0], out x))
                    {
                        pos.x = x;
                    }
                }
                if (message.Args.Length == 2)
                {
                    pos.y = 10000;
                    float z;
                    if (float.TryParse(message.Args[1], out z))
                    {
                        pos.z = z;
                    }
                }
                if (message.Args.Length == 3)
                {
                    float y;
                    if (float.TryParse(message.Args[1], out y))
                    {
                        pos.y = y;
                    }
                    float z;
                    if (float.TryParse(message.Args[2], out z))
                    {
                        pos.z = z;
                    }
                }
                pos = pos.ShiftedPosition();
                var        ray = new Ray(pos, Vector3.down);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit))
                {
                    player.position.Value = hit.point;
                    result = "ok";
                }
                else
                {
                    player.position.Value = pos;
                    result = "没有检测到碰撞,资源未加载完成或此位置没有碰撞,请指定y值";
                }

                break;

            case DebugCommands.KillMe:
                player.gamePlay.CurHp = 0;
                player.gamePlay.ChangeLifeState(EPlayerLifeState.Dead, currentTime.CurrentTime);
                break;

            case DebugCommands.DyingMe:
                player.gamePlay.ChangeLifeState(EPlayerLifeState.Dying, currentTime.CurrentTime);
                break;

            case DebugCommands.ShowAniInfo:
                result = string.Format("{0}\n{1}", player.state, player.thirdPersonAnimator.DebugJumpInfo());
                break;

            case DebugCommands.Speed:
                if (message.Args.Length < 1)
                {
                    return("Argument Error!");
                }

                float i;
                if (!float.TryParse(message.Args[0], out i))
                {
                    return("Argument Error! speed should be float");
                }

                if (player != null && player.hasPlayerMove)
                {
                    result = string.Format("change player:{0} speedAffect from:{1}, to:{2}", player.entityKey.Value.ToString(), player.playerMove.SpeedAffect, i);
                    player.playerMove.SpeedAffect = i;
                    if (message.Args.Length >= 2)
                    {
                        float j;
                        if (!float.TryParse(message.Args[0], out j))
                        {
                            return("Argument Error! jump should be float");
                        }
                        player.playerMove.JumpAffect = j;
                    }
                    return(result);
                }
                break;

            case DebugCommands.TestMap:
                result = BigMapDebug.HandleCommand(player, message.Args);
                break;

            case DebugCommands.ChangeBag:
                player.WeaponController().SwitchBag(int.Parse(message.Args[0]));
                //   contexts.session.clientSessionObjects.UserCmdGenerator.SetUserCmd((cmd) => cmd.BagIndex = 1);
                break;

            case DebugCommands.ChangeHp:
                player.gamePlay.CurHp = int.Parse(message.Args[0]);
                break;

            case DebugCommands.SetCurBullet:
                player.WeaponController().HeldWeaponAgent.BaseComponent.Bullet = int.Parse(message.Args[0]);
                break;

            case DebugCommands.SetReservedBullet:
                if (message.Args.Length > 1)
                {
                    int slot  = int.Parse(message.Args[0]);
                    int count = int.Parse(message.Args[1]);

                    player.WeaponController().SetReservedBullet((EWeaponSlotType)slot, count);
                }
                else
                {
                    int count = int.Parse(message.Args[0]);
                    player.WeaponController().SetReservedBullet(count);
                }
                break;

            case DebugCommands.SetGrenade:
                //IGrenadeCacheHelper helper = player.WeaponController().GrenadeHelper;
                //helper.AddCache(37);
                //helper.AddCache(37);
                //helper.AddCache(38);
                //helper.AddCache(39);
                player.WeaponController().PickUpWeapon(WeaponUtil.CreateScan(37));
                break;

            case DebugCommands.AudioEmitter:
                var sceneObjectEntityFactory = contexts.session.entityFactoryObject.SceneObjectEntityFactory;
                sceneObjectEntityFactory.CreateSceneAudioEmitterEntity(player.position.Value, player.entityKey.Value);

                break;

            case DebugCommands.AudioBgm:
                var sceneObjectEntityFactory2 = contexts.session.entityFactoryObject.SceneObjectEntityFactory;
                sceneObjectEntityFactory2.CreateSceneAudioBgEmitterEntity(player.position.Value, player.entityKey.Value);

                break;

            case DebugCommands.Shoot:
                if (message.Args.Length > 0)
                {
                    string s = message.Args[0];
                    if (s == "clean")
                    {
                        GMVariable.CleanShowShootText = true;
                    }
                }
                else
                {
                    GMVariable.ShowShootText = !GMVariable.ShowShootText;
                }


                break;

            case DebugCommands.SetAudio:
                if (message.Args.Length > 0)
                {
                    string arg1 = message.Args[0];
                    switch (arg1)
                    {
                    case "step":
                        int matType = int.Parse(message.Args[1].Trim());
                        var isUse   = (matType > -1);
                        GMVariable.AudioFoostepMatType = matType;
                        player.AudioController().SetGMFootstep(isUse);
                        break;

                    case "log":
                        int logType = int.Parse(message.Args[1].Trim());
                        if (logType == 1)
                        {
                            GMVariable.AudioPostEventLog = !GMVariable.AudioPostEventLog;
                        }
                        else if (logType == 2)
                        {
                            GMVariable.AudioListenerLog = !GMVariable.AudioListenerLog;
                        }
                        else if (logType == 3)
                        {
                            GMVariable.AudioFootstepLog = !GMVariable.AudioFootstepLog;
                        }

                        break;
                    }
                }

                break;

            case DebugCommands.SetWeapon:
                int weaponIdToSet   = 0;
                int avatarId        = 0;
                var weaponSlotToSet = 0;
                if (message.Args.Length > 0)
                {
                    weaponIdToSet = int.Parse(message.Args[0].Trim());
                }
                if (message.Args.Length > 2)
                {
                    avatarId = int.Parse(message.Args[1].Trim());
                }
                if (message.Args.Length > 3)
                {
                    weaponSlotToSet = int.Parse(message.Args[2].Trim());
                }
                var weaponInfo = WeaponUtil.CreateScan(weaponIdToSet, (val) => val.AvatarId = avatarId > 0 ? avatarId : 0);
                weaponInfo.Bullet         = 100;
                weaponInfo.ReservedBullet = 100;
                if (weaponSlotToSet != 0)
                {
                    player.WeaponController().ReplaceWeaponToSlot((EWeaponSlotType)weaponSlotToSet, weaponInfo);
                }
                else
                {
                    player.WeaponController().PickUpWeapon(weaponInfo);
                }
                break;

            case DebugCommands.DropWeapon:
                var dropSlot = int.Parse(message.Args[0]);
                player.WeaponController().DropWeapon((EWeaponSlotType)dropSlot);
                break;

            case DebugCommands.TestWeaponAssemble:
                if (null == _twaRootGo)
                {
                    _twaRootGo = new GameObject("TwaRoot");
                    _twaRootGo.transform.parent           = Camera.main.transform;
                    _twaRootGo.transform.localPosition    = new Vector3(0, 0, 2);
                    _twaRootGo.transform.localEulerAngles = new Vector3(0, 90, 0);
                }
                if (null == _weaponModelController)
                {
                    _weaponModelController = new WeaponModelController(
                        //SingletonManager.Get<WeaponResourceConfigManager>(),
                        //SingletonManager.Get<WeaponPartsConfigManager>(),
                        //SingletonManager.Get<WeaponAvatarConfigManager>(),
                        new WeaponModelLoadController <object>(
                            new WeaponModelLoader(sessionObjects.AssetManager),
                            new WeaponModelAssemblyController(_twaRootGo))
                        );
                }
                var operate = int.Parse(message.Args[0]);
                var dataId  = int.Parse(message.Args[1]);
                switch (operate)
                {
                case 0:
                    _weaponModelController.SetWeapon(dataId);
                    break;

                case 1:
                    _weaponModelController.SetPart(dataId);
                    break;

                case 2:
                    _weaponModelController.RemovePart(dataId);
                    break;
                }
                break;

            case DebugCommands.TestCmd:
                var targ1 = int.Parse(message.Args[0]);
                switch (targ1)
                {
                case 1:
                    GMVariable.ShowSessionTimer = !GMVariable.ShowSessionTimer;
                    //    LocalObjectGenerator.Dispose(true);
                    break;

                case 2:
                    GMVariable.SpreadOffsetFactor = int.Parse(message.Args[1]);
                    break;
                }
                break;

            case DebugCommands.SetAttachment:
                var res   = Core.Enums.EFuncResult.Failed;
                var apply = 0;
                if (message.Args.Length == 2)
                {
                    var slot = int.Parse(message.Args[0]);
                    apply = int.Parse(message.Args[1]);
                    res   = player.WeaponController().SetWeaponPart((EWeaponSlotType)slot, apply) ? Core.Enums.EFuncResult.Success : Core.Enums.EFuncResult.Failed;
                }
                else
                {
                    apply = int.Parse(message.Args[0]);
                    res   = player.WeaponController().SetWeaponPart(apply) ? Core.Enums.EFuncResult.Success : Core.Enums.EFuncResult.Failed;
                }

                switch (res)
                {
                case Core.Enums.EFuncResult.Exception:
                    result = "exception occurs";
                    break;

                case Core.Enums.EFuncResult.Failed:
                    result = "attachment doesn't match";
                    break;

                case Core.Enums.EFuncResult.Success:
                    result = "attach " + apply + " to weapon";
                    break;
                }
                break;

            case DebugCommands.SetWeaponAttachment:
                var resu = Core.Enums.EFuncResult.Failed;
                var id   = 0;
                if (message.Args.Length == 2)
                {
                    var slot = int.Parse(message.Args[0]);
                    id   = int.Parse(message.Args[1]);
                    resu = player.WeaponController().SetWeaponPartByPartId((EWeaponSlotType)slot, id) ? Core.Enums.EFuncResult.Success : Core.Enums.EFuncResult.Failed;
                }
                else
                {
                    id   = int.Parse(message.Args[0]);
                    resu = player.WeaponController().SetWeaponPartByPartId(id) ? Core.Enums.EFuncResult.Success : Core.Enums.EFuncResult.Failed;
                }

                switch (resu)
                {
                case Core.Enums.EFuncResult.Exception:
                    result = "exception occurs";
                    break;

                case Core.Enums.EFuncResult.Failed:
                    result = "attachment doesn't match";
                    break;

                case Core.Enums.EFuncResult.Success:
                    result = "attach " + id + " to weapon";
                    break;
                }
                break;

            case DebugCommands.ClearAttachment:
                var weaponSlot = (EWeaponSlotType)int.Parse(message.Args[0]);
                var part       = (EWeaponPartType)int.Parse(message.Args[1]);
                player.WeaponController().DeleteWeaponPart(weaponSlot, part);
                break;

            case DebugCommands.SwitchAttachment:
                break;

            case DebugCommands.SetEquip:
                player.appearanceInterface.Appearance.ChangeAvatar(int.Parse(message.Args[0]));
                break;

            case DebugCommands.ShowAvaliablePartType:
                int weaponId = player.WeaponController().HeldWeaponAgent.ConfigId;
                if (weaponId > 0)
                {
                    var list = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(weaponId).ApplyParts;
                    for (int j = 0; j < list.Count; j++)
                    {
                        result += list[j] + ",";
                    }
                }
                break;

            case DebugCommands.ReloadConfig:
                ConfigReloadSystem.Reload = true;
                break;

            case DebugCommands.ShowArtTools:
                GameObject.Instantiate(Resources.Load <GameObject>("RuntimeTestTools"));
                result = "RuntimeTestTools";
                break;

            case DebugCommands.ShowTerrainTrace:
                SharedConfig.IsShowTerrainTrace = !SharedConfig.IsShowTerrainTrace;
                break;

            case DebugCommands.Revive:
                player.gamePlay.LifeState     = (int)EPlayerLifeState.Alive;
                player.gamePlay.CurHp         = player.gamePlay.MaxHp;
                player.gamePlay.InHurtedCount = 0;
                break;
            }
            return(result);
        }
        public static string ProcessDebugCommand(DebugCommand message)
        {
            var result = string.Empty;

            switch (message.Command)
            {
            case DebugCommands.ShowConfig:
                var config = message.Args[0] as string;
                switch (config)
                {
                case "camera":
                    result = SingletonManager.Get <CameraConfigManager>().XMLContent;
                    break;
                }
                break;

            case DebugCommands.EnableRecordProfiler:
            {
                var isClient = true;
                var enabled  = false;
                if (message.Args.Length == 1)
                {
                    enabled = int.Parse(message.Args[0]) != 0;
                }
                else if (message.Args.Length == 2)
                {
                    isClient = message.Args[0].ToLower().Equals("c");
                    enabled  = int.Parse(message.Args[1]) != 0;
                }

                if (isClient && !SharedConfig.IsServer ||
                    !isClient && SharedConfig.IsServer)
                {
                    if (enabled)
                    {
                        SingletonManager.Get <MyProfilerManager>().EnableProfiler();
                    }
                    else
                    {
                        SingletonManager.Get <MyProfilerManager>().DisableProfiler();
                    }
                }

                break;
            }

            case DebugCommands.EnableProfiler:
            {
                var cmdargs  = CmdParser.ParseCommandLine(message.Args, "-");
                var isClient = false;
                var isServer = false;
                var value    = 0;
                isClient = TryGetArgs <int>(cmdargs, "c", out value);
                if (!isClient)
                {
                    isServer = TryGetArgs <int>(cmdargs, "s", out value);
                }
                var enabled = value != 0;

                var isProfileGpu = TryGetArgs <int>(cmdargs, "g", out value);
                var profileGpu   = value != 0;
                //profilegpu is only valid on client
                profileGpu = !SharedConfig.IsServer && profileGpu;

                if (isClient && !SharedConfig.IsServer ||
                    isServer && SharedConfig.IsServer)
                {
                    if (enabled)
                    {
                        UnityProfiler.EnableProfiler(profileGpu);
                        result = String.Format("ok, start {0} profiler profile gpu {1}", SharedConfig.IsServer ? "server" : "client", profileGpu ? "enabled" : "disabled");
                    }
                    else
                    {
                        UnityProfiler.DisableProfiler();
                        result = "ok, stop profiler";
                    }
                }
                else if (isProfileGpu)
                {
                    UnityProfiler.EnableProfileGpu(profileGpu);
                    result = String.Format("ok, profile gpu {0}", (profileGpu ? "enabled" : "disabled"));
                }
                else if (!isServer)
                {
                    result = "Invalid Argument.";
                }

                break;
            }
            }
            return(result);
        }
        public static string ProcessPlayerCommands(DebugCommand message, PlayerEntity player, ICommonSessionObjects sessionObjects, ICurrentTime currentTime)
        {
            var            result = "";
            WeaponBagLogic bagLogicImp;

            switch (message.Command)
            {
            case DebugCommands.ClientMove:
                var pos = new Vector3(0, 1000, 0);
                var yaw = 0f;
                switch (message.Args.Length)
                {
                case 2:
                    break;

                case 3:
                    break;

                case 4:
                    break;
                }
                if (message.Args.Length > 0)
                {
                    float x;
                    if (float.TryParse(message.Args[0], out x))
                    {
                        pos.x = x;
                    }
                }
                if (message.Args.Length == 2)
                {
                    pos.y = 10000;
                    float z;
                    if (float.TryParse(message.Args[1], out z))
                    {
                        pos.z = z;
                    }
                }
                if (message.Args.Length == 3)
                {
                    float y;
                    if (float.TryParse(message.Args[1], out y))
                    {
                        pos.y = y;
                    }
                    float z;
                    if (float.TryParse(message.Args[2], out z))
                    {
                        pos.z = z;
                    }
                }
                var        ray = new Ray(pos, Vector3.down);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit))
                {
                    player.position.Value = hit.point;
                    result = "ok";
                }
                else
                {
                    player.position.Value = pos;
                    result = "没有检测到碰撞,资源未加载完成或此位置没有碰撞,请指定y值";
                }
                break;

            case DebugCommands.KillMe:
                player.gamePlay.CurHp = 0;
                player.gamePlay.ChangeLifeState(Components.Player.EPlayerLifeState.Dead, currentTime.CurrentTime);
                break;

            case DebugCommands.ShowAniInfo:
                result = string.Format("{0}\n{1}", player.state, player.thirdPersonAnimator.DebugJumpInfo());
                break;

            case DebugCommands.TestMap:
                result = BigMapDebug.HandleCommand(player, message.Args);
                break;

            case DebugCommands.ChangeHp:
                player.gamePlay.CurHp = int.Parse(message.Args[0]);
                break;

            case DebugCommands.SetCurBullet:
                player.GetBagLogicImp().SetWeaponBullet(int.Parse(message.Args[0]));
                break;

            case DebugCommands.SetReservedBullet:
                if (message.Args.Length > 1)
                {
                    int slot  = int.Parse(message.Args[0]);
                    int count = int.Parse(message.Args[1]);

                    player.GetBagLogicImp().SetReservedBullet((EWeaponSlotType)slot, count);
                }
                else
                {
                    int count = int.Parse(message.Args[0]);
                    player.GetBagLogicImp().SetReservedBullet(player.GetBagLogicImp().GetCurrentWeaponSlot(), count);
                }
                break;

            case DebugCommands.SetWeapon:
            {
                int weaponIdToSet   = 0;
                int avatarId        = 0;
                var weaponSlotToSet = 0;
                if (message.Args.Length > 0)
                {
                    weaponIdToSet = int.Parse(message.Args[0].Trim());
                }
                if (message.Args.Length > 2)
                {
                    avatarId = int.Parse(message.Args[1].Trim());
                }
                if (message.Args.Length > 3)
                {
                    weaponSlotToSet = int.Parse(message.Args[2].Trim());
                }
                var weaponInfo = new WeaponInfo
                {
                    Id       = weaponIdToSet,
                    AvatarId = avatarId > 0 ? avatarId : 0,
                };
                if (weaponSlotToSet != 0)
                {
                    player.playerAction.Logic.ReplaceWeaponToSlot((EWeaponSlotType)weaponSlotToSet, weaponInfo);
                }
                else
                {
                    player.playerAction.Logic.PickUpWeapon(weaponInfo);
                }
            }
            break;

            case DebugCommands.DropWeapon:
                var dropSlot = int.Parse(message.Args[0]);
                player.playerAction.Logic.DropWeapon((EWeaponSlotType)dropSlot);
                break;

            case DebugCommands.TestWeaponAssemble:
                if (null == _twaRootGo)
                {
                    _twaRootGo = new GameObject("TwaRoot");
                    _twaRootGo.transform.parent           = Camera.main.transform;
                    _twaRootGo.transform.localPosition    = new Vector3(0, 0, 2);
                    _twaRootGo.transform.localEulerAngles = new Vector3(0, 90, 0);
                }
                if (null == _weaponModelController)
                {
                    _weaponModelController = new WeaponModelController(
                        SingletonManager.Get <WeaponConfigManager>(),
                        SingletonManager.Get <WeaponPartsConfigManager>(),
                        SingletonManager.Get <WeaponAvatarConfigManager>(),
                        new WeaponModelLoadController <object>(
                            new WeaponModelLoader(sessionObjects.LoadRequestManager),
                            new WeaponModelAssemblyController(_twaRootGo))
                        );
                }
                var operate = int.Parse(message.Args[0]);
                var dataId  = int.Parse(message.Args[1]);
                switch (operate)
                {
                case 0:
                    _weaponModelController.SetWeapon(dataId);
                    break;

                case 1:
                    _weaponModelController.SetPart(dataId);
                    break;

                case 2:
                    _weaponModelController.RemovePart(dataId);
                    break;
                }
                break;

            case DebugCommands.SetAttachment:
                var res = Core.Enums.EFuncResult.Failed;
                var id  = 0;
                if (message.Args.Length == 2)
                {
                    var slot = int.Parse(message.Args[0]);
                    id = int.Parse(message.Args[1]);


                    res = player.GetBagLogicImp().SetWeaponPart((EWeaponSlotType)slot, id);
                }
                else
                {
                    id  = int.Parse(message.Args[0]);
                    res = player.GetBagLogicImp().SetCurrentWeaponPart(id);
                }

                switch (res)
                {
                case Core.Enums.EFuncResult.Exception:
                    result = "exception occurs";
                    break;

                case Core.Enums.EFuncResult.Failed:
                    result = "attachment doesn't match";
                    break;

                case Core.Enums.EFuncResult.Success:
                    result = "attach " + id + " to weapon";
                    break;
                }
                break;

            case DebugCommands.ClearAttachment:
                var weaponSlot = (EWeaponSlotType)int.Parse(message.Args[0]);
                var part       = (EWeaponPartType)int.Parse(message.Args[1]);
                player.GetBagLogicImp().DeleteWeaponPart(weaponSlot, part);
                break;

            case DebugCommands.SwitchAttachment:
                break;

            case DebugCommands.SetEquip:
                player.appearanceInterface.Appearance.ChangeAvatar(int.Parse(message.Args[0]));
                break;

            case DebugCommands.ShowAvaliablePartType:
                var weapon = player.GetBagLogicImp().GetCurrentWeaponInfo();
                if (weapon.Id > 0)
                {
                    var list = SingletonManager.Get <WeaponPartsConfigManager>().GetAvaliablePartTypes(weapon.Id);
                    for (int i = 0; i < list.Count; i++)
                    {
                        result += list[i] + ",";
                    }
                }
                break;

            case DebugCommands.ReloadConfig:
                ConfigReloadSystem.Reload = true;
                break;

            case DebugCommands.ShowArtTools:
                GameObject.Instantiate(Resources.Load <GameObject>("RuntimeTestTools"));
                result = "RuntimeTestTools";
                break;

            case DebugCommands.ShowTerrainTrace:
                SharedConfig.IsShowTerrainTrace = !SharedConfig.IsShowTerrainTrace;
                break;
            }
            return(result);
        }