Ballz.GameSession.Physics.PhysicsControl.Update C# (CSharp) Метод

Update() публичный Метод

public Update ( GameTime time ) : void
time GameTime
Результат void
        public override void Update(GameTime time)
        {
            using (new PerformanceReporter(Game))
            {
                if (Game.Match.State != SessionState.Running)
                    return;

                var worldState = Game.Match.World;
                float elapsedSeconds = (float)time.ElapsedGameTime.TotalSeconds;

                PreparePhysicsEngine(worldState);
                PhysicsStep(worldState, elapsedSeconds);

                // Update shots
                var shots = (from e in worldState.Entities
                                         where e is Shot
                                         select (e as Shot))
                             .ToArray();

                foreach (var shot in shots)
                {
                    if (shot.ShotType == Shot.ShotType_T.InstantHit)
                    {
                        Vector2 targetPos = Vector2.Zero;
                        Fixture targetFixture = null;
                        Func<Fixture, Vector2, Vector2, float, float> raycastCallback =
                            (Fixture fixture, Vector2 position, Vector2 normal, float fraction) =>
                            {
                                targetFixture = fixture;
                                targetPos = position;
                                return fraction;
                            };

                        PhysicsWorld.RayCast(raycastCallback, shot.Position, shot.Position + 100 * shot.Velocity);
                        if (TerrainBodies.Contains(targetFixture.Body))
                        {
                            // Shot collides with terrain
                            shot.OnTerrainCollision(worldState.StaticGeometry, targetPos);
                        }
                        else if (EntityIdByPhysicsBody.ContainsKey(targetFixture.Body))
                        {
                            int entityId = EntityIdByPhysicsBody[targetFixture.Body];
                            Entity entity = worldState.EntityById(entityId);

                            // Mutual collision
                            entity.OnEntityCollision(shot);
                            shot.OnEntityCollision(entity);
                        }

                        worldState.RemoveEntity(shot);
                    }
                    else
                    {
                        shot.update(elapsedSeconds);
                    }
                }
            }
        }