コード例 #1
0
 public static Mesh NewBoltMesh(Vector2 vector, float str = 3f, float width = 1f, float VertexInterval = 0.25f)
 {
     LightningLaserBoltMeshMaker.lightningOrigin = vector;
     LightningLaserBoltMeshMaker.MakeVerticesBase(VertexInterval);
     LightningLaserBoltMeshMaker.PeturbVerticesRandomly(str);
     LightningLaserBoltMeshMaker.DoubleVertices(width);
     return(LightningLaserBoltMeshMaker.MeshFromVerts());
 }
コード例 #2
0
 public static Mesh NewBoltMesh(Vector2 vector, float str = 3f, float width = 1f)
 {
     LightningLaserBoltMeshMaker.lightningTop = vector;
     LightningLaserBoltMeshMaker.MakeVerticesBase();
     LightningLaserBoltMeshMaker.PeturbVerticesRandomly(str);
     LightningLaserBoltMeshMaker.DoubleVertices(width);
     return(LightningLaserBoltMeshMaker.MeshFromVerts());
 }
コード例 #3
0
 // Token: 0x0600137D RID: 4989 RVA: 0x00095543 File Offset: 0x00093943
 public static Mesh NewBoltMesh(float xMin = -50f, float xMax = 50f, float z = 200f, float str = 3f)
 {
     LightningLaserBoltMeshMaker.lightningTop = new Vector2(Rand.Range(xMin, xMax), z);
     LightningLaserBoltMeshMaker.MakeVerticesBase();
     LightningLaserBoltMeshMaker.PeturbVerticesRandomly(str);
     LightningLaserBoltMeshMaker.DoubleVertices();
     return(LightningLaserBoltMeshMaker.MeshFromVerts());
 }
コード例 #4
0
        public void SetupDrawing()
        {
            if (mesh != null)
            {
                return;
            }

            materialBeam = projDef.GetBeamMaterial(colorIndex) ?? LaserBeamGraphicCE.BeamMat;

            if (this.def.graphicData != null)
            {
                if (this.def.graphicData.graphicClass != null)
                {
                    if (this.def.graphicData.graphicClass == typeof(Graphic_Random))
                    {
                        materialBeam = projDef.GetBeamMaterial(0) ?? def.graphicData.Graphic.MatSingle;
                    }
                }
            }
            beamWidth = projDef.beamWidth;
            Quaternion rotation = Quaternion.LookRotation(b - a);
            Vector3    dir      = (b - a).normalized;

            beamLength = (b - a).magnitude;

            Vector3 drawingScale    = new Vector3(beamWidth, 1f, beamLength);
            Vector3 drawingPosition = (a + b) / 2;

            drawingPosition.y = AltitudeLayer.MetaOverlays.AltitudeFor();
            drawingMatrix.SetTRS(drawingPosition, rotation, drawingScale);

            float textureRatio = 1.0f * materialBeam.mainTexture.width / materialBeam.mainTexture.height;
            float seamTexture  = projDef.seam < 0 ? textureRatio : projDef.seam;
            float capLength    = beamWidth / textureRatio / 2f * seamTexture;
            float seamGeometry = beamLength <= capLength * 2 ? 0.5f : capLength * 2 / beamLength;

            if (Lightning)
            {
                float distance = Vector3.Distance(a, b);
                for (int i = 0; i < projDef.ArcCount; i++)
                {
                    Mesh m = LightningLaserBoltMeshMaker.NewBoltMesh(new Vector2(0, -(distance + 0.25f)), projDef.LightningVariance, beamWidth);
                    meshes.Add(m);
                }
                //    this.mesh = LightningBoltMeshMakerOG.NewBoltMesh(new Vector2(0, -(distance + 0.25f)), def.LightningVariance);
            }
            else
            {
                this.mesh = MeshMakerLaser.Mesh(seamTexture, seamGeometry);
            }
        }
コード例 #5
0
        public override void Draw()
        {
            SetupDrawing();

            float opacity = Opacity;
            Color color   = projDef.graphicData.color;

            color.a *= opacity;
            LaserBeamGraphicCE.MatPropertyBlock.SetColor(ShaderPropertyIDs.Color, color);
            if (Lightning)
            {
                Vector3 vector;
                vector.x = (float)b.x;
                vector.y = (float)b.y;
                vector.z = (float)b.z;
                float distance = Vector3.Distance(a, b);

                for (int i = 0; i < projDef.ArcCount; i++)
                {
                    if (this.def.graphicData != null)
                    {
                        if (this.def.graphicData.graphicClass != null)
                        {
                            if (this.def.graphicData.graphicClass == typeof(Graphic_Flicker))
                            {
                                if (!Find.TickManager.Paused && Find.TickManager.TicksGame % this.projDef.flickerFrameTime == 0)
                                {
                                    materialBeam = projDef.GetBeamMaterial((this.projDef.materials.IndexOf(materialBeam) + 1 < this.projDef.materials.Count ? this.projDef.materials.IndexOf(materialBeam) + 1 : 0)) ?? def.graphicData.Graphic.MatSingle;
                                }
                            }
                        }
                    }
                    meshes[i] = Find.TickManager.Paused || Find.TickManager.TicksGame % this.projDef.flickerFrameTime != 0 || meshes[i] != null && Static ? meshes[i] : LightningLaserBoltMeshMaker.NewBoltMesh(new Vector2(0, -(distance + 0.25f)), projDef.LightningVariance, beamWidth);
                    Graphics.DrawMesh(this.meshes[i], b, Quaternion.LookRotation((vector - this.a).normalized), materialBeam, 0, null, 0, LaserBeamGraphicCE.MatPropertyBlock, 0);
                }
            }
            else
            {
                if (this.def.graphicData != null)
                {
                    if (this.def.graphicData.graphicClass != null)
                    {
                        if (this.def.graphicData.graphicClass == typeof(Graphic_Flicker))
                        {
                            if (!Find.TickManager.Paused && Find.TickManager.TicksGame % this.projDef.flickerFrameTime == 0)
                            {
                                materialBeam = projDef.GetBeamMaterial((this.projDef.materials.IndexOf(materialBeam) + 1 < this.projDef.materials.Count ? this.projDef.materials.IndexOf(materialBeam) + 1 : 0)) ?? def.graphicData.Graphic.MatSingle;
                            }
                        }
                    }
                }
                Graphics.DrawMesh(mesh, drawingMatrix, materialBeam, 0, null, 0, LaserBeamGraphicCE.MatPropertyBlock);
                //   Graphics.DrawMesh(mesh, drawingMatrix, FadedMaterialPool.FadedVersionOf(materialBeam, opacity), 0);
            }
        }