Esempio n. 1
0
 public void Update(float deltaTime, List <GameObject> nearbyNPC, GameMap map)
 {
     PhysicsProcessor.Update(deltaTime, nearbyNPC, map, this);
     StatsProcessor.Update(deltaTime, StatsComponent);
     SpriteProcessor.Update(deltaTime, SpriteComponent);
     AnimationProcessor.SwitchToFrameCategory(this);
 }
        public override EmitterSaveContentList Process(EmitterSaveContentList input, ContentProcessorContext context)
        {
            if (input.emitters.Count != 0)
            {
                string          directory       = System.IO.Path.GetDirectoryName(input.emitters[0].FileName) + @"\";
                SpriteProcessor spriteProcessor = new SpriteProcessor(directory);

                for (int i = 0; i < input.emitters.Count; i++)
                {
                    // 04/2015 Justin Johnson: This is a known break as a result of updates to
                    // the emitter save system. Particle blueprints were retired and the
                    // new ParticleBlueprint is a dummy object, not a real Sprite
                    //spriteProcessor.Process(input.emitters[i].ParticleBlueprint, context);
                }
            }
            return(input);
        }
Esempio n. 3
0
        protected override void PrepareCore(RenderContext context, RenderItemCollection opaqueList, RenderItemCollection transparentList)
        {
            spriteProcessor = SceneInstance.GetProcessor <SpriteProcessor>();
            if (spriteProcessor == null)
            {
                return;
            }

            // If no camera, early exit
            var camera = context.GetCurrentCamera();

            if (camera == null)
            {
                return;
            }
            var viewProjectionMatrix = camera.ViewProjectionMatrix;

            foreach (var spriteState in spriteProcessor.Sprites)
            {
                var sprite = spriteState.SpriteComponent.CurrentSprite;
                if (sprite == null)
                {
                    continue;
                }

                // Perform culling on group and accept
                if (!CurrentCullingMask.Contains(spriteState.SpriteComponent.Entity.Group))
                {
                    continue;
                }

                // Project the position
                // TODO: This could be done in a SIMD batch, but we need to figure-out how to plugin in with RenderMesh object
                var worldPosition = new Vector4(spriteState.TransformComponent.WorldMatrix.TranslationVector, 1.0f);

                Vector4 projectedPosition;
                Vector4.Transform(ref worldPosition, ref viewProjectionMatrix, out projectedPosition);
                var projectedZ = projectedPosition.Z / projectedPosition.W;

                var list = sprite.IsTransparent ? transparentList : opaqueList;

                list.Add(new RenderItem(this, spriteState, projectedZ));
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Calls a delegate method on each descendant sprite in this sprite.
 /// </summary>
 /// <param name="sp"></param>
 public void SpriteProc(SpriteProcessor sp)
 {
     foreach (Frame f in FrameList)
     {
         foreach (IDisplayListItem dli in f.DisplayList)
         {
             ICharacterReference cr = dli as ICharacterReference;
             if (cr != null)
             {
                 Sprite child = cr.Character as Sprite;
                 if (child != null)
                 {
                     sp(child);
                     child.SpriteProc(sp);
                 }
             }
         }
     }
 }
        protected override void PrepareCore(RenderContext context, RenderItemCollection opaqueList, RenderItemCollection transparentList)
        {
            spriteProcessor = SceneInstance.GetProcessor<SpriteProcessor>();
            if (spriteProcessor == null)
            {
                return;
            }

            // If no camera, early exit
            var camera = context.GetCurrentCamera();
            if (camera == null)
            {
                return;
            }
            var viewProjectionMatrix = camera.ViewProjectionMatrix;

            foreach (var spriteState in spriteProcessor.Sprites)
            {
                var sprite = spriteState.SpriteComponent.CurrentSprite;
                if(sprite == null || sprite.Texture == null || sprite.Region.Width <= 0 || sprite.Region.Height <= 0f)
                    continue;

                // Perform culling on group and accept
                if (!CurrentCullingMask.Contains(spriteState.SpriteComponent.Entity.Group))
                    continue;

                // Project the position
                // TODO: This could be done in a SIMD batch, but we need to figure-out how to plugin in with RenderMesh object
                var worldPosition = new Vector4(spriteState.TransformComponent.WorldMatrix.TranslationVector, 1.0f);

                Vector4 projectedPosition;
                Vector4.Transform(ref worldPosition, ref viewProjectionMatrix, out projectedPosition);
                var projectedZ = projectedPosition.Z / projectedPosition.W;

                var list = sprite.IsTransparent ? transparentList : opaqueList;

                list.Add(new RenderItem(this, spriteState, projectedZ));
            }
        }
Esempio n. 6
0
 public SpriteFrameProcessor(string directory, SpriteProcessor spriteProcessor) : base()
 {
     mDirectory       = directory;
     mSpriteProcessor = spriteProcessor;
 }
Esempio n. 7
0
 public void LoadContent(Game1 game)
 {
     gameMap.LoadContent(game);
     SpriteProcessor.LoadContent(game, unit.SpriteComponent);
     npcs.ForEach(n => SpriteProcessor.LoadContent(game, n.SpriteComponent));
 }
Esempio n. 8
0
 public void Draw(SpriteBatch spriteBatch, Vector2 position)
 {
     SpriteProcessor.Draw(spriteBatch, position, SpriteComponent, PhysicsComponent.FacingDirection);
 }
Esempio n. 9
0
 /// <summary>
 /// Calls a delegate method on each descendant sprite in this sprite.
 /// </summary>
 /// <param name="sp"></param>
 public void SpriteProc(SpriteProcessor sp)
 {
     foreach (Frame f in FrameList)
     {
         foreach (IDisplayListItem dli in f.DisplayList)
         {
             ICharacterReference cr = dli as ICharacterReference;
             if (cr != null)
             {
                 Sprite child = cr.Character as Sprite;
                 if (child != null)
                 {
                     sp(child);
                     child.SpriteProc(sp);
                 }
             }
         }
     }
 }
 public SpriteGridProcessor(SpriteProcessor spriteProcessor)
 {
     mSpriteProcessor = spriteProcessor;
 }