corner01Breakable = nil
corner02Breakable = nil
corner03Breakable = nil
corner04Breakable = nil
topBreakable = nil
corner01Broken = false
corner02Broken = false
corner03Broken = false
corner04Broken = false
topBreakableBroken = false
brokenCount = 0
function OnScriptLoaded(level, obj)
  corner01Breakable = obj:FindSingleGOByName("ruin_block_corner_01_grp"):GetBreakable()
  corner02Breakable = obj:FindSingleGOByName("ruin_block_corner_02_grp"):GetBreakable()
  corner03Breakable = obj:FindSingleGOByName("ruin_block_corner_03_grp"):GetBreakable()
  corner04Breakable = obj:FindSingleGOByName("ruin_block_corner_04_grp"):GetBreakable()
  topBreakable = obj:FindSingleGOByName("ruin_block_corner_05_grp"):GetBreakable()
end
function OnUpdate(level, obj)
  if corner01Broken == false and corner01Breakable.Broken then
    corner01Broken = true
    brokenCount = brokenCount + 1
  end
  if corner02Broken == false and corner02Breakable.Broken then
    corner02Broken = true
    brokenCount = brokenCount + 1
  end
  if corner03Broken == false and corner03Breakable.Broken then
    corner03Broken = true
    brokenCount = brokenCount + 1
  end
  if corner04Broken == false and corner04Breakable.Broken then
    corner04Broken = true
    brokenCount = brokenCount + 1
  end
  if brokenCount >= 2 and brokenCount < 5 then
    if corner01Breakable.Broken == false then
      corner01Breakable:Break()
    end
    if corner02Breakable.Broken == false then
      corner02Breakable:Break()
    end
    if corner03Breakable.Broken == false then
      corner03Breakable:Break()
    end
    if corner04Breakable.Broken == false then
      corner04Breakable:Break()
    end
    if topBreakableBroken == false and topBreakable.Broken == false then
      topBreakable:Break()
      topBreakableBroken = true
      obj:HideCollision()
      brokenCount = brokenCount + 1
    end
  end
end
