private void ShowImpactFXForView(ProjectileView view, string assetName) { EmitterPool emitter = this.GetEmitter(assetName); if (emitter == null) { return; } Vector3 vector = view.TargetLocation; if (view.TargetTracker != null) { vector = view.TargetTracker.position; } else if (view.MeshTracker != null) { vector = view.MeshTracker.position; } bool directional = view.ProjectileType.Directional; bool seeksTarget = view.ProjectileType.SeeksTarget; if (directional) { Vector3 a = view.StartLocation - vector; a.Normalize(); vector += a * 0.2f; } if (emitter is MultipleEmittersPool) { MultipleEmittersPool multipleEmittersPool = (MultipleEmittersPool)emitter; GameObject emitterRoot = multipleEmittersPool.GetEmitterRoot(); float num = 0f; if (emitterRoot != null) { emitterRoot.SetActive(true); ParticleSystem[] allEmitters = MultipleEmittersPool.GetAllEmitters(emitterRoot); Transform transform = emitterRoot.transform; transform.position = vector; if (directional) { transform.LookAt(view.StartLocation); } ParticleSystem[] array = allEmitters; for (int i = 0; i < array.Length; i++) { ParticleSystem particleSystem = array[i]; if (particleSystem.duration > num) { num = particleSystem.duration; } this.PlayParticle(particleSystem); } if (seeksTarget && view.Bullet.Target != null && view.Bullet.Target.GameObjectViewComp != null && !GameUtils.IsEntityDead(view.Bullet.Target)) { SmartEntity target = view.Bullet.Target; Vector3 positionOffset = emitterRoot.transform.position - target.GameObjectViewComp.MainTransform.position; DerivedTransformationObject derivedTransformationObject = new DerivedTransformationObject(target.GameObjectViewComp.MainGameObject, positionOffset, false); Service.Get <DerivedTransformationManager>().AddDerivedTransformation(emitterRoot, derivedTransformationObject); this.AssociateEntityWithEmitterObject(target, emitterRoot); } multipleEmittersPool.StopEmissionAndReturnToPool(emitterRoot, num, 0f); return; } } else if (emitter is SingleEmitterPool) { SingleEmitterPool singleEmitterPool = (SingleEmitterPool)emitter; ParticleSystem emitter2 = singleEmitterPool.GetEmitter(); if (emitter2 != null) { if (directional) { this.PlayParticleLookingAt(emitter2, vector, view.StartLocation); } else { this.PlayParticleAt(emitter2, vector); } singleEmitterPool.StopEmissionAndReturnToPool(emitter2, emitter2.startLifetime, 0f); } } }
private void StartDirectionalEmitter(SmartEntity owner, GameObject gunLocator, Vector3 startLocation, Vector3 endLocation, string assetName, float fadeTime) { EmitterPool emitter = this.GetEmitter(assetName); if (emitter != null) { if (emitter is MultipleEmittersPool) { MultipleEmittersPool multipleEmittersPool = (MultipleEmittersPool)emitter; GameObject emitterRoot = multipleEmittersPool.GetEmitterRoot(); float num = 0f; if (emitterRoot != null) { ParticleSystem[] allEmitters = MultipleEmittersPool.GetAllEmitters(emitterRoot); Transform transform = emitterRoot.transform; transform.position = startLocation; if (gunLocator != null) { DerivedTransformationObject derivedTransformationObject = new DerivedTransformationObject(gunLocator, Vector3.zero, true); Service.Get <DerivedTransformationManager>().AddDerivedTransformation(emitterRoot, derivedTransformationObject); this.AssociateEntityWithEmitterObject(owner, emitterRoot); } else { GameObjectViewComponent gameObjectViewComponent = null; if (owner != null) { gameObjectViewComponent = owner.GameObjectViewComp; } if (gameObjectViewComponent == null) { transform.LookAt(endLocation); } else { transform.rotation = gameObjectViewComponent.MainTransform.rotation; } } emitterRoot.SetActive(true); ParticleSystem[] array = allEmitters; for (int i = 0; i < array.Length; i++) { ParticleSystem particleSystem = array[i]; if (particleSystem != null) { if (particleSystem.duration > num) { num = particleSystem.duration; } this.PlayParticle(particleSystem); } } multipleEmittersPool.StopEmissionAndReturnToPool(emitterRoot, num, fadeTime); return; } } else if (emitter is SingleEmitterPool) { SingleEmitterPool singleEmitterPool = (SingleEmitterPool)emitter; ParticleSystem emitter2 = singleEmitterPool.GetEmitter(); if (emitter2 != null) { this.PlayParticleAt(emitter2, startLocation); singleEmitterPool.StopEmissionAndReturnToPool(emitter2, emitter2.startLifetime, fadeTime); } } } }