Ejemplo n.º 1
0
        protected override IntVec3 GetWanderRoot(Pawn pawn)
        {
            HorrorHive hive = pawn.mindState.duty.focus.Thing as HorrorHive;

            if (hive == null || !hive.Spawned)
            {
                return(pawn.Position);
            }
            return(hive.Position);
        }
        private HorrorHive SpawnHiveCluster(int hiveCount, Map map)
        {
            IntVec3 loc;

            if (!InfestationCellFinder.TryFindCell(out loc, map))
            {
                return(null);
            }
            HorrorHive hive = (HorrorHive)GenSpawn.Spawn(ThingMaker.MakeThing(ThingDef.Named("HorrorHive"), null), loc, map);

            hive.SetFaction(Find.FactionManager.FirstFactionOfDef(FactionDef.Named("Horrors")));

            return(hive);
        }
        public new bool TryExecute(IncidentParms parms)
        {
            Map        map = (Map)parms.target;
            HorrorHive t   = null;
            int        num;

            for (int i = Mathf.Max(GenMath.RoundRandom(parms.points / HivePoints), 1); i > 0; i -= num)
            {
                num = Mathf.Min(3, i);
                t   = this.SpawnHiveCluster(num, map);
            }
            base.SendStandardLetter(parms, t);
            Find.TickManager.slower.SignalForceNormalSpeedShort();
            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            var        map = (Map)parms.target;
            HorrorHive t   = null;
            int        num;

            for (var i = Mathf.Max(GenMath.RoundRandom(parms.points / HivePoints), 1); i > 0; i -= num)
            {
                num = Mathf.Min(3, i);
                t   = SpawnHiveCluster(map);
            }

            SendStandardLetter(parms, t);
            Find.TickManager.slower.SignalForceNormalSpeedShort();
            return(true);
        }
Ejemplo n.º 5
0
        public override void CompTickRare()
        {
            HorrorHive hive = this.parent as HorrorHive;

            if ((hive == null || hive.active) && Find.TickManager.TicksGame >= this.nextHiveSpawnTick)
            {
                HorrorHive hive2;
                if (this.TrySpawnChildHive(false, out hive2))
                {
                    hive2.nextPawnSpawnTick = Find.TickManager.TicksGame + Rand.Range(150, 350);
                    Messages.Message("MessageHiveReproduced".Translate(), hive2, MessageTypeDefOf.NegativeEvent);
                }
                else
                {
                    this.CalculateNextHiveSpawnTick();
                }
            }
        }
Ejemplo n.º 6
0
        public bool TrySpawnChildHive(bool ignoreRoofedRequirement, out HorrorHive newHive)
        {
            if (!this.CanSpawnChildHive)
            {
                newHive = null;
                return(false);
            }
            IntVec3 invalid = IntVec3.Invalid;

            for (int i = 0; i < 3; i++)
            {
                float minDist = this.Props.HiveSpawnPreferredMinDist;
                if (i == 1)
                {
                    minDist = 0f;
                }
                else
                {
                    if (i == 2)
                    {
                        newHive = null;
                        return(false);
                    }
                }
                if (CellFinder.TryFindRandomReachableCellNear(this.parent.Position, this.parent.Map, this.Props.HiveSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), (IntVec3 c) => this.CanSpawnHiveAt(c, minDist, ignoreRoofedRequirement), null, out invalid, 999999))
                {
                    break;
                }
            }
            newHive = (HorrorHive)GenSpawn.Spawn(this.parent.def, invalid, this.parent.Map);
            if (newHive.Faction != this.parent.Faction)
            {
                newHive.SetFaction(this.parent.Faction, null);
            }
            HorrorHive hive = this.parent as HorrorHive;

            if (hive != null)
            {
                newHive.active = hive.active;
            }
            this.CalculateNextHiveSpawnTick();
            return(true);
        }