private void DrawHammerHitDecals(Vector3 shotDirection, PelletThrowingGraphicsNode weapon, SingleNode <DecalManagerComponent> decalManagerNode, DecalSettingsComponent settings) { if (settings.EnableDecals && (settings.MaxDecalsForHammer > 0)) { DecalMeshBuilder decalMeshBuilder = decalManagerNode.component.DecalMeshBuilder; BulletHoleDecalManager bulletHoleDecalManager = decalManagerNode.component.BulletHoleDecalManager; MuzzlePointComponent muzzlePoint = weapon.muzzlePoint; HammerDecalProjectorComponent hammerDecalProjector = weapon.hammerDecalProjector; Vector3 barrelOriginWorld = new MuzzleVisualAccessor(muzzlePoint).GetBarrelOriginWorld(); decalMeshBuilder.Clean(); DecalProjection projection2 = new DecalProjection { HalfSize = hammerDecalProjector.CombineHalfSize, Distantion = hammerDecalProjector.Distance, Ray = new Ray(barrelOriginWorld - shotDirection, shotDirection) }; DecalProjection decalProjection = projection2; if (decalMeshBuilder.CompleteProjectionByRaycast(decalProjection) && decalMeshBuilder.CollectPolygons(decalProjection)) { Vector3 localDirection = muzzlePoint.Current.InverseTransformVector(shotDirection); Vector3[] vectorArray = PelletDirectionsCalculator.GetRandomDirections(weapon.hammerPelletCone, muzzlePoint.Current.rotation, localDirection); List <Mesh> list = new List <Mesh>(vectorArray.Length); for (int i = 0; i < Math.Min(vectorArray.Length, settings.MaxDecalsForHammer); i++) { Vector3 direction = vectorArray[i]; projection2 = new DecalProjection { AtlasHTilesCount = hammerDecalProjector.AtlasHTilesCount, AtlasVTilesCount = hammerDecalProjector.AtlasVTilesCount, SurfaceAtlasPositions = hammerDecalProjector.SurfaceAtlasPositions, HalfSize = hammerDecalProjector.HalfSize, Up = hammerDecalProjector.Up, Distantion = hammerDecalProjector.Distance, Ray = new Ray(barrelOriginWorld - shotDirection, direction) }; DecalProjection projection3 = projection2; if (decalMeshBuilder.CompleteProjectionByRaycast(projection3)) { decalMeshBuilder.BuilldDecalFromCollectedPolygons(projection3); Mesh mesh = null; if (decalMeshBuilder.GetResultToMesh(ref mesh)) { list.Add(mesh); } } } if (list.Count != 0) { CombineInstance[] combine = new CombineInstance[list.Count]; for (int j = 0; j < list.Count; j++) { combine[j].mesh = list[j]; } Mesh decalMesh = new Mesh(); decalMesh.CombineMeshes(combine, true, false); decalMesh.RecalculateBounds(); bulletHoleDecalManager.AddDecal(decalMesh, hammerDecalProjector.Material, hammerDecalProjector.Color, hammerDecalProjector.LifeTime); } } } }
public void DrawHammerHitDecalsSelf(SelfHammerShotEvent evt, PelletThrowingGraphicsNode weapon, [JoinAll] SingleNode <DecalManagerComponent> decalManagerNode, [JoinAll] SingleNode <DecalSettingsComponent> settings) { this.DrawHammerHitDecals(evt.ShotDirection, weapon, decalManagerNode, settings.component); }
public void DrawHammerHitDecalsRemote(RemoteHammerShotEvent evt, PelletThrowingGraphicsNode weapon, [JoinAll] SingleNode <DecalManagerComponent> decalManagerNode, [JoinAll] SingleNode <DecalSettingsComponent> settings) { weapon.hammerPelletCone.ShotSeed = evt.RandomSeed; this.DrawHammerHitDecals(evt.ShotDirection, weapon, decalManagerNode, settings.component); }
private static unsafe void InstantiatePelletsByBaseEvent(Vector3 shotDirection, PelletThrowingGraphicsNode weapon) { MuzzlePointComponent muzzlePoint = weapon.muzzlePoint; PelletThrowingGraphicsComponent pelletThrowingGraphics = weapon.pelletThrowingGraphics; float radiusOfMinDamage = weapon.damageWeakeningByDistance.RadiusOfMinDamage; float constant = pelletThrowingGraphics.Trails.main.startSpeed.constant; float num3 = radiusOfMinDamage / constant; ParticleSystem.EmitParams params2 = new ParticleSystem.EmitParams { position = pelletThrowingGraphics.Trails.transform.position, startColor = pelletThrowingGraphics.Trails.main.startColor.color, startSize = pelletThrowingGraphics.Trails.main.startSizeMultiplier }; ParticleSystem.EmitParams emitParams = params2; params2 = new ParticleSystem.EmitParams { startColor = pelletThrowingGraphics.Hits.main.startColor.color, startSize = pelletThrowingGraphics.Hits.main.startSizeMultiplier }; ParticleSystem.EmitParams params3 = params2; Vector3 localDirection = muzzlePoint.Current.InverseTransformVector(shotDirection); foreach (Vector3 vector2 in PelletDirectionsCalculator.GetRandomDirections(weapon.hammerPelletCone, muzzlePoint.Current.rotation, localDirection)) { RaycastHit hit; ParticleSystem.MainModule main = pelletThrowingGraphics.Trails.main; ParticleSystem.MinMaxGradient startColor = main.startColor; if (startColor.mode == ParticleSystemGradientMode.RandomColor) { emitParams.startColor = pelletThrowingGraphics.Trails.main.startColor.Evaluate(Random.Range((float)0f, (float)1f)); } emitParams.randomSeed = (uint)(Random.value * 4.294967E+09f); emitParams.velocity = vector2 * constant; if (!Physics.Raycast(pelletThrowingGraphics.Trails.transform.position, vector2, out hit, radiusOfMinDamage, LayerMasks.GUN_TARGETING_WITH_DEAD_UNITS)) { emitParams.startLifetime = num3; } else { emitParams.startLifetime = Vector3.Distance(pelletThrowingGraphics.Trails.transform.position, hit.point) / constant; params3.startLifetime = Random.Range(pelletThrowingGraphics.SparklesMinLifetime, pelletThrowingGraphics.SparklesMaxLifetime); params3.randomSeed = (uint)(Random.value * 4.294967E+09f); params3.position = hit.point; params3.velocity = Random.onUnitSphere; ParticleSystem.EmitParams *paramsPtr1 = ¶ms3; paramsPtr1.velocity *= Mathf.Sign(Vector3.Dot(params3.velocity, hit.normal)) * pelletThrowingGraphics.HitReflectVeolcity; pelletThrowingGraphics.Hits.Emit(params3, 1); } pelletThrowingGraphics.Trails.Emit(emitParams, 1); } }
public void InstantiatePellets(SelfHammerShotEvent evt, PelletThrowingGraphicsNode weapon) { InstantiatePelletsByBaseEvent(evt.ShotDirection, weapon); }
public void InstantiatePellets(RemoteHammerShotEvent evt, PelletThrowingGraphicsNode weapon) { weapon.hammerPelletCone.ShotSeed = evt.RandomSeed; InstantiatePelletsByBaseEvent(evt.ShotDirection, weapon); }