(include "sci.sh")
(use "Main")
(use "Obj")
(script 989)



(class Sound of Obj
    (properties
        state 0
        number 0
        priority 0
        loop 1
        handle 0
        client 0
        signal 0
        keep 0
        prevSignal 0
    )

    (method (init)
        = state (= signal 0)
        (send gSounds:add(self))
        DoSound(0 self)
    )


    (method (dispose)
        (if (keep)
            (if (handle)
                DoSound(5 handle)
            )
        )(else
            (send gSounds:delete(self))
            (if (handle)
                DoSound(3 handle)
                = handle 0
            )
            (super:dispose())
        )
    )


    (method (play param1)
        (var the_info_)
        = the_info_ {-info-}
        = {-info-} (| {-info-} $0002)
        (self:dispose())
        = {-info-} the_info_
        (if (not loop)
            = loop 1
        )
        (self:init())
        = client 
            (if (paramTotal)
                param1
            )(else
                0
            )
        DoSound(1 self)
    )


    (method (playMaybe param1)
        (self:play(rest param1))
        (if (== state 2)
            (self:dispose())
        )
    )


    (method (delete)
        (if (== state 4)
            (self:dispose())
        )
    )


    (method (check)
        (var temp0[40])
        (if (signal)
            (if (IsObject(client))
                (send client:cue(self))
            )
            (if (== (= prevSignal signal) -1)
                = state 4
            )
            = signal 0
        )
    )


    (method (pause param1)
        DoSound(6 param1)
    )


    (method (changeState)
        DoSound(9 self)
    )

)
