C# Artemis Entity System Tutorial

Artemis is a high performance Entity System framework for games, originally written in Java by Arni Arent and Tiago Costa, now ported to C#.
Its goal is to provide a clean API to abstract your game world organization into entities, components and systems.
Artemis has no dependencies (for PC, in Xbox and Windows Phone 7 we have one) and can be used with any game framework or library, 2D or 3D, and even multiplatform, if you use it with Mono/MonoTouch/Mono4Android.

Differences from the original version

We support all the features included in the original Java version, but we’ve also added the following features:

  • Multithreading Support (two ways of doing this)
  • Specialized System templates for your multithreading needs
  • Communication between Systems using a Blackboard approach
  • Bugs fixed, performance improvements
  • Xbox/WP7/Mono(Android/Linux/Mac/iOS) support
  • Events for intercepting adding/removal of entities/components
  • Blackboard for sharing common objects between systems
  • Entity Pool (to make objects reusable, minimize garbage collection activity, improve performance)
  • Small goodies, like feeding the EntityWorld with whole Entities(maybe loading from external resources), enabling/disabling systems and entities, getting Entity tag, API shortcuts(see unit tests for more on this), etc.

Getting Started

  • Entities are only an aggregation of Components, identified by a unique id
  • Components are only data
  • Systems publish/subscribe to Components, creating behavior

There is much more to tell about this paradigm and we already have rich articles which inspired this framework. Some of them:

And many more can be found here.

Your components must inherit from the class Component or ComponentPoolable if you want it to use the Artemis Component Pool. Example:

//Add this Attribute and extend ComponentPoolable if you want your Component to use Artemis Component Pool
[Artemis.Attributes.ArtemisComponentPool(InitialSize=5,Resizes=true, ResizeSize=20, isSupportMultiThread=false)]
class Velocity : ComponentPoolable
        private float velocity;
        private float angle;

        public Velocity() { }

        public Velocity(float vector)
            velocity = vector;

        public Velocity(float velocity, float angle)
            this.velocity = velocity;
            this.angle = angle;

        public float Speed {
            get { return velocity;}
            set { velocity = value; }

        public float Angle
            get { return angle; }
            set { angle = value;}

        public void AddAngle(float a)
            angle = (angle + a) % 360;

        public float AngleAsRadians
            get { return (float)Math.PI * angle / 180.0f; }

        //obligatory for poolable Components
        public void Cleanup()
             coords = Vector3.Zero;

A sample for entity assembling:

Entity e = world.CreateEntity(); // you can pass an unique ID as first parameter.
e.AddComponent(new Transform(200,400));
e.AddComponentFromPool(new Velocity(2.4f,0.9f)); // use AddComponentFromPool if the Component extend from ComponentPoolable
e.Refresh();// always call Refresh() when adding/removing components!

Your systems should inherit from one of the following templates:

  • EntitySystem – the simplest system template, not tied to components, good for stuff like collision
  • EntityProcessingSystem – a template for processing many entities, tied to components
  • IntervalEntitySystem – a simple system template, not tied to components, process periodically, based on world delta.
  • IntervalEntityProcessingSystem – a template that process entities periodically, based on world delta, tied to components.
  • ParallelEntityProcessingSystem – a template to leverage your multicore CPU for processing many entities, tied to components
  • ProcessingSystem – a template that process whichever logic you desire, without being tied to components
  • QueueProcessingSystem – instead of filter by components, this system process entities that are added to its public queue
  • HybridQueueProcessingSystem – process entities by queue and components
  • QueueProcessingSystemThreadSafe – process entities by a public static thread safe queue
  • FQueueSystemProcessingThreadSafe – process anything (not only entities) added to its public static thread safe queue
  • TagSystem – a simple system template, not tied to components, process a tagged entity
  • IntervalTagSystem – a simple system template, not tied to components, process a tagged entity periodically, based on world delta.
  • DelayedEntitySystem – a simple system template that starts process after a given time, based on world delta.
  • DelayedEntityProcessingSystem – a template that starts processing entities after a given time, based on world delta. Tied to components

And here is a system example, using Velocity and Transform components to create the Movement behavior:

//Add this attribute so the EntityWorld knows the systems it should execute, use the Layer to determine execution order
[Artemis.Attributes.ArtemisEntitySystem(ExecutionType = ExecutionType.UpdateSynchronous, Layer = 1)]
public class MovementSystem : EntityProcessingSystem {

    public MovementSystem() : base(Aspect.All(typeof(Transform), typeof(Velocity))) { }

    public override void Initialize() {}

    public override void Process(Entity e) {
        Velocity velocity = e.getComponent();
        float v = velocity.Speed;

        Transform transform = e.getComponent();

        float r = velocity.AngleAsRadians;

        float xn = transform.X + (TrigLUT.Cos(r) * v * world.Delta);
        float yn = transform.Y + (TrigLUT.Sin(r) * v * world.Delta);

        transform.SetLocation(xn, yn);

On your game initialization, create a new EntityWorld and initialize it:

var world = new EntityWorld();
world.InitializeAll(true); // pass true/false to enable/disable DataAttributes on Systems

Update or Draw the World:

world.Draw(); // do this on a different loop, e.g: every 15 ms

And you are good to go. The Entity object has some intuitive methods like Delete(), GetComponent(), RemoveComponent(), which you can see in action on the example game.


Aspects are used in the constructor of your entity systems to tell them which components they should be interested. At the moment we have three methods to build Aspects:

  • Aspect.All(params Type[] types) – Most of the time you will use this option, so the system processes entities which have all components of the Aspect.
  • Aspect.One(params Type[] types) – The system will process entities which have at least one of the components of the Aspect.
  • Aspect.Exclude(params Type[] types) – The system will not process entities which have at least one of the components of the Aspect.

You can also compose your Aspect utilizing these methods together, example:

public LogEnemySystem() : base(Aspect.All(typeof(Health)).One(typeof(Koopa),typeof(Goomba),typeof(Magikoopa)).exclude(typeof(Ghost))) {}

Extending Systems

It’s quite simple to extend the EntitySystem with your own logic, an example can be found here, which gives us less setup on systems which only uses Aspect.All(), example:

[Artemis.Attributes.ArtemisEntitySystem(ExecutionType = ExecutionType.UpdateSynchronous, Layer = 1)]
public class MovementSystem : EntityComponentProcessingSystem {
    public override void Process(Entity e,Transform transform, Velocity velocity) {
        float v = velocity.Speed;
        float r = velocity.AngleAsRadians;

        float xn = transform.X + (TrigLUT.Cos(r) * v * world.Delta);
        float yn = transform.Y + (TrigLUT.Sin(r) * v * world.Delta);

        transform.SetLocation(xn, yn);


Create your entity templates to avoid manually creating and configuring entities:

public EnemyTemplate : Artemis.IEntityTemplate {
	public Entity BuildEntity(Entity e,EntityWorld entityWorld, params object[] args) {
		e.AddComponent(new Transform(200,400));
		e.AddComponent(new Velocity(2.4f,0.9f));

Create your entities with the template applied:

var enemy = world.CreateEntityFromTemplate("BulletExplosion",array_of_parameters); // you can also use an alternative signature passing a custom unique id as the first parameter.


You can easily share common objects between systems using the blackboard, here is a XNA example, on the game initialization:

EntitySystem.BlackBoard.SetEntry("ContentManager", Content);
EntitySystem.BlackBoard.SetEntry("GraphicsDevice", GraphicsDevice);
EntitySystem.BlackBoard.SetEntry("SpriteBatch", spriteBatch);

Then you can retrieve the objects inside systems like this:

this.device = EntitySystem.BlackBoard.GetEntry("GraphicsDevice");
this.spriteBatch = EntitySystem.BlackBoard.GetEntry("SpriteBatch");
this.contentManager = EntitySystem.BlackBoard.GetEntry("ContentManager");

Games created with Artemis C#

Magnetic by Nature – by Tripleslash Studios. They also have a Kickstarter running for the game, support it!

Discussion, issues, suggestions

We have a forum section here.

 Use It !!!


  1. #1 by do auto insurance quotes affect your credit on 25 de outubro de 2016 - 8:30 am

    That’s an expert answer to an interesting question

  2. #2 by http://stanthonyscatholicchurch.org/media/293.html on 25 de outubro de 2016 - 8:34 am

    Therefore once I bought they i thought this is will be the best good still cheaply prepared bracelet most appropriate towards stocking stuffers. Then again it’s done amazingly and are thick so that it is never plastic or conveniently chipped metal. Our mom loved it. It is a little on the limited side so if you get a larger wrist i wouldnt encourage that it however it is quite worth that steal price tag!!

  3. #3 by http://dairyindia.com/Website/page/479.html on 25 de outubro de 2016 - 8:35 am

    This is certainly completely pretty. I love this plenty. That the estimate are pretty as well as box wrapped inside amazing bow. It isn’t the essential magnificent bracelet ever before, however for the price that it exceeds the expectations. Cannotwait on offer things at my mother of Mother’s evening!

  4. #4 by http://viadit.com/site/html/491.html on 25 de outubro de 2016 - 8:38 am

    sThe premium that it awesome, however, because ones models run mini need it a person shape increase.If you’re 5f 4inches therefore duration requirements adjusting or even simply don completely tall shoes or boots. Other than that adored the particular outfit

  5. #5 by http://arewater.com/nc-cms/content/upload/page/334.html on 25 de outubro de 2016 - 8:38 am

    sThe premium they great, still, simply because the actual models run mini consume information technology single shape upwards.If you are 5f 4inches subsequently size needs adjusting or even really use quite high shoes or boots. Other than that liked the dress

  6. #6 by http://hutchingsfuneralchapel.com/cp/public/285.html on 25 de outubro de 2016 - 8:38 am

    sThe grade that awesome, still, considering on dimensions run limited choose that it any size upwards.If you’re 5f 4inches subsequently span ought modifying or simply use quite tall footwear. Besides that loved that the outfit

  7. #7 by pet ramp on 25 de outubro de 2016 - 8:39 am

    This is getting a little bit extra subjective, still I much desire the Zune Marketplace. The interface is colorful, includes even further flair, and some cool functions such as ‘Mixview’ that enable yourself out of the blue see equivalent albums, tunes, or other customers comparable towards what you are listening toward. Clicking upon a single of individuals will middle on that item, and another fixed of “neighbors” will come into perspective, permitting you in direction of navigate about studying through very similar artists, songs, or consumers. Talking of end users, the Zune “Social” is furthermore superior enjoyment, allowing for on your own uncover other people with shared tastes and becoming pals with them. By yourself then can listen towards a playlist intended dependent on an amalgamation of what all your good friends are listening towards, which is as well thrilling. Those nervous with privateness will be relieved toward understand oneself can prevent the general public versus observing your personal listening behaviors if you thus determine.

  8. #8 by car insurance on 25 de outubro de 2016 - 9:04 am

    At last! Someone with real expertise gives us the answer. Thanks!

  9. #9 by fine art prints sale on 25 de outubro de 2016 - 9:11 am

    Zune and iPod: Most us citizens examine the Zune towards the Touch, nonetheless after observing how slim and astonishingly little and gentle it is, I consider it in the direction of be a in its place distinctive hybrid that brings together properties of either the Touch and the Nano. It really is incredibly vibrant and beautiful OLED show is somewhat smaller sized than the touch screen, nonetheless the participant itself feels quite a little bit scaled-down and lighter. It weighs in excess of 2/3 as much, and is noticeably more compact in just width and height, though currently being simply a hair thicker.

  10. #10 by the cheapest auto insurance in nc on 25 de outubro de 2016 - 9:11 am

    As Charlie Sheen says, this article is “WINNING!”

  11. #11 by اطفال on 25 de outubro de 2016 - 9:21 am

    There is apparently a bunch to realize about this. I assume you made certain good points in features also.

  12. #12 by hoverboard Belgium on 25 de outubro de 2016 - 9:28 am

    There are numerous self-sufficient learning ability you will be wanting to nutriment as part of your trainees.

  13. #13 by http://www.groundworkproject.org/ on 25 de outubro de 2016 - 9:35 am

    Your post has moved the debate forward. Thanks for sharing!

  14. #14 by http://motosruta52.com/paying-too-much-on-car-insurance.html on 25 de outubro de 2016 - 9:38 am

    It’s a relief to find someone who can explain things so well

  15. #15 by http://www.rosylia.net/ on 25 de outubro de 2016 - 9:41 am

    kalo kebiasaan saya, adalah harus ada laptop dan konesksi jkekekekekbukan itu!!! pertu kenyang iya, rokok, susu ultra *ah kayak anak kecil yah*, iringan musikZilhaq hobi minum susu yah?

  16. #16 by NIKE Free ナイキ フリー on 25 de outubro de 2016 - 9:47 am

    NIKE|ナイキ専門店。ナイキ スニーカー,ナイキ エアジョーダン,ナイキ エアマックス,ナイキ コルテッツ,ナイキ iPhone ケース,ナイキ リュックの専門店ならではの品揃え!NIKE|ナイキはサービスを頑張ります!

  17. #17 by etat des risques naturels on 25 de outubro de 2016 - 9:50 am

    Im thankful for the blog post.Really looking forward to read more. Really Great.

  18. #18 by http://microrentacar.com/changing-insurance-to-new-car.html on 25 de outubro de 2016 - 10:00 am

    products. That tweet should really help Jac when negotiations for her contract for next season comes up. Though if Jac’s tweet is true, I can only assume she is a spokesperson for some pharmaceutical company. Maybe she is so strung out on some drug she can’t remember she is the spokesperson.

1 427 428 429
(não será publicado)