Exemple #1
0
        public static SoundId AsSoundId(Character character, IExpression expression, SoundId failover)
        {
            if (expression == null || expression.IsValid == false)
            {
                return(failover);
            }

            var result = expression.Evaluate(character);

            if (result.Length > 0 && result[0].NumberType != NumberType.None)
            {
                if (result.Length > 1 && result[1].NumberType != NumberType.None)
                {
                    return(new SoundId(result[0].IntValue, result[1].IntValue));
                }

                return(new SoundId(result[0].IntValue, 0));
            }

            return(failover);
        }
        public static SoundId AsSoundId(Object state, IExpression expression, SoundId failover)
        {
            if (expression == null || expression.IsValid == false)
            {
                return(failover);
            }

            Number[] result = expression.Evaluate(state);

            if (result.Length > 0 && result[0].NumberType != NumberType.None)
            {
                if (result.Length > 1 && result[1].NumberType != NumberType.None)
                {
                    return(new SoundId(result[0].IntValue, result[1].IntValue));
                }
                else
                {
                    return(new SoundId(result[0].IntValue, 0));
                }
            }

            return(failover);
        }