public void Update(IPhysicsEngineContext world, TimeSpan elapsedTime) { _collisionEngine.Move(world, elapsedTime); foreach (var movableObject in world.GetMovableObjects()) { movableObject.Position = CoordinateSystem.Normalize(movableObject.Position); } foreach (var movableObject in world.GetMovableObjects()) { _collisionEngine.DetectTouchedBlocks(world, movableObject); } foreach (var movableObject in world.GetMovableObjects()) { ResetVelocityInBlockedDirections(movableObject); } foreach (var movableObject in world.GetMovableObjects()) { ApplyGravityIfNotBlocked(movableObject, world.Gravity, elapsedTime); ApplyDrag(movableObject, elapsedTime); } }
public void Initialize(IPhysicsEngineContext world) { foreach (var entity in world.GetMovableObjects()) { _collisionEngine.DetectTouchedBlocks(world, entity); } }