(include "sci.sh")
(use "DCIcon")
(use "Cycle")
(script 814)



(class TalkIcon of DCIcon
    (properties
        type 4
        state 0
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        key 0
        said 0
        value 0
        view 0
        loop 0
        cel 0
        cycler 0
        cycleSpeed 0
        signal 0
        iterate -1
        iterCnt 0
        saveBits 0
    )

    (method (init)
        (if (== cycler -1)
            = cycler 0
        )(else
            (if (cycler)
                (send (= cycler (send cycler:new())):init(self))
            )(else
                (send (= cycler (Fwd:new())):init(self))
            )
        )
        = iterCnt 0
    )


    (method (draw)
        (var temp0)
        (if (saveBits)
            Graph(8 saveBits)
            Graph(13 nsTop nsLeft nsBottom nsRight)
        )
        = saveBits Graph(7 nsTop nsLeft nsBottom nsRight 3)
        DrawCel(view loop cel nsLeft nsTop 15)
    )


    (method (cycle)
        (var theCel)
        = theCel cel
        (super:cycle())
        (if (not IsObject(cycler) or (== cel theCel))
            0
        )(else
            (if ((== iterate -1) or (<= iterCnt iterate))
                ++iterCnt
                (if ((> NumLoops(self) 1) and (loop or (< Random(1 100) 51)))
                    = loop (^ loop $0001)
                )
            )(else
                (if (> iterCnt iterate)
                    (if (IsObject(cycler))
                        (send cycler:dispose())
                    )
                    = loop (= cycler (= cel 0))
                )
            )
        )
    )

)
