Skip to content

Commit

Permalink
Merge pull request #14 from jay602/1.x
Browse files Browse the repository at this point in the history
safekill后bots报错 #1180
  • Loading branch information
kbengine authored May 6, 2019
2 parents e6d543d + 1ccb1b3 commit 9191191
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scripts/bots/Avatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def onBecomePlayer( self ):
当这个entity被引擎定义为角色时被调用
"""
DEBUG_MSG("%s::onBecomePlayer: %i" % (self.__class__.__name__, self.id))

def onBecomeNonPlayer(self):
DEBUG_MSG("%s::onBecomeNonPlayer: %i" % (self.__class__.__name__, self.id))

def onJump(self):
"""
Expand All @@ -79,6 +82,7 @@ def __init__(self):
self.testType = random.randint(0, 2) # 测试类别, 0:随机移动, 1:找目标攻击, 2:测试传送
self.changeTestTypeTime = time.time()
self.spawnPosition = Math.Vector3( self.position )
self.cbID = 0

def onBecomePlayer( self ):
"""
Expand All @@ -91,7 +95,10 @@ def onBecomePlayer( self ):
# 这里手动进行初始化一下
self.__init__()

KBEngine.callback(1, self.update)
self.cbID = KBEngine.callback(1, self.update)

def onBecomeNonPlayer(self):
KBEngine.cancelCallback(self.cbID)

def onEnterSpace(self):
"""
Expand Down Expand Up @@ -186,7 +193,7 @@ def update(self):
if self.isDestroyed:
return

KBEngine.callback(1, self.update)
self.cbID = KBEngine.callback(1, self.update)

# 如果自己已经死亡了,那么延时一下复活
if self.isState(GlobalDefine.ENTITY_STATE_DEAD):
Expand Down

0 comments on commit 9191191

Please sign in to comment.