#Decompiled with Drizzle30!  Enjoy :)

global DoEsher
global DoingTake
global DoingKeep
global intSlate
global byteEsher
global glue_cl
global glue_inst
global glue_params
global glue_paramKeys
from Plasma import *
from PlasmaTypes import *
sdlSlate = ptAttribString(1, 'SDL: which pedestal')
sdlEsher = ptAttribString(2, 'SDL: Esher')
respEsherSetup = ptAttribResponder(3, 'resp: Esher setup')
respEsherAtTake = ptAttribResponder(4, 'resp: do Esher at Take')
respEsherAtKeep = ptAttribResponder(5, 'resp: do Esher at Keep')
actInsideKeep = ptAttribActivator(6, 'rgn snsr: interior of Keep')
actLinkInRegion = ptAttribActivator(7, 'rgn snsr: link-in point')
DoEsher = 0
DoingTake = 0
DoingKeep = 0
intSlate = 0
byteEsher = 0
kTakeSpawnPt = 'LinkInPointDefault'
kKeepSpawnPt = 'LinkInPointKeep'

class lakiEsher(ptResponder):


    def __init__(self):
        ptResponder.__init__(self)
        self.id = 6361
        version = 2
        self.version = version
        print '__init__lakiEsher v. ',
        print version,
        print '.0'


    def OnAgeDataInitialized(self):
        global intSlate
        global byteEsher
        global DoEsher
        intSlate = sdlSlate.value.getValue()
        byteEsher = sdlEsher.value.getValue()
        mgr = ptClientSessionMgr()
        linkInfo = mgr.getLinkInfo()
        spawnInfo = linkInfo.getSpawnPointInfo()
        spawnPt = spawnInfo.getObjectName()
        if (spawnPt == kTakeSpawnPt):
            print 'SEER: at Take, intSlate =',
            print intSlate,
            print 'and byteEsher =',
            print byteEsher
            if ((intSlate == 101) and (byteEsher == 1)):
                DoEsher = 1
                print 'lakiEsher.OnAgeDataInitialized(): Player linked into Take point, slate is on the Take pedestal, and hasn\'t seen the Esher there yet'
            else:
                print 'lakiEsher.OnAgeDataInitialized(): Player linked into Take point but either the slate isn\'t present or the Esher was already seen there'


    def OnPlayerSpawned(self):
        global DoEsher
        if (DoEsher == 1):
            respEsherSetup.run(self.key)


    def OnNotify(self, state, id, events):
        global DoingTake
        global DoEsher
        global byteEsher
        global intSlate
        global DoingKeep
        raise RuntimeError("This shouldn't be executed !")
        if (id == actLinkInRegion.id):
            if DoingTake:
                return
            if ((DoEsher == 1) and (byteEsher == 1)):
                print 'lakiEsher.OnOnNotify(): will play Esher\'s resp at Take'
                DoingTake = 1
                PtEnableInput(0)
                respEsherAtTake.run(self.key)
        if ((id == actInsideKeep.id) and state):
            if ((intSlate == 102) and (byteEsher == 2)):
                print 'lakiEsher.OnNotify(): player is inside Keep and the slate is on the pedestal, will run Esher\'s resp at Keep'
                if (not (DoingKeep)):
                    DoingKeep = 1
                    respEsherAtKeep.run(self.key)
        if (id == respEsherAtTake.id):
            print 'lakiEsher.OnNotify(): got callback from Esher\'s resp at Take'
            DoingTake = 0
            PtEnableInput(1)
            sdlEsher.value.setValue(2)
        elif (id == respEsherAtKeep.id):
            print 'lakiEsher.OnNotify(): got callback from Esher\'s resp at Keep'
            DoingKeep = 0
            sdlEsher.value.setValue(0)


    def OnSDLNotify(self, notifierVar, changedVar, changeType):
        global intSlate
        global byteEsher
        if (changedVar.getName() == sdlSlate.value.getName()):
            intSlate = changedVar.getValue()
            print 'lakiEsher.OnSDLNotify(): SDL value of',
            print sdlSlate.value.getName(),
            print 'changed to',
            print intSlate
        if (changedVar.getName() == sdlEsher.value.getName()):
            byteEsher = changedVar.getValue()
            print 'lakiEsher.OnSDLNotify(): SDL value of',
            print sdlEsher.value.getName(),
            print 'changed to',
            print byteEsher


glue_cl = None
glue_inst = None
glue_params = None
glue_paramKeys = None
try:
    x = glue_verbose
except NameError:
    glue_verbose = 0

def glue_getClass():
    global glue_cl
    if (glue_cl == None):
        try:
            cl = eval(glue_name)
            if issubclass(cl, ptModifier):
                glue_cl = cl
            elif glue_verbose:
                print ('Class %s is not derived from modifier' % cl.__name__)
        except NameError:
            if glue_verbose:
                try:
                    print ('Could not find class %s' % glue_name)
                except NameError:
                    print 'Filename/classname not set!'
    return glue_cl


def glue_getInst():
    global glue_inst
    if (type(glue_inst) == type(None)):
        cl = glue_getClass()
        if (cl != None):
            glue_inst = cl()
    return glue_inst


def glue_delInst():
    global glue_inst
    global glue_cl
    global glue_params
    global glue_paramKeys
    if (type(glue_inst) != type(None)):
        del glue_inst
    glue_cl = None
    glue_params = None
    glue_paramKeys = None


def glue_getVersion():
    inst = glue_getInst()
    ver = inst.version
    glue_delInst()
    return ver


def glue_findAndAddAttribs(obj, glue_params):
    if isinstance(obj, ptAttribute):
        if glue_params.has_key(obj.id):
            if glue_verbose:
                print 'WARNING: Duplicate attribute ids!'
                print ('%s has id %d which is already defined in %s' % (obj.name, obj.id, glue_params[obj.id].name))
        else:
            glue_params[obj.id] = obj
    elif (type(obj) == type([])):
        for o in obj:
            glue_findAndAddAttribs(o, glue_params)
    elif (type(obj) == type({})):
        for o in obj.values():
            glue_findAndAddAttribs(o, glue_params)
    elif (type(obj) == type(())):
        for o in obj:
            glue_findAndAddAttribs(o, glue_params)


def glue_getParamDict():
    global glue_params
    global glue_paramKeys
    if (type(glue_params) == type(None)):
        glue_params = {}
        gd = globals()
        for obj in gd.values():
            glue_findAndAddAttribs(obj, glue_params)
        glue_paramKeys = glue_params.keys()
        glue_paramKeys.sort()
        glue_paramKeys.reverse()
    return glue_params


def glue_getClassName():
    cl = glue_getClass()
    if (cl != None):
        return cl.__name__
    if glue_verbose:
        print ('Class not found in %s.py' % glue_name)
    return None


def glue_getBlockID():
    inst = glue_getInst()
    if (inst != None):
        return inst.id
    if glue_verbose:
        print ('Instance could not be created in %s.py' % glue_name)
    return None


def glue_getNumParams():
    pd = glue_getParamDict()
    if (pd != None):
        return len(pd)
    if glue_verbose:
        print ('No attributes found in %s.py' % glue_name)
    return 0


def glue_getParam(number):
    global glue_paramKeys
    pd = glue_getParamDict()
    if (pd != None):
        if (type(glue_paramKeys) == type([])):
            if ((number >= 0) and (number < len(glue_paramKeys))):
                return pd[glue_paramKeys[number]].getdef()
            else:
                print ('glue_getParam: Error! %d out of range of attribute list' % number)
        else:
            pl = pd.values()
            if ((number >= 0) and (number < len(pl))):
                return pl[number].getdef()
            elif glue_verbose:
                print ('glue_getParam: Error! %d out of range of attribute list' % number)
    if glue_verbose:
        print 'GLUE: Attribute list error'
    return None


def glue_setParam(id, value):
    pd = glue_getParamDict()
    if (pd != None):
        if pd.has_key(id):
            try:
                pd[id].__setvalue__(value)
            except AttributeError:
                if isinstance(pd[id], ptAttributeList):
                    try:
                        if (type(pd[id].value) != type([])):
                            pd[id].value = []
                    except AttributeError:
                        pd[id].value = []
                    pd[id].value.append(value)
                else:
                    pd[id].value = value
        elif glue_verbose:
            print 'setParam: can\'t find id=',
            print id
    else:
        print 'setParma: Something terribly has gone wrong. Head for the cover.'


def glue_isNamedAttribute(id):
    pd = glue_getParamDict()
    if (pd != None):
        try:
            if isinstance(pd[id], ptAttribNamedActivator):
                return 1
            if isinstance(pd[id], ptAttribNamedResponder):
                return 2
        except KeyError:
            if glue_verbose:
                print ('Could not find id=%d attribute' % id)
    return 0


def glue_isMultiModifier():
    inst = glue_getInst()
    if isinstance(inst, ptMultiModifier):
        return 1
    return 0


def glue_getVisInfo(number):
    global glue_paramKeys
    pd = glue_getParamDict()
    if (pd != None):
        if (type(glue_paramKeys) == type([])):
            if ((number >= 0) and (number < len(glue_paramKeys))):
                return pd[glue_paramKeys[number]].getVisInfo()
            else:
                print ('glue_getVisInfo: Error! %d out of range of attribute list' % number)
        else:
            pl = pd.values()
            if ((number >= 0) and (number < len(pl))):
                return pl[number].getVisInfo()
            elif glue_verbose:
                print ('glue_getVisInfo: Error! %d out of range of attribute list' % number)
    if glue_verbose:
        print 'GLUE: Attribute list error'
    return None



