public static void Update(GameWorld world, EntityCommandBuffer commandBuffer, ClientProjectile clientProjectile) { var deltaTime = world.frameDuration; if (clientProjectile.impacted) { return; } // When projectile disappears we hide clientprojectile if (clientProjectile.projectile == Entity.Null) { clientProjectile.SetVisible(false); return; } var projectileData = world.GetEntityManager().GetComponentData <ProjectileData>(clientProjectile.projectile); var aliveDuration = world.worldTime.DurationSinceTick(projectileData.startTick); // Interpolation delay can cause projectiles to be spawned before they should be shown. if (aliveDuration < 0) { return; } if (!clientProjectile.IsVisible) { clientProjectile.SetVisible(true); } var dir = Vector3.Normalize(projectileData.endPos - projectileData.startPos); var moveDist = aliveDuration * projectileData.settings.velocity; var pos = (Vector3)projectileData.startPos + dir * moveDist; var rot = Quaternion.LookRotation(dir); var worldOffset = Vector3.zero; if (clientProjectile.offsetScale > 0.0f) { clientProjectile.offsetScale -= deltaTime / clientProjectile.offsetScaleDuration; worldOffset = rot * clientProjectile.startOffset * clientProjectile.offsetScale; } if (projectileData.impacted == 1 && !clientProjectile.impacted) { clientProjectile.impacted = true; if (clientProjectile.impactEffect != null) { SpatialEffectRequest.Create(commandBuffer, clientProjectile.impactEffect, projectileData.impactPos, Quaternion.LookRotation(projectileData.impactNormal)); } clientProjectile.SetVisible(false); } clientProjectile.transform.position = pos + worldOffset; // Debug.DrawLine(projectileData.startPos, pos, Color.red); // DebugDraw.Sphere(clientProjectile.transform.position, 0.2f, Color.red); clientProjectile.roll += deltaTime * clientProjectile.rotationSpeed; var roll = Quaternion.Euler(0, 0, clientProjectile.roll); clientProjectile.transform.rotation = rot * roll; if (ProjectileModuleClient.drawDebug.IntValue == 1) { DebugDraw.Sphere(clientProjectile.transform.position, 0.1f, Color.cyan, 1.0f); } }
public static void Update(GameWorld world, EntityCommandBuffer commandBuffer, ClientProjectile clientProjectile) { var deltaTime = world.frameDuration; if (clientProjectile.impacted) { return; } // When projectile disappears we hide clientprojectile if (clientProjectile.projectile == Entity.Null) { clientProjectile.SetVisible(false); return; } var projectileData = world.GetEntityManager().GetComponentData <ProjectileData>(clientProjectile.projectile); var aliveDuration = world.worldTime.DurationSinceTick(projectileData.startTick); // Interpolation delay can cause projectiles to be spawned before they should be shown. if (aliveDuration < 0) { return; } if (!clientProjectile.IsVisible) { clientProjectile.SetVisible(true); } var dir = Vector3.Normalize(projectileData.endPos - projectileData.startPos); var moveDist = aliveDuration * projectileData.settings.velocity; var pos = (Vector3)projectileData.startPos + dir * moveDist; var rot = Quaternion.LookRotation(dir); var worldOffset = Vector3.zero; if (clientProjectile.offsetScale > 0.0f) { clientProjectile.offsetScale -= deltaTime / clientProjectile.offsetScaleDuration; worldOffset = rot * clientProjectile.startOffset * clientProjectile.offsetScale; } if (projectileData.impacted == 1 && !clientProjectile.impacted) { clientProjectile.impacted = true; if (clientProjectile.impactEffect != null) { world.GetECSWorld().GetExistingManager <HandleSpatialEffectRequests>().Request(clientProjectile.impactEffect, projectileData.impactPos, Quaternion.LookRotation(projectileData.impactNormal)); } //Added by Logan 01-18-2022 //Plays the proper sound for a projectile if (clientProjectile.playExplosionSound) { switch (clientProjectile.projectileSoundType) { case ClientProjectile.ProjectileSoundType.None: break; case ClientProjectile.ProjectileSoundType.Girl_Goo: break; case ClientProjectile.ProjectileSoundType.Girl_Rocket: FMODUnity.RuntimeManager.PlayOneShot(clientProjectile.playerAudio.Girl_WeaponRocketExplode, projectileData.impactPos); //UnityEngine.Debug.Log("Girl Rocket Projectile Tail!"); break; case ClientProjectile.ProjectileSoundType.Robot_Rivet: break; case ClientProjectile.ProjectileSoundType.Robot_Grenade: break; default: //FMODUnity.RuntimeManager.PlayOneShot(clientProjectile.playerAudio.SomethingOrOther, projectileData.impactPos); break; } } clientProjectile.SetVisible(false); } clientProjectile.transform.position = pos + worldOffset; // Debug.DrawLine(projectileData.startPos, pos, Color.red); // DebugDraw.Sphere(clientProjectile.transform.position, 0.2f, Color.red); clientProjectile.roll += deltaTime * clientProjectile.rotationSpeed; var roll = Quaternion.Euler(0, 0, clientProjectile.roll); clientProjectile.transform.rotation = rot * roll; if (ProjectileModuleClient.drawDebug.IntValue == 1) { DebugDraw.Sphere(clientProjectile.transform.position, 0.1f, Color.cyan, 1.0f); } }