当前位置: 首页>>代码示例>>Python>>正文


Python CallbackDelayer.delayCallback方法代码示例

本文整理汇总了Python中helpers.CallbackDelayer.CallbackDelayer.delayCallback方法的典型用法代码示例。如果您正苦于以下问题:Python CallbackDelayer.delayCallback方法的具体用法?Python CallbackDelayer.delayCallback怎么用?Python CallbackDelayer.delayCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在helpers.CallbackDelayer.CallbackDelayer的用法示例。


在下文中一共展示了CallbackDelayer.delayCallback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CombatEquipmentManager

# 需要导入模块: from helpers.CallbackDelayer import CallbackDelayer [as 别名]
# 或者: from helpers.CallbackDelayer.CallbackDelayer import delayCallback [as 别名]

#.........这里部分代码省略.........
            self.debugDirs.append(nextDir)
            self.debugPoints.append(nextPos + Vector3(nextDir.x, 0, nextDir.y) * 10)
            self.debugPoints.append(nextPos)
            self.debugPolyLine.set(self.debugPoints)
        return

    def showHittingArea(self, equipmentID, pos, dir, time):
        if _ENABLE_DEBUG_LOG:
            LOG_DEBUG("===== showHittingArea =====")
            LOG_DEBUG(equipmentID)
            LOG_DEBUG(pos, dir, time)
        correctedCoords = tuple((int(x * 1000.0) for x in pos.tuple()))
        areaUID = (int(equipmentID), correctedCoords)
        if areaUID in self.__selectedAreas:
            return
        eq = vehicles.g_cache.equipments()[equipmentID]
        if BattleReplay.isPlaying():
            BigWorld.callback(0.0, functools.partial(self.__showMarkerCallback, eq, pos, dir, time, areaUID))
        else:
            self.__showMarkerCallback(eq, pos, dir, time, areaUID)

    def __delayedAreaDestroy(self, areaUID):
        area = self.__selectedAreas.pop(areaUID, None)
        if area is not None:
            area.destroy()
        return

    def __showMarkerCallback(self, eq, pos, dir, time, areaUID):
        timer = round(time - BigWorld.serverTime())
        area = self.__selectedAreas.pop(areaUID, None)
        if area is not None:
            area.destroy()
        self.__selectedAreas[areaUID] = self.createEquipmentSelectedArea(pos, dir, eq)
        self.__callbackDelayer.delayCallback(timer, functools.partial(self.__delayedAreaDestroy, areaUID))
        g_sessionProvider.getEquipmentsCtrl().showMarker(eq, pos, dir, timer)
        return

    @staticmethod
    def __calcBombsDistribution(bombsCnt, areaWidth, areaLength):
        coeff = areaWidth / areaLength
        bombsPerWidth = math.sqrt(bombsCnt * coeff)
        bombsPerLength = bombsPerWidth / coeff
        return (bombsPerWidth, bombsPerLength)

    def showCarpetBombing(self, equipmentID, pos, dir, time):
        if _ENABLE_DEBUG_LOG:
            LOG_DEBUG("===== showCarpetBombing =====")
            LOG_DEBUG(equipmentID)
            LOG_DEBUG(pos, dir, time)
        bombEquipment = vehicles.g_cache.equipments()[equipmentID]
        shellDescr = items.vehicles.getDictDescr(bombEquipment.shellCompactDescr)
        shotEffect = vehicles.g_cache.shotEffects[shellDescr["effectsIndex"]]
        airstrikeID = shotEffect.get("airstrikeID")
        if airstrikeID is None:
            LOG_ERROR("EquipmentID %s has no airstrike shot effect settings" % equipmentID)
            return
        else:
            areaWidth, areaLength = bombEquipment.areaWidth, bombEquipment.areaLength
            if _ENABLE_DEBUG_LOG:
                LOG_DEBUG("Ideal", areaWidth, areaLength)
            beginExplosionPos = BigWorld.wg_collideSegment(BigWorld.player().spaceID, pos, pos + dir * 1000.0, 18)
            if beginExplosionPos is None:
                return
            beginExplosionPos = beginExplosionPos[0]
            flatDir = Vector3(dir)
            flatDir.y = 0.0
开发者ID:webiumsk,项目名称:WOT0.10.0,代码行数:70,代码来源:combatequipmentmanager.py

示例2: DetachedTurret

# 需要导入模块: from helpers.CallbackDelayer import CallbackDelayer [as 别名]
# 或者: from helpers.CallbackDelayer.CallbackDelayer import delayCallback [as 别名]
class DetachedTurret(BigWorld.Entity):
    allTurrets = list()

    def __init__(self):
        self.__vehDescr = vehicles.VehicleDescr(compactDescr=self.vehicleCompDescr)
        self.filter = BigWorld.WGTurretFilter()
        self.__detachConfirmationTimer = SynchronousDetachment(self)
        self.__detachConfirmationTimer.onInit()
        self.__detachmentEffects = None
        self.__hitEffects = {TankPartNames.TURRET: None,
         TankPartNames.GUN: None}
        self.__reactors = []
        self.targetFullBounds = True
        self.targetCaps = [1]
        self.__isBeingPulledCallback = None
        return

    def reload(self):
        pass

    def prerequisites(self):
        prereqs = [self.__vehDescr.turret['models']['exploded'], self.__vehDescr.gun['models']['exploded']]
        prereqs += self.__vehDescr.prerequisites()
        return prereqs

    def onEnterWorld(self, prereqs):
        self.model = prereqs[self.__vehDescr.turret['models']['exploded']]
        self.model.addMotor(BigWorld.Servo(self.matrix))
        self.__gunModel = prereqs[self.__vehDescr.gun['models']['exploded']]
        node = self.model.node(TankNodeNames.GUN_JOINT, Math.Matrix())
        node.attach(self.__gunModel)
        self.__detachConfirmationTimer.onEnterWorld()
        self.__vehDescr.keepPrereqs(prereqs)
        turretDescr = self.__vehDescr.turret
        if self.isUnderWater == 0:
            self.__detachmentEffects = _TurretDetachmentEffects(self.model, turretDescr['turretDetachmentEffects'], self.isCollidingWithWorld == 1)
            self.__reactors.append(self.__detachmentEffects)
        else:
            self.__detachmentEffects = None
        self.__hitEffects[TankPartNames.TURRET] = turretHitEffects = _HitEffects(self.model)
        self.__hitEffects[TankPartNames.GUN] = gunHitEffects = _HitEffects(self.__gunModel)
        self.__reactors.append(turretHitEffects)
        self.__reactors.append(gunHitEffects)
        self.__componentsDesc = (self.__vehDescr.turret, self.__vehDescr.gun)
        for desc in self.__componentsDesc:
            desc['hitTester'].loadBspModel()

        from helpers.CallbackDelayer import CallbackDelayer
        self.__isBeingPulledCallback = CallbackDelayer()
        self.__isBeingPulledCallback.delayCallback(self.__checkIsBeingPulled(), self.__checkIsBeingPulled)
        DetachedTurret.allTurrets.append(self)
        return

    def onLeaveWorld(self):
        DetachedTurret.allTurrets.remove(self)
        self.__detachConfirmationTimer.cancel()
        self.__detachConfirmationTimer = None
        for reactor in self.__reactors:
            if reactor is not None:
                reactor.destroy()

        self.__isBeingPulledCallback.destroy()
        self.__isBeingPulledCallback = None
        return

    def onStaticCollision(self, energy, point, normal):
        if self.__detachmentEffects is not None:
            surfaceMaterial = calcSurfaceMaterialNearPoint(point, normal, self.spaceID)
            effectIdx = surfaceMaterial.effectIdx
            groundEffect = True
            distToWater = BigWorld.wg_collideWater(self.position, surfaceMaterial.point)
            if distToWater != -1:
                vel = Math.Vector3(self.velocity).length
                if vel < _MIN_COLLISION_SPEED:
                    groundEffect = False
                effectIdx = material_kinds.EFFECT_MATERIAL_INDEXES_BY_NAMES['water']
            self.__detachmentEffects.notifyAboutCollision(energy, point, effectIdx, groundEffect, self.isUnderWater)
        return

    def showDamageFromShot(self, points, effectsIndex):
        maxHitEffectCode, decodedPoints = DamageFromShotDecoder.decodeHitPoints(points, self.__vehDescr)
        for shotPoint in decodedPoints:
            hitEffects = self.__hitEffects.get(shotPoint.componentName)
            if hitEffects is not None:
                hitEffects.showHit(shotPoint, effectsIndex)
            else:
                LOG_ERROR("Detached turret got hit into %s component, but it's impossible" % shotPoint.componentName)

        return

    def collideSegment(self, startPoint, endPoint, skipGun = False):
        res = None
        filterMethod = getattr(self.filter, 'segmentMayHitEntity', lambda : True)
        if not filterMethod(startPoint, endPoint, 0):
            return res
        else:
            modelsToCheck = (self.model,) if skipGun else (self.model, self.__gunModel)
            for model, desc in zip(modelsToCheck, self.__componentsDesc):
                toModel = Matrix(model.matrix)
                toModel.invert()
#.........这里部分代码省略.........
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:103,代码来源:detachedturret.py


注:本文中的helpers.CallbackDelayer.CallbackDelayer.delayCallback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。