Axiom.Serialization.MaterialSerializer.ParseAlphaOpEx C# (CSharp) Метод

ParseAlphaOpEx() приватный Метод

private ParseAlphaOpEx ( string parameters, MaterialScriptContext context ) : bool
parameters string
context MaterialScriptContext
Результат bool
		protected static bool ParseAlphaOpEx( string parameters, MaterialScriptContext context )
		{
			string[] values = parameters.ToLower().Split( new char[] { ' ', '\t' } );

			if ( values.Length < 3 || values.Length > 6 )
			{
				LogParseError( context, "Bad alpha_op_ex attribute, wrong number of parameters (expected 3 or 6)." );
				return false;
			}

			LayerBlendOperationEx op = 0;
			LayerBlendSource src1 = 0;
			LayerBlendSource src2 = 0;
			float manual = 0.0f;
			float arg1 = 1.0f, arg2 = 1.0f;

			try
			{
				op = (LayerBlendOperationEx)ScriptEnumAttribute.Lookup( values[ 0 ], typeof( LayerBlendOperationEx ) );
				src1 = (LayerBlendSource)ScriptEnumAttribute.Lookup( values[ 1 ], typeof( LayerBlendSource ) );
				src2 = (LayerBlendSource)ScriptEnumAttribute.Lookup( values[ 2 ], typeof( LayerBlendSource ) );

				if ( op == LayerBlendOperationEx.BlendManual )
				{
					if ( values.Length < 4 )
					{
						LogParseError( context, "Bad alpha_op_ex attribute, wrong number of parameters (expected 4 for manual blend)." );
						return false;
					}

					manual = int.Parse( values[ 3 ] );
				}

				if ( src1 == LayerBlendSource.Manual )
				{
					int paramIndex = 3;
					if ( op == LayerBlendOperationEx.BlendManual )
					{
						paramIndex++;
					}

					if ( values.Length < paramIndex )
					{
						LogParseError( context, "Bad alpha_op_ex attribute, wrong number of parameters (expected {0}).", paramIndex - 1 );
						return false;
					}

					arg1 = StringConverter.ParseFloat( values[ paramIndex ] );
				}

				if ( src2 == LayerBlendSource.Manual )
				{
					int paramIndex = 3;

					if ( op == LayerBlendOperationEx.BlendManual )
					{
						paramIndex++;
					}
					if ( src1 == LayerBlendSource.Manual )
					{
						paramIndex++;
					}

					if ( values.Length < paramIndex )
					{
						LogParseError( context, "Bad alpha_op_ex attribute, wrong number of parameters (expected {0}).", paramIndex - 1 );
						return false;
					}

					arg2 = StringConverter.ParseFloat( values[ paramIndex ] );
				}
			}
			catch ( Exception ex )
			{
				LogParseError( context, "Bad alpha_op_ex attribute, {0}.", ex.Message );
				return false;
			}

			context.textureUnit.SetAlphaOperation( op, src1, src2, arg1, arg2, manual );

			return false;
		}