Abstract class defining the interface to be implemented by particle affectors.
        /// <summary>
        ///		Adds an affector to this particle system.
        ///	 </summary>
        ///	 <remarks>
        ///		Particles are modified over time in a particle system by affectors - see the ParticleAffector
        ///		class for more details.
        /// </remarks>
        /// <param name="emitterType">
        ///		string identifying the affector type to create. Affector types are defined
        ///		by registering new factories with the manager - see ParticleAffectorFactory for more details.
        ///		Affector types can be extended by plugin authors.
        /// </param>
        /// <returns></returns>
        public ParticleAffector AddAffector(string affectorType)
        {
            ParticleAffector affector = ParticleSystemManager.Instance.CreateAffector(affectorType);

            affectorList.Add(affector);
            return(affector);
        }
        public void RemoveAffector(int index)
        {
            Debug.Assert(index < affectorList.Count, "Affector index out of bounds!");
            ParticleAffector affector = affectorList[index];

            // ParticleSystemManager.Instance.DestroyAffector(affector);
            affectorList.RemoveAt(index);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="line"></param>
        /// <param name="affector"></param>
        private void ParseAffectorAttrib(string line, ParticleAffector affector)
        {
            string[] values = line.Split(new char[] { ' ' }, 2);

            if (!(affector.SetParam(values[0], values[1])))
            {
                ParseHelper.LogParserError(values[0], affector.Type, "Command not found.");
            }
        }
Ejemplo n.º 4
0
			/// <see cref="Translator.Translate"/>
			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 );
					}
				}
			}
Ejemplo n.º 5
0
        public virtual void CopyTo(ParticleAffector affector)
        {
            // loop through all registered commands and copy from this instance to the target instance
            foreach (var key in this.commandTable.Keys)
            {
                // get the value of the param from this instance
                var val = ((IPropertyCommand)this.commandTable[key]).Get(this);

                // set the param on the target instance
                affector.SetParam(key, val);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="emitter"></param>
        public virtual void CopyTo(ParticleAffector affector)
        {
            // loop through all registered commands and copy from this instance to the target instance
            foreach (DictionaryEntry entry in commandTable)
            {
                string name = (string)entry.Key;

                // get the value of the param from this instance
                string val = ((ICommand)entry.Value).Get(this);

                // set the param on the target instance
                affector.SetParam(name, val);
            }
        }
        /// <summary>
        ///		Cloning will deep copy all particle emitters and effectors, but not particles. The
        ///		system's name is also not copied.
        /// </summary>
        /// <returns></returns>
        public void CopyTo(ParticleSystem system)
        {
            // remove the target's emitters and affectors
            system.RemoveAllEmitters();
            system.RemoveAllAffectors();

            // loop through emitter and affector lists and copy them over
            foreach (ParticleEmitter emitter in emitterList)
            {
                ParticleEmitter newEmitter = system.AddEmitter(emitter.Type);
                emitter.CopyTo(newEmitter);
            }

            foreach (ParticleAffector affector in affectorList)
            {
                ParticleAffector newAffector = system.AddAffector(affector.Type);
                affector.CopyTo(newAffector);
            }
            system.ParticleQuota = this.ParticleQuota;
            system.MaterialName  = this.MaterialName;
            system.SetDefaultDimensions(this.defaultWidth, this.defaultHeight);
            system.cullIndividual       = this.cullIndividual;
            system.sorted               = this.sorted;
            system.localSpace           = this.localSpace;
            system.iterationInterval    = this.iterationInterval;
            system.iterationIntervalSet = this.iterationIntervalSet;
            system.nonvisibleTimeout    = this.nonvisibleTimeout;
            system.nonvisibleTimeoutSet = this.nonvisibleTimeoutSet;
            if (this.color != null)
            {
                system.color = new ColorEx(this.color);
            }
            // last frame visible and time since last visible should be left default
            system.RendererName = this.RendererName;
            // FIXME
            if (system.renderer != null && renderer != null)
            {
                renderer.CopyParametersTo(system.renderer);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="line"></param>
        /// <param name="system"></param>
        private void ParseAffector(string type, TextReader script, ParticleSystem system)
        {
            ParticleAffector affector = system.AddAffector(type);

            string line = "";

            while (line != null)
            {
                line = ParseHelper.ReadLine(script);

                if (!(line.Length == 0 || line.StartsWith("//")))
                {
                    if (line == "}")
                    {
                        // finished with this affector
                        break;
                    }
                    else
                    {
                        ParseAffectorAttrib(line.ToLower(), affector);
                    }
                } // if
            }     // while
        }
Ejemplo n.º 9
0
		/// <summary>
		///
		/// </summary>
        /// <param name="affector"></param>
		public virtual void CopyTo( ParticleAffector affector )
		{
			// loop through all registered commands and copy from this instance to the target instance
			foreach ( string key in commandTable.Keys )
			{
				// get the value of the param from this instance
				string val = ( (IPropertyCommand)commandTable[ key ] ).Get( this );

				// set the param on the target instance
				affector.SetParam( key, val );
			}
		}
 /// <summary>
 ///		Destroys the affector referenced by the parameter.
 /// </summary>
 /// <param name="e">The Affector to destroy.</param>
 public virtual void Destroy(ParticleAffector e)
 {
     // remove the affector from the list
     affectorList.Remove(e);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="line"></param>
        /// <param name="affector"></param>
        private void ParseAffectorAttrib(string line, ParticleAffector affector)
        {
            string[] values = line.Split(new char[] {' '}, 2);

            if(!(affector.SetParam(values[0], values[1]))) {
                ParseHelper.LogParserError(values[0], affector.Type, "Command not found.");
            }
        }
Ejemplo n.º 12
0
			public ParticleAffectorTranslator()
				: base()
			{
				_Affector = null;
			}
        /// <summary>
        /// 
        /// </summary>
        /// <param name="emitter"></param>
        public virtual void CopyTo(ParticleAffector affector)
        {
            // loop through all registered commands and copy from this instance to the target instance
            foreach(DictionaryEntry entry in commandTable) {
                string name = (string)entry.Key;

                // get the value of the param from this instance
                string val = ((ICommand)entry.Value).Get(this);

                // set the param on the target instance
                affector.SetParam(name, val);
            }
        }
Ejemplo n.º 14
0
		/// <summary>
		///		Destroys the affector referenced by the parameter.
		/// </summary>
		/// <param name="e">The Affector to destroy.</param>
		public virtual void Destroy( ParticleAffector e )
		{
			// remove the affector from the list
			affectorList.Remove( e );
		}