Ejemplo n.º 1
0
        public virtual void OnStart()
        {
            ((Task)this).OnStart();
            this._agent = this.Agent;
            this._agent.RuntimeMotivationInPhoto = this._agent.AgentData.StatsTable[5];
            this._prevStateType   = this._agent.StateType;
            this._agent.StateType = AIProject.Definitions.State.Type.Immobility;
            this._poseIDList      = ListPool <int> .Get();

            NavMeshAgent navMeshAgent = this._agent.NavMeshAgent;

            navMeshAgent.set_isStopped(true);
            this._prevPriority = navMeshAgent.get_avoidancePriority();
            navMeshAgent.set_avoidancePriority(Singleton <Resources> .Instance.AgentProfile.AvoidancePriorityStationary);
            this._player          = Singleton <Manager.Map> .Instance.Player;
            this._playerCameraCon = this._player.CameraControl;
            this._prevShotType    = this._playerCameraCon.ShotType;
            this._isFadeOut       = false;
            this._poseStateTable  = (ReadOnlyDictionary <int, ValueTuple <PoseKeyPair, bool> >)null;
            this._poseInfo        = new ValueTuple <PoseKeyPair, bool>(new PoseKeyPair(), false);
            Dictionary <int, ValueTuple <PoseKeyPair, bool> > source;

            if (Singleton <Resources> .Instance.Animation.AgentGravurePoseTable.TryGetValue(this._agent.ChaControl.fileParam.personality, out source) && !source.IsNullOrEmpty <int, ValueTuple <PoseKeyPair, bool> >())
            {
                this._poseStateTable = new ReadOnlyDictionary <int, ValueTuple <PoseKeyPair, bool> >((IDictionary <int, ValueTuple <PoseKeyPair, bool> >)source);
                this._poseIDList.AddRange((IEnumerable <int>) this._poseStateTable.get_Keys());
                this._lastPoseID = this._poseIDList[Random.Range(0, this._poseIDList.Count)];
                this._poseStateTable.TryGetValue(this._lastPoseID, ref this._poseInfo);
            }
            this._poseOutAnimAction = new Subject <Unit>();
            ObservableExtensions.Subscribe <Unit>(Observable.Take <Unit>(Observable.TakeUntilDestroy <Unit>((IObservable <M0>) this._poseOutAnimAction, (Component)this._agent), 1), (System.Action <M0>)(_ =>
            {
                this._isFadeOut = true;
                this.PlayOutAnimation(this._poseInfo);
                this._isWait = (Func <AgentActor, bool>)(actor => actor.Animation.PlayingOutAnimation);
            }));
            this._poseReplayAnimAction = new Subject <Unit>();
            ObservableExtensions.Subscribe <Unit>(Observable.TakeUntilDestroy <Unit>((IObservable <M0>) this._poseReplayAnimAction, (Component)this._agent), (System.Action <M0>)(_ =>
            {
                if (this._poseIDList.IsNullOrEmpty <int>())
                {
                    this._poseOutAnimAction.OnNext(Unit.get_Default());
                }
                else
                {
                    if (this._poseIDList.Count == 1)
                    {
                        this._agent.ClearItems();
                        this.PlayInAnimation(this._poseInfo);
                    }
                    else
                    {
                        List <int> toRelease = ListPool <int> .Get();
                        toRelease.AddRange((IEnumerable <int>) this._poseIDList);
                        toRelease.Remove(this._lastPoseID);
                        this._lastPoseID = toRelease[Random.Range(0, toRelease.Count)];
                        ListPool <int> .Release(toRelease);
                        this._poseStateTable.TryGetValue(this._lastPoseID, ref this._poseInfo);
                        this._agent.ClearItems();
                        this.PlayInAnimation(this._poseInfo);
                    }
                    this._isWait      = (Func <AgentActor, bool>)(actor => actor.Animation.PlayingInAnimation);
                    this._onEndAction = (Subject <Unit>)null;
                }
            }));
            this._poseLoopEndAnimAction = new Subject <Unit>();
            ObservableExtensions.Subscribe <Unit>(Observable.TakeUntilDestroy <Unit>((IObservable <M0>) this._poseLoopEndAnimAction, (Component)this._agent), (System.Action <M0>)(_ =>
            {
                this.PlayOutAnimation(this._poseInfo);
                this._isWait      = (Func <AgentActor, bool>)(actor => actor.Animation.PlayingOutAnimation);
                this._onEndAction = this._poseReplayAnimAction;
            }));
            this.PlayInAnimation(this._poseInfo);
            this._isWait      = (Func <AgentActor, bool>)(actor => actor.Animation.PlayingInAnimation);
            this._onEndAction = (Subject <Unit>)null;
        }