Ejemplo n.º 1
0
        public override void End()
        {
            CompSkeletonLichController comp = null;

            if (!thing.DestroyedOrNull())
            {
                comp = thing.TryGetComp <CompSkeletonLichController>();
                SendAssaultWave(comp.ParentPawn.Faction, true);
            }
            else
            {
                List <Pawn> allPawns = this.SingleMap.mapPawns.AllPawnsSpawned;
                for (int i = 0; i < allPawns.Count; i++)
                {
                    if (allPawns[i].def == TorannMagicDefOf.TM_SkeletonR || allPawns[i].def == TorannMagicDefOf.TM_GiantSkeletonR || allPawns[i].def == TorannMagicDefOf.TM_SkeletonLichR)
                    {
                        if (allPawns[i].Faction != Faction.OfPlayer)
                        {
                            allPawns[i].Kill(null, null);
                            i--;
                        }
                    }
                }
            }
            List <GameCondition> gcs = new List <GameCondition>();

            gcs = this.SingleMap.GameConditionManager.ActiveConditions;
            for (int i = 0; i < gcs.Count; i++)
            {
                if (gcs[i].def == TorannMagicDefOf.DarkClouds)
                {
                    gcs[i].End();
                }
                else if (gcs[i].def == GameConditionDefOf.SolarFlare)
                {
                    gcs[i].End();
                }
            }

            MagicMapComponent mmc = this.SingleMap.GetComponent <MagicMapComponent>();

            if (mmc != null && mmc.allowAllIncidents)
            {
                mmc.allowAllIncidents = false;;
            }
            base.End();
        }
        public override void GameConditionTick()
        {
            base.GameConditionTick();
            if (Find.TickManager.TicksGame % 60 == 0)
            {
                //Log.Message("wandering lich duration pct: " + (float)((float)this.TicksPassed / (float)this.Duration) + "  duration ticks: " + this.Duration);
                if (this.thing.DestroyedOrNull())
                {
                    this.End();
                }

                CompSkeletonLichController comp = thing.TryGetComp <CompSkeletonLichController>();
                if (this.nextEventTick <= Find.TickManager.TicksGame)
                {
                    if (comp != null && comp.tauntTarget == null)
                    {
                        this.nextEventTick = Find.TickManager.TicksGame + this.ticksBetweenEvents;
                        comp.raiseRadius   = this.areaRadius;
                        comp.tauntTarget   = TM_Calc.TryFindSafeCell(comp.ParentPawn, comp.ParentPawn.Position, 30, 1, 10);
                        if (comp.tauntTarget == null || comp.tauntTarget == default(IntVec3))
                        {
                            FindGoodCenterLocation();
                            comp.tauntTarget = this.centerLocation.ToIntVec3;
                        }
                        comp.geChance       = this.geChance;
                        comp.leChance       = this.leChance;
                        this.centerLocation = comp.tauntTarget.Cell.ToIntVec2;
                        ChangeDefendPoint(thing.Faction);
                    }
                }

                if (comp != null && comp.shouldAssault)
                {
                    comp.shouldAssault = false;
                    SendAssaultWave(comp.ParentPawn.Faction);
                }
            }
        }