示例#1
0
 // Token: 0x0600137D RID: 4989 RVA: 0x00095543 File Offset: 0x00093943
 public static Mesh NewBoltMesh(Vector2 vector, float str = 3f)
 {
     LightningBoltMeshMakerOG.lightningTop = vector;
     LightningBoltMeshMakerOG.MakeVerticesBase();
     LightningBoltMeshMakerOG.PeturbVerticesRandomly(str);
     LightningBoltMeshMakerOG.DoubleVertices();
     return(LightningBoltMeshMakerOG.MeshFromVerts());
 }
示例#2
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)
 {
     LightningBoltMeshMakerOG.lightningTop = new Vector2(Rand.Range(xMin, xMax), z);
     LightningBoltMeshMakerOG.MakeVerticesBase();
     LightningBoltMeshMakerOG.PeturbVerticesRandomly(str);
     LightningBoltMeshMakerOG.DoubleVertices();
     return(LightningBoltMeshMakerOG.MeshFromVerts());
 }
        public void SetupDrawing()
        {
            if (mesh != null)
            {
                return;
            }

            materialBeam = def.GetBeamMaterial(colorIndex) ?? def.graphicData.Graphic.MatSingle;

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

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

            drawingMatrix.SetTRS(drawingPosition, rotation, drawingScale);

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

            if (Lightning)
            {
                float distance = Vector3.Distance(a, b);
                for (int i = 0; i < def.ArcCount; i++)
                {
                    meshes.Add(LightningBoltMeshMakerOG.NewBoltMesh(new Vector2(0, -(distance + 0.25f)), def.LightningVariance));
                }
                //    this.mesh = LightningBoltMeshMakerOG.NewBoltMesh(new Vector2(0, -(distance + 0.25f)), def.LightningVariance);
            }
            else
            {
                this.mesh = MeshMakerLaser.Mesh(seamTexture, seamGeometry);
            }
        }
 // Token: 0x0600139E RID: 5022 RVA: 0x00096090 File Offset: 0x00094490
 public override void FireEvent()
 {
     base.FireEvent();
     if (!this.strikeLoc.IsValid)
     {
         this.strikeLoc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(this.map) && !this.map.roofGrid.Roofed(sq), this.map, 1000);
     }
     this.boltMesh = LightningBoltMeshMakerOG.NewBoltMesh(minX, maxX, Z);
     if (!this.strikeLoc.Fogged(this.map))
     {
         GenExplosion.DoExplosion(this.strikeLoc, this.map, 2.9f, DamageDefOf.Smoke, null, 0, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
         Vector3 loc = this.strikeLoc.ToVector3Shifted();
         for (int i = 0; i < 4; i++)
         {
             AM_MeshBolt bolt = new AM_MeshBolt(strikeLoc, loc, MaterialPool.MatFrom(boltstring, ShaderDatabase.Transparent, -1));
             bolt.CreateBolt();
             MoteMaker.ThrowSmoke(loc, this.map, 1.5f);
             MoteMaker.ThrowMicroSparks(loc, this.map);
             MoteMaker.ThrowLightningGlow(loc, this.map, 1.5f);
         }
     }
     SoundInfo info = SoundInfo.InMap(new TargetInfo(this.strikeLoc, this.map, false), MaintenanceType.None);
 }
        public override void Draw()
        {
            SetupDrawing();

            float opacity = Opacity;

            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 < def.ArcCount; i++)
                {
                    if (this.def.graphicData.graphicClass == typeof(Graphic_Flicker))
                    {
                        if (!Find.TickManager.Paused && Find.TickManager.TicksGame % this.def.flickerFrameTime == 0)
                        {
                            materialBeam = def.GetBeamMaterial((this.def.materials.IndexOf(materialBeam) + 1 < this.def.materials.Count ? this.def.materials.IndexOf(materialBeam) + 1 : 0)) ?? def.graphicData.Graphic.MatSingle;
                        }
                    }
                    meshes[i] = Find.TickManager.Paused || meshes[i] != null && Static ? meshes[i] : LightningBoltMeshMakerOG.NewBoltMesh(new Vector2(0, -(distance + 0.25f)));
                    Graphics.DrawMesh(this.meshes[i], b, Quaternion.LookRotation((vector - this.a).normalized), FadedMaterialPool.FadedVersionOf(materialBeam, opacity), 0);
                }

                /*
                 * mesh = Find.TickManager.Paused || mesh != null && Static ? mesh : LightningBoltMeshMakerOG.NewBoltMesh(new Vector2(0, -(distance + 0.25f)));
                 * Graphics.DrawMesh(this.mesh, b, Quaternion.LookRotation((vector - this.a).normalized), FadedMaterialPool.FadedVersionOf(materialBeam, opacity), 0);
                 * if (meshb != null && def.ArcCount > 1)
                 * {
                 *  meshb = Find.TickManager.Paused || meshb != null && Static ? meshb : LightningBoltMeshMakerOG.NewBoltMesh(new Vector2(0, -(distance + 0.25f)));
                 *  Graphics.DrawMesh(this.meshb, b, Quaternion.LookRotation((vector - this.a).normalized), FadedMaterialPool.FadedVersionOf(materialBeam, opacity), 0);
                 * }
                 * if (meshc != null && def.ArcCount > 2)
                 * {
                 *  meshc = Find.TickManager.Paused || meshc != null && Static ? meshc : LightningBoltMeshMakerOG.NewBoltMesh(new Vector2(0, -(distance + 0.25f)));
                 *  Graphics.DrawMesh(this.meshc, b, Quaternion.LookRotation((vector - this.a).normalized), FadedMaterialPool.FadedVersionOf(materialBeam, opacity), 0);
                 * }
                 */
            }
            else
            {
                if (this.def.graphicData.graphicClass == typeof(Graphic_Flicker))
                {
                    if (!Find.TickManager.Paused && Find.TickManager.TicksGame % this.def.flickerFrameTime == 0)
                    {
                        materialBeam = def.GetBeamMaterial((this.def.materials.IndexOf(materialBeam) + 1 < this.def.materials.Count ? this.def.materials.IndexOf(materialBeam) + 1 : 0)) ?? def.graphicData.Graphic.MatSingle;
                    }
                }
                Graphics.DrawMesh(mesh, drawingMatrix, FadedMaterialPool.FadedVersionOf(materialBeam, opacity), 0);
            }
        }