def start(self, prereqs=None):
     self.collisions = prereqs['collisionAssembler']
     self.__typeDesc.chassis.hitTester.bbox = self.collisions.getBoundingBox(
         TankPartNames.getIdx(TankPartNames.CHASSIS))
     self.__typeDesc.hull.hitTester.bbox = self.collisions.getBoundingBox(
         TankPartNames.getIdx(TankPartNames.HULL))
     self.__typeDesc.turret.hitTester.bbox = self.collisions.getBoundingBox(
         TankPartNames.getIdx(TankPartNames.TURRET))
     self.__typeDesc.gun.hitTester.bbox = self.collisions.getBoundingBox(
         TankPartNames.getIdx(TankPartNames.GUN))
     self.__compoundModel = prereqs[self.__typeDesc.name]
     self.__boundEffects = bound_effects.ModelBoundEffects(
         self.__compoundModel)
     isCurrentModelDamaged = self.__currentDamageState.isCurrentModelDamaged
     fashions = camouflages.prepareFashions(isCurrentModelDamaged)
     if not isCurrentModelDamaged:
         model_assembler.setupTracksFashion(self.__typeDesc,
                                            fashions.chassis)
     self.__setFashions(fashions, self.__isTurretDetached)
     self.__setupModels()
     if not isCurrentModelDamaged:
         self.__splineTracks = model_assembler.setupSplineTracks(
             self.__fashion, self.__typeDesc, self.__compoundModel, prereqs)
         self.crashedTracksController = CrashedTrackController(
             self.__typeDesc, self.__fashion)
     else:
         self.__trackScrollCtl = None
     if self.__currentDamageState.effect is not None:
         self.__playEffect(self.__currentDamageState.effect,
                           SpecialKeyPointNames.STATIC)
     self.__chassisDecal.create()
     return
    def start(self, prereqs = None):
        if prereqs is None:
            self.__typeDesc.chassis['hitTester'].loadBspModel()
            self.__typeDesc.hull['hitTester'].loadBspModel()
            self.__typeDesc.turret['hitTester'].loadBspModel()
        for hitTester in self.__typeDesc.getHitTesters():
            hitTester.loadBspModel()

        self.__compoundModel = prereqs[self.__typeDesc.name]
        self.__boundEffects = bound_effects.ModelBoundEffects(self.__compoundModel)
        fashions = camouflages.prepareFashions(self.__typeDesc, self.__currentDamageState.isCurrentModelDamaged, self.__getCamouflageParams(self.__typeDesc, self.__vID)[0])
        if not self.__currentDamageState.isCurrentModelDamaged:
            self.__trackFashionSet = _setupVehicleFashion(fashions[0], self.__typeDesc)
        self.__compoundModel.setupFashions(fashions)
        fashions = camouflages.applyCamouflage(self.__typeDesc, fashions, self.__currentDamageState.isCurrentModelDamaged, self.__getCamouflageParams(self.__typeDesc, self.__vID)[0])
        fashions = camouflages.applyRepaint(self.__typeDesc, fashions)
        self.__setFashions(fashions, self.__isTurretDetached)
        self.__setupModels()
        if not VehicleDamageState.isDamagedModel(self.__currentDamageState.modelState):
            self.__splineTracks = setupSplineTracks(self.__fashion, self.__typeDesc, self.__compoundModel, prereqs)
        if self.__currentDamageState.effect is not None:
            self.__playEffect(self.__currentDamageState.effect, SpecialKeyPointNames.STATIC)
        if self.__currentDamageState.isCurrentModelDamaged:
            self.__trackScrollCtl = None
            self.__crashedTracksCtrl = None
        else:
            self.__crashedTracksCtrl = CrashedTrackController(self.__typeDesc, self.__fashion)
        return
    def start(self, prereqs=None):
        for hitTester in self.__typeDesc.getHitTesters():
            hitTester.loadBspModel()

        self.__compoundModel = prereqs[self.__typeDesc.name]
        self.__boundEffects = bound_effects.ModelBoundEffects(
            self.__compoundModel)
        isCurrentModelDamaged = self.__currentDamageState.isCurrentModelDamaged
        fashions = camouflages.prepareFashions(
            self.__typeDesc, isCurrentModelDamaged,
            self.__getCamouflageParams(self.__typeDesc, self.__vID)[0])
        if not isCurrentModelDamaged:
            model_assembler.setupVehicleFashion(fashions[0], self.__typeDesc)
        self.__compoundModel.setupFashions(fashions)
        fashions = camouflages.applyCamouflage(
            self.__typeDesc, fashions, isCurrentModelDamaged,
            self.__getCamouflageParams(self.__typeDesc, self.__vID)[0])
        fashions = camouflages.applyRepaint(self.__typeDesc, fashions)
        self.__setFashions(fashions, self.__isTurretDetached)
        self.__setupModels()
        if not isCurrentModelDamaged:
            self.__splineTracks = model_assembler.setupSplineTracks(
                self.__fashion, self.__typeDesc, self.__compoundModel, prereqs)
            self.__crashedTracksCtrl = CrashedTrackController(
                self.__typeDesc, self.__fashion)
        else:
            self.__trackScrollCtl = None
        if self.__currentDamageState.effect is not None:
            self.__playEffect(self.__currentDamageState.effect,
                              SpecialKeyPointNames.STATIC)
        self.__chassisDecal.create()
        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
Exemplo n.º 5
0
 def start(self, vehicle, prereqs=None):
     self.__vehicle = vehicle
     player = BigWorld.player()
     if prereqs is None:
         self.__typeDesc.chassis['hitTester'].loadBspModel()
         self.__typeDesc.hull['hitTester'].loadBspModel()
         self.__typeDesc.turret['hitTester'].loadBspModel()
     if not self.__isPillbox:
         self.__filter.isStrafing = vehicle.isStrafing
         self.__filter.vehicleCollisionCallback = player.handleVehicleCollidedVehicle
     self.__originalFilter = vehicle.filter
     vehicle.filter = self.__filter
     enableNewPhysics = vehicle.physicsMode == VEHICLE_PHYSICS_MODE.DETAILED
     vehicle.filter.enableNewPhysics(enableNewPhysics)
     vehicle.filter.enableStabilisedMatrix(vehicle.isPlayerVehicle)
     self.__createStickers(prereqs)
     self.__compoundModel = prereqs[self.__typeDesc.name]
     self.__compoundModel.isHighPriorityReflection = vehicle.isPlayerVehicle
     self.__boundEffects = bound_effects.ModelBoundEffects(
         self.__compoundModel)
     fashions = camouflages.prepareFashions(
         self.__typeDesc, self.__currentDamageState.isCurrentModelDamaged,
         self.__getCamouflageParams(vehicle)[0],
         vehicle.physicsMode == VEHICLE_PHYSICS_MODE.DETAILED)
     if not self.__currentDamageState.isCurrentModelDamaged:
         _setupVehicleFashion(self, fashions[0], self.__vehicle)
     self.__compoundModel.setupFashions(fashions)
     fashions = camouflages.applyCamouflage(
         self.__typeDesc, fashions,
         self.__currentDamageState.isCurrentModelDamaged,
         self.__getCamouflageParams(vehicle)[0])
     fashions = camouflages.applyRepaint(self.__typeDesc, fashions)
     self.fashions = fashions
     self.__setupModels(True)
     if not VehicleDamageState.isDamagedModel(
             self.__currentDamageState.modelState):
         self.__splineTracks = setupSplineTracks(
             self.__fashion, self.__vehicle.typeDescriptor,
             self.__compoundModel, prereqs)
     if self.__currentDamageState.effect is not None:
         self.__playEffect(self.__currentDamageState.effect,
                           SpecialKeyPointNames.STATIC)
     toCrashedFashion = self.__fashion
     if self.__currentDamageState.isCurrentModelDamaged:
         toCrashedFashion = None
         self.__trackScrollCtl = None
     else:
         self.__trackScrollCtl.setData(self.__vehicle.filter,
                                       self.fashions.chassis)
     self.__crashedTracksCtrl = CrashedTrackController(
         vehicle.typeDescriptor, vehicle, toCrashedFashion,
         self.__vehicle.isPlayerVehicle)
     if vehicle.isAlive() and self.__vehicle.isPlayerVehicle:
         self.__vibrationsCtrl = VibrationControllersManager()
         if LightFx.LightManager.g_instance is not None and LightFx.LightManager.g_instance.isEnabled(
         ):
             self.__lightFxCtrl = LightFxControllersManager(self.__vehicle)
         if AuxiliaryFx.g_instance is not None:
             self.__auxiliaryFxCtrl = AuxiliaryFx.g_instance.createFxController(
                 self.__vehicle)
     if not BattleReplay.isPlaying():
         self.compoundModel.stipple = True
         self.delayCallback(_VEHICLE_APPEAR_TIME, self.__disableStipple)
     self.__vehicleMatrixProv = vehicle.model.matrix
     return