Beispiel #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="game">Game</param>
        /// <param name="name">Name</param>
        /// <param name="description">Particle system description</param>
        /// <param name="emitter">Particle emitter</param>
        public ParticleSystemCpu(Game game, string name, ParticleSystemDescription description, ParticleEmitter emitter)
        {
            this.Game = game;
            this.Name = name;

            this.parameters = new ParticleSystemParams(description) * emitter.Scale;

            var imgContent = new ImageContent()
            {
                Streams = ContentManager.FindContent(description.ContentPath, description.TextureName),
            };

            this.Texture      = game.ResourceManager.CreateResource(imgContent);
            this.TextureCount = (uint)imgContent.Count;

            this.Emitter = emitter;
            this.Emitter.UpdateBounds(this.parameters);
            this.MaxConcurrentParticles = this.Emitter.GetMaximumConcurrentParticles(description.MaxDuration);

            this.particles = new VertexCpuParticle[this.MaxConcurrentParticles];

            this.buffer = new EngineBuffer <VertexCpuParticle>(game.Graphics, description.Name, this.particles, true);
            buffer.AddInputLayout(game.Graphics.CreateInputLayout(DrawerPool.EffectDefaultCPUParticles.RotationDraw.GetSignature(), VertexCpuParticle.Input(BufferSlot)));
            buffer.AddInputLayout(game.Graphics.CreateInputLayout(DrawerPool.EffectDefaultCPUParticles.NonRotationDraw.GetSignature(), VertexCpuParticle.Input(BufferSlot)));

            this.TimeToEnd = this.Emitter.Duration + this.parameters.MaxDuration;
        }
Beispiel #2
0
 /// <summary>
 /// Dispose resources
 /// </summary>
 /// <param name="disposing">Free managed resources</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         buffer?.Dispose();
         buffer = null;
     }
 }
Beispiel #3
0
 protected override void WriteSqlServerVariable()
 {
     EnginePatternWriter.WriteSqlServerVariable(new TestSqlServerVariable(EngineBuffer.Flush(), ++sql_var_incrementor), EngineCurrentKeyPress);
 }
Beispiel #4
0
 protected override void WriteSarbId()
 {
     EnginePatternWriter.WriteSarbId(new TestSarbId(EngineBuffer.Flush(), ++sarb_id_incrementor), EngineCurrentKeyPress);
 }
Beispiel #5
0
 protected override void WriteNumericConstant()
 {
     EnginePatternWriter.WriteNumericConstant(new TestNumericConstant(EngineBuffer.Flush(), ++num_const_incrementor), EngineCurrentKeyPress);
 }
Beispiel #6
0
 protected override void WriteOtherKeyword()
 {
     EnginePatternWriter.WriteKeyword(new TestOtherKeyword(EngineBuffer.FlushKeyword().Value, ++oth_keyword_incrementor), EngineCurrentKeyPress);
 }
Beispiel #7
0
 protected override void WriteControlFlowKeyword()
 {
     EnginePatternWriter.WriteKeyword(new TestControlFlowKeyword(EngineBuffer.FlushKeyword().Value, ++cf_keyword_incrementor), EngineCurrentKeyPress);
 }
Beispiel #8
0
 protected override void WriteTextConstant()
 {
     EnginePatternWriter.WriteTextConstant(new MeasureTextConstantSegment(EngineBuffer.Flush(), 0), EngineCurrentKeyPress);
 }
Beispiel #9
0
 protected override void WriteOrganisationId()
 {
     EnginePatternWriter.WriteOrganisationId(new MeasureOrganisationIdSegment(EngineBuffer.Flush(), ++org_id_incrementer), EngineCurrentKeyPress);
 }
Beispiel #10
0
 protected override void WriteOtherKeyword()
 {
     EnginePatternWriter.WriteKeyword(new MeasureKeywordSegment(EngineBuffer.FlushKeyword().Value, 0), EngineCurrentKeyPress);
 }
Beispiel #11
0
 protected override void WriteOperatorKeyword()
 {
     EnginePatternWriter.WriteKeyword(new MeasureKeywordSegment(EngineBuffer.FlushKeyword().Value, ++operator_incrementor), EngineCurrentKeyPress);
 }
Beispiel #12
0
 protected override void WriteFunctionKeyword()
 {
     EnginePatternWriter.WriteKeyword(new MeasureFunctionKeywordSegment(EngineBuffer.FlushKeyword().Value, ++func_keyword_incrementor), EngineCurrentKeyPress);
 }
Beispiel #13
0
 protected override void WriteField()
 {
     EnginePatternWriter.WriteNumericConstant(new FilterVariableSegment(EngineBuffer.Flush(), ++var_incrementor), EngineCurrentKeyPress);
 }
Beispiel #14
0
 protected override void WriteFunctionKeyword()
 {
     EnginePatternWriter.WriteKeyword(new FilterKeywordSegment(EngineBuffer.FlushKeyword().Value, 0), EngineCurrentKeyPress);
 }
Beispiel #15
0
 protected override void WriteTextConstant()
 {
     EnginePatternWriter.WriteTextConstant(new TestTextConstant(EngineBuffer.Flush(), ++text_const_incrementor), EngineCurrentKeyPress);
 }
Beispiel #16
0
 protected override void WriteField()
 {
     EnginePatternWriter.WriteField(new TestField(EngineBuffer.Flush(), ++fld_incrementor), EngineCurrentKeyPress);
 }
Beispiel #17
0
 protected override void WriteSqlServerVariable()
 {
     EnginePatternWriter.WriteSqlServerVariable(new MeasureSqlServerVariableSegment(EngineBuffer.Flush(), 0), EngineCurrentKeyPress);
 }