private ProjectileView SpawnProjectile(Bullet bullet, bool isOnGround) { if (!ProjectileUtils.AreAllBulletAssetsLoaded(bullet, this.loadedAssets)) { this.LoadBulletAssets(bullet); if (bullet.ProjectileType != null) { Service.Get <StaRTSLogger>().Warn("Loading assets on demand for projectile " + bullet.ProjectileType.Uid); } } bool isDeflection = bullet.IsDeflection; ProjectileTypeVO projectileType = bullet.ProjectileType; GameObject gunLocator = bullet.GunLocator; Vector3 vector; if (!isDeflection && gunLocator != null) { vector = gunLocator.transform.position; } else { vector = bullet.SpawnWorldLocation; } Vector3 targetWorldLocation = bullet.TargetWorldLocation; if (isOnGround) { vector.y = 0f; targetWorldLocation.y = 0f; } else if (projectileType.IsBeam || (bullet.Owner != null && bullet.Target != null && bullet.Target.ShieldBorderComp != null)) { targetWorldLocation.y = vector.y; } ProjectileView projectileView = (this.projectilePool.Count > 0) ? this.projectilePool.Pop() : new ProjectileView(); projectileView.Init(projectileType, bullet, isOnGround); if (!isDeflection && !string.IsNullOrEmpty(projectileType.MuzzleFlashAssetName)) { this.StartDirectionalEmitter(bullet.Owner, gunLocator, vector, targetWorldLocation, projectileType.MuzzleFlashAssetName, projectileType.MuzzleFlashFadeTime); int num = 0; if (bullet.AppliedBuffs != null) { num = bullet.AppliedBuffs.Count; } FactionType ownerFaction = bullet.OwnerFaction; for (int i = 0; i < num; i++) { string muzzleAssetNameBasedOnFaction = bullet.AppliedBuffs[i].BuffType.GetMuzzleAssetNameBasedOnFaction(ownerFaction); if (!string.IsNullOrEmpty(muzzleAssetNameBasedOnFaction)) { this.StartDirectionalEmitter(bullet.Owner, gunLocator, vector, targetWorldLocation, muzzleAssetNameBasedOnFaction, projectileType.MuzzleFlashFadeTime); } } } GameObject gameObject = null; float num2 = bullet.TravelTime / 1000f; GameObject gameObject2 = null; ParticleSystem particleSystem = null; string bulletAssetName = projectileType.GetBulletAssetName(isOnGround); EmitterPool emitter = this.GetEmitter(bulletAssetName); if (emitter != null) { float num3 = num2; float delayPostEmitterStop = 0f; if (projectileType.IsBeam) { num3 = num2 * (float)(projectileType.BeamEmitterLength - projectileType.BeamInitialZeroes) / (float)(projectileType.BeamLifeLength - projectileType.BeamInitialZeroes); delayPostEmitterStop = num2 - num3; } if (emitter is MultipleEmittersPool) { MultipleEmittersPool multipleEmittersPool = (MultipleEmittersPool)emitter; gameObject = multipleEmittersPool.GetEmitterRoot(); if (gameObject != null) { multipleEmittersPool.StopEmissionAndReturnToPool(gameObject, num3, delayPostEmitterStop); } } else if (emitter is SingleEmitterPool) { SingleEmitterPool singleEmitterPool = (SingleEmitterPool)emitter; particleSystem = singleEmitterPool.GetEmitter(); if (particleSystem != null) { singleEmitterPool.StopEmissionAndReturnToPool(particleSystem, num3, delayPostEmitterStop); } } if (this.meshes.ContainsKey(bulletAssetName)) { gameObject2 = this.meshes[bulletAssetName].GetMesh(); } } Transform targetTransform = this.GetTargetTransform(bullet, vector, targetWorldLocation); if (gameObject2 != null && particleSystem != null) { projectileView.InitWithMeshAndEmitter(num2, vector, targetWorldLocation, gameObject2, particleSystem, targetTransform); } else if (gameObject2 != null && gameObject == null) { projectileView.InitWithMesh(num2, vector, targetWorldLocation, gameObject2, targetTransform); } else if (particleSystem != null) { projectileView.InitWithEmitter(num2, vector, targetWorldLocation, particleSystem, targetTransform); } else if (gameObject != null) { projectileView.InitWithEmitters(num2, vector, targetWorldLocation, gameObject, gameObject2, targetTransform); } else { projectileView.InitWithoutBullet(num2, vector, targetWorldLocation, targetTransform); } this.activeProjectiles.Add(projectileView); if (!isOnGround && !string.IsNullOrEmpty(projectileType.GroundBulletAssetName)) { this.SpawnProjectile(bullet, true); } return(projectileView); }