예제 #1
0
        /// <summary>
        /// ����Ҫ��Դ���صij�ʼ��
        /// </summary>
        /// <param name="player"></param>
        /// <param name="vehicleContext"></param>
        public static void PostCreateNewPlayerEntity(
            PlayerEntity player,
            Contexts contexts)
        {
            Logger.Info("PostCreateNewPlayerEntity");
            var sessionObjects = contexts.session.commonSession;

            var sceneObjectFactory = contexts.session.entityFactoryObject.SceneObjectEntityFactory;

            player.AttachModeController(sessionObjects.SessionMode);

            var characterInfo = new CharacterInfoProviderContext();

            if (!player.hasCharacterInfo)
            {
                player.AddCharacterInfo(characterInfo);
            }

            var stateManager = new CharacterStateManager(characterInfo);

            if (!player.hasStatisticsData)
            {
                player.AddStatisticsData(new BattleData(), false, new StatisticsData());
            }

            if (!player.hasAutoMoveInterface)
            {
                player.AddAutoMoveInterface(new GameModules.Player.Move.PlayerAutoMove(player));
            }

            var speed = new SpeedManager(player, contexts, stateManager, stateManager,
                                         stateManager.GetIPostureInConfig(),
                                         stateManager.GetIMovementInConfig(), characterInfo);

            stateManager.SetSpeedInterface(speed);
            player.AddStateInterface(stateManager);

            player.AddFsmInputRelateInterface(new FsmInputRelate());

            var oxygen = new OxygenEnergy(100, 0);

            player.AddOxygenEnergyInterface(oxygen);

            var genericAction = new GenericAction();

            player.AddGenericActionInterface(genericAction);
            player.AddLadderActionInterface(new LadderAction());

            var clipManager = new AnimatorClipManager();

            player.AddAnimatorClip(clipManager);

            if (!player.hasPlayerRotateLimit)
            {
                player.AddPlayerRotateLimit(false);
            }

            if (!player.hasFirePosition)
            {
                player.AddFirePosition();
            }

            if (!player.hasState)
            {
                player.AddState();
            }
            if (!player.hasStateInterVar)
            {
                player.AddStateInterVar(new StateInterCommands(), new StateInterCommands(),
                                        new UnityAnimationEventCommands(), new UnityAnimationEventCommands());
            }
            if (!player.hasStateBefore)
            {
                player.AddStateBefore();
            }
            if (!player.hasStateInterVarBefore)
            {
                player.AddStateInterVarBefore();
            }
            ComponentSynchronizer.SyncToStateComponent(player.state, player.stateInterface.State);

            if (!player.hasVehicleCmdSeq)
            {
                player.AddVehicleCmdSeq(0);
            }
            if (!player.hasControlledVehicle)
            {
                player.AddControlledVehicle();
            }

            if (!player.hasPlayerSkyMove)
            {
                player.AddPlayerSkyMove(false, -1);
            }

            if (!player.hasPlayerSkyMoveInterVar)
            {
                player.AddPlayerSkyMoveInterVar();
            }

            if (!player.hasCharacterBone)
            {
                player.AddCharacterBone(0, 0, false, 0, -1, true);
            }

            if (!player.hasNetworkWeaponAnimation)
            {
                player.AddNetworkWeaponAnimation(string.Empty, 0, string.Empty, 0);
            }

            if (!player.hasOverrideNetworkAnimator)
            {
                player.AddOverrideNetworkAnimator();
            }

            AddCameraStateNew(player);
            player.AddLocalEvents(new PlayerEvents());


            if (!player.hasPingStatistics)
            {
                player.AddPingStatistics();
            }

            player.AddTip();
            AttachAudio(contexts, player);
            AttachWeaponComponents(contexts, player);
            AttachStateInteract(player);
            AttachStatistics(player);

            if (!player.hasFreeData)
            {
                FreeData fd = new FreeData(contexts, player);
                if (player.hasStatisticsData)
                {
                    fd.AddFields(new ObjectFields(player.statisticsData.Statistics));
                }

                if (player.hasStatisticsServerData)
                {
                    fd.AddFields(new ObjectFields(player.statisticsServerData));
                }

                if (player.hasOxygenEnergy)
                {
                    fd.AddFields(new ObjectFields(player.oxygenEnergy));
                }
                player.AddFreeData(fd);
            }

            player.AddPlayerHitMaskController(new CommonHitMaskController(contexts.player, player));
            player.AddThrowingUpdate(false);
            player.AddThrowingAction();
            player.throwingAction.ActionData = new ThrowingActionData();
            Logger.Info("*********posted player initialize finish*********");
            DebugUtil.MyLog("posted player initialize finish", DebugUtil.DebugColor.Green);
            if (!SharedConfig.IsServer)
            {
                DebugUtil.InitShootArchiveC(player.entityKey.Value.ToString(), contexts.session.commonSession.RoomInfo.RoomDisplayId);
            }
            else
            {
                IEventArgs args = contexts.session.commonSession.FreeArgs as IEventArgs;
                if (null != args)
                {
                    args.Trigger(FreeTriggerConstant.POST_PLAYER_INI, new TempUnit("current", (FreeData)player.freeData.FreeData));
                }
            }
//            contexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity(ECategory.GameRes,
//                1004, 1, Vector3.zero);
        }