Go to the documentation of this file.00001 '''
00002 Anoria (c) Gsk 2010
00003 '''
00004
00005 import BigWorld
00006 import random
00007
00008 import Avatar
00009 from Actor import Actor
00010
00011 MESSAGES = [
00012 "Hello Anoria",
00013 "Have a nice day in Anoria",
00014 "I greet, therefore I am"
00015 ]
00016
00017 class Greeter(BigWorld.Entity, Actor):
00018
00019 def __init__(self):
00020 BigWorld.Entity.__init__(self)
00021 Actor.__init__(self)
00022
00023
00024 self.addProximity( self.radius, 0 )
00025
00026 def onEnterTrap( self, entityEntering, range, controllerID ):
00027 print "Greeter.onEnterTrap", self.id, entityEntering, range, controllerID, self.activated
00028
00029
00030 if not self.activated:
00031 return
00032
00033
00034
00035 if not isinstance( entityEntering, Avatar.Avatar ):
00036 return
00037
00038
00039 self.allClients.greet( entityEntering.id, random.choice(MESSAGES) )
00040
00041
00042 def toggleActive( self, sourceID ):
00043
00044
00045
00046
00047
00048 print "Greeter.toggleActive (self.id=%d, sourceID=%d)" % (self.id, sourceID)
00049
00050
00051
00052 try:
00053 sourceEntity = BigWorld.entities[ sourceID ]
00054 except KeyError:
00055 return
00056
00057
00058 dist = sourceEntity.position.distTo( self.position )
00059
00060
00061 if dist > self.radius:
00062 return
00063
00064
00065
00066 self.activated = not self.activated
00067