Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
SpriteProcessor.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 
4 using SiliconStudio.Core;
5 using SiliconStudio.Paradox.Effects;
6 using SiliconStudio.Paradox.EntityModel;
7 using SiliconStudio.Paradox.Games;
8 
9 namespace SiliconStudio.Paradox.Engine
10 {
11  /// <summary>
12  /// The processor in charge of updating and drawing the entities having sprite components.
13  /// </summary>
14  internal class SpriteProcessor : EntityProcessor<SpriteProcessor.AssociatedData>
15  {
16  private RenderSystem renderSystem;
17 
18  public SpriteProcessor()
19  : base(new PropertyKey[] { SpriteComponent.Key, TransformationComponent.Key })
20  {
21  }
22 
23  protected internal override void OnSystemAdd()
24  {
25  renderSystem = Services.GetSafeServiceAs<RenderSystem>();
26  }
27 
28  public override void Draw(GameTime gameTime)
29  {
30  base.Draw(gameTime);
31 
32  // Update the entities to render to renderers
33  foreach (var renderProcessor in renderSystem.SpriteRenderProcessors)
34  {
35  renderProcessor.EntitiesToRender.Clear();
36  foreach (var entity in enabledEntities.Keys)
37  renderProcessor.EntitiesToRender.Add(entity);
38  }
39  }
40 
41  protected override AssociatedData GenerateAssociatedData(Entity entity)
42  {
43  return new AssociatedData
44  {
45  SpriteComponent = entity.Get(SpriteComponent.Key),
46  TransformationComponent = entity.Get(TransformationComponent.Key),
47  };
48  }
49 
50  public class AssociatedData
51  {
53 
55  }
56  }
57 }
Game entity. It usually aggregates multiple EntityComponent
Definition: Entity.cs:28
Defines Position, Rotation and Scale of its Entity.
Entity processor, triggered on various EntitySystem events such as Entity and Component additions and...
Add a Sprite to an Entity. It could be an animated sprite.
Current timing used for variable-step (real time) or fixed-step (game time) games.
Definition: GameTime.cs:31
Renders its RenderSystem.Pipeline, which will usually result in drawing all meshes, UI, etc...
Definition: RenderSystem.cs:18
A class that represents a tag propety.
Definition: PropertyKey.cs:17