Go to the documentation of this file.00001 '''
00002 Anoria (c) Gsk 2010
00003 '''
00004
00005 import BigWorld
00006
00007 from config import event
00008
00009 class Actor():
00010
00011 def __init__(self):
00012 self.deathPosition = None
00013 self.deathDirection = None
00014 self.isPlayer = False
00015 self.eventProc = { }
00016
00017
00018
00019
00020
00021 def addEventProc(self, eventId, proc):
00022 print "Actor_%d adding eventProc for event:%d" % (self.id, eventId), proc
00023 self.eventProc[eventId]=proc
00024
00025
00026
00027
00028
00029
00030 def rpcProcessEvent(self, sourceId, eventType, eventValue):
00031 print "Actor_%d.rpcReceiveEvent(): sourceId=%d, eventType=%s, eventValue=%d" % \
00032 (self.id, sourceId, event.EVENTS[eventType], eventValue)
00033
00034
00035 func = None
00036 try:
00037 func = self.eventProc[eventType]
00038 except:
00039 pass
00040
00041 if func != None: func(sourceId, eventValue)
00042
00043
00044
00045 def rpcDeathLoc(self, position, direction, modelNumber):
00046 ''' This RPC function is called by the cell component of actors to notify the base of the whereabouts of
00047 the entity's death. The base component does not normaly have or require spatial information but here it
00048 is required in order to properly have the MORGUE create a corpse entity at the right spot.
00049 Additionaly we trigger the respawn of dead Player Avatars here.
00050
00051 @param: position vec3 death location
00052 @param: direction vec3 orientation
00053 '''
00054
00055 print "Actor_%d.rpcDeathLoc(): notifying MORGUE" % (self.id)
00056 self.deathPosition = position
00057 self.deathDirection = direction
00058
00059
00060
00061
00062
00063 Morgue = BigWorld.globalBases["MORGUE"]
00064 Morgue.rpcRegisterCorpse(self.cell, position, direction, modelNumber)
00065
00066
00067 if self.isPlayer:
00068 print "Actor_%d has been a PLAYER AVATAR: initiating respawn!" % (self.id)
00069 properties = { "spawnerCellMb" : self.cell }
00070 base = BigWorld.createBaseAnywhere("Avatar", properties, spawnerCellMb = self.cell,
00071 name="REBORN", position=position, direction=direction)
00072
00073 print "Actor_%d respawned as Avatar entity with id %d, transfering client control ..." % (self.id, base.id)
00074 self.giveClientTo(base)