Example #1
0
    private void SetupPredictionData()
    {
        ItemID id = this.m_Player.GetCurrentItem(Hand.Right).m_Info.m_ID;

        if (this.m_PredictionData.ContainsKey((int)id))
        {
            return;
        }
        this.m_PredictionData[(int)id] = new Dictionary <AnimationClip, List <MeleeAttackPredictionData> >();
        RuntimeAnimatorController runtimeAnimatorController = this.m_Animator.runtimeAnimatorController;
        List <string>             list = this.m_PredictionDataClipNames[291];

        if (this.m_PredictionDataClipNames.TryGetValue((int)id, out list))
        {
            list = this.m_PredictionDataClipNames[(int)id];
        }
        else
        {
            list = this.m_PredictionDataClipNames[291];
        }
        AnimationClip[] animationClips = runtimeAnimatorController.animationClips;
        string[]        array          = new string[animationClips.Length];
        for (int i = 0; i < animationClips.Length; i++)
        {
            array[i] = animationClips[i].name;
        }
        for (int j = 0; j < list.Count; j++)
        {
            AnimationClip animationClip = null;
            for (int k = 0; k < animationClips.Length; k++)
            {
                if (array[k] == list[j])
                {
                    animationClip = animationClips[k];
                    break;
                }
            }
            this.m_PredictionData[(int)id][animationClip] = new List <MeleeAttackPredictionData>();
            for (int l = 0; l <= MeleeAttackPredictionData.s_NumSteps; l++)
            {
                float time = animationClip.length * ((float)l / (float)MeleeAttackPredictionData.s_NumSteps);
                animationClip.SampleAnimation(this.m_Player.gameObject, time);
                Vector3 position  = this.m_Player.GetCurrentItem(Hand.Right).m_DamagerStart.position;
                Vector3 position2 = this.m_Player.GetCurrentItem(Hand.Right).m_DamagerEnd.position;
                MeleeAttackPredictionData meleeAttackPredictionData = new MeleeAttackPredictionData();
                meleeAttackPredictionData.m_DamagerStart   = this.m_HeadTransform.InverseTransformPoint(position);
                meleeAttackPredictionData.m_DamagerEnd     = this.m_HeadTransform.InverseTransformPoint(position2);
                meleeAttackPredictionData.m_NormalizedTime = (float)l / (float)MeleeAttackPredictionData.s_NumSteps;
                this.m_PredictionData[(int)id][animationClip].Add(meleeAttackPredictionData);
            }
        }
    }
    private void SetupPredictionData()
    {
        Item   currentItem = this.m_Player.GetCurrentItem(Hand.Right);
        ItemID id          = currentItem.m_Info.m_ID;

        if (this.m_PredictionData.ContainsKey((int)id))
        {
            return;
        }
        this.m_PredictionData[(int)id] = new Dictionary <AnimationClip, List <MeleeAttackPredictionData> >();
        RuntimeAnimatorController runtimeAnimatorController = this.m_Animator.runtimeAnimatorController;
        List <string>             list = this.m_PredictionDataClipNames[291];

        if (this.m_PredictionDataClipNames.TryGetValue((int)id, out list))
        {
            list = this.m_PredictionDataClipNames[(int)id];
        }
        else
        {
            list = this.m_PredictionDataClipNames[291];
        }
        for (int i = 0; i < list.Count; i++)
        {
            AnimationClip animationClipByName = this.GetAnimationClipByName(runtimeAnimatorController, list[i]);
            this.m_PredictionData[(int)id][animationClipByName] = new List <MeleeAttackPredictionData>();
            for (int j = 0; j <= MeleeAttackPredictionData.s_NumSteps; j++)
            {
                float time = animationClipByName.length * ((float)j / (float)MeleeAttackPredictionData.s_NumSteps);
                animationClipByName.SampleAnimation(this.m_Player.gameObject, time);
                Vector3 position  = this.m_Player.GetCurrentItem(Hand.Right).m_DamagerStart.position;
                Vector3 position2 = this.m_Player.GetCurrentItem(Hand.Right).m_DamagerEnd.position;
                MeleeAttackPredictionData meleeAttackPredictionData = new MeleeAttackPredictionData();
                meleeAttackPredictionData.m_DamagerStart   = this.m_HeadTransform.InverseTransformPoint(position);
                meleeAttackPredictionData.m_DamagerEnd     = this.m_HeadTransform.InverseTransformPoint(position2);
                meleeAttackPredictionData.m_NormalizedTime = (float)j / (float)MeleeAttackPredictionData.s_NumSteps;
                this.m_PredictionData[(int)id][animationClipByName].Add(meleeAttackPredictionData);
            }
        }
    }