예제 #1
0
        // Token: 0x0600041B RID: 1051 RVA: 0x0002C940 File Offset: 0x0002AD40
        protected override Job TryGiveJob(Pawn pawn)
        {
            Room room = pawn.GetRoom(RegionType.Set_Passable);
            int  num  = 0;

            while ((float)num < JobGiver_MaintainHiveLikes.CellsInScanRadius)
            {
                IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[num];
                if (intVec.InBounds(pawn.Map))
                {
                    if (intVec.GetRoom(pawn.Map, RegionType.Set_Passable) == room)
                    {
                        HiveLike hivelike = (HiveLike)pawn.Map.thingGrid.ThingsListAt(intVec).Find(x => x.def.thingClass == typeof(AdeptusMechanicus.HiveLike));
                        if (hivelike != null && pawn.CanReserve(hivelike, 1, -1, null, false))
                        {
                            CompMaintainable compMaintainable = hivelike.TryGetComp <CompMaintainable>();
                            if (compMaintainable.CurStage != MaintainableStage.Healthy)
                            {
                                if (!this.onlyIfDamagingState || compMaintainable.CurStage == MaintainableStage.Damaging)
                                {
                                    return(new Job(JobDefOf.Maintain, hivelike));
                                }
                            }
                        }
                    }
                }
                num++;
            }
            return(null);
        }
예제 #2
0
        // Token: 0x060029CA RID: 10698 RVA: 0x0013C760 File Offset: 0x0013AB60
        private void TickInterval(int interval)
        {
            if (!this.parent.Spawned)
            {
                return;
            }
            HiveLike hive = this.parent as HiveLike;

            if (hive != null)
            {
                if (!hive.active)
                {
                    return;
                }
            }
            else if (this.parent.Position.Fogged(this.parent.Map))
            {
                return;
            }
            if (this.PropsSpawner.requiresPower && !this.PowerOn)
            {
                return;
            }
            this.ticksUntilSpawn -= interval;
            this.CheckShouldSpawn();
        }
        // Token: 0x06000E64 RID: 3684 RVA: 0x0006B8B4 File Offset: 0x00069CB4
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map           = (Map)parms.target;
            int hivelikeCount = Mathf.Max(GenMath.RoundRandom(parms.points / 220f), 1);

            if (def.tags.Contains("TunnelLike"))
            {
                //Log.Message(string.Format("TunnelLike"));

                TunnelHiveLikeSpawner t = null;
                int num;
                for (int i = Mathf.Max(GenMath.RoundRandom(parms.points / 220f), 1); i > 0; i -= num)
                {
                    num = Mathf.Min(3, i);
                    t   = this.SpawnTunnelLikeCluster(num, map);
                }
                base.SendStandardLetter(t, null, new string[0]);
            }
            else
            {
                //Log.Message(string.Format("HiveLike"));

                HiveLike t = null;
                int      num;
                for (int i = Mathf.Max(GenMath.RoundRandom(parms.points / 400f), 1); i > 0; i -= num)
                {
                    num = Mathf.Min(3, i);
                    t   = this.SpawnHiveLikeCluster(num, map);
                }
                base.SendStandardLetter(t, null, new string[0]);
            }
            Find.TickManager.slower.SignalForceNormalSpeedShort();
            return(true);
        }
        // Token: 0x060029E3 RID: 10723 RVA: 0x0013D300 File Offset: 0x0013B700
        public bool TrySpawnChildHiveLike(bool ignoreRoofedRequirement, out HiveLike newHiveLike)
        {
            if (!this.CanSpawnChildHiveLike)
            {
                newHiveLike = null;
                return(false);
            }
            IntVec3 loc = CompSpawner_HiveLike_CrashedShipPart.FindChildHiveLocation(this.parent.Position, this.parent.Map, this.parent.def, this.Props, true, false);

            if (!loc.IsValid)
            {
                newHiveLike = null;
                return(false);
            }
            newHiveLike = (HiveLike)ThingMaker.MakeThing(this.parent.def, null);
            if (newHiveLike.Faction != this.parent.Faction)
            {
                newHiveLike.SetFaction(this.parent.Faction, null);
            }
            HiveLike hivelike = this.parent as HiveLike;

            if (hivelike != null)
            {
                newHiveLike.active = hivelike.active;
            }
            GenSpawn.Spawn(newHiveLike.Def.TunnelDef, loc, this.parent.Map, WipeMode.FullRefund);
            this.CalculateNextHiveLikeSpawnTick();
            return(true);
        }
        // Token: 0x06000416 RID: 1046 RVA: 0x0002C898 File Offset: 0x0002AC98
        protected override IntVec3 GetFlagPosition(Pawn pawn)
        {
            HiveLike hivelike = pawn.mindState.duty.focus.Thing as HiveLike;

            if (hivelike != null && hivelike.Spawned)
            {
                return(hivelike.Position);
            }
            return(pawn.Position);
        }
        // Token: 0x06000420 RID: 1056 RVA: 0x0002CD30 File Offset: 0x0002B130
        protected override IntVec3 GetWanderRoot(Pawn pawn)
        {
            HiveLike hivelike = pawn.mindState.duty.focus.Thing as HiveLike;

            if (hivelike == null || !hivelike.Spawned)
            {
                return(pawn.Position);
            }
            return(hivelike.Position);
        }
예제 #7
0
 // Token: 0x06000860 RID: 2144 RVA: 0x00047694 File Offset: 0x00045A94
 public override void UpdateAllDuties()
 {
     base.FilterOutUnspawnedHiveLikes();
     for (int i = 0; i < this.lord.ownedPawns.Count; i++)
     {
         HiveLike hiveFor = (HiveLike)base.GetHiveLikeFor(this.lord.ownedPawns[i]);
         PawnDuty duty    = new PawnDuty(OGHiveLikeDefOf.OGAMXB_DefendAndExpandHiveLike, hiveFor, this.distToHiveToAttack);
         this.lord.ownedPawns[i].mindState.duty = duty;
     }
 }
예제 #8
0
        private static void SpawnItemInstantly(HiveLike hive)
        {
            CompSpawnerLike compSpawner = (CompSpawnerLike)hive.AllComps.Find(delegate(ThingComp x)
            {
                CompSpawnerLike compSpawner2 = x as CompSpawnerLike;
                return(compSpawner2 != null && compSpawner2.PropsSpawner.thingToSpawn == ThingDefOf.InsectJelly);
            });

            if (compSpawner != null)
            {
                compSpawner.TryDoSpawn();
            }
        }
예제 #9
0
        // Token: 0x06000880 RID: 2176 RVA: 0x000475D8 File Offset: 0x000459D8
        private HiveLike FindClosestHiveLike(Pawn pawn)
        {
            HiveLike hiveLike = null;

            if (!DefDatabase <ThingDef_HiveLike> .AllDefsListForReading.FindAll(x => x.Faction == pawn.Faction.def).NullOrEmpty())
            {
                foreach (ThingDef_HiveLike hivelikeDef in DefDatabase <ThingDef_HiveLike> .AllDefsListForReading.FindAll(x => x.Faction == pawn.Faction.def))
                {
                    hiveLike = (HiveLike)GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(hivelikeDef), PathEndMode.Touch, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 30f, (Thing x) => x.Faction == pawn.Faction, null, 0, 30, false, RegionType.Set_Passable, false);
                    if (hiveLike != null)
                    {
                        break;
                    }
                }
            }
            return(hiveLike);
        }
예제 #10
0
파일: Class3.cs 프로젝트: Ogliss/AdMechXeno
        // Token: 0x0600268A RID: 9866 RVA: 0x00124ABC File Offset: 0x00122EBC
        public static void Notify_HiveLikeDespawned(HiveLike hivelike, Map map)
        {
            int num = GenRadial.NumCellsInRadius(2f);

            for (int i = 0; i < num; i++)
            {
                IntVec3 c = hivelike.Position + GenRadial.RadialPattern[i];
                if (c.InBounds(map))
                {
                    List <Thing> thingList = c.GetThingList(map);
                    for (int j = 0; j < thingList.Count; j++)
                    {
                        if (thingList[j].Faction == hivelike.OfFaction && !TyranidHiveUtility.AnyHiveLikePreventsClaiming(thingList[j]))
                        {
                            thingList[j].SetFaction(null, null);
                        }
                    }
                }
            }
        }
예제 #11
0
        private HiveLike SpawnHiveLikeCluster(int hiveCount, Map map)
        {
            ;
            IntVec3           loc      = DropCellFinder.RandomDropSpot(map);
            ThingDef_HiveLike thingDef = (ThingDef_HiveLike)this.def.mechClusterBuilding;
            HiveLike          hivelike = (HiveLike)ThingMaker.MakeThing(thingDef, null);

            GenSpawn.Spawn(ThingMaker.MakeThing(hivelike.OfTunnel, null), loc, map);
            hivelike.SetFaction(hivelike.OfFaction, null);
            IncidentWorker_Hivelike.SpawnItemInstantly(hivelike);
            for (int i = 0; i < hiveCount - 1; i++)
            {
                HiveLike             hivelike2;
                CompSpawnerHiveLikes c = hivelike.GetComp <CompSpawnerHiveLikes>();
                if (hivelike.Spawned && hivelike.GetComp <CompSpawnerHiveLikes>().TrySpawnChildHiveLike(true, out hivelike2))
                {
                    IncidentWorker_Hivelike.SpawnItemInstantly(hivelike2);
                    hivelike = hivelike2;
                }
            }
            return(hivelike);
        }
예제 #12
0
        public static List <Thing> SpawnedHivelikes(Map map, FactionDef factionDef)
        {
            HiveLike     hiveLike = null;
            List <Thing> lista    = new List <Thing>();

            if (!DefDatabase <ThingDef_HiveLike> .AllDefsListForReading.FindAll(x => x.Faction == factionDef).NullOrEmpty())
            {
                List <Thing> listb = new List <Thing>();
                foreach (ThingDef_HiveLike hivelikeDef in DefDatabase <ThingDef_HiveLike> .AllDefsListForReading.FindAll(x => x.Faction == factionDef))
                {
                    listb = map.listerThings.ThingsOfDef(hivelikeDef);
                    if (!listb.NullOrEmpty())
                    {
                        foreach (var item in listb)
                        {
                            lista.Add(item);
                        }
                    }
                }
            }
            return(lista);
        }
 // Token: 0x06002627 RID: 9767 RVA: 0x00122210 File Offset: 0x00120610
 public override void Tick()
 {
     if (base.Spawned)
     {
         HiveLike hive = (HiveLike)ThingMaker.MakeThing(hiveDef, null);
         this.sustainer.Maintain();
         Vector3 vector = base.Position.ToVector3Shifted();
         IntVec3 c;
         ResetStaticData();
         if (Rand.MTBEventOccurs(FilthSpawnMTB, 1f, 1.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(base.Position, base.Map, TunnelHiveLikeSpawner.FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c, 999999))
         {
             FilthMaker.MakeFilth(c, base.Map, filthTypes.RandomElement <ThingDef>(), 1);
         }
         if (Rand.MTBEventOccurs(DustMoteSpawnMTB, 1f, 1.TicksToSeconds()))
         {
             MoteMaker.ThrowDustPuffThick(new Vector3(vector.x, 0f, vector.z)
             {
                 y = AltitudeLayer.MoteOverhead.AltitudeFor()
             }, base.Map, Rand.Range(1.5f, 3f), new Color(1f, 1f, 1f, 2.5f));
         }
         if (this.secondarySpawnTick <= Find.TickManager.TicksGame)
         {
             this.sustainer.End();
             Map     map      = base.Map;
             IntVec3 position = base.Position;
             this.Destroy(DestroyMode.Vanish);
             if (this.spawnHive)
             {
                 if (Def.strikespreexplode)
                 {
                     FireEvent(map, position);
                     EventDraw(map, position);
                 }
                 if (Def.explodesprespawn)
                 {
                     GenExplosion.DoExplosion(position, map, Def.blastradius, Def.damageDef, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                 }
                 hive = (HiveLike)GenSpawn.Spawn(ThingMaker.MakeThing(hiveDef, null), position, map, WipeMode.Vanish);
                 hive.SetFaction(faction, null);
                 foreach (CompSpawnerLike compSpawner in hive.GetComps <CompSpawnerLike>())
                 {
                     if (compSpawner.PropsSpawner.thingToSpawn == ThingDefOf.InsectJelly)
                     {
                         compSpawner.TryDoSpawn();
                         break;
                     }
                 }
             }
             if (this.hivePoints > 0f)
             {
                 this.hivePoints = Mathf.Max(this.hivePoints, pawnKinds.Min((PawnKindDef x) => x.combatPower));
                 float       pointsLeft = this.hivePoints;
                 List <Pawn> list       = new List <Pawn>();
                 int         num        = 0;
                 while (pointsLeft > 0f)
                 {
                     num++;
                     if (num > 1000)
                     {
                         Log.Error("Too many iterations.", false);
                         break;
                     }
                     IEnumerable <PawnKindDef> source = from x in pawnKinds
                                                        where x.combatPower <= pointsLeft
                                                        select x;
                     PawnKindDef pawnKindDef;
                     if (!source.TryRandomElement(out pawnKindDef))
                     {
                         break;
                     }
                     Pawn pawn = PawnGenerator.GeneratePawn(pawnKindDef, faction);
                     GenSpawn.Spawn(pawn, CellFinder.RandomClosewalkCellNear(position, map, 2, null), map, WipeMode.Vanish);
                     pawn.mindState.spawnedByInfestationThingComp = this.spawnedByInfestationThingComp;
                     list.Add(pawn);
                     pointsLeft -= pawnKindDef.combatPower;
                 }
                 if (list.Any <Pawn>())
                 {
                     LordMaker.MakeNewLord(faction, new LordJob_AssaultColony(faction, true, false, false, false, true), map, list);
                 }
             }
         }
     }
 }