Пример #1
0
        public override void Process(GameTime gameTime, int entityId)
        {
            var direction          = _alignableMapper.Get(entityId).Direction;
            var directionalTexture = _directionalTextureMapper.Get(entityId);
            var texture            = direction switch
            {
                Direction.NorthEast => directionalTexture.NorthEastTexture,
                Direction.SouthEast => directionalTexture.SouthEastTexture,
                Direction.SouthWest => directionalTexture.SouthWestTexture,
                Direction.NorthWest => directionalTexture.NorthWestTexture,
                _ => directionalTexture.NorthEastTexture,
            };

            var sprite = _spriteMapper.Get(entityId);

            if (sprite != null)
            {
                sprite.TextureRegion = textureManager.GetRandomTexture(texture);
            }
            else
            {
                sprite = new Sprite(textureManager.GetRandomTexture(texture));
                GetEntity(entityId).Attach(sprite);
            }

            sprite.Alpha = directionalTexture.Alpha;
        }