public override void Translate( ScriptCompiler compiler, AbstractNode node )
{
ObjectAbstractNode obj = (ObjectAbstractNode)node;
// Must have a type as the first value
if ( obj.Values.Count == 0 )
{
compiler.AddError( CompileErrorCode.StringExpected, obj.File, obj.Line );
return;
}
string type = string.Empty;
if ( !getString( obj.Values[ 0 ], out type ) )
{
compiler.AddError( CompileErrorCode.InvalidParameters, obj.File, obj.Line );
return;
}
ParticleSystem system = (ParticleSystem)obj.Parent.Context;
_Affector = system.AddAffector( type );
foreach ( AbstractNode i in obj.Children )
{
if ( i is PropertyAbstractNode )
{
PropertyAbstractNode prop = (PropertyAbstractNode)i;
string value = string.Empty;
// Glob the values together
foreach ( AbstractNode it in prop.Values )
{
if ( it is AtomAbstractNode )
{
if ( string.IsNullOrEmpty( value ) )
value = ( (AtomAbstractNode)it ).Value;
else
value = value + " " + ( (AtomAbstractNode)it ).Value;
}
else
{
compiler.AddError( CompileErrorCode.InvalidParameters, prop.File, prop.Line );
break;
}
}
if ( !_Affector.SetParam( prop.Name, value ) )
{
compiler.AddError( CompileErrorCode.InvalidParameters, prop.File, prop.Line );
}
}
else
{
_processNode( compiler, i );
}
}
}