def start(self, shellReloadTime, alert, shellCount, reloadShellCount, shellID, reloadStart): if gEffectsDisabled(): return else: if BARREL_DEBUG_ENABLED: LOG_DEBUG( 'AutoReload::start time = {0} {1} {2} {3} {4} {5} {6} '. format(BigWorld.time(), shellReloadTime, alert, shellCount, reloadShellCount, shellID, reloadStart)) SoundGroups.g_instance.setSwitch(_CALIBER_RELOAD_SOUND_SWITCH, self._desc.caliber) self.stopCallback(self.__onShellInTheBarrel) self._almostCompleteSnd = None if self._sound is None: self._sound = SoundGroups.g_instance.getSound2D( self._desc.soundEvent) else: self._sound.stop() if reloadStart: if shellCount == 0: playByName(self._desc.reloadStart) if alert: playByName(self._desc.ammoLow) time = shellReloadTime - self._desc.duration if time < 0.0: time = 0.0 self.delayCallback(time, self.__onShellInTheBarrel, shellCount, reloadShellCount, BigWorld.time() + time) self._checkAndPlayGunRammerEffect(shellReloadTime) return
def _createEffects(appearance): if gEffectsDisabled(): appearance.customEffectManager = None return else: appearance.customEffectManager = CustomEffectManager(appearance) return
def __init__(self, avatar): self.__avatar = weakref.proxy(avatar) self.__isStarted = False self.__prevSentShotPoint = None self.__targetLastShotPoint = False self.__lastShotPoint = Math.Vector3(0, 0, 0) self.__shotPointSourceFunctor = self.__shotPointSourceFunctor_Default self.__maxTurretRotationSpeed = None self.__maxGunRotationSpeed = None self.__turretYaw = 0.0 self.__gunPitch = 0.0 self.__turretRotationSpeed = 0.0 self.__dispersionAngles = [0.0, 0.0] self.__markerInfo = (Math.Vector3(0.0, 0.0, 0.0), Math.Vector3(0.0, 1.0, 0.0), 1.0) self.__clientMode = True self.__showServerMarker = False self.__time = None self.__timerID = None self.__turretMatrixAnimator = _MatrixAnimator(self.__avatar) self.__gunMatrixAnimator = _MatrixAnimator(self.__avatar) self.__isLocked = False self.estimatedTurretRotationTime = 0 if not gEffectsDisabled(): self.__turretRotationSoundEffect = _PlayerTurretRotationSoundEffectWWISE() else: self.__turretRotationSoundEffect = None g__attachToCam = False return
def _assembleParts(self, isPlayer, appearance): if appearance.isAlive: appearance.detailedEngineState = self.__assembleEngineState( isPlayer) if not appearance.isPillbox and not gEffectsDisabled(): appearance.engineAudition = self.__assembleEngineAudition( isPlayer, appearance) appearance.detailedEngineState.onEngineStart += appearance.engineAudition.onEngineStart appearance.detailedEngineState.onStateChanged += appearance.engineAudition.onStateChanged createEffects(appearance) if isPlayer: gunRotatorConnector = GunRotatorConnector(appearance) appearance.addComponent(gunRotatorConnector) appearance.frictionAudition = Vehicular.FrictionAudition( TANK_FRICTION_EVENT) self.__createTrackCrashControl(appearance) appearance.highlighter = Highlighter() isLodTopPriority = isPlayer lodCalcInst = Vehicular.LodCalculator( DataLinks.linkMatrixTranslation(appearance.compoundModel.matrix), True, VEHICLE_PRIORITY_GROUP, isLodTopPriority) appearance.lodCalculator = lodCalcInst lodLink = DataLinks.createFloatLink(lodCalcInst, 'lodDistance') lodStateLink = lodCalcInst.lodStateLink if not appearance.damageState.isCurrentModelDamaged: model_assembler.assembleRecoil(appearance, lodLink) model_assembler.assembleLeveredSuspensionIfNeed( appearance, lodStateLink) _assembleSwinging(appearance, lodLink) model_assembler.assembleSuspensionSound(appearance, lodLink, isPlayer) model_assembler.assembleSuspensionController(appearance) model_assembler.setupTurretRotations(appearance)
def add(self, shotID, effectsDescr, gravity, refStartPoint, refVelocity, startPoint, maxDistance, attackerID = 0, tracerCameraPos = Math.Vector3(0, 0, 0)): import BattleReplay if BattleReplay.g_replayCtrl.isTimeWarpInProgress: return else: artID = effectsDescr.get('artilleryID') if artID is not None: self.salvo.addProjectile(artID, gravity, refStartPoint, refVelocity) return projectileMotor = self.__ballistics.addProjectile(shotID, gravity, refStartPoint, refVelocity, startPoint, maxDistance, attackerID, ownVehicleGunPositionGetter(), tracerCameraPos) if projectileMotor is None: return projModelName, projModelOwnShotName, projEffects = effectsDescr['projectile'] isOwnShoot = attackerID == BigWorld.player().playerVehicleID model = BigWorld.Model(projModelOwnShotName if isOwnShoot else projModelName) proj = {'model': model, 'motor': projectileMotor, 'effectsDescr': effectsDescr, 'showExplosion': False, 'fireMissedTrigger': isOwnShoot, 'autoScaleProjectile': isOwnShoot, 'attackerID': attackerID, 'effectsData': {}} if not gEffectsDisabled(): BigWorld.player().addModel(model) model.addMotor(projectileMotor) model.visible = False model.visibleAttachments = True projEffects.attachTo(proj['model'], proj['effectsData'], 'flying', isPlayerVehicle=isOwnShoot, isArtillery=False) self.__projectiles[shotID] = proj FlockManager.getManager().onProjectile(startPoint) return
def __isNeedToPlay(self, waitForKeyOff): if helpers.gEffectsDisabled(): return (False, None) import BattleReplay replayCtrl = BattleReplay.g_replayCtrl if replayCtrl.isPlaying: entity_id = -1 if 'entity_id' in self.__args: entity_id = self.__args['entity_id'] need_play = True if entity_id > -1: need_play = replayCtrl.isNeedToPlay(entity_id) if need_play: if replayCtrl.isTimeWarpInProgress: if not waitForKeyOff: warpDelta = replayCtrl.warpTime - replayCtrl.currentTime if self.__keyPoints[-1].time / 2 < warpDelta: return (False, None) else: return (True, None) for key in self.__keyPoints: if key.name == SpecialKeyPointNames.STATIC: return (True, SpecialKeyPointNames.STATIC) return (False, None) else: return (True, None)
def add(self, shotID, effectsDescr, gravity, refStartPoint, refVelocity, startPoint, maxDistance, attackerID = 0, tracerCameraPos = Math.Vector3(0, 0, 0)): import BattleReplay if BattleReplay.g_replayCtrl.isTimeWarpInProgress: return else: if startPoint.distTo(refStartPoint) > ProjectileMover.__START_POINT_MAX_DIFF: startPoint = refStartPoint artID = effectsDescr.get('artilleryID') if artID is not None: self.salvo.addProjectile(artID, gravity, refStartPoint, refVelocity) return projectileMotor = self.__ballistics.addProjectile(shotID, gravity, refStartPoint, refVelocity, startPoint, maxDistance, attackerID, ownVehicleGunPositionGetter(), tracerCameraPos) if projectileMotor is None: return projModelName, projModelOwnShotName, projEffects = effectsDescr['projectile'] isOwnShoot = attackerID == BigWorld.player().playerVehicleID model = BigWorld.Model(projModelOwnShotName if isOwnShoot else projModelName) proj = {'model': model, 'motor': projectileMotor, 'effectsDescr': effectsDescr, 'showExplosion': False, 'fireMissedTrigger': isOwnShoot, 'autoScaleProjectile': isOwnShoot, 'attackerID': attackerID, 'effectsData': {}} if not gEffectsDisabled(): BigWorld.player().addModel(model) model.addMotor(projectileMotor) model.visible = False model.visibleAttachments = True projEffects.attachTo(proj['model'], proj['effectsData'], 'flying', isPlayerVehicle=isOwnShoot, isArtillery=False) self.__projectiles[shotID] = proj FlockManager.getManager().onProjectile(startPoint) return
def start(self, shellReloadTime, alert, shellCount, reloadShellCount): if gEffectsDisabled(): return SoundGroups.g_instance.setSwitch('SWITCH_ext_rld_automat_caliber', self._desc.caliber) if shellCount == 0: self.stopCallback(self._startLoopEvent) self.stopCallback(self._loopOneShoot) SoundGroups.g_instance.playSound2D(self._desc.stopLoop) time = shellReloadTime - self._desc.duration self.delayCallback(time, self._startLoopEvent) if reloadShellCount != 0: self.__shellDt = self._desc.duration / reloadShellCount else: self.__shellDt = self._desc.duration self.__reloadCount = reloadShellCount if BARREL_DEBUG_ENABLED: LOG_DEBUG('!!! Play Long = {0}'.format(self._desc.startLong)) SoundGroups.g_instance.playSound2D(self._desc.startLong) if alert: if BARREL_DEBUG_ENABLED: LOG_DEBUG('!!! Play Ammo Low = {0}'.format(self._desc.ammoLow)) SoundGroups.g_instance.playSound2D(self._desc.ammoLow) else: if shellCount == 1: if BARREL_DEBUG_ENABLED: LOG_DEBUG('!!! Play Alert = {0}'.format(self._desc.lastShellAlert)) SoundGroups.g_instance.playSound2D(self._desc.lastShellAlert) time = shellReloadTime - self._desc.shellDuration self.delayCallback(time, self._startOneShoot)
def start(self, shellReloadTime, alert, shellCount, reloadShellCount): if gEffectsDisabled(): return SoundGroups.g_instance.setSwitch('SWITCH_ext_rld_automat_caliber', self._desc.caliber) if shellCount == 0: self.stopCallback(self._startLoopEvent) self.stopCallback(self._loopOneShoot) SoundGroups.g_instance.playSound2D(self._desc.stopLoop) time = shellReloadTime - self._desc.duration self.delayCallback(time, self._startLoopEvent) if reloadShellCount != 0: self.__shellDt = self._desc.duration / reloadShellCount else: self.__shellDt = self._desc.duration self.__reloadCount = reloadShellCount if BARREL_DEBUG_ENABLED: LOG_DEBUG('!!! Play Long = {0}'.format(self._desc.startLong)) SoundGroups.g_instance.playSound2D(self._desc.startLong) if alert: if BARREL_DEBUG_ENABLED: LOG_DEBUG('!!! Play Ammo Low = {0}'.format( self._desc.ammoLow)) SoundGroups.g_instance.playSound2D(self._desc.ammoLow) else: if shellCount == 1: if BARREL_DEBUG_ENABLED: LOG_DEBUG('!!! Play Alert = {0}'.format( self._desc.lastShellAlert)) SoundGroups.g_instance.playSound2D(self._desc.lastShellAlert) time = shellReloadTime - self._desc.shellDuration self.delayCallback(time, self._startOneShoot)
def start(self, shellReloadTime, alert, shellCount, reloadShellCount, shellID, reloadStart): if gEffectsDisabled(): return else: SoundGroups.g_instance.setSwitch('SWITCH_ext_rld_automat_caliber', self._desc.caliber) currentTime = BigWorld.time() if shellCount == 0: self.stopCallback(self._startOneShoot) self.__reloadSequence.schedule(shellReloadTime, reloadShellCount) self._checkAndPlayGunRammerEffect(shellReloadTime) if reloadStart and shellReloadTime > self._desc.duration: if self._startLongSound is not None: self._startLongSound.stop() self._startLongSound = SoundGroups.g_instance.getSound2D(self._desc.startLong) self.__playStartLongSound() if BARREL_DEBUG_ENABLED: LOG_DEBUG('!!! Play Long = {0} {1}'.format(currentTime, self._desc.startLong)) if alert: playByName(self._desc.ammoLow) if BARREL_DEBUG_ENABLED: LOG_DEBUG('!!! Play Ammo Low = {0} {1}'.format(currentTime, self._desc.ammoLow)) else: if shellCount == 1 and reloadShellCount > 2: if BARREL_DEBUG_ENABLED: LOG_DEBUG('!!! Play Alert = {0} {1}'.format(currentTime, self._desc.lastShellAlert)) playByName(self._desc.lastShellAlert) time = shellReloadTime - self._desc.shellDuration self.delayCallback(time, self._startOneShoot, currentTime + time) return
def __init__(self, avatar): self.__avatar = weakref.proxy(avatar) self.__isStarted = False self.__prevSentShotPoint = None self.__targetLastShotPoint = False self.__lastShotPoint = Math.Vector3(0, 0, 0) self.__shotPointSourceFunctor = self.__shotPointSourceFunctor_Default self.__maxTurretRotationSpeed = None self.__maxGunRotationSpeed = None self.__turretYaw = 0.0 self.__gunPitch = 0.0 self.__turretRotationSpeed = 0.0 self.__dispersionAngles = [0.0, 0.0] self.__markerInfo = (Math.Vector3(0.0, 0.0, 0.0), Math.Vector3(0.0, 1.0, 0.0), 1.0) self.__clientMode = True self.__showServerMarker = False self.__time = None self.__timerID = None self.__turretMatrixAnimator = _MatrixAnimator(self.__avatar) self.__gunMatrixAnimator = _MatrixAnimator(self.__avatar) self.__isLocked = False self.estimatedTurretRotationTime = 0 if not gEffectsDisabled(): self.__turretRotationSoundEffect = _PlayerTurretRotationSoundEffectWWISE( ) else: self.__turretRotationSoundEffect = None self.__aimingPerfectionStartTime = None return
def start(self, shellReloadTime, alert, shellCount, reloadShellCount, shellID, reloadStart): if gEffectsDisabled(): return SoundGroups.g_instance.setSwitch('SWITCH_ext_rld_automat_caliber', self._desc.caliber) currentTime = BigWorld.time() if shellCount == 0: self.__reloadSequence.schedule(shellReloadTime, reloadShellCount) if reloadStart: playByName(self._desc.startLong) if BARREL_DEBUG_ENABLED: LOG_DEBUG('!!! Play Long = {0} {1}'.format( currentTime, self._desc.startLong)) if alert: if BARREL_DEBUG_ENABLED: LOG_DEBUG('!!! Play Ammo Low = {0} {1}'.format( currentTime, self._desc.ammoLow)) else: if shellCount == 1: if BARREL_DEBUG_ENABLED: LOG_DEBUG('!!! Play Alert = {0} {1}'.format( currentTime, self._desc.lastShellAlert)) playByName(self._desc.lastShellAlert) time = shellReloadTime - self._desc.shellDuration self.delayCallback(time, self._startOneShoot, currentTime + time)
def createEffects(appearance): if gEffectsDisabled(): appearance.customEffectManager = None return else: appearance.customEffectManager = CustomEffectManager(appearance) if not appearance.typeDescriptor.hasSiegeMode: return appearance.siegeEffects = SiegeEffectsController(appearance) return
def _assembleParts(self, vehicle, appearance): appearance.detailedEngineState = self.__assembleEngineState(vehicle) _createEffects(vehicle, appearance) if vehicle.isAlive(): if not appearance.isPillbox and not gEffectsDisabled(): appearance.engineAudition = self.__assembleEngineAudition(vehicle, appearance) appearance.detailedEngineState.onEngineStart += appearance.engineAudition.onEngineStart if vehicle.isPlayerVehicle: gunRotatorConnector = GunRotatorConnector(appearance.compoundModel) appearance.addComponent(gunRotatorConnector) self.__createTrackCrashControl(vehicle, appearance) appearance.highlighter = Highlighter(vehicle)
def start(self, shellReloadTime, alert, lastShell, reloadShellCount): if gEffectsDisabled(): return else: if self._sound is None: self._sound = SoundGroups.g_instance.getSound2D(self._desc.soundEvent) else: self._sound.stop() time = shellReloadTime - self._desc.duration if time > 0.0: self.delayCallback(time, self._startEvent) return
def start(self, shellReloadTime, alert, lastShell, reloadShellCount): if gEffectsDisabled(): return else: if self._sound is None: self._sound = SoundGroups.g_instance.getSound2D( self._desc.soundEvent) else: self._sound.stop() time = shellReloadTime - self._desc.duration if time > 0.0: self.delayCallback(time, self._startEvent) return
def _createEffects(vehicle, appearance): if not vehicle.isAlive(): return elif gEffectsDisabled(): appearance.customEffectManager = None return else: if vehicle.physicsMode == VEHICLE_PHYSICS_MODE.DETAILED: appearance.customEffectManager = CustomEffectManager(vehicle, appearance.detailedEngineState) else: appearance.exhaustEffects = VehicleExhaustEffects(vehicle.typeDescriptor) appearance.trailEffects = VehicleTrailEffects(vehicle) return
def start(self, shellReloadTime, alert, shellCount, reloadShellCount, shellID, reloadStart): if gEffectsDisabled(): return else: if self._sound is None: self._sound = SoundGroups.g_instance.getSound2D(self._desc.soundEvent) else: self._sound.stop() time = shellReloadTime - self._desc.duration if time < 0.0: time = 0.0 self._checkAndPlayGunRammerEffect(shellReloadTime) self.delayCallback(time, self.__playSound) return
def _assembleParts(self, isPlayer, appearance): appearance.filter = model_assembler.createVehicleFilter( appearance.typeDescriptor) if appearance.isAlive: appearance.detailedEngineState = model_assembler.assembleDetailedEngineState( appearance.compoundModel, appearance.filter, appearance.typeDescriptor, isPlayer) if not gEffectsDisabled(): model_assembler.assembleVehicleAudition(isPlayer, appearance) model_assembler.subscribeEngineAuditionToEngineState( appearance.engineAudition, appearance.detailedEngineState) createEffects(appearance) if isPlayer: gunRotatorConnector = GunRotatorConnector(appearance) appearance.addComponent(gunRotatorConnector) appearance.frictionAudition = Vehicular.FrictionAudition( TANK_FRICTION_EVENT) appearance.peripheralsController = PeripheralsController() self.__createTrackCrashControl(appearance) appearance.highlighter = Highlighter() isLodTopPriority = isPlayer lodCalcInst = Vehicular.LodCalculator( DataLinks.linkMatrixTranslation(appearance.compoundModel.matrix), True, VEHICLE_PRIORITY_GROUP, isLodTopPriority) appearance.lodCalculator = lodCalcInst lodLink = DataLinks.createFloatLink(lodCalcInst, 'lodDistance') lodStateLink = lodCalcInst.lodStateLink isDamaged = appearance.damageState.isCurrentModelDamaged if not isDamaged: self.__assembleNonDamagedOnly(appearance, isPlayer, lodLink, lodStateLink) model_assembler.setupTurretRotations(appearance) if appearance.fashion is not None: appearance.fashion.movementInfo = appearance.filter.movementInfo appearance.waterSensor = model_assembler.assembleWaterSensor( appearance.typeDescriptor, appearance, lodStateLink) if appearance.engineAudition is not None: appearance.engineAudition.setIsUnderwaterInfo( DataLinks.createBoolLink(appearance.waterSensor, 'isUnderWater')) appearance.engineAudition.setIsInWaterInfo( DataLinks.createBoolLink(appearance.waterSensor, 'isInWater')) if isPlayer and BigWorld.player().isInTutorial: tutorialMatKindsController = TutorialMatKindsController() tutorialMatKindsController.terrainMatKindsLink = lambda: appearance.terrainMatKind appearance.addComponent(tutorialMatKindsController) self.__postSetupFilter(appearance) return
def start(self, shellReloadTime, ammoLow, directTrigger=False): if gEffectsDisabled() or not directTrigger: return else: SoundGroups.g_instance.setSwitch(_CALIBER_RELOAD_SOUND_SWITCH, self._desc.caliber) self.stopCallback(self.__onReloadStart) timeToStart = shellReloadTime - self._desc.runTimeDelta if self.__sound is None: self.__sound = SoundGroups.g_instance.getSound2D(self._desc.soundEvent) if timeToStart > 0: self.delayCallback(timeToStart, self.__onReloadStart, BigWorld.time() + timeToStart) if ammoLow: timeToStart = shellReloadTime - self._desc.runTimeDeltaAmmoLow self.__ammoLowSound = SoundGroups.g_instance.getSound2D(self._desc.ammoLowSound) self.delayCallback(timeToStart, self.__onAmmoLow, BigWorld.time() + timeToStart) self._checkAndPlayGunRammerEffect(shellReloadTime) return
def _assembleParts(self, isPlayer, appearance): if appearance.isAlive: appearance.detailedEngineState = self.__assembleEngineState(isPlayer) if not appearance.isPillbox and not gEffectsDisabled(): appearance.engineAudition = self.__assembleEngineAudition(isPlayer, appearance) appearance.detailedEngineState.onEngineStart += appearance.engineAudition.onEngineStart appearance.detailedEngineState.onStateChanged += appearance.engineAudition.onStateChanged _createEffects(appearance) if isPlayer: gunRotatorConnector = GunRotatorConnector(appearance) appearance.addComponent(gunRotatorConnector) self.__createTrackCrashControl(appearance) appearance.highlighter = Highlighter() lodCalcInst = Vehicular.LodCalculator(DataLinks.linkMatrixTranslation(appearance.compoundModel.matrix), True) appearance.lodCalculator = lodCalcInst lodLink = DataLinks.createFloatLink(lodCalcInst, 'lodDistance') if not appearance.damageState.isCurrentModelDamaged: model_assembler.assembleRecoil(appearance, lodLink) _assembleSwinging(appearance, lodLink) model_assembler.setupTurretRotations(appearance)
def _assembleParts(self, isPlayer, appearance): if appearance.isAlive: appearance.detailedEngineState = self.__assembleEngineState( isPlayer) if not appearance.isPillbox and not gEffectsDisabled(): appearance.engineAudition = self.__assembleEngineAudition( isPlayer, appearance) appearance.detailedEngineState.onEngineStart += appearance.engineAudition.onEngineStart appearance.detailedEngineState.onStateChanged += appearance.engineAudition.onStateChanged _createEffects(appearance) if isPlayer: gunRotatorConnector = GunRotatorConnector(appearance) appearance.addComponent(gunRotatorConnector) self.__createTrackCrashControl(appearance) appearance.highlighter = Highlighter() lodCalcInst = Vehicular.LodCalculator( DataLinks.linkMatrixTranslation(appearance.compoundModel.matrix), True) appearance.lodCalculator = lodCalcInst lodLink = DataLinks.createFloatLink(lodCalcInst, 'lodDistance') if not appearance.damageState.isCurrentModelDamaged: model_assembler.assembleRecoil(appearance, lodLink) _assembleSwinging(appearance, lodLink) model_assembler.setupTurretRotations(appearance)
def _assembleParts(self, isPlayer, appearance, resourceRefs): appearance.filter = model_assembler.createVehicleFilter( appearance.typeDescriptor) if appearance.isAlive: appearance.detailedEngineState = model_assembler.assembleDetailedEngineState( appearance.compoundModel, appearance.filter, appearance.typeDescriptor, isPlayer) if not gEffectsDisabled(): model_assembler.assembleVehicleAudition(isPlayer, appearance) model_assembler.subscribeEngineAuditionToEngineState( appearance.engineAudition, appearance.detailedEngineState) createEffects(appearance) if isPlayer: gunRotatorConnector = GunRotatorConnector(appearance) appearance.addComponent(gunRotatorConnector) appearance.frictionAudition = Vehicular.FrictionAudition( TANK_FRICTION_EVENT) appearance.peripheralsController = PeripheralsController() self.__createTrackCrashControl(appearance) appearance.highlighter = Highlighter() compoundModel = appearance.compoundModel isLodTopPriority = isPlayer lodCalcInst = Vehicular.LodCalculator( DataLinks.linkMatrixTranslation(appearance.compoundModel.matrix), True, VEHICLE_PRIORITY_GROUP, isLodTopPriority) appearance.lodCalculator = lodCalcInst lodLink = DataLinks.createFloatLink(lodCalcInst, 'lodDistance') lodStateLink = lodCalcInst.lodStateLink matrixBinding = BigWorld.player( ).consistentMatrices.onVehicleMatrixBindingChanged appearance.shadowManager = VehicleShadowManager( compoundModel, matrixBinding) isDamaged = appearance.damageState.isCurrentModelDamaged if not isDamaged: self.__assembleNonDamagedOnly(appearance, isPlayer, lodLink, lodStateLink) dirtEnabled = BigWorld.WG_dirtEnabled( ) and 'HD' in appearance.typeDescriptor.type.tags fashions = appearance.fashions if dirtEnabled and fashions is not None: dirtHandlers = [ BigWorld.PyDirtHandler( True, compoundModel.node(TankPartNames.CHASSIS).position.y), BigWorld.PyDirtHandler( False, compoundModel.node(TankPartNames.HULL).position.y), BigWorld.PyDirtHandler( False, compoundModel.node(TankPartNames.TURRET).position.y), BigWorld.PyDirtHandler( False, compoundModel.node(TankPartNames.GUN).position.y) ] modelHeight, _ = appearance.computeVehicleHeight() appearance.dirtComponent = Vehicular.DirtComponent( dirtHandlers, modelHeight) for fashionIdx, _ in enumerate(TankPartNames.ALL): fashions[fashionIdx].addMaterialHandler( dirtHandlers[fashionIdx]) model_assembler.setupTurretRotations(appearance) if appearance.fashion is not None: appearance.fashion.movementInfo = appearance.filter.movementInfo appearance.waterSensor = model_assembler.assembleWaterSensor( appearance.typeDescriptor, appearance, lodStateLink) if appearance.engineAudition is not None: appearance.engineAudition.setIsUnderwaterInfo( DataLinks.createBoolLink(appearance.waterSensor, 'isUnderWater')) appearance.engineAudition.setIsInWaterInfo( DataLinks.createBoolLink(appearance.waterSensor, 'isInWater')) if isPlayer and BigWorld.player().isInTutorial: tutorialMatKindsController = TutorialMatKindsController() tutorialMatKindsController.terrainMatKindsLink = lambda: appearance.terrainMatKind appearance.addComponent(tutorialMatKindsController) self.__postSetupFilter(appearance) compoundModel.setPartBoundingBoxAttachNode( TankPartIndexes.GUN, TankNodeNames.GUN_INCLINATION) return
def construct(self, isPlayer, resourceRefs): self.__isObserver = 'observer' in self.typeDescriptor.type.tags self._compoundModel = resourceRefs[self.typeDescriptor.name] self.removeComponentByType(GenericComponents.DynamicModelComponent) self.createComponent(GenericComponents.DynamicModelComponent, self._compoundModel) if not self._compoundModel.isValid(): _logger.error('compoundModel is not valid') if self.typeDescriptor.gun.edgeByVisualModel: self._compoundModel.setPartProperties( TankPartIndexes.GUN, PartProperties.HIGHLIGHTABLE | PartProperties.HIGHLIGHTBYVISUAL) self._compoundModel.setPartProperties( TankPartIndexes.CHASSIS, PartProperties.HIGHLIGHTABLE | PartProperties.HIGHLIGHTBYVISUAL) self.__boundEffects = bound_effects.ModelBoundEffects( self.compoundModel) isCurrentModelDamaged = self.damageState.isCurrentModelDamaged fashions = camouflages.prepareFashions(isCurrentModelDamaged) if not isCurrentModelDamaged: model_assembler.setupTracksFashion(self.typeDescriptor, fashions.chassis) self.collisions = self.createComponent( BigWorld.CollisionComponent, resourceRefs['collisionAssembler']) model_assembler.setupCollisions(self.typeDescriptor, self.collisions) self._setFashions(fashions, self.isTurretDetached) self._setupModels() if not isCurrentModelDamaged: modelsSet = self.outfit.modelsSet if IS_EDITOR: modelsSet = self.currentModelsSet self._splineTracks = model_assembler.setupSplineTracks( self.fashion, self.typeDescriptor, self.compoundModel, resourceRefs, modelsSet) self.crashedTracksController = CrashedTrackController( self.typeDescriptor, self.fashion, modelsSet) else: self.__trackScrollCtl = None self._chassisDecal.create() if self.modelsSetParams.state == 'undamaged': self.__modelAnimators = camouflages.getModelAnimators( self.outfit, self.typeDescriptor, self.spaceID, resourceRefs, self.compoundModel) self.__modelAnimators.extend( camouflages.getAttachmentsAnimators(self.__attachments, self.spaceID, resourceRefs, self.compoundModel)) self.transform = self.createComponent( GenericComponents.TransformComponent, Math.Vector3(0, 0, 0)) self.areaTriggerTarget = self.createComponent( Triggers.AreaTriggerTarget) self.__filter = model_assembler.createVehicleFilter( self.typeDescriptor) compoundModel = self.compoundModel if self.isAlive: self.detailedEngineState, self.gearbox = model_assembler.assembleDrivetrain( self, isPlayer) if not gEffectsDisabled(): self.customEffectManager = CustomEffectManager(self) if self.typeDescriptor.hasSiegeMode: self.siegeEffects = SiegeEffectsController(self, isPlayer) model_assembler.assembleVehicleAudition(isPlayer, self) self.detailedEngineState.onEngineStart = self._onEngineStart self.detailedEngineState.onStateChanged = self.engineAudition.onEngineStateChanged if isPlayer: turret = self.typeDescriptor.turret gunRotatorAudition = self.createComponent( Vehicular.GunRotatorAudition, turret.turretRotatorSoundManual, turret.weight / 1000.0, compoundModel.node(TankPartNames.TURRET)) gunRotatorAudition.vehicleMatrixLink = self.compoundModel.root gunRotatorAudition.damaged = lambda: self.turretDamaged() gunRotatorAudition.maxTurretRotationSpeed = lambda: self.maxTurretRotationSpeed( ) self.gunRotatorAudition = gunRotatorAudition self.frictionAudition = self.createComponent( Vehicular.FrictionAudition, TANK_FRICTION_EVENT) isLodTopPriority = isPlayer lodCalcInst = self.createComponent( Vehicular.LodCalculator, DataLinks.linkMatrixTranslation(compoundModel.matrix), True, VEHICLE_PRIORITY_GROUP, isLodTopPriority) self.lodCalculator = lodCalcInst self.allLodCalculators.append(lodCalcInst) lodLink = DataLinks.createFloatLink(lodCalcInst, 'lodDistance') lodStateLink = lodCalcInst.lodStateLink if IS_EDITOR: matrixBinding = None changeCamera = None else: matrixBinding = BigWorld.player( ).consistentMatrices.onVehicleMatrixBindingChanged changeCamera = BigWorld.player().inputHandler.onCameraChanged self.shadowManager = VehicleShadowManager(compoundModel, matrixBinding, changeCamera) if not self.damageState.isCurrentModelDamaged: self.__assembleNonDamagedOnly(resourceRefs, isPlayer, lodLink, lodStateLink) dirtEnabled = BigWorld.WG_dirtEnabled( ) and 'HD' in self.typeDescriptor.type.tags if dirtEnabled and self.fashions is not None: dirtHandlers = [ BigWorld.PyDirtHandler( True, compoundModel.node(TankPartNames.CHASSIS).position.y), BigWorld.PyDirtHandler( False, compoundModel.node(TankPartNames.HULL).position.y), BigWorld.PyDirtHandler( False, compoundModel.node(TankPartNames.TURRET).position.y), BigWorld.PyDirtHandler( False, compoundModel.node(TankPartNames.GUN).position.y) ] modelHeight, _ = self.computeVehicleHeight() self.dirtComponent = self.createComponent( Vehicular.DirtComponent, dirtHandlers, modelHeight) for fashionIdx, _ in enumerate(TankPartNames.ALL): self.fashions[fashionIdx].addMaterialHandler( dirtHandlers[fashionIdx]) self.fashions[fashionIdx].addTrackMaterialHandler( dirtHandlers[fashionIdx]) model_assembler.setupTurretRotations(self) self.waterSensor = model_assembler.assembleWaterSensor( self.typeDescriptor, self, lodStateLink, self.spaceID) if self.engineAudition is not None: self.engineAudition.setIsUnderwaterInfo( DataLinks.createBoolLink(self.waterSensor, 'isUnderWater')) self.engineAudition.setIsInWaterInfo( DataLinks.createBoolLink(self.waterSensor, 'isInWater')) self.__postSetupFilter() compoundModel.setPartBoundingBoxAttachNode( TankPartIndexes.GUN, TankNodeNames.GUN_INCLINATION) camouflages.updateFashions(self) model_assembler.assembleCustomLogicComponents(self, self.typeDescriptor, self.__attachments, self.__modelAnimators) self._createStickers() while self._loadingQueue: prefab, go, vector, callback = self._loadingQueue.pop() CGF.loadGameObjectIntoHierarchy(prefab, go, vector, callback) return