// Token: 0x06000033 RID: 51 RVA: 0x0000369C File Offset: 0x0000189C
        public void TurretTopTick()
        {
            LocalTargetInfo currentTarget = this.parentTurret.CurrentTarget;
            bool            isValid       = currentTarget.IsValid;

            if (isValid)
            {
                this.CurRotation        = Vector3Utility.AngleFlat(currentTarget.Cell.ToVector3Shifted() - this.parentTurret.DrawPos);
                this.ticksUntilIdleTurn = Rand.RangeInclusive(150, 350);
            }
            else
            {
                bool flag = this.ticksUntilIdleTurn > 0;
                if (flag)
                {
                    this.ticksUntilIdleTurn--;
                    bool flag2 = this.ticksUntilIdleTurn == 0;
                    if (flag2)
                    {
                        bool flag3 = (double)Rand.Value < 0.5;
                        if (flag3)
                        {
                            this.idleTurnClockwise = true;
                        }
                        else
                        {
                            this.idleTurnClockwise = false;
                        }
                        this.idleTurnTicksLeft = 140;
                    }
                }
                else
                {
                    bool flag4 = this.idleTurnClockwise;
                    if (flag4)
                    {
                        this.CurRotation += 0.26f;
                    }
                    else
                    {
                        this.CurRotation -= 0.26f;
                    }
                    this.idleTurnTicksLeft--;
                    bool flag5 = this.idleTurnTicksLeft <= 0;
                    if (flag5)
                    {
                        this.ticksUntilIdleTurn = Rand.RangeInclusive(150, 350);
                    }
                }
            }
        }
        // Token: 0x060000F6 RID: 246 RVA: 0x00009180 File Offset: 0x00007380
        private void AddLaserGraphicUsing(Projectile_LaserConfig setting)
        {
            Vector3 a      = (this.Destination - this.origin).normalized * 0.9f;
            Vector3 s      = new Vector3(1f, 1f, (this.Destination - this.origin).magnitude - a.magnitude);
            Vector3 vector = this.OriginIV3.ToVector3() + a / 2f + (this.destinationInt - this.OriginIV3.ToVector3()) / 2f + Vector3.up * this.def.Altitude;
            float   num    = 0f;
            bool    flag   = GenGeo.MagnitudeHorizontalSquared(this.destinationInt - this.OriginIV3.ToVector3()) > 0.001f;

            if (flag)
            {
                num = Vector3Utility.AngleFlat(this.Destination - this.origin);
            }
            vector += Vector3Utility.RotatedBy(setting.offset, num);
            Matrix4x4 item = default(Matrix4x4);

            item.SetTRS(vector, this.ExactRotation, s);
            this.drawingMatrix.Add(item);
        }
예제 #3
0
 public override void Draw()
 {
     base.Draw();
     if (wallActive)
     {
         float   altitude  = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays);       //graphic depth
         float   wallWidth = Mathf.Clamp(1f * (wallEnergy / 1000f), .3f, 2f);
         Vector3 pos       = wallStart + (wallDir * wallLength * .5f);
         pos.y = altitude;
         float     angle  = Vector3Utility.AngleFlat(wallDir);
         Matrix4x4 matrix = new Matrix4x4();
         matrix.SetTRS(pos, Quaternion.AngleAxis(angle, Vector3.up), new Vector3(wallWidth, altitude, wallLength));   //drawer for wall shell
         Graphics.DrawMesh(MeshPool.plane10, matrix, TM_MatPool.LightBarrier, 0);
         if (Rand.Chance(.5f))
         {
             angle += 180;
         }
         Matrix4x4 matrix2 = new Matrix4x4();
         matrix2.SetTRS(pos, Quaternion.AngleAxis(angle, Vector3.up), new Vector3(wallWidth * 1.3f, altitude, wallLength * .95f));   //drawer for internal pulse
         Graphics.DrawMesh(MeshPool.plane10, matrix2, TM_MatPool.chiLightning, 0, null, 0, Projectile_Refraction.MatPropertyBlock);
     }
 }
예제 #4
0
        public static IEnumerable <IntVec3> circularSectorCellsStartedCaster(IntVec3 center, Map map, IntVec3 target, float radius, float angle, bool useCenter = false)
        {
            int   cellCount             = GenRadial.NumCellsInRadius(radius);
            float currentDirectionAngle = Vector3Utility.AngleFlat(target.ToVector3Shifted() - center.ToVector3Shifted());
            float angleMin = AngleWrapped(currentDirectionAngle - angle * 0.5f);
            float angleMax = AngleWrapped(angleMin + angle);

            if (useCenter)
            {
                yield return(GenRadial.RadialPattern[0] + center);
            }
            for (int i = 1; i < cellCount; i++)
            {
                IntVec3 cell            = GenRadial.RadialPattern[i] + center;
                float   targetCellAngle = Vector3Utility.AngleFlat(cell.ToVector3Shifted() - center.ToVector3Shifted());
                bool    flag            = (angleMin > angleMax) ? (targetCellAngle >= angleMin || targetCellAngle <= angleMax) : (targetCellAngle >= angleMin && targetCellAngle <= angleMax);
                if (GenGrid.InBounds(cell, map) && Verse.GenSight.LineOfSight(center, cell, map, true) && flag)
                {
                    yield return(cell);
                }
            }
            yield break;
        }