Default() public méthode

Sets the stage to a default state.
public Default ( ) : void
Résultat void
Exemple #1
0
        private idParticleStage ParseParticleStage(idLexer lexer)
        {
            idToken token;
            string  tokenLower;

            idParticleStage stage = new idParticleStage();

            stage.Default();

            while (true)
            {
                if (lexer.HadError == true)
                {
                    break;
                }
                else if ((token = lexer.ReadToken()) == null)
                {
                    break;
                }
                else
                {
                    tokenLower = token.ToString().ToLower();

                    if (tokenLower == "}")
                    {
                        break;
                    }
                    else if (tokenLower == "material")
                    {
                        token          = lexer.ReadToken();
                        stage.Material = idE.DeclManager.FindMaterial(token.ToString());
                    }
                    else if (tokenLower == "count")
                    {
                        stage.TotalParticles = lexer.ParseInt();
                    }
                    else if (tokenLower == "time")
                    {
                        stage.ParticleLife = lexer.ParseFloat();
                    }
                    else if (tokenLower == "cycles")
                    {
                        stage.Cycles = lexer.ParseFloat();
                    }
                    else if (tokenLower == "timeoffset")
                    {
                        stage.TimeOffset = lexer.ParseFloat();
                    }
                    else if (tokenLower == "deadtime")
                    {
                        stage.DeadTime = lexer.ParseFloat();
                    }
                    else if (tokenLower == "randomdistribution")
                    {
                        stage.RandomDistribution = lexer.ParseBool();
                    }
                    else if (tokenLower == "bunching")
                    {
                        stage.SpawnBunching = lexer.ParseFloat();
                    }
                    else if (tokenLower == "distribution")
                    {
                        token      = lexer.ReadToken();
                        tokenLower = token.ToString().ToLower();

                        if (tokenLower == "rect")
                        {
                            stage.Distribution = ParticleDistribution.Rectangle;
                        }
                        else if (tokenLower == "cyclinder")
                        {
                            stage.Distribution = ParticleDistribution.Cyclinder;
                        }
                        else if (tokenLower == "sphere")
                        {
                            stage.Distribution = ParticleDistribution.Sphere;
                        }
                        else
                        {
                            lexer.Error("bad distribution type: {0}", token.ToString());
                        }

                        stage.DistributionParameters = ParseParams(lexer, stage.DistributionParameters.Length);
                    }
                    else if (tokenLower == "direction")
                    {
                        token      = lexer.ReadToken();
                        tokenLower = token.ToString().ToLower();

                        if (tokenLower == "cone")
                        {
                            stage.Direction = ParticleDirection.Cone;
                        }
                        else if (tokenLower == "outward")
                        {
                            stage.Direction = ParticleDirection.Outward;
                        }
                        else
                        {
                            lexer.Error("bad direction type: {0}", token.ToString());
                        }

                        stage.DirectionParameters = ParseParams(lexer, stage.DirectionParameters.Length);
                    }
                    else if (tokenLower == "orientation")
                    {
                        token      = lexer.ReadToken();
                        tokenLower = token.ToString().ToLower();

                        if (tokenLower == "view")
                        {
                            stage.Orientation = ParticleOrientation.View;
                        }
                        else if (tokenLower == "aimed")
                        {
                            stage.Orientation = ParticleOrientation.Aimed;
                        }
                        else if (tokenLower == "x")
                        {
                            stage.Orientation = ParticleOrientation.X;
                        }
                        else if (tokenLower == "y")
                        {
                            stage.Orientation = ParticleOrientation.Y;
                        }
                        else if (tokenLower == "z")
                        {
                            stage.Orientation = ParticleOrientation.Z;
                        }
                        else
                        {
                            lexer.Error("bad orientation type: {0}", token.ToString());
                        }

                        stage.OrientationParameters = ParseParams(lexer, stage.OrientationParameters.Length);
                    }
                    else if (tokenLower == "custompath")
                    {
                        token      = lexer.ReadToken();
                        tokenLower = tokenLower.ToLower().ToLower();

                        if (tokenLower == "standard")
                        {
                            stage.CustomPath = ParticleCustomPath.Standard;
                        }
                        else if (tokenLower == "helix")
                        {
                            stage.CustomPath = ParticleCustomPath.Helix;
                        }
                        else if (tokenLower == "flies")
                        {
                            stage.CustomPath = ParticleCustomPath.Flies;
                        }
                        else if (tokenLower == "spherical")
                        {
                            stage.CustomPath = ParticleCustomPath.Orbit;
                        }
                        else
                        {
                            lexer.Error("bad path type: {0}", token.ToString());
                        }

                        stage.CustomPathParameters = ParseParams(lexer, stage.CustomPathParameters.Length);
                    }
                    else if (tokenLower == "speed")
                    {
                        ParseParametric(lexer, stage.Speed);
                    }
                    else if (tokenLower == "rotation")
                    {
                        ParseParametric(lexer, stage.RotationSpeed);
                    }
                    else if (tokenLower == "angle")
                    {
                        stage.InitialAngle = lexer.ParseFloat();
                    }
                    else if (tokenLower == "entitycolor")
                    {
                        stage.EntityColor = lexer.ParseBool();
                    }
                    else if (tokenLower == "size")
                    {
                        ParseParametric(lexer, stage.Size);
                    }
                    else if (tokenLower == "aspect")
                    {
                        ParseParametric(lexer, stage.Aspect);
                    }
                    else if (tokenLower == "fadein")
                    {
                        stage.FadeInFraction = lexer.ParseFloat();
                    }
                    else if (tokenLower == "fadeout")
                    {
                        stage.FadeOutFraction = lexer.ParseFloat();
                    }
                    else if (tokenLower == "fadeindex")
                    {
                        stage.FadeIndexFraction = lexer.ParseFloat();
                    }
                    else if (tokenLower == "color")
                    {
                        stage.Color = new Vector4(lexer.ParseFloat(), lexer.ParseFloat(), lexer.ParseFloat(), lexer.ParseFloat());
                    }
                    else if (tokenLower == "fadecolor")
                    {
                        stage.FadeColor = new Vector4(lexer.ParseFloat(), lexer.ParseFloat(), lexer.ParseFloat(), lexer.ParseFloat());
                    }
                    else if (tokenLower == "offset")
                    {
                        stage.Offset = new Vector3(lexer.ParseFloat(), lexer.ParseFloat(), lexer.ParseFloat());
                    }
                    else if (tokenLower == "animationframes")
                    {
                        stage.AnimationFrames = lexer.ParseInt();
                    }
                    else if (tokenLower == "animationrate")
                    {
                        stage.AnimationRate = lexer.ParseFloat();
                    }
                    else if (tokenLower == "boundsexpansion")
                    {
                        stage.BoundsExpansion = lexer.ParseFloat();
                    }
                    else if (tokenLower == "gravity")
                    {
                        token      = lexer.ReadToken();
                        tokenLower = token.ToString().ToLower();

                        if (tokenLower == "world")
                        {
                            stage.WorldGravity = true;
                        }
                        else
                        {
                            lexer.UnreadToken = token;
                        }

                        stage.Gravity = lexer.ParseFloat();
                    }
                    else
                    {
                        lexer.Error("unknown token {0}", token.ToString());
                    }
                }
            }

            // derive values.
            stage.CycleTime = (int)(stage.ParticleLife + stage.DeadTime) * 1000;

            return(stage);
        }
		private idParticleStage ParseParticleStage(idLexer lexer)
		{
			idToken token;
			string tokenLower;
			
			idParticleStage stage = new idParticleStage();
			stage.Default();

			while(true)
			{
				if(lexer.HadError == true)
				{
					break;
				}
				else if((token = lexer.ReadToken()) == null)
				{
					break;
				}
				else
				{
					tokenLower = token.ToString().ToLower();

					if(tokenLower == "}")
					{
						break;
					}
					else if(tokenLower == "material")
					{
						token = lexer.ReadToken();
						stage.Material = idE.DeclManager.FindMaterial(token.ToString());
					}
					else if(tokenLower == "count")
					{
						stage.TotalParticles = lexer.ParseInt();
					}
					else if(tokenLower == "time")
					{
						stage.ParticleLife = lexer.ParseFloat();
					}
					else if(tokenLower == "cycles")
					{
						stage.Cycles = lexer.ParseFloat();
					}
					else if(tokenLower == "timeoffset")
					{
						stage.TimeOffset = lexer.ParseFloat();
					}
					else if(tokenLower == "deadtime")
					{
						stage.DeadTime = lexer.ParseFloat();
					}
					else if(tokenLower == "randomdistribution")
					{
						stage.RandomDistribution = lexer.ParseBool();
					}
					else if(tokenLower == "bunching")
					{
						stage.SpawnBunching = lexer.ParseFloat();
					}
					else if(tokenLower == "distribution")
					{
						token = lexer.ReadToken();
						tokenLower = token.ToString().ToLower();

						if(tokenLower == "rect")
						{
							stage.Distribution = ParticleDistribution.Rectangle;
						}
						else if(tokenLower == "cyclinder")
						{
							stage.Distribution = ParticleDistribution.Cyclinder;
						}
						else if(tokenLower == "sphere")
						{
							stage.Distribution = ParticleDistribution.Sphere;
						}
						else
						{
							lexer.Error("bad distribution type: {0}", token.ToString());
						}

						stage.DistributionParameters = ParseParams(lexer, stage.DistributionParameters.Length);
					}
					else if(tokenLower == "direction")
					{
						token = lexer.ReadToken();
						tokenLower = token.ToString().ToLower();

						if(tokenLower == "cone")
						{
							stage.Direction = ParticleDirection.Cone;
						}
						else if(tokenLower == "outward")
						{
							stage.Direction = ParticleDirection.Outward;
						}
						else
						{
							lexer.Error("bad direction type: {0}", token.ToString());
						}

						stage.DirectionParameters = ParseParams(lexer, stage.DirectionParameters.Length);
					}
					else if(tokenLower == "orientation")
					{
						token = lexer.ReadToken();
						tokenLower = token.ToString().ToLower();

						if(tokenLower == "view")
						{
							stage.Orientation = ParticleOrientation.View;
						}
						else if(tokenLower == "aimed")
						{
							stage.Orientation = ParticleOrientation.Aimed;
						}
						else if(tokenLower == "x")
						{
							stage.Orientation = ParticleOrientation.X;
						}
						else if(tokenLower == "y")
						{
							stage.Orientation = ParticleOrientation.Y;
						}
						else if(tokenLower == "z")
						{
							stage.Orientation = ParticleOrientation.Z;
						}
						else 
						{
							lexer.Error("bad orientation type: {0}", token.ToString());
						}

						stage.OrientationParameters = ParseParams(lexer, stage.OrientationParameters.Length);
					}
					else if(tokenLower == "custompath")
					{
						token = lexer.ReadToken();
						tokenLower = tokenLower.ToLower().ToLower();

						if(tokenLower == "standard")
						{
							stage.CustomPath = ParticleCustomPath.Standard;
						}
						else if(tokenLower == "helix")
						{
							stage.CustomPath = ParticleCustomPath.Helix;
						}
						else if(tokenLower == "flies")
						{
							stage.CustomPath = ParticleCustomPath.Flies;
						}
						else if(tokenLower == "spherical")
						{
							stage.CustomPath = ParticleCustomPath.Orbit;
						}
						else
						{
							lexer.Error("bad path type: {0}", token.ToString());
						}

						stage.CustomPathParameters = ParseParams(lexer, stage.CustomPathParameters.Length);
					}
					else if(tokenLower == "speed")
					{					
						ParseParametric(lexer, stage.Speed);
					}
					else if(tokenLower == "rotation")
					{
						ParseParametric(lexer, stage.RotationSpeed);
					}
					else if(tokenLower == "angle")
					{
						stage.InitialAngle = lexer.ParseFloat();
					}
					else if(tokenLower == "entitycolor")
					{
						stage.EntityColor = lexer.ParseBool();
					}
					else if(tokenLower == "size")
					{
						ParseParametric(lexer, stage.Size);
					}
					else if(tokenLower == "aspect")
					{
						ParseParametric(lexer, stage.Aspect);
					}
					else if(tokenLower == "fadein")
					{
						stage.FadeInFraction = lexer.ParseFloat();
					}
					else if(tokenLower == "fadeout")
					{
						stage.FadeOutFraction = lexer.ParseFloat();
					}
					else if(tokenLower == "fadeindex")
					{
						stage.FadeIndexFraction = lexer.ParseFloat();
					}
					else if(tokenLower == "color")
					{
						stage.Color = new Vector4(lexer.ParseFloat(), lexer.ParseFloat(), lexer.ParseFloat(), lexer.ParseFloat());
					}
					else if(tokenLower == "fadecolor")
					{
						stage.FadeColor = new Vector4(lexer.ParseFloat(), lexer.ParseFloat(), lexer.ParseFloat(), lexer.ParseFloat());
					}
					else if(tokenLower == "offset")
					{
						stage.Offset = new Vector3(lexer.ParseFloat(), lexer.ParseFloat(), lexer.ParseFloat());
					}
					else if(tokenLower == "animationframes")
					{
						stage.AnimationFrames = lexer.ParseInt();
					}
					else if(tokenLower == "animationrate")
					{
						stage.AnimationRate = lexer.ParseFloat();
					}
					else if(tokenLower == "boundsexpansion")
					{
						stage.BoundsExpansion = lexer.ParseFloat();
					}
					else if(tokenLower == "gravity")
					{
						token = lexer.ReadToken();
						tokenLower = token.ToString().ToLower();

						if(tokenLower == "world")
						{
							stage.WorldGravity = true;
						}
						else
						{
							lexer.UnreadToken = token;
						}

						stage.Gravity = lexer.ParseFloat();
					}
					else
					{
						lexer.Error("unknown token {0}", token.ToString());
					}
				}
			}

			// derive values.
			stage.CycleTime = (int) (stage.ParticleLife + stage.DeadTime) * 1000;

			return stage;
		}