 BlobSplitAction = Action.scaffold (engine) ->
   entPos = @entity.c 'pos'
   entBlob = @entity.c 'blob'
+  entBlob.weight = entBlob.weightCap if entBlob.weightCap
   weight = entBlob.weight / 2
   direction = Math.random() * Math.PI * 2
   vel = 3 * Math.sqrt weight

      # TODO: Implement better algorithm of this, such as QuadTree
      for other, j in @entities
        continue if not j > i
        otherBlob = other.c 'blob'
        otherPos = other.c 'pos'
        continue if otherBlob.weightCap
        if entBlob.parent == other.id
          entBlob.parent = null if not entPos.collides otherPos
          continue
        if otherBlob.parent == entity.id
          otherBlob.parent = null if not entPos.collides otherPos
          continue
        if entPos.collides otherPos
          # Bigger one eats smaller one
          entityBig = entPos.radius > otherPos.radius

          bigPos.radius = Math.sqrt bigBlob.weight
          smallPos.radius = Math.sqrt smallBlob.weight
          diff = bigPos.radius + smallPos.radius - bigPos.distance smallPos
          expectedWeight = square Math.max 0, smallPos.radius - diff
          expectedWeight = 0 if expectedWeight < 10
          weightGain = smallBlob.weight - expectedWeight
          # Velocity sharing doesn't work as well as expected.
          #bigBlob.velX = (bigBlob.velX + smallBlob.velX) * bigBlob.weight / (bigBlob.weight + weightGain)
          #bigBlob.velY = (bigBlob.velY + smallBlob.velY) * bigBlob.weight / (bigBlob.weight + weightGain)
          bigBlob.weight += weightGain
          bigPos.radius = Math.sqrt bigBlob.weight
          smallBlob.weight -= weightGain
          smallBlob.weight = Math.max 0, smallBlob.weight
          smallPos.radius = Math.sqrt smallBlob.weight
    i = 0
    while i < @entities.length
      entity = @entities[i]
