public static PlayerEntity CreateNewPlayerEntity( PlayerContext playerContext, 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.AddLatestAdjustCmd(-1, -1); playerEntity.AddUserCmdOwner(new UserCmdOwnerAdapter(playerEntity)); playerEntity.AddEntityKey(new EntityKey(playerInfo.EntityId, (int)EEntityType.Player)); playerEntity.AddPosition(position); playerEntity.AddVehicleCmdSeq(0); playerEntity.isFlagSyncSelf = true; //On server-side, do not sync player entity to other players until the player login server successfully if (!SharedConfig.IsServer) { playerEntity.isFlagCompensation = 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(false, -1); playerEntity.AddPlayerSkyMoveInterVar(); playerEntity.AddTime(0); playerEntity.AddGamePlay(100, 100); // playerEntity.AddWeaponState(); AddCameraStateNew(playerEntity); playerEntity.AddState(); playerEntity.AddFirePosition(); playerEntity.AddStateBefore(); playerEntity.AddStateInterVar(new StateInterCommands(), new StateInterCommands(), new UnityAnimationEventCommands(), new UnityAnimationEventCommands()); playerEntity.AddStateInterVarBefore(); playerEntity.AddMoveUpdate(); playerEntity.AddSkyMoveUpdate(); playerEntity.AddPlayerMoveByAnimUpdate(); playerEntity.AddFirstPersonAppearance(playerEntity.entityKey.Value.EntityId); playerEntity.AddFirstPersonAppearanceUpdate(); 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()); playerEntity.AddPlayerMask((byte)(EPlayerMask.TeamA | EPlayerMask.TeamB), (byte)(EPlayerMask.TeamA | EPlayerMask.TeamB)); playerEntity.AddPlayerWeaponUpdate(0); playerEntity.AttachPlayerAux(); #if UNITY_EDITOR if (SharedConfig.IsOffline) { playerEntity.playerWeaponAuxiliary.BagOpenLimitTime = 50000; } #endif playerEntity.AddTriggerEvent(); playerEntity.AddRaycastTest(5f, new List <GameObject>()); //Logger.Info(playerEntity.Dump()); return(playerEntity); }