Example #1
0
        public override void CompTick()
        {
            base.CompTick();

            if (this.ticks > 0)
            {
                this.ticks--;
            }
            if (this.ticks < 0)
            {
                this.ticks = 0;
            }
            if (this.ticks < 1)
            {
                lastHitBuild = null;
                hitTime      = 0;
            }


            if (this.ticks > 0 && this.ticks % 5 == 0 && lastHitBuild != null)
            {
                ChronoMoteMaker.ThrowCell(lastHitBuild.TrueCenter().ToIntVec3(), lastHitBuild.Map, DefDatabase <ThingDef> .GetNamed("Mote_BlastEMP", true), new UnityEngine.Color(1, 1, 1), (lastHitBuild is Pawn)?new IntVec2((int)((Pawn)lastHitBuild).RaceProps.baseBodySize, (int)((Pawn)lastHitBuild).RaceProps.baseBodySize) :lastHitBuild.def.size);
            }


            if (lastHitBuild != null)
            {
                if (lastHitBuild.Destroyed)
                {
                    lastHitBuild = null;
                    hitTime      = 0;
                    return;
                }

                int HP = 1000;
                if (lastHitBuild.def.useHitPoints)
                {
                    HP = this.lastHitBuild.MaxHitPoints;
                }
                if (lastHitBuild is Pawn)
                {
                    HP = 400;
                }

                if (this.hitTime > (int)(HP / (20 * this.hitTime)))
                {
                    SoundStarter.PlayOneShot(DefDatabase <SoundDef> .GetNamed("ra2_Chrono_kill", true), lastHitBuild);
                    MoteMaker.ThrowExplosionCell(lastHitBuild.Position, lastHitBuild.Map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1, 1, 1));


                    if (lastHitBuild.def == ThingDefOf.SteamGeyser)
                    {
                        lastHitBuild.DeSpawn(DestroyMode.Vanish);
                    }
                    else
                    {
                        lastHitBuild.Destroy(DestroyMode.Vanish);
                    }


                    lastHitBuild = null;
                    hitTime      = 0;
                    ticks        = 0;
                }
            }
            else
            {
                // Log.Warning("null");
            }
        }
Example #2
0
        public override void CompTick()
        {
            base.CompTick();

            if (ticks > 0)
            {
                ticks--;
            }

            if (ticks < 0)
            {
                ticks = 0;
            }

            if (ticks < 1)
            {
                lastHitBuild = null;
                hitTime      = 0;
            }


            if (ticks > 0 && ticks % 5 == 0 && lastHitBuild != null)
            {
                ChronoMoteMaker.ThrowCell(lastHitBuild.TrueCenter().ToIntVec3(), lastHitBuild.Map,
                                          DefDatabase <ThingDef> .GetNamed("Mote_BlastEMP"), new Color(1, 1, 1),
                                          lastHitBuild is Pawn pawn
                        ? new IntVec2((int)pawn.RaceProps.baseBodySize,
                                      (int)pawn.RaceProps.baseBodySize)
                        : lastHitBuild.def.size);
            }


            if (lastHitBuild == null)
            {
                return;
            }

            if (lastHitBuild.Destroyed)
            {
                lastHitBuild = null;
                hitTime      = 0;
                return;
            }

            var HP = 1000;

            if (lastHitBuild.def.useHitPoints)
            {
                HP = lastHitBuild.MaxHitPoints;
            }

            if (lastHitBuild is Pawn)
            {
                HP = 400;
            }

            if (hitTime <= HP / (20 * hitTime))
            {
                return;
            }

            DefDatabase <SoundDef> .GetNamed("ra2_Chrono_kill").PlayOneShot(lastHitBuild);

            FleckMaker.ThrowExplosionCell(lastHitBuild.Position, lastHitBuild.Map, FleckDefOf.ExplosionFlash,
                                          new Color(1, 1, 1));


            if (lastHitBuild.def == ThingDefOf.SteamGeyser)
            {
                lastHitBuild.DeSpawn();
            }
            else
            {
                lastHitBuild.Destroy();
            }


            lastHitBuild = null;
            hitTime      = 0;
            ticks        = 0;
        }