Stride Forums Archive

Difference between Get<TransformationComponent> and Transformation?

2 posts, 1359 views, 2015-02-01 to 2015-02-06

Borkason 2015-02-01 #1

Is there a difference between the next two lines?

agentEntity.Get<TransformationComponent>().Translation.X += 1;
agentEntity.Transformation.Translation.X += 1;

Both work in my case. I am asking because if there would be no difference, I could do the same with the SpriteComponent. But I cannot access the SpriteComponent Property directly.

agentEntity.Get<SpriteComponent>().SpriteEffect = SpriteEffects.FlipHorizontally;
agentEntity.Sprite.SpriteEffect = SpriteEffects.FlipHorizontally; // Does not work

xen2 (Virgile) 2015-02-06 #2

agentEntity.Get<TransformationComponent>() will actually use agentEntity.Transformation behind the scene.
This is to allow this “important” component to be cached and accessible easily through an Entity (it is widely used when iterating through entities).