Exemple #1
0
        public override float Run <T>(Dictionary <string, float> variables, CommandExecutor <T> executor, Dictionary <string, BoardFluid> dropPositions)
        {
            int   arrayLength = (int)variables[FluidArray.GetArrayLengthVariable(ArrayName)];
            float floatIndex  = IndexBlock.Run(variables, executor, dropPositions);

            if (float.IsInfinity(floatIndex) || float.IsNaN(floatIndex))
            {
                throw new InvalidNumberException(BlockID, floatIndex);
            }

            int index = (int)floatIndex;

            if (index < 0 || index >= arrayLength)
            {
                throw new ArrayIndexOutOfRange(BlockID, ArrayName, arrayLength, index);
            }

            return(variables[FluidArray.GetArrayIndexName(ArrayName, index)]);
        }
Exemple #2
0
 public override float Run <T>(Dictionary <string, float> variables, CommandExecutor <T> executor, Dictionary <string, BoardFluid> dropPositions)
 {
     return(variables[FluidArray.GetArrayLengthVariable(ArrayName)]);
 }