예제 #1
0
        public override void UpdateConditionState(BitArray <ModelConditionFlag> flags)
        {
            ModelConditionState bestConditionState = null;
            var bestMatch = int.MinValue;

            // Find best matching ModelConditionState.
            foreach (var conditionState in _conditionStates)
            {
                var numStateBits        = conditionState.ConditionFlags.NumBitsSet;
                var numIntersectionBits = conditionState.ConditionFlags.CountIntersectionBits(flags);

                // If there's no intersection never select this.
                if (numIntersectionBits == 0)
                {
                    continue;
                }

                if (numIntersectionBits > bestMatch)
                {
                    bestConditionState = conditionState;
                    bestMatch          = numIntersectionBits;
                }
            }

            if (bestConditionState == null || bestMatch == 0)
            {
                bestConditionState = _defaultConditionState;
            }

            SetActiveConditionState(bestConditionState);

            foreach (var weaponMuzzleFlash in bestConditionState.WeaponMuzzleFlashes)
            {
                var visible = flags.Get(ModelConditionFlag.FiringA);
                for (var i = 0; i < _activeModelDrawConditionState.Model.ModelBoneInstances.Length; i++)
                {
                    var bone = _activeModelDrawConditionState.Model.ModelBoneInstances[i];
                    // StartsWith is a bit awkward here, but for instance AVCommance has WeaponMuzzleFlashes = { TurretFX }, and Bones = { TURRETFX01 }
                    if (bone.Name.StartsWith(weaponMuzzleFlash.BoneName.ToUpper()))
                    {
                        _activeModelDrawConditionState.Model.BoneVisibilities[i] = visible;
                    }
                }
            }
            ;

            AnimationState bestAnimationState = null;

            bestMatch = int.MinValue;

            // Find best matching ModelConditionState.
            foreach (var animationState in _animationStates)
            {
                var numStateBits        = animationState.TypeFlags.NumBitsSet;
                var numIntersectionBits = animationState.TypeFlags.CountIntersectionBits(flags);

                // If there's no intersection never select this.
                if (numIntersectionBits != numStateBits)
                {
                    continue;
                }

                if (numIntersectionBits > bestMatch)
                {
                    bestAnimationState = animationState;
                    bestMatch          = numIntersectionBits;
                }
            }

            if (bestAnimationState == null || bestMatch == 0)
            {
                bestAnimationState = _idleAnimationState;
            }

            SetActiveAnimationState(bestAnimationState);
        }
예제 #2
0
 protected override bool SetActiveAnimationState(AnimationState animationState, Random random)
 {
     return(base.SetActiveAnimationState(animationState, random));
 }
예제 #3
0
        public override void UpdateConditionState(BitArray <ModelConditionFlag> flags)
        {
            ModelConditionState bestConditionState = null;
            var bestMatch = int.MinValue;

            // Find best matching ModelConditionState.
            foreach (var conditionState in _conditionStates)
            {
                var numStateBits        = conditionState.ConditionFlags.NumBitsSet;
                var numIntersectionBits = conditionState.ConditionFlags.CountIntersectionBits(flags);

                // If there's no intersection never select this.
                if (numIntersectionBits != numStateBits)
                {
                    continue;
                }

                if (numIntersectionBits > bestMatch)
                {
                    bestConditionState = conditionState;
                    bestMatch          = numIntersectionBits;
                }
            }

            if (bestConditionState == null || bestMatch == 0)
            {
                bestConditionState = _defaultConditionState;
            }

            SetActiveConditionState(bestConditionState);

            AnimationState bestAnimationState = null;

            bestMatch = int.MinValue;

            // Find best matching ModelConditionState.
            foreach (var animationState in _animationStates)
            {
                var numStateBits        = animationState.TypeFlags.NumBitsSet;
                var numIntersectionBits = animationState.TypeFlags.CountIntersectionBits(flags);

                // If there's no intersection never select this.
                if (numIntersectionBits != numStateBits)
                {
                    continue;
                }

                if (numIntersectionBits > bestMatch)
                {
                    bestAnimationState = animationState;
                    bestMatch          = numIntersectionBits;
                }
            }

            if (bestAnimationState == null || bestMatch == 0)
            {
                bestAnimationState = _idleAnimationState;
            }

            SetActiveAnimationState(bestAnimationState);
        }