Ejemplo n.º 1
0
        public static PlayerEntity CreateNewPlayerEntity(
            PlayerContext playerContext,
            IWeaponSlotController weaponSlotController,
            Vector3 position,
            ICreatePlayerInfo playerInfo,
            bool prediction,
            bool autoMove)
        {
            PlayerEntity playerEntity = playerContext.CreateEntity();
            var          sex          = SingletonManager.Get <RoleConfigManager>().GetRoleItemById(playerInfo.RoleModelId).Sex;
            var          modelName    = sex == 1 ? SharedConfig.maleModelName : SharedConfig.femaleModelName;


            playerEntity.AddPlayerInfo(playerInfo.EntityId, playerInfo.PlayerId, playerInfo.PlayerName, playerInfo.RoleModelId, modelName,
                                       playerInfo.TeamId, playerInfo.Num, playerInfo.Level, playerInfo.BackId, playerInfo.TitleId, playerInfo.BadgeId, playerInfo.AvatarIds, playerInfo.WeaponAvatarIds, playerInfo.Camp);

            playerEntity.playerInfo.WeaponBags = playerInfo.WeaponBags;
            playerEntity.AddUserCmd();
            playerEntity.AddUserCmdSeq(0);
            playerEntity.AddUserCmdOwner(new UserCmdOwnerAdapter(playerEntity));
            playerEntity.AddEntityKey(new EntityKey(playerInfo.EntityId, (int)EEntityType.Player));
            playerEntity.AddPosition(position);

            playerEntity.AddVehicleCmdSeq(0);
            playerEntity.isFlagCompensation = true;
            playerEntity.isFlagSyncSelf     = true;
            playerEntity.isFlagSyncNonSelf  = true;
            playerEntity.isFlagAutoMove     = autoMove;
            playerEntity.isFlagSelf         = prediction;
            playerEntity.AddOrientation(0, 0, 0, 0, 0);
            playerEntity.AddPlayerRotateLimit(false);
            playerEntity.AddPlayerMove(Vector3.zero, 0, true, false, 0);
            playerEntity.AddPlayerSkyMove(true, -1);
            playerEntity.AddPlayerSkyMoveInterVar();
            playerEntity.AddTime(0);
            playerEntity.AddGamePlay(100, 100);

            playerEntity.AddWeaponState(0, 0);

#if UNITY_EDITOR
            if (SharedConfig.IsOffline)
            {
                playerEntity.weaponState.BagOpenLimitTime = 50000;
            }
#endif

            playerEntity.AddPlayerWeaponState(0, false, 0, 0, 0, 0, false, 0, 0);
            AddCameraStateNew(playerEntity);
            playerEntity.AddState();

            playerEntity.AddFirePosition();
            playerEntity.AddStateBefore();
            playerEntity.AddStateInterVar(new StateInterCommands(), new StateInterCommands(), new StateInterCommands(), new StateInterCommands());
            playerEntity.AddStateInterVarBefore();
            playerEntity.AddMoveUpdate();
            playerEntity.AddSkyMoveUpdate();
            playerEntity.AddPlayerMoveByAnimUpdate();

            playerEntity.AddFirstPersonAppearance(playerEntity.entityKey.Value.EntityId);
            playerEntity.AddThirdPersonAppearance();
            //playerEntity.AddNetworkWeaponAnimation(string.Empty, 0, string.Empty, 0);

            playerEntity.AddLatestAppearance();
            playerEntity.latestAppearance.Init();
            playerEntity.AddPredictedAppearance();

            playerEntity.AddOxygenEnergy(0);

            playerEntity.AddSound();
            playerEntity.AddUpdateMessagePool();
            playerEntity.AddRemoteEvents(new PlayerEvents());

            playerEntity.AddStatisticsData(false, new BattleData(), new StatisticsData());
            weaponSlotController.InitPlayerWeaponBySlotInfo(playerEntity);
            playerEntity.AddPlayerMask((byte)(EPlayerMask.TeamA | EPlayerMask.TeamB), (byte)(EPlayerMask.TeamA | EPlayerMask.TeamB));
            playerEntity.AddOverrideBag(0);
            //Logger.Info(playerEntity.Dump());
            return(playerEntity);
        }