示例#1
0
        // Token: 0x0600295E RID: 10590 RVA: 0x00139BAC File Offset: 0x00137FAC

        public override void CompTickRare()
        {
            float ambientTemperature = this.parent.AmbientTemperature;
            bool  selected           = Find.Selector.SelectedObjects.Contains(this.parent) && Prefs.DevMode;
            Thing thing = null;

            if (MyMap != null && MyPos.InBounds(MyMap))
            {
                thing = GenClosest.ClosestThingReachable(MyPos, MyMap, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), Props.triggerRadius, x => XenomorphUtil.isInfectablePawn(((Pawn)x)), null, 0, -1, false, RegionType.Set_Passable, false);
            }
            int huggercount = thing != null?XenomorphUtil.TotalSpawnedFacehuggerPawnCount(MyMap, 10, (Pawn)thing) : 0;

            int hostcount = thing != null?XenomorphUtil.TotalSpawnedInfectablePawnCount(MyMap, 10, this.MyPos) : 0;

            bool shouldHatch = huggercount < hostcount;

            if (thing != null && ambientTemperature > -20f)
            {
                Pawn pawn = (Pawn)thing;
                bool flag = XenomorphUtil.isInfectablePawn(pawn);
                if (selected)
                {
                    //    Log.Message(string.Format("{0} isInfectable?: {1}", pawn.Label, flag));
                }
                if (flag)
                {
                    this.canHatch = true;
                }
                if (canHatch && shouldHatch && DistanceBetween(MyPos, pawn.Position) < 10f)
                {
                    float thingdist      = DistanceBetween(MyPos, pawn.Position);
                    float thingsize      = pawn.BodySize;
                    float thingstealth   = thing.GetStatValue(StatDefOf.HuntingStealth);
                    float thingmovespeed = thing.GetStatValue(StatDefOf.MoveSpeed);
                    if (selected)
                    {
                        //    Log.Message(string.Format("distance between {1} @{3} and {2} @ {4}: {0}", DistanceBetween(MyPos, pawn.Position), this.parent.LabelShort, pawn.Label, MyPos, pawn.Position));
                        //    Log.Message(string.Format("{0} thingsize: {1}, thingstealth: {2}, thingmovespeed: {3}", pawn.Label, thingsize, thingstealth, thingmovespeed));
                    }

                    float hatchon = ((10 * thingdist) - (thingsize * 5));
                    float roll    = thingstealth > 0 ? (Rand.RangeInclusive(0, 100) * thingstealth): (Rand.RangeInclusive(0, 100));
                    if (roll > hatchon)
                    {
                        this.willHatch = true;
                    }
                    if (selected)
                    {
                        Log.Message(string.Format("{0} hatchon: {1}, roll: {2}, willHatch: {3}", pawn.Label, hatchon, roll, willHatch));
                    }
                }
            }
            if (thing == null)
            {
                //    if (selected) Log.Message(string.Format("{0} @ {1}, Cant hatch No suitable Host Found", this.parent.Label, MyPos, canHatch));
            }
        }