예제 #1
0
 def __init__(self, dataSec, aim):
     CallbackDelayer.__init__(self)
     TimeDeltaMeter.__init__(self)
     self.__shiftKeySensor = None
     self.__movementOscillator = None
     self.__impulseOscillator = None
     self.__noiseOscillator = None
     self.__dynamicCfg = CameraDynamicConfig()
     self.__accelerationSmoother = None
     self.__readCfg(dataSec)
     if aim is None:
         return
     self.__aim = weakref.proxy(aim)
     self.__cam = BigWorld.HomingCamera()
     aimOffset = self.__aim.offset()
     self.__cam.aimPointClipCoords = Vector2(aimOffset)
     self.__curSense = 0
     self.__curScrollSense = 0
     self.__defaultAimOffset = (aimOffset[0], aimOffset[1])
     self.__postmortemMode = False
     self.__modelsToCollideWith = []
     self.__onChangeControlMode = None
     self.__aimingSystem = None
     self.__focalPointDist = 1.0
     self.__autoUpdateDxDyDz = Vector3(0.0)
예제 #2
0
파일: videocamera.py 프로젝트: webiumsk/WoT
 def destroy(self):
     CallbackDelayer.destroy(self)
     self.__cam = None
     if self.__aim is not None:
         self.__aim.destroy()
         self.__aim = None
     return
예제 #3
0
 def __init__(self):
     CallbackDelayer.__init__(self)
     self.__alwaysShowAim = False
     self.__alwaysShowAimKey = None
     self.__showMarkersKey = None
     sec = self._readCfg()
     self.onCameraChanged = Event()
     self.onPostmortemVehicleChanged = Event()
     self.onSetReloading = Event()
     self.onSetReloadingPercents = Event()
     self.__isArenaStarted = False
     self.__isStarted = False
     self.__targeting = _Targeting()
     self.__vertScreenshotCamera = _VertScreenshotCamera()
     self.__ctrls = dict()
     self.__killerVehicleID = None
     self.__isAutorotation = True
     self.__prevModeAutorotation = None
     self.__isSPG = False
     self.__isATSPG = False
     self.__setupCtrls(sec)
     self.__curCtrl = self.__ctrls[_CTRLS_FIRST]
     self.__eMode = _CTRLS_FIRST
     self.__detachCount = 0
     return
예제 #4
0
    def onEnterWorld(self, prereqs):
        self.model = prereqs[self.__vehDescr.turret['models']['exploded']]
        self.__gunModel = prereqs[self.__vehDescr.gun['models']['exploded']]
        node = self.model.node('HP_gunJoint', 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[
            TankComponentNames.TURRET] = turretHitEffects = _HitEffects(
                self.model)
        self.__hitEffects[
            TankComponentNames.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 AvatarInputHandler.CallbackDelayer import CallbackDelayer
        self.__isBeingPulledCallback = CallbackDelayer()
        self.__isBeingPulledCallback.delayCallback(self.__checkIsBeingPulled(),
                                                   self.__checkIsBeingPulled)
        DetachedTurret.allTurrets.append(self)
예제 #5
0
 def __init__(self, updatePeriod = 0.0):
     CallbackDelayer.__init__(self)
     self.__updatePeriod = updatePeriod
     self.__currentSpeedState = self.__SPEED_IDLE
     self.__keyOffCalled = False
     self.__manualSound = None
     self.__gearSound = None
     self.__gearDamagedParam = None
     self.__manGearDamagedParam = None
     self.__gearKeyOffParam = None
     self.__stateTable = ((None,
       self.__startManualSound,
       self.__initHighSpeed,
       None),
      (self.__stopManualSound,
       None,
       self.__initHighSpeed,
       None),
      (self.__stopManualSound,
       self.__startManualSoundFromFast,
       None,
       None),
      (self.__stopGearSoundPlaying,
       self.__startManualSoundFromFast,
       None,
       self.__checkGearSound))
예제 #6
0
 def __init__(self, dataSec, aim, binoculars):
     CallbackDelayer.__init__(self)
     self.__impulseOscillator = None
     self.__movementOscillator = None
     self.__noiseOscillator = None
     self.__dynamicCfg = CameraDynamicConfig()
     self.__accelerationSmoother = None
     self.__readCfg(dataSec)
     if aim is None or binoculars is None:
         return
     self.__cam = BigWorld.FreeCamera()
     self.__zoom = self.__cfg['zoom']
     self.__curSense = 0
     self.__curScrollSense = 0
     self.__waitVehicleCallbackId = None
     self.__onChangeControlMode = None
     self.__aimingSystem = SniperAimingSystem(dataSec)
     self.__aim = weakref.proxy(aim)
     self.__binoculars = binoculars
     self.__defaultAimOffset = self.__aim.offset()
     self.__defaultAimOffset = (self.__defaultAimOffset[0],
                                self.__defaultAimOffset[1])
     self.__crosshairMatrix = createCrosshairMatrix(
         offsetFromNearPlane=self.__dynamicCfg['aimMarkerDistance'])
     self.__prevTime = BigWorld.time()
     self.__autoUpdateDxDyDz = Vector3(0, 0, 0)
예제 #7
0
 def __init__(self, configDataSec):
     CallbackDelayer.__init__(self)
     self.__cam = BigWorld.FreeCamera()
     self.__ypr = Math.Vector3()
     self.__position = Math.Vector3()
     self.__defaultFov = BigWorld.projection().fov
     self.__velocity = Math.Vector3()
     self.__isVerticalVelocitySeparated = False
     self.__yprVelocity = Math.Vector3()
     self.__zoomVelocity = 0.0
     self.__inertiaEnabled = False
     self.__movementInertia = None
     self.__rotationInertia = None
     self.__movementSensor = None
     self.__verticalMovementSensor = None
     self.__rotationSensor = None
     self.__zoomSensor = None
     self.__targetRadiusSensor = None
     self.__mouseSensitivity = 0.0
     self.__scrollSensitivity = 0.0
     self.__prevTime = 0.0
     self.__rotateAroundPointEnabled = False
     self.__rotationRadius = 40.0
     self.__boundVehicleMProv = None
     self.__alignerToLand = _AlignerToLand()
     self.__predefinedVelocities = {}
     self.__predefinedVerticalVelocities = {}
     self.__keySwitches = {}
     self.__readCfg(configDataSec)
     self.__aim = None
     return
예제 #8
0
 def __init__(self, updatePeriod = 0.0):
     CallbackDelayer.__init__(self)
     self.__updatePeriod = updatePeriod
     self.__currentSpeedState = self.__SPEED_IDLE
     self.__keyOffCalled = False
     self.__manualSound = None
     self.__gearSound = None
     self.__gearDamagedParam = None
     self.__manGearDamagedParam = None
     self.__gearKeyOffParam = None
     self.__stateTable = ((None,
       self.__startManualSound,
       self.__initHighSpeed,
       None),
      (self.__stopManualSound,
       None,
       self.__initHighSpeed,
       None),
      (self.__stopManualSound,
       self.__startManualSoundFromFast,
       None,
       None),
      (self.__stopGearSoundPlaying,
       self.__startManualSoundFromFast,
       None,
       self.__checkGearSound))
     return
예제 #9
0
 def __init__(self, updatePeriod=0.0):
     CallbackDelayer.__init__(self)
     TimeDeltaMeter.__init__(self)
     self.__updatePeriod = updatePeriod
     self.__turretSound = None
     self.__prevTurretYaw = None
     return
예제 #10
0
 def destroy(self):
     CallbackDelayer.destroy(self)
     if self.__manualSound is not None:
         self.__manualSound.stop()
     if self.__gearSound is not None:
         self.__gearSound.stop()
     self.__stateTable = None
예제 #11
0
 def __init__(self, dataSec, aim):
     CallbackDelayer.__init__(self)
     TimeDeltaMeter.__init__(self)
     self.__shiftKeySensor = None
     self.__movementOscillator = None
     self.__impulseOscillator = None
     self.__noiseOscillator = None
     self.__dynamicCfg = CameraDynamicConfig()
     self.__accelerationSmoother = None
     self.__readCfg(dataSec)
     if aim is None:
         return
     else:
         self.__aim = weakref.proxy(aim)
         self.__cam = BigWorld.HomingCamera()
         aimOffset = self.__aim.offset()
         self.__cam.aimPointClipCoords = Vector2(aimOffset)
         self.__curSense = 0
         self.__curScrollSense = 0
         self.__defaultAimOffset = (aimOffset[0], aimOffset[1])
         self.__postmortemMode = False
         self.__modelsToCollideWith = []
         self.__onChangeControlMode = None
         self.__aimingSystem = None
         self.__focalPointDist = 1.0
         self.__autoUpdateDxDyDz = Vector3(0.0)
         return
예제 #12
0
 def destroy(self):
     CallbackDelayer.destroy(self)
     self.disable()
     self.__activeSelector = None
     self.__cam.destroy()
     self.__aih = None
     return
예제 #13
0
 def __init__(self, updatePeriod=0.0):
     CallbackDelayer.__init__(self)
     TimeDeltaMeter.__init__(self)
     self.__updatePeriod = updatePeriod
     self.__turretSound = None
     self.__prevTurretYaw = None
     return
예제 #14
0
 def __init__(self, dataSec, aim, binoculars):
     CallbackDelayer.__init__(self)
     self.__impulseOscillator = None
     self.__movementOscillator = None
     self.__noiseOscillator = None
     self.__dynamicCfg = CameraDynamicConfig()
     self.__accelerationSmoother = None
     self.__readCfg(dataSec)
     if aim is None or binoculars is None:
         return
     else:
         self.__cam = BigWorld.FreeCamera()
         self.__zoom = self.__cfg['zoom']
         self.__curSense = 0
         self.__curScrollSense = 0
         self.__waitVehicleCallbackId = None
         self.__onChangeControlMode = None
         self.__aimingSystem = SniperAimingSystem(dataSec)
         self.__aim = weakref.proxy(aim)
         self.__binoculars = binoculars
         self.__defaultAimOffset = self.__aim.offset()
         self.__defaultAimOffset = (self.__defaultAimOffset[0], self.__defaultAimOffset[1])
         self.__crosshairMatrix = createCrosshairMatrix(offsetFromNearPlane=self.__dynamicCfg['aimMarkerDistance'])
         self.__prevTime = BigWorld.time()
         self.__autoUpdateDxDyDz = Vector3(0, 0, 0)
         return
예제 #15
0
파일: videocamera.py 프로젝트: webiumsk/WoT
 def __init__(self, configDataSec):
     CallbackDelayer.__init__(self)
     TimeDeltaMeter.__init__(self)
     self.__cam = BigWorld.FreeCamera()
     self.__cam.invViewProvider = Math.MatrixProduct()
     self.__ypr = Math.Vector3()
     self.__position = Math.Vector3()
     self.__defaultFov = BigWorld.projection().fov
     self.__velocity = Math.Vector3()
     self.__isVerticalVelocitySeparated = False
     self.__yprVelocity = Math.Vector3()
     self.__zoomVelocity = 0.0
     self.__inertiaEnabled = False
     self.__movementInertia = None
     self.__rotationInertia = None
     self.__movementSensor = None
     self.__verticalMovementSensor = None
     self.__rotationSensor = None
     self.__zoomSensor = None
     self.__targetRadiusSensor = None
     self.__mouseSensitivity = 0.0
     self.__scrollSensitivity = 0.0
     self.__rotateAroundPointEnabled = False
     self.__rotationRadius = 40.0
     self.__alignerToLand = _AlignerToLand()
     self.__predefinedVelocities = {}
     self.__predefinedVerticalVelocities = {}
     self.__keySwitches = {}
     self.__readCfg(configDataSec)
     self.__aim = None
     self.__basisMProv = _VehicleBounder()
     self.__entityPicker = _VehiclePicker()
     return
예제 #16
0
 def destroy(self):
     CallbackDelayer.destroy(self)
     self.__cam = None
     if self.__aim is not None:
         self.__aim.destroy()
         self.__aim = None
     return
예제 #17
0
 def destroy(self):
     _SPGFlashGunMarker.destroy(self)
     CallbackDelayer.destroy(self)
     self.__desiredShotInfoFunc = None
     self.__trajectoryDrawer.visible = False
     self.__trajectoryDrawer = None
     return
예제 #18
0
 def destroy(self):
     CallbackDelayer.destroy(self)
     if self.__manualSound is not None:
         self.__manualSound.stop()
     if self.__gearSound is not None:
         self.__gearSound.stop()
     self.__stateTable = None
예제 #19
0
 def destroy(self):
     CallbackDelayer.destroy(self)
     self.disable()
     self.__onChangeControlMode = None
     self.__cam = None
     self._writeUserPreferences()
     self.__aimingSystem.destroy()
     self.__aimingSystem = None
예제 #20
0
 def destroy(self):
     CallbackDelayer.destroy(self)
     self.disable()
     self.__onChangeControlMode = None
     self.__cam = None
     self._writeUserPreferences()
     self.__aimingSystem.destroy()
     self.__aimingSystem = None
예제 #21
0
 def __init__(self):
     self.__callbackDelayer = CallbackDelayer()
     self.__selectedAreas = {}
     self.__wings = {}
     if _ENABLE_DEBUG_DRAW:
         self.debugPolyLine = Flock.DebugPolyLine()
         self.debugPoints = []
         self.debugDirs = []
예제 #22
0
 def enable(self, enableSound):
     if enableSound:
         self.delayCallback(self.__updatePeriod, self.__update)
     else:
         CallbackDelayer.destroy(self)
         if self.__manualSound is not None:
             self.__manualSound.stop()
         if self.__gearSound is not None:
             self.__gearSound.stop()
예제 #23
0
 def __init__(self, curShotInfoFunc, dispersionUpdateFunc,
              desiredShotInfoFunc):
     _SPGFlashGunMarker.__init__(self, curShotInfoFunc,
                                 dispersionUpdateFunc,
                                 _SuperGunMarker.GUN_MARKER_CLIENT)
     CallbackDelayer.__init__(self)
     self.__updateInterval = 0.0 if BattleReplay.g_replayCtrl.isPlaying else 0.1
     self.__desiredShotInfoFunc = desiredShotInfoFunc
     self.__trajectoryDrawer = BigWorld.wg_trajectory_drawer()
예제 #24
0
 def enable(self, enableSound):
     if enableSound:
         self.delayCallback(self.__updatePeriod, self.__update)
     else:
         CallbackDelayer.destroy(self)
         if self.__manualSound is not None:
             self.__manualSound.stop()
         if self.__gearSound is not None:
             self.__gearSound.stop()
예제 #25
0
 def __init__(self):
     BigWorld.Entity.__init__(self)
     FlockLike.__init__(self)
     CallbackDelayer.__init__(self)
     self.flightAngleMin = math.radians(self.flightAngleMin)
     self.flightAngleMax = math.radians(self.flightAngleMax)
     if self.flightAngleMin < 0:
         self.flightAngleMin += math.ceil(abs(self.flightAngleMin) / (math.pi * 2)) * math.pi * 2
     elif self.flightAngleMin > math.pi * 2:
         self.flightAngleMin -= math.floor(self.flightAngleMin / (math.pi * 2)) * math.pi * 2
     self.__isTriggered = False
예제 #26
0
 def __init__(self):
     BigWorld.Entity.__init__(self)
     FlockLike.__init__(self)
     CallbackDelayer.__init__(self)
     self.flightAngleMin = math.radians(self.flightAngleMin)
     self.flightAngleMax = math.radians(self.flightAngleMax)
     if self.flightAngleMin < 0:
         self.flightAngleMin += math.ceil(abs(self.flightAngleMin) / (math.pi * 2)) * math.pi * 2
     elif self.flightAngleMin > math.pi * 2:
         self.flightAngleMin -= math.floor(self.flightAngleMin / (math.pi * 2)) * math.pi * 2
     self.__isTriggered = False
예제 #27
0
 def __init__(self, dataSection, avatarInputHandler):
     CallbackDelayer.__init__(self)
     self.__preferredPos = Vector3(0, 0, 0)
     self.__aih = weakref.proxy(avatarInputHandler)
     self.__cam = StrategicCamera.StrategicCamera(dataSection["camera"], None)
     self.__isEnabled = False
     self.__updateInterval = 0.1
     self.__activeSelector = _DefaultStrikeSelector(Vector3(0, 0, 0), None)
     self.__equipmentID = None
     self.__aimingMode = 0
     MapCaseControlMode.prevCtlMode = [Vector3(0, 0, 0), "", 0]
예제 #28
0
 def __init__(self):
     if not constants.IS_DEVELOPMENT:
         return
     CallbackDelayer.__init__(self)
     self.__items = {}
     self.__avgInfo = {}
     self.__textGui = GUI.Text()
     GUI.addRoot(self.__textGui)
     self.__textGui.position = (0, -0.25, 0)
     self.__textGui.multiline = True
     self.clear()
     self.__tickNames = {}
예제 #29
0
 def __init__(self, dataSection, avatarInputHandler):
     CallbackDelayer.__init__(self)
     self.__preferredPos = Vector3(0, 0, 0)
     self.__aih = weakref.proxy(avatarInputHandler)
     self.__cam = StrategicCamera.StrategicCamera(dataSection['camera'],
                                                  None)
     self.__isEnabled = False
     self.__updateInterval = 0.1
     self.__activeSelector = _DefaultStrikeSelector(Vector3(0, 0, 0), None)
     self.__equipmentID = None
     self.__aimingMode = 0
     MapCaseControlMode.prevCtlMode = [Vector3(0, 0, 0), '', 0]
예제 #30
0
 def __init__(self):
     if not constants.IS_DEVELOPMENT:
         return
     CallbackDelayer.__init__(self)
     self.__items = {}
     self.__avgInfo = {}
     self.__textGui = GUI.Text()
     GUI.addRoot(self.__textGui)
     self.__textGui.position = (0, -0.25, 0)
     self.__textGui.multiline = True
     self.clear()
     self.__tickNames = {}
 def __init__(self, beginExplosionPos, endExplosionPos, areaWidth, velocity):
     CallbackDelayer.__init__(self)
     self.model = BigWorld.Model('helpers/models/unit_cube.model')
     BigWorld.addModel(self.model)
     self.model.position = beginExplosionPos
     linearHomer = BigWorld.LinearHomer()
     self.model.addMotor(linearHomer)
     linearHomer.align = mathUtils.createSRTMatrix((areaWidth, 5, 1), (0.0, 0, 0), Vector3(0, 0, 0))
     linearHomer.acceleration = 0
     linearHomer.velocity = velocity
     linearHomer.target = mathUtils.createTranslationMatrix(endExplosionPos)
     linearHomer.proximityCallback = self.__onDeath
예제 #32
0
 def __init__(self, beginExplosionPos, endExplosionPos, areaWidth,
              velocity):
     CallbackDelayer.__init__(self)
     self.model = BigWorld.Model('helpers/models/unit_cube.model')
     BigWorld.addModel(self.model)
     self.model.position = beginExplosionPos
     linearHomer = BigWorld.LinearHomer()
     self.model.addMotor(linearHomer)
     linearHomer.align = mathUtils.createSRTMatrix((areaWidth, 5, 1),
                                                   (0.0, 0, 0),
                                                   Vector3(0, 0, 0))
     linearHomer.acceleration = 0
     linearHomer.velocity = velocity
     linearHomer.target = mathUtils.createTranslationMatrix(endExplosionPos)
     linearHomer.proximityCallback = self.__onDeath
예제 #33
0
    def onEnterWorld(self, prereqs):
        self.model = prereqs[self.__vehDescr.turret['models']['exploded']]
        self.__gunModel = prereqs[self.__vehDescr.gun['models']['exploded']]
        node = self.model.node('HP_gunJoint', 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[TankComponentNames.TURRET] = turretHitEffects = _HitEffects(self.model)
        self.__hitEffects[TankComponentNames.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 AvatarInputHandler.CallbackDelayer import CallbackDelayer
        self.__isBeingPulledCallback = CallbackDelayer()
        self.__isBeingPulledCallback.delayCallback(self.__checkIsBeingPulled(), self.__checkIsBeingPulled)
        DetachedTurret.allTurrets.append(self)
예제 #34
0
    def __init__(self, equipmentID, wingControlPoints):
        CallbackDelayer.__init__(self)
        self.__withdrawn = False
        self.__bombers = []
        modelName, soundEvent = self.__readData(equipmentID)
        speed = self.__calculateSpeed(wingControlPoints[0], wingControlPoints[1])
        flatVectors = map(self.__calculateDirAndNorm, (wingControlPoints[0].direction, wingControlPoints[1].direction))
        times = map(self.__convertTime, (wingControlPoints[0].time, wingControlPoints[1].time))
        for offset in self.__offsets:
            points = []
            for i in xrange(2):
                point = wingControlPoints[i]
                realOffset = self.__calculateOffset(offset, flatVectors[i])
                points.append(CurveControlPoint(point.position + realOffset, speed * point.direction, times[i]))

            bomberDesc = BomberDesc(modelName, soundEvent, points[0], points[1])
            self.__bombers.append(Bomber(bomberDesc))
 def __init__(self):
     self.__callbackDelayer = CallbackDelayer()
     self.__selectedAreas = {}
     self.__wings = {}
     if _ENABLE_DEBUG_DRAW:
         self.debugPolyLine = Flock.DebugPolyLine()
         self.debugPoints = []
         self.debugDirs = []
예제 #36
0
    def stop(self):
        self.__isStarted = False
        FMOD.setEventsParam('viewPlayMode', 0)
        self.__removeBattleCtrlListeners()
        for control in self.__ctrls.itervalues():
            control.destroy()

        replayCtrl = BattleReplay.g_replayCtrl
        if replayCtrl.isRecording:
            replayCtrl.setPlayerVehicleID(0)
        self.onCameraChanged = None
        self.__targeting.enable(False)
        self.__killerVehicleID = None
        g_guiResetters.remove(self.__onRecreateDevice)
        BigWorld.player().arena.onPeriodChange -= self.__onArenaStarted
        from account_helpers.settings_core.SettingsCore import g_settingsCore
        g_settingsCore.onSettingsChanged -= self.__onSettingsChanged
        CallbackDelayer.destroy(self)
예제 #37
0
 def __init__(self, dataSec, aim):
     CallbackDelayer.__init__(self)
     self.__positionOscillator = None
     self.__positionNoiseOscillator = None
     self.__dynamicCfg = CameraDynamicConfig()
     self.__readCfg(dataSec)
     self.__cam = BigWorld.CursorCamera()
     self.__curSense = self.__cfg['sensitivity']
     self.__onChangeControlMode = None
     self.__aimingSystem = StrategicAimingSystem(self.__cfg['distRange'][0], StrategicCamera._CAMERA_YAW)
     self.__prevTime = BigWorld.time()
     self.__aimOffsetFunc = None
     if aim is None:
         self.__aimOffsetFunc = lambda x = None: (0, 0)
     else:
         self.__aimOffsetFunc = aim.offset
     self.__autoUpdatePosition = False
     self.__dxdydz = Vector3(0, 0, 0)
     self.__needReset = 0
예제 #38
0
    def stop(self):
        self.__isStarted = False
        import SoundGroups
        SoundGroups.g_instance.changePlayMode(0)
        self.__removeBattleCtrlListeners()
        for control in self.__ctrls.itervalues():
            control.destroy()

        replayCtrl = BattleReplay.g_replayCtrl
        if replayCtrl.isRecording:
            replayCtrl.setPlayerVehicleID(0)
        self.onCameraChanged = None
        self.__targeting.enable(False)
        self.__killerVehicleID = None
        g_guiResetters.remove(self.__onRecreateDevice)
        BigWorld.player().arena.onPeriodChange -= self.__onArenaStarted
        from account_helpers.settings_core.SettingsCore import g_settingsCore
        g_settingsCore.onSettingsChanged -= self.__onSettingsChanged
        CallbackDelayer.destroy(self)
예제 #39
0
 def __init__(self, dataSec, aim):
     CallbackDelayer.__init__(self)
     self.__positionOscillator = None
     self.__positionNoiseOscillator = None
     self.__dynamicCfg = CameraDynamicConfig()
     self.__readCfg(dataSec)
     self.__cam = BigWorld.CursorCamera()
     self.__curSense = self.__cfg['sensitivity']
     self.__onChangeControlMode = None
     self.__aimingSystem = StrategicAimingSystem(
         self.__cfg['distRange'][0], StrategicCamera._CAMERA_YAW)
     self.__prevTime = BigWorld.time()
     self.__aimOffsetFunc = None
     if aim is None:
         self.__aimOffsetFunc = lambda x=None: (0, 0)
     else:
         self.__aimOffsetFunc = aim.offset
     self.__autoUpdatePosition = False
     self.__dxdydz = Vector3(0, 0, 0)
     self.__needReset = 0
예제 #40
0
 def __init__(self):
     CallbackDelayer.__init__(self)
     self.__alwaysShowAim = False
     self.__alwaysShowAimKey = None
     self.__showMarkersKey = None
     sec = self._readCfg()
     self.onCameraChanged = Event()
     self.onPostmortemVehicleChanged = Event()
     self.onSetReloading = Event()
     self.onSetReloadingPercents = Event()
     self.__isArenaStarted = False
     self.__isStarted = False
     self.__targeting = _Targeting()
     self.__vertScreenshotCamera = _VertScreenshotCamera()
     self.__ctrls = dict()
     self.__killerVehicleID = None
     self.__isAutorotation = True
     self.__prevModeAutorotation = None
     self.__isSPG = False
     self.__isATSPG = False
     self.__setupCtrls(sec)
     self.__curCtrl = self.__ctrls[_CTRLS_FIRST]
     self.__eMode = _CTRLS_FIRST
     self.__detachCount = 0
예제 #41
0
    def __init__(self, equipmentID, wingControlPoints):
        CallbackDelayer.__init__(self)
        self.__withdrawn = False
        self.__bombers = []
        modelName, soundEvent = self.__readData(equipmentID)
        speed = self.__calculateSpeed(wingControlPoints[0],
                                      wingControlPoints[1])
        flatVectors = map(
            self.__calculateDirAndNorm,
            (wingControlPoints[0].direction, wingControlPoints[1].direction))
        times = map(self.__convertTime,
                    (wingControlPoints[0].time, wingControlPoints[1].time))
        for offset in self.__offsets:
            points = []
            for i in xrange(2):
                point = wingControlPoints[i]
                realOffset = self.__calculateOffset(offset, flatVectors[i])
                points.append(
                    CurveControlPoint(point.position + realOffset,
                                      speed * point.direction, times[i]))

            bomberDesc = BomberDesc(modelName, soundEvent, points[0],
                                    points[1])
            self.__bombers.append(Bomber(bomberDesc))
예제 #42
0
 def __init__(self, avatar):
     CallbackDelayer.__init__(self)
     self.__avatar = weakref.proxy(avatar)
     self.__bFollowCamera = False
예제 #43
0
 def destroy(self):
     CallbackDelayer.destroy(self)
     for bomber in self.__bombers:
         bomber.destroy()
예제 #44
0
 def destroy(self):
     _SPGFlashGunMarker.destroy(self)
     CallbackDelayer.destroy(self)
     self.__desiredShotInfoFunc = None
     self.__trajectoryDrawer.visible = False
     self.__trajectoryDrawer = None
예제 #45
0
class CombatEquipmentManager(object):
    def testArtyStrike(self, id=33, offset=Vector3(0, 0, 0)):
        if not IS_DEVELOPMENT:
            return
        p = Vector3(BigWorld.camera().position)
        d = BigWorld.camera().direction
        collRes = BigWorld.wg_collideSegment(
            BigWorld.player().spaceID, p, p + d * 1000, 18,
            lambda matKind, collFlags, itemId, chunkId: collFlags & 8)
        if collRes is None:
            return
        strikePos = collRes[0]
        vDir = Vector2(d.x, d.z)
        vDir.normalise()
        self.setEquipmentApplicationPoint(id, strikePos + offset, vDir)

    def __init__(self):
        self.__callbackDelayer = CallbackDelayer()
        self.__selectedAreas = {}
        self.__wings = {}
        if _ENABLE_DEBUG_DRAW:
            self.debugPolyLine = Flock.DebugPolyLine()
            self.debugPoints = []
            self.debugDirs = []

    def onBecomePlayer(self):
        pass

    def onBecomeNonPlayer(self):
        for area in self.__selectedAreas.itervalues():
            area.destroy()

        for wing in self.__wings.itervalues():
            wing.destroy()

        self.__callbackDelayer.destroy()
        self.__selectedAreas = {}
        self.__wings = {}

    def updateBomberTrajectory(self, equipmentID, team, curTime, curPos,
                               curDir, nextTime, nextPos, nextDir,
                               isDroppingPoint):
        if _ENABLE_DEBUG_LOG:
            LOG_DEBUG('===== updateBomberTrajectory =====')
            LOG_DEBUG(equipmentID, team)
            LOG_DEBUG(curPos, curDir, curTime)
            LOG_DEBUG(nextPos, nextDir, nextTime)
            LOG_DEBUG(isDroppingPoint)
        moveDir = nextPos - curPos
        moveDir.normalise()
        nextDir3d = Vector3(nextDir.x, moveDir.y, nextDir.y)
        nextDir3d.normalise()
        startP = BombersWing.CurveControlPoint(curPos,
                                               Vector3(curDir.x, 0, curDir.y),
                                               curTime)
        nextP = BombersWing.CurveControlPoint(nextPos, nextDir3d, nextTime)
        points = (startP, nextP)
        wingID = (team, equipmentID)
        wing = self.__wings.get(wingID)
        if wing is None or wing.withdrawn:
            if wing is not None:
                wing.destroy()
            self.__wings[wingID] = BombersWing.BombersWing(equipmentID, points)
            if _ENABLE_DEBUG_DRAW:
                self.debugPoints.append(curPos)
                self.debugDirs.append(curDir)
        else:
            wing.addControlPoint(points, isDroppingPoint)
        if _ENABLE_DEBUG_DRAW:
            self.debugPoints.append(nextPos)
            self.debugDirs.append(nextDir)
            self.debugPoints.append(nextPos +
                                    Vector3(nextDir.x, 0, nextDir.y) * 10)
            self.debugPoints.append(nextPos)
            self.debugPolyLine.set(self.debugPoints)

    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()

    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)

    @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
        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
        flatDir.normalise()
        endDropPoint = pos + flatDir * (areaLength *
                                        bombEquipment.waveFraction)
        endExplosionPos = BigWorld.wg_collideSegment(
            BigWorld.player().spaceID, endDropPoint,
            endDropPoint + dir * 1000.0, 18)
        if endExplosionPos is None:
            endExplosionPos = beginExplosionPos + flatDir * (
                areaLength * bombEquipment.waveFraction)
        else:
            endExplosionPos = endExplosionPos[0]
        areaLength = beginExplosionPos.flatDistTo(endExplosionPos)
        averageBombCount = bombEquipment.bombsNumber
        bombsPerWidth, bombsPerLength = CombatEquipmentManager.__calcBombsDistribution(
            averageBombCount, areaWidth, areaLength)
        delay = time - BigWorld.serverTime()
        explosionVelocity = flatDir * bombEquipment.speed
        partialAirstrikeFunc = functools.partial(
            BigWorld.PyGroundEffectManager().playAirstrike, airstrikeID,
            beginExplosionPos, explosionVelocity, areaWidth, areaLength,
            math.ceil(bombsPerWidth), math.ceil(bombsPerLength))
        if _ENABLE_DEBUG_LOG:
            LOG_DEBUG('delta', delay)
            LOG_DEBUG('pos, dir', pos, dir)
            LOG_DEBUG('Params for artyStrike effect', airstrikeID,
                      beginExplosionPos, flatDir, areaWidth, areaLength,
                      bombsPerWidth, bombsPerLength)
        if delay < 0.0:
            partialAirstrikeFunc()
        else:
            self.__callbackDelayer.delayCallback(delay, partialAirstrikeFunc)
        if _ENABLE_DEBUG_DRAW:
            self.debugStartLine = Flock.DebugLine(pos, beginExplosionPos)
            self.debugEndLine = Flock.DebugLine(endDropPoint, endExplosionPos)
            self.__callbackDelayer.delayCallback(
                delay,
                functools.partial(_DebugFrontLine.launch, beginExplosionPos,
                                  endExplosionPos, areaWidth,
                                  explosionVelocity))

    def setEquipmentApplicationPoint(self, equipmentID, point, direction):
        myTeam = BigWorld.player().team
        wingID = (myTeam, equipmentID)
        wing = self.__wings.get(wingID)
        if wing is not None:
            wing.destroy()
            del self.__wings[wingID]
        self.cell.setEquipmentApplicationPoint(equipmentID, point, direction)

    @staticmethod
    def createEquipmentSelectedArea(pos, dir, equipment):
        area = CombatSelectedArea.CombatSelectedArea()
        size = Math.Vector2(equipment.areaWidth, equipment.areaLength)
        visual = equipment.areaVisual
        color = equipment.areaColor
        marker = equipment.areaMarker
        if visual is None:
            visual = CombatSelectedArea.DEFAULT_RADIUS_MODEL
        if color is None:
            color = CombatSelectedArea.COLOR_WHITE
        if marker is None:
            pass
        area.setup(pos, dir, size, visual, color, marker)
        return area
예제 #46
0
 def destroy(self):
     CallbackDelayer.destroy(self)
예제 #47
0
 def __init__(self, position, equipment):
     CallbackDelayer.__init__(self)
     self.equipment = equipment
     self.delayCallback(self._TICK_DELAY, self.__tick)
예제 #48
0
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 = {TankComponentNames.TURRET: None,
         TankComponentNames.GUN: None}
        self.__reactors = []
        self.targetFullBounds = True
        self.targetCaps = [1]
        self.__isBeingPulledCallback = None



    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.__gunModel = prereqs[self.__vehDescr.gun['models']['exploded']]
        node = self.model.node('HP_gunJoint', 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[TankComponentNames.TURRET] = turretHitEffects = _HitEffects(self.model)
        self.__hitEffects[TankComponentNames.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 AvatarInputHandler.CallbackDelayer import CallbackDelayer
        self.__isBeingPulledCallback = CallbackDelayer()
        self.__isBeingPulledCallback.delayCallback(self.__checkIsBeingPulled(), self.__checkIsBeingPulled)
        DetachedTurret.allTurrets.append(self)



    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



    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)



    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)




    def collideSegment(self, startPoint, endPoint, skipGun = False):
        res = None
        filterMethod = getattr(self.filter, 'segmentMayHitEntity', lambda : True)
        if not filterMethod(startPoint, endPoint):
            return res
        modelsToCheck = (self.model,) if skipGun else (self.model, self.__gunModel)
        for (model, desc,) in zip(modelsToCheck, self.__componentsDesc):
            toModel = Matrix(model.matrix)
            toModel.invert()
            collisions = desc['hitTester'].localHitTest(toModel.applyPoint(startPoint), toModel.applyPoint(endPoint))
            if collisions is None:
                continue
            for (dist, _, hitAngleCos, matKind,) in collisions:
                if res is None or res.dist >= dist:
                    matInfo = desc['materials'].get(matKind)
                    res = SegmentCollisionResult(dist, hitAngleCos, matInfo.armor if matInfo is not None else 0)


        return res



    def set_isUnderWater(self, prev):
        if self.__detachmentEffects is not None:
            if self.isUnderWater:
                self.__detachmentEffects.stopEffects()



    def set_isCollidingWithWorld(self, prev):
        pass



    def changeAppearanceVisibility(self, isVisible):
        self.model.visible = isVisible
        self.model.visibleAttachments = isVisible



    def __checkIsBeingPulled(self):
        if self.__detachmentEffects is not None:
            if self.isCollidingWithWorld and not self.isUnderWater and self.velocity.lengthSquared > 0.1:
                extent = Math.Matrix(self.model.bounds).applyVector(Math.Vector3(0.5, 0.5, 0.5)).length
                surfaceMaterial = calcSurfaceMaterialNearPoint(self.position, Math.Vector3(0, extent, 0), self.spaceID)
                self.__detachmentEffects.notifyAboutBeingPulled(True, surfaceMaterial.effectIdx)
                if surfaceMaterial.matKind == 0:
                    LOG_ERROR('calcSurfaceMaterialNearPoint failed to find the collision point')
            else:
                self.__detachmentEffects.notifyAboutBeingPulled(False, None)
        return SERVER_TICK_LENGTH
예제 #49
0
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 = {
            TankComponentNames.TURRET: None,
            TankComponentNames.GUN: None
        }
        self.__reactors = []
        self.targetFullBounds = True
        self.targetCaps = [1]
        self.__isBeingPulledCallback = None

    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.__gunModel = prereqs[self.__vehDescr.gun['models']['exploded']]
        node = self.model.node('HP_gunJoint', 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[
            TankComponentNames.TURRET] = turretHitEffects = _HitEffects(
                self.model)
        self.__hitEffects[
            TankComponentNames.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 AvatarInputHandler.CallbackDelayer import CallbackDelayer
        self.__isBeingPulledCallback = CallbackDelayer()
        self.__isBeingPulledCallback.delayCallback(self.__checkIsBeingPulled(),
                                                   self.__checkIsBeingPulled)
        DetachedTurret.allTurrets.append(self)

    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

    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)

    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)

    def collideSegment(self, startPoint, endPoint, skipGun=False):
        res = None
        filterMethod = getattr(self.filter, 'segmentMayHitEntity',
                               lambda: True)
        if not filterMethod(startPoint, endPoint, 0):
            return res
        modelsToCheck = (self.model, ) if skipGun else (self.model,
                                                        self.__gunModel)
        for model, desc in zip(modelsToCheck, self.__componentsDesc):
            toModel = Matrix(model.matrix)
            toModel.invert()
            collisions = desc['hitTester'].localHitTest(
                toModel.applyPoint(startPoint), toModel.applyPoint(endPoint))
            if collisions is None:
                continue
            for dist, _, hitAngleCos, matKind in collisions:
                if res is None or res.dist >= dist:
                    matInfo = desc['materials'].get(matKind)
                    res = SegmentCollisionResult(
                        dist, hitAngleCos,
                        matInfo.armor if matInfo is not None else 0)

        return res

    def set_isUnderWater(self, prev):
        if self.__detachmentEffects is not None:
            if self.isUnderWater:
                self.__detachmentEffects.stopEffects()

    def set_isCollidingWithWorld(self, prev):
        pass

    def changeAppearanceVisibility(self, isVisible):
        self.model.visible = isVisible
        self.model.visibleAttachments = isVisible

    def __checkIsBeingPulled(self):
        if self.__detachmentEffects is not None:
            if self.isCollidingWithWorld and not self.isUnderWater and self.velocity.lengthSquared > 0.1:
                extent = Math.Matrix(self.model.bounds).applyVector(
                    Math.Vector3(0.5, 0.5, 0.5)).length
                surfaceMaterial = calcSurfaceMaterialNearPoint(
                    self.position, Math.Vector3(0, extent, 0), self.spaceID)
                self.__detachmentEffects.notifyAboutBeingPulled(
                    True, surfaceMaterial.effectIdx)
                if surfaceMaterial.matKind == 0:
                    LOG_ERROR(
                        'calcSurfaceMaterialNearPoint failed to find the collision point'
                    )
            else:
                self.__detachmentEffects.notifyAboutBeingPulled(False, None)
        return SERVER_TICK_LENGTH
예제 #50
0
 def destroy(self):
     self.__avatar = None
     CallbackDelayer.destroy(self)
예제 #51
0
 def destroy(self):
     CallbackDelayer.destroy(self)
     for bomber in self.__bombers:
         bomber.destroy()
예제 #52
0
 def destroy(self):
     CallbackDelayer.destroy(self)
     if self.__turretSound is not None:
         self.__turretSound.stop()
     return
예제 #53
0
 def destroy(self):
     self.__avatar = None
     CallbackDelayer.destroy(self)
     return
예제 #54
0
 def onLeaveWorld(self):
     self.models = []
     FlockLike.destroy(self)
     CallbackDelayer.destroy(self)
class CombatEquipmentManager(object):

    def testArtyStrike(self, id = 33, offset = Vector3(0, 0, 0)):
        if not IS_DEVELOPMENT:
            return
        else:
            p = Vector3(BigWorld.camera().position)
            d = BigWorld.camera().direction
            collRes = BigWorld.wg_collideSegment(BigWorld.player().spaceID, p, p + d * 1000, 18, lambda matKind, collFlags, itemId, chunkId: collFlags & 8)
            if collRes is None:
                return
            strikePos = collRes[0]
            vDir = Vector2(d.x, d.z)
            vDir.normalise()
            self.setEquipmentApplicationPoint(id, strikePos + offset, vDir)
            return

    def __init__(self):
        self.__callbackDelayer = CallbackDelayer()
        self.__selectedAreas = {}
        self.__wings = {}
        if _ENABLE_DEBUG_DRAW:
            self.debugPolyLine = Flock.DebugPolyLine()
            self.debugPoints = []
            self.debugDirs = []

    def onBecomePlayer(self):
        pass

    def onBecomeNonPlayer(self):
        for area in self.__selectedAreas.itervalues():
            area.destroy()

        for wing in self.__wings.itervalues():
            wing.destroy()

        self.__callbackDelayer.destroy()
        self.__selectedAreas = {}
        self.__wings = {}

    def updateBomberTrajectory(self, equipmentID, team, curTime, curPos, curDir, nextTime, nextPos, nextDir, isDroppingPoint):
        if _ENABLE_DEBUG_LOG:
            LOG_DEBUG('===== updateBomberTrajectory =====')
            LOG_DEBUG(equipmentID, team)
            LOG_DEBUG(curPos, curDir, curTime)
            LOG_DEBUG(nextPos, nextDir, nextTime)
            LOG_DEBUG(isDroppingPoint)
        moveDir = nextPos - curPos
        moveDir.normalise()
        nextDir3d = Vector3(nextDir.x, moveDir.y, nextDir.y)
        nextDir3d.normalise()
        startP = BombersWing.CurveControlPoint(curPos, Vector3(curDir.x, 0, curDir.y), curTime)
        nextP = BombersWing.CurveControlPoint(nextPos, nextDir3d, nextTime)
        points = (startP, nextP)
        wingID = (team, equipmentID)
        wing = self.__wings.get(wingID)
        if wing is None or wing.withdrawn:
            if wing is not None:
                wing.destroy()
            self.__wings[wingID] = BombersWing.BombersWing(equipmentID, points)
            if _ENABLE_DEBUG_DRAW:
                self.debugPoints.append(curPos)
                self.debugDirs.append(curDir)
        else:
            wing.addControlPoint(points, isDroppingPoint)
        if _ENABLE_DEBUG_DRAW:
            self.debugPoints.append(nextPos)
            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
            flatDir.normalise()
            endDropPoint = pos + flatDir * (areaLength * bombEquipment.waveFraction)
            endExplosionPos = BigWorld.wg_collideSegment(BigWorld.player().spaceID, endDropPoint, endDropPoint + dir * 1000.0, 18)
            if endExplosionPos is None:
                endExplosionPos = beginExplosionPos + flatDir * (areaLength * bombEquipment.waveFraction)
            else:
                endExplosionPos = endExplosionPos[0]
            areaLength = beginExplosionPos.flatDistTo(endExplosionPos)
            averageBombCount = bombEquipment.bombsNumber
            bombsPerWidth, bombsPerLength = CombatEquipmentManager.__calcBombsDistribution(averageBombCount, areaWidth, areaLength)
            delay = time - BigWorld.serverTime()
            explosionVelocity = flatDir * bombEquipment.speed
            partialAirstrikeFunc = functools.partial(BigWorld.PyGroundEffectManager().playAirstrike, airstrikeID, beginExplosionPos, explosionVelocity, areaWidth, areaLength, math.ceil(bombsPerWidth), math.ceil(bombsPerLength))
            if _ENABLE_DEBUG_LOG:
                LOG_DEBUG('delta', delay)
                LOG_DEBUG('pos, dir', pos, dir)
                LOG_DEBUG('Params for artyStrike effect', airstrikeID, beginExplosionPos, flatDir, areaWidth, areaLength, bombsPerWidth, bombsPerLength)
            if delay < 0.0:
                partialAirstrikeFunc()
            else:
                self.__callbackDelayer.delayCallback(delay, partialAirstrikeFunc)
            if _ENABLE_DEBUG_DRAW:
                self.debugStartLine = Flock.DebugLine(pos, beginExplosionPos)
                self.debugEndLine = Flock.DebugLine(endDropPoint, endExplosionPos)
                self.__callbackDelayer.delayCallback(delay, functools.partial(_DebugFrontLine.launch, beginExplosionPos, endExplosionPos, areaWidth, explosionVelocity))
            return

    def setEquipmentApplicationPoint(self, equipmentID, point, direction):
        myTeam = BigWorld.player().team
        wingID = (myTeam, equipmentID)
        wing = self.__wings.get(wingID)
        if wing is not None:
            wing.destroy()
            del self.__wings[wingID]
        self.cell.setEquipmentApplicationPoint(equipmentID, point, direction)
        return

    @staticmethod
    def createEquipmentSelectedArea(pos, dir, equipment):
        area = CombatSelectedArea.CombatSelectedArea()
        size = Math.Vector2(equipment.areaWidth, equipment.areaLength)
        visual = equipment.areaVisual
        color = equipment.areaColor
        marker = equipment.areaMarker
        if visual is None:
            visual = CombatSelectedArea.DEFAULT_RADIUS_MODEL
        if color is None:
            color = CombatSelectedArea.COLOR_WHITE
        if marker is None:
            pass
        area.setup(pos, dir, size, visual, color, marker)
        return area
예제 #56
0
 def onLeaveWorld(self):
     self.models = []
     FlockLike.destroy(self)
     CallbackDelayer.destroy(self)
예제 #57
0
 def __init__(self, curShotInfoFunc, dispersionUpdateFunc, desiredShotInfoFunc):
     _SPGFlashGunMarker.__init__(self, curShotInfoFunc, dispersionUpdateFunc, _SuperGunMarker.GUN_MARKER_CLIENT)
     CallbackDelayer.__init__(self)
     self.__updateInterval = 0.0 if BattleReplay.g_replayCtrl.isPlaying else 0.1
     self.__desiredShotInfoFunc = desiredShotInfoFunc
     self.__trajectoryDrawer = BigWorld.wg_trajectory_drawer()
예제 #58
0
 def __init__(self, avatar):
     CallbackDelayer.__init__(self)
     self.__avatar = weakref.proxy(avatar)
     self.__bFollowCamera = False
예제 #59
0
 def destroy(self):
     CallbackDelayer.destroy(self)
예제 #60
0
 def destroy(self):
     CallbackDelayer.destroy(self)
     self.disable()
     self.__activeSelector = None
     self.__cam.destroy()
     self.__aih = None