Пример #1
0
        // Token: 0x06000051 RID: 81 RVA: 0x00004498 File Offset: 0x00002698
        internal void JPHitRoof(bool up)
        {
            if (!this.def.skyfaller.hitRoof)
            {
                return;
            }
            CellRect cr;

            if (up)
            {
                IntVec3 hrpcell   = IntVec3Utility.ToIntVec3(base.DrawPos);
                IntVec2 punchsize = new IntVec2(3, 3);
                cr = GenAdj.OccupiedRect(hrpcell, base.Rotation, punchsize);
            }
            else
            {
                cr = GenAdj.OccupiedRect(this);
            }
            if (cr.Cells.Any((IntVec3 x) => GridsUtility.Roofed(x, this.Map)))
            {
                RoofDef roof = GridsUtility.GetRoof(cr.Cells.First((IntVec3 x) => GridsUtility.Roofed(x, this.Map)), base.Map);
                if (!SoundDefHelper.NullOrUndefined(roof.soundPunchThrough))
                {
                    SoundStarter.PlayOneShot(roof.soundPunchThrough, new TargetInfo(base.Position, base.Map, false));
                }
                RoofCollapserImmediate.DropRoofInCells(cr.ExpandedBy(1).ClipInsideMap(base.Map).Cells.Where(delegate(IntVec3 c)
                {
                    if (!GenGrid.InBounds(c, this.Map))
                    {
                        return(false);
                    }
                    if (cr.Contains(c))
                    {
                        return(true);
                    }
                    if (GridsUtility.GetFirstPawn(c, this.Map) != null)
                    {
                        return(false);
                    }
                    Building edifice = GridsUtility.GetEdifice(c, this.Map);
                    return(edifice == null || !edifice.def.holdsRoof);
                }), base.Map, null);
                if (up)
                {
                    this.PilotRoofPunchUp = true;
                    return;
                }
                this.PilotRoofPunchDown = true;
            }
        }
        // Token: 0x0600013B RID: 315 RVA: 0x0000B4A4 File Offset: 0x000096A4
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null)
        {
            bool flag = true;

            //    bool flag = GridsUtility.GetThingList(loc, map).FirstOrDefault((Thing x) => x.def.defName.Contains("Wall") || x.def.defName.Contains("Smoothed")) != null;
            foreach (IntVec3 c in GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size))
            {
                if (GridsUtility.GetThingList(c, map).FirstOrDefault((Thing x) => x.def.defName.Contains("Wall") || x.def.defName.Contains("Smoothed")) == null)
                {
                    return(new AcceptanceReport(Translator.Translate("PWP_PlaceWorker_OnTopOfWalls")));
                }
            }
            return(true);
        }
Пример #3
0
        public void SwitchOnLight()
        {
            IntVec3 val = IntVec3Utility.ToIntVec3(this.get_Wearer().get_DrawPos());

            if (!ThingUtility.DestroyedOrNull(light) && val != light.get_Position())
            {
                SwitchOffLight();
            }
            if (ThingUtility.DestroyedOrNull(light) && GridsUtility.GetFirstThing(val, this.get_Wearer().get_Map(), Util_VehicleLights.MiningLightDef) == null)
            {
                light = GenSpawn.Spawn(Util_VehicleLights.VehicleLightDef, val, this.get_Wearer().get_Map(), 0);
            }
            lightIsOn = true;
        }
Пример #4
0
        public override void CompPostTick(ref float severityAdjustment)
        {
            base.CompPostTick(ref severityAdjustment);

            if (base.Pawn != null)
            {
                if (base.Pawn.Position != null)
                {
                    if (base.Pawn.Map != null)
                    {
                        bool         present   = false;
                        List <Thing> thingList = GridsUtility.GetThingList(base.Pawn.Position, base.Pawn.Map);
                        foreach (var item in thingList.Where(x => x.TryGetComp <Comp_PinningWeapon>() != null))
                        {
                            present     = true;
                            pinnerThing = item;
                        }
                        this.present = present;
                        if (this.present)
                        {
                            float breakoutResistRoll = Rand.RangeInclusive(((int)this.parent.Severity * 2), (100 * (int)this.parent.Severity));
                            float breakoutResist     = breakoutResistRoll + this.parent.Severity;
                            float breakoutChanceRoll = Rand.RangeInclusive(1, 100);
                            float breakoutChance     = (breakoutChanceRoll * parent.pawn.health.summaryHealth.SummaryHealthPercent) + (parent.pawn.BodySize * 10);
                            if (breakoutResist < breakoutChance)
                            {
                                //    Log.Message(string.Format("breakoutResist rolled: {0}  ", breakoutResist));
                                //    Log.Message(string.Format("breakoutChance rolled: {0}  ", breakoutChance));
                                pinnerThing.Position = parent.pawn.Position.RandomAdjacentCell8Way();
                            }
                        }
                        if (!this.present)
                        {
                            Pawn.health.RemoveHediff(this.parent);
                        }
                        else
                        {
                            DamageInfo dinfo2 = new DamageInfo()
                            {
                            };
                            float stundur = 1f;
                            dinfo2.Def = DamageDefOf.Stun;
                            dinfo2.SetAmount((float)stundur.SecondsToTicks() / 30f);
                            Pawn.TakeDamage(dinfo2);
                        }
                    }
                }
            }
        }
        public override Job JobOnCell(Pawn pawn, IntVec3 c, bool forced = false)
        {
            Job job = base.JobOnCell(pawn, c);

            if (job == null || job.plantDefToSow == null || job.plantDefToSow.blueprintDef == null)
            {
                return(job);
            }
            Zone zone = GridsUtility.GetZone(c, pawn.Map);

            if (zone != null)
            {
                foreach (IntVec3 current in GenAdj.AdjacentCells8WayRandomized())
                {
                    IntVec3 intVec = c + current;
                    if (zone.ContainsCell(intVec))
                    {
                        foreach (Thing current2 in pawn.Map.thingGrid.ThingsAt(intVec))
                        {
                            if (current2.def != job.plantDefToSow && current2.def.BlockPlanting && ReservationUtility.CanReserve(pawn, current2, 1, -1, null, false) && !ForbidUtility.IsForbidden(current2, pawn))
                            {
                                if (current2.def.category == ThingCategory.Plant)
                                {
                                    Job result = new Job(JobDefOf.CutPlant, current2);
                                    return(result);
                                }
                                if (current2.def.EverHaulable)
                                {
                                    Job result = HaulAIUtility.HaulAsideJobFor(pawn, current2);
                                    return(result);
                                }
                            }
                        }
                    }
                }
            }
            Predicate <Thing> predicate = (Thing tempThing) => !ForbidUtility.IsForbidden(tempThing, pawn.Faction) && PawnLocalAwareness.AnimalAwareOf(pawn, tempThing) && ReservationUtility.CanReserve(pawn, tempThing, 1, -1, null, false);
            Thing             thing     = GenClosest.ClosestThingReachable(c, pawn.Map, ThingRequest.ForDef(job.plantDefToSow.blueprintDef), PathEndMode.ClosestTouch, TraverseParms.For(pawn, Danger.Deadly, 0, false), 9999f, predicate, null, 0, -1, false, RegionType.Set_Passable, false);

            if (thing != null)
            {
                return(new Job(DefDatabase <JobDef> .GetNamed("SowWithSeeds"), c, thing)
                {
                    plantDefToSow = job.plantDefToSow,
                    count = 25
                });
            }
            return(null);
        }
        internal static IntVec3 ClosestLocationReachable(WorkGiver_GrowerHarvest workGiver_GrowerHarvest, Pawn pawn)
        {
            Danger maxDanger = pawn.NormalMaxDanger();
            //bool forced = false;
            Map         map         = pawn.Map;
            ZoneManager zoneManager = pawn.Map.zoneManager;

            foreach (IntVec3 actionableLocation in PlantHarvest_Cache.GetClosestActionableLocations(pawn, map, PlantHarvest_Cache.awaitingHarvestCellsMapDict))
            {
                List <Thing> thingsAtLocation = GridsUtility.GetThingList(actionableLocation, map);
                foreach (Thing thingAtLocation in thingsAtLocation)
                {
                    if (thingAtLocation is Building_PlantGrower building_PlantGrower)
                    {
                        if (building_PlantGrower == null || !workGiver_GrowerHarvest.ExtraRequirements(building_PlantGrower, pawn) ||
                            building_PlantGrower.IsForbidden(pawn) ||
                            !pawn.CanReach(building_PlantGrower, PathEndMode.OnCell, maxDanger)
                            )
                        {
                            continue;
                        }
                        return(actionableLocation);
                    }
                }
                if (!(zoneManager.ZoneAt(actionableLocation) is Zone_Growing growZone))
                {
                    continue;
                }
                if (!workGiver_GrowerHarvest.ExtraRequirements(growZone, pawn))
                {
                    continue;
                }
                //if (!JobOnCellTest(workGiver_GrowerHarvest, pawn, actionableLocation, forced))
                //{
                //	continue;
                //}
                if (!workGiver_GrowerHarvest.HasJobOnCell(pawn, actionableLocation))
                {
                    PlantHarvest_Cache.ReregisterObject(pawn.Map, actionableLocation, PlantHarvest_Cache.awaitingHarvestCellsMapDict);
                    continue;
                }
                if (!pawn.CanReach(actionableLocation, PathEndMode.OnCell, maxDanger))
                {
                    continue;
                }
                return(actionableLocation);
            }
            return(IntVec3.Invalid);
        }
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null)
        {
            bool             flag = GridsUtility.GetThingList(loc, map).FirstOrDefault((Thing x) => x.def.defName.Contains("Sandbag") || x.def.defName.Contains("Barricade")) != null;
            AcceptanceReport result;

            if (flag)
            {
                result = true;
            }
            else
            {
                return(base.AllowsPlacing(checkingDef, loc, rot, map, thingToIgnore, thing));
            }
            return(result);
        }
Пример #8
0
 public static Pawn postfix_Job(Pawn __result, IntVec3 c, Map map)
 {
     if (__result == null)
     {
         foreach (Thing thing in GridsUtility.GetThingList(c, map))
         {
             Pawn val = thing as Pawn;
             if (val != null && !val.Dead && !val.Downed && val.IsPrisonerOfColony)
             {
                 return(val);
             }
         }
     }
     return(__result);
 }
        // Token: 0x0600013B RID: 315 RVA: 0x0000B4A4 File Offset: 0x000096A4
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null)
        {
            bool             flag = GridsUtility.GetThingList(loc, map).FirstOrDefault((Thing x) => x.def.defName.Contains("Wall") || x.def.defName.Contains("Smoothed")) != null;
            AcceptanceReport result;

            if (flag)
            {
                result = true;
            }
            else
            {
                result = new AcceptanceReport(Translator.Translate("AM_PlaceWorker_OnTopOfWalls"));
            }
            return(result);
        }
 public override float GetScore(Room room)
 {
     using (IEnumerator <IntVec3> enumerator = room.BorderCells.GetEnumerator())
     {
         while (((IEnumerator)enumerator).MoveNext())
         {
             Building edifice = GridsUtility.GetEdifice(enumerator.Current, room.Map);
             if (edifice == null || !edifice.def.building.shipPart)
             {
                 return(0.0f);
             }
         }
     }
     return(1.701412E+38f);
 }
 public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null)
 {
     if (GridsUtility.GetRoom(loc, map, (RegionType)7) == null)
     {
         ((RegionAndRoomUpdater)map.regionAndRoomUpdater).TryRebuildDirtyRegionsAndRooms();
     }
     if (GridsUtility.GetDoor(loc, map) != null && GridsUtility.GetDoor(loc, map).def.defName.Equals("ShipAirlock"))
     {
         return(true);
     }
     if (GridsUtility.GetRoom(loc, map, (RegionType)7) == null || !((string)((Def)GridsUtility.GetRoom(loc, map, (RegionType)7).Role).defName).Equals("ShipFramework"))
     {
         return(new AcceptanceReport(Translator.Translate("MustPlaceInsideShipFramework")));
     }
     return(true);
 }
 /// <summary>
 /// Sets a list of cells that will be changed so that they can be reverted if removed.
 /// </summary>
 private void GetOriginalRoofInRange()
 {
     foreach (IntVec3 cell in GenRadial.RadialCellsAround(base.Position, this.def.specialDisplayRadius, true))
     {
         if (cell.InBounds(base.Map))
         {
             if (cell.GetRoof(base.Map) != null)
             {
                 if (GridsUtility.GetRoof(cell, base.Map).isThickRoof)
                 {
                     originalThickRoof.Add(cell);
                 }
             }
         }
     }
 }
Пример #13
0
        public static void DestroyAllAtLocation(IntVec3 c, Map map)
        {
            List <Thing> thingList = GridsUtility.GetThingList(c, map);

            for (int i = 0; i < thingList.Count; i++)
            {
                if (!thingList[i].def.destroyable)
                {
                    return;
                }
            }
            for (int j = thingList.Count - 1; j >= 0; j--)
            {
                thingList[j].Destroy(0);
            }
        }
Пример #14
0
        private static void TryToSetFloorTile(IntVec3 c, Map map, TerrainDef floorDef)
        {
            List <Thing> thingList = GridsUtility.GetThingList(c, map);

            for (int i = 0; i < thingList.Count; i++)
            {
                if (!thingList[i].def.destroyable)
                {
                    return;
                }
            }
            for (int j = thingList.Count - 1; j >= 0; j--)
            {
                thingList[j].Destroy(0);
            }
            map.terrainGrid.SetTerrain(c, floorDef);
        }
Пример #15
0
        // Token: 0x0600000A RID: 10 RVA: 0x000021CC File Offset: 0x000003CC
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            List <Thing> thingList = GridsUtility.GetThingList(t.Position, t.Map);

            for (int i = 0; i < thingList.Count; i++)
            {
                if (thingList[i] != t && thingList[i].def.category == ThingCategory.Item)
                {
                    Job job = HaulAIUtility.HaulAsideJobFor(pawn, thingList[i]);
                    if (job != null)
                    {
                        return(job);
                    }
                }
            }
            return(new Job(TrapsDefOf.TR_RearmTrapJob, t));
        }
        // Token: 0x06000067 RID: 103 RVA: 0x00004390 File Offset: 0x00002590
        protected virtual void Impact(Thing hitThing)
        {
            bool flag = hitThing == null;

            if (flag)
            {
                Pawn pawn;
                bool flag2 = (pawn = (GridsUtility.GetThingList(base.Position, base.Map).FirstOrDefault((Thing x) => x == this.usedTarget) as Pawn)) != null;
                if (flag2)
                {
                    hitThing = pawn;
                }
            }
            bool flag3 = this.impactDamage != null;

            if (flag3)
            {
                for (int i = 0; i < this.timesToDamage; i++)
                {
                    bool flag4 = this.damageLaunched;
                    if (flag4)
                    {
                        this.flyingThing.TakeDamage(this.impactDamage.Value);
                    }
                    else
                    {
                        hitThing.TakeDamage(this.impactDamage.Value);
                    }
                }
            }
            GenSpawn.Spawn(this.flyingThing, base.Position, base.Map, 0);
            bool flag5 = this.def.projectile.explosionRadius > 0;

            if (flag5)
            {
                GenExplosion.DoExplosion(base.Position, base.Map, this.def.projectile.explosionRadius, this.def.projectile.damageDef, flyingThing, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
            }
            Pawn p = this.flyingThing as Pawn;

            if (drafted && p != null && !p.Downed)
            {
                p.drafter.Drafted = true;
            }
            this.Destroy(0);
        }
Пример #17
0
 // Token: 0x0600237B RID: 9083 RVA: 0x0010F4C4 File Offset: 0x0010D8C4
 public override void Tick()
 {
     if (this.InnerThing == null)
     {
         //    Log.Error("MinifiedThing with null InnerThing. Destroying.", false);
         this.Destroy(DestroyMode.Vanish);
         return;
     }
     base.Tick();
     if (this.InnerThing.TryGetComp <CompXenoHatcher>() is CompXenoHatcher comp)
     {
         comp.CompTick();
         if (this.MapHeld != null && this.Map == null)
         {
             //    Log.Message("MinifiedThing being carried.", false);
         }
         else
         {
             ticksTillInstall--;
             if (ticksTillInstall == 0)
             {
                 Map     map = this.Map;
                 IntVec3 c   = this.Position;
                 this.InnerThing.SetFaction(null);
                 if (this.Spawned)
                 {
                     this.DeSpawn();
                 }
                 try
                 {
                     GenPlace.TryPlaceThing(this.InnerThing, c, map, ThingPlaceMode.Direct);
                 }
                 catch (Exception)
                 {
                     CellFinder.TryFindRandomCellNear(c, map, 2, (x => GridsUtility.GetFirstBuilding(x, this.Map) == null), out c);
                     GenPlace.TryPlaceThing(this.InnerThing, c, map, ThingPlaceMode.Direct);
                     throw;
                 }
                 ticksTillInstall = 1000;
             }
             //
             //    Log.Message("MinifiedThing on the ground.", false);
         }
     }
 }
Пример #18
0
        /// <summary>
        /// Checks for cover along the flight path of the bullet, doesn't check for walls or plants, only intended for cover with partial fillPercent
        /// </summary>
        private bool GetPartialCoverBetween(Vector3 sourceLoc, Vector3 targetLoc, out Thing cover)
        {
            //Sanity check
            if (this.verbProps.projectileDef.projectile.flyOverhead)
            {
                cover = null;
                return(false);
            }

            sourceLoc.Scale(new Vector3(1, 0, 1));
            targetLoc.Scale(new Vector3(1, 0, 1));

            //Calculate segment vector and segment amount
            Vector3 shotVec     = sourceLoc - targetLoc;                             //Vector from target to source
            Vector3 segmentVec  = shotVec.normalized * segmentLength;
            float   distToCheck = Mathf.Min(distToCheckForCover, shotVec.magnitude); //The distance to raycast
            float   numSegments = distToCheck / segmentLength;

            //Raycast accross all segments to check for cover
            List <IntVec3> checkedCells = new List <IntVec3>();
            Thing          targetThing  = GridsUtility.GetEdifice(targetLoc.ToIntVec3());
            Thing          newCover     = null;

            for (int i = 0; i <= numSegments; i++)
            {
                IntVec3 cell = (targetLoc + segmentVec * i).ToIntVec3();
                if (!checkedCells.Contains(cell))
                {
                    //Cover check, if cell has cover compare fillPercent and get the highest piece of cover, ignore if cover is the target (e.g. solar panels, crashed ship, etc)
                    Thing coverAtCell = GridsUtility.GetCover(cell);
                    if (coverAtCell != null &&
                        (targetThing == null || !coverAtCell.Equals(targetThing)) &&
                        (newCover == null || newCover.def.fillPercent < coverAtCell.def.fillPercent))
                    {
                        newCover = coverAtCell;
                    }
                }
            }
            cover = newCover;

            //Report success if found cover that is not a wall or plant
            return(cover != null &&
                   cover.def.Fillage != FillCategory.Full &&
                   cover.def.category != ThingCategory.Plant);  //Don't care about trees
        }
Пример #19
0
        // Token: 0x06000046 RID: 70 RVA: 0x00003CC0 File Offset: 0x00001EC0
        internal static bool DFAEvent(IntVec3 cell, Thing instigator, bool fullDmg)
        {
            bool         DFAEvent   = false;
            List <Thing> cellThings = GridsUtility.GetThingList(cell, instigator.Map);

            if (cellThings.Count > 0)
            {
                for (int i = 0; i < cellThings.Count; i++)
                {
                    if (cellThings[i] is Pawn && cellThings[i] != instigator)
                    {
                        JPInjury.DoJPRelatedInjury(cellThings[i], true, true, instigator, fullDmg);
                        DFAEvent = true;
                    }
                }
            }
            return(DFAEvent);
        }
Пример #20
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            Building b = GridsUtility.GetFirstBuilding(pawn.Position, pawn.Map);

            Log.Message("Attempting to burrow.");
            if (b != null)
            {
                Log.Message("There is a thing here.");
                return(null);
            }
            else
            {
                Log.Message("There is nothing here, burrowing.");
                Thing e = GenSpawn.Spawn(ThingDef.Named("HorrorBurrow"), pawn.Position, pawn.Map);

                return(new Job(JobDefOf.EnterCryptosleepCasket, (Building_CryptosleepCasket)e));
            }
        }
        /// <summary>
        /// Sets thickRoofed cells in specialDisplayRadius to RoofClean RoofDef
        /// </summary>
        private void SetRoofInRange()
        {
            foreach (IntVec3 cell in GenRadial.RadialCellsAround(base.Position, this.def.specialDisplayRadius, true))
            {
                if (cell.InBounds(base.Map))
                {
                    if (cell.GetRoof(base.Map) != null)
                    {
                        if (GridsUtility.GetRoof(cell, base.Map).isThickRoof)
                        {
                            RoofDef roofType = DefDatabase <RoofDef> .GetNamed("RoofClean");

                            base.Map.roofGrid.SetRoof(cell, roofType);
                        }
                    }
                }
            }
        }
Пример #22
0
        // Token: 0x06000027 RID: 39 RVA: 0x00002FDC File Offset: 0x000011DC
        public void damageBuildings(int amt)
        {
            IntVec3 intVec = GenAdj.RandomAdjacentCell8Way(this);
            bool    flag   = GenGrid.InBounds(intVec, base.Map);
            bool    flag2  = flag;

            if (flag2)
            {
                Building   firstBuilding = GridsUtility.GetFirstBuilding(intVec, base.Map);
                DamageInfo damageInfo    = new DamageInfo(DamageDefOf.Burn, (float)amt, 0f, -1f, null, null, null, 0, null);
                bool       flag3         = firstBuilding != null;
                bool       flag4         = flag3;
                if (flag4)
                {
                    firstBuilding.TakeDamage(damageInfo);
                }
            }
        }
        protected override void ScatterAt(IntVec3 loc, Map map, int stackCount = 1)
        {
            if (!TryGetRandomValidRotation(loc, map, out Rot4 rot))
            {
                Log.Warning("Could not find any valid rotation for " + thingDef);
                return;
            }
            if (clearSpaceSize > 0)
            {
                using (IEnumerator <IntVec3> enumerator = GridShapeMaker.IrregularLump(loc, map, clearSpaceSize).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Building edifice = GridsUtility.GetEdifice(enumerator.Current, map);
                        if (edifice != null)
                        {
                            edifice.Destroy(0);
                        }
                    }
                }
            }
            Thing thing = ThingMaker.MakeThing(thingDef, stuff);

            if (thingDef.Minifiable)
            {
                thing = MinifyUtility.MakeMinified(thing);
            }
            if (thing.def.category == ThingCategory.Item)
            {
                thing.stackCount = stackCount;
                ForbidUtility.SetForbidden(thing, true, false);
                GenPlace.TryPlaceThing(thing, loc, map, ThingPlaceMode.Near, out Thing thing2, null);
                if (nearPlayerStart && thing2 != null && thing2.def.category == ThingCategory.Item && TutorSystem.TutorialMode)
                {
                    Find.TutorialState.AddStartingItem(thing2);
                    return;
                }
            }
            else
            {
                GenSpawn.Spawn(thing, loc, map, rot, false);
            }
        }
        public override void TickLong()
        {
            base.TickLong();
            bool selected = Find.Selector.SingleSelectedThing == this;

            if (!this.IsBurning() && !this.Destroyed && this.Map != null)
            {
                Thing thing = GenClosest.ClosestThingReachable(this.Position, this.Map, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), radius, x => x.isPotentialHost(), null, 0, -1, false, RegionType.Set_Passable, false);
                if (thing != null && this.Growth > 0.95f && !thing.Destroyed && !((Pawn)thing).Dead)
                {
                    List <Thing> thingList = GridsUtility.GetThingList(thing.Position, this.Map);
                    Thing        thing2;


                    if (!PlayerKnowledgeDatabase.IsComplete(XenomorphConceptDefOf.RRY_Concept_Fungus))
                    {
                        thing2 = ThingMaker.MakeThing(XenomorphDefOf.RRY_Neomorph_Spores_Hidden);
                    }
                    else
                    {
                        thing2 = ThingMaker.MakeThing(XenomorphDefOf.RRY_Neomorph_Spores);
                    }

                    float Chance = ((0.5f * Growth) * ((Pawn)thing).BodySize) / DistanceBetween(this.Position, thing.Position);
                    //    if (selected) Log.Message(string.Format("Chance: {0}", Chance));

                    if (Rand.Chance(Chance) && !thingList.Exists(x => x.def == XenomorphDefOf.RRY_Neomorph_Spores) && this.CanSee(thing))
                    {
                        if (thing.Faction == Faction.OfPlayer)
                        {
                            string text = TranslatorFormattedStringExtensions.Translate("Xeno_Neospores_Trigger", thing.LabelShortCap, this.Label);
                            //    Log.Message(text);
                            MoteMaker.ThrowText(this.Position.ToVector3(), this.Map, text, 5f);
                        }
                        GenSpawn.Spawn(thing2, thing.Position, this.Map);
                    }
                }
                else
                {
                    HarmRandomPlantInRadius(radius / 2);
                }
            }
        }
Пример #25
0
        // Token: 0x06000033 RID: 51 RVA: 0x00002B8E File Offset: 0x00000D8E
        private IEnumerable <Thing> RearmablesInCell(IntVec3 c)
        {
            if (GridsUtility.Fogged(c, base.Map))
            {
                yield break;
            }
            List <Thing> thingList = GridsUtility.GetThingList(c, base.Map);
            int          num;

            for (int i = 0; i < thingList.Count; i = num + 1)
            {
                if (this.CanDesignateThing(thingList[i]).Accepted)
                {
                    yield return(thingList[i]);
                }
                num = i;
            }
            yield break;
        }
Пример #26
0
        // Places the planning designators in radius around center.
        public override void DesignateSingleCell(IntVec3 c)
        {
            foreach (var cell in GenRadial.RadialCellsAround(c, 6.71f, true))
            {
                // Skip cells out of bounds.
                if (!cell.InBounds(Map) || cell.InNoBuildEdgeArea(Map))
                {
                    continue;
                }

                // Clear center cell to help see where to place wall.
                if (cell == c)
                {
                    foreach (Designation current in Map.designationManager.AllDesignationsAt(c).ToList <Designation>())
                    {
                        if (current.def == this.desDef)
                        {
                            base.Map.designationManager.RemoveDesignation(current);
                        }
                    }
                }

                // Mark radius, exluding walls.
                else if (Map.designationManager.DesignationAt(cell, this.desDef) == null)
                {
                    bool         holdsRoof = false;
                    List <Thing> thingList = GridsUtility.GetThingList(cell, Map);
                    for (int i = 0; i < thingList.Count; i++)
                    {
                        Thing thing = thingList[i];
                        if (thing.def.holdsRoof)
                        {
                            holdsRoof = true;
                            break;
                        }
                    }
                    if (!holdsRoof)
                    {
                        Map.designationManager.AddDesignation(new Designation(new LocalTargetInfo(cell), this.desDef));
                    }
                }
            }
        }
Пример #27
0
        // Token: 0x0600001D RID: 29 RVA: 0x00002B28 File Offset: 0x00000D28
        public void damageBuildings(int amt)
        {
            IntVec3 intVec = GenAdj.RandomAdjacentCell8Way(this);
            bool    flag   = GenGrid.InBounds(intVec, base.Map);
            bool    flag2  = flag;

            if (flag2)
            {
                Building   firstBuilding = GridsUtility.GetFirstBuilding(intVec, base.Map);
                DamageInfo damageInfo;
                damageInfo = new DamageInfo(XenomorphDefOf.RRY_AcidBurn, (float)amt, 0f, -1f, null, null, null, 0, null);
                bool flag3 = firstBuilding != null;
                bool flag4 = flag3;
                if (flag4)
                {
                    MoteMaker.ThrowDustPuff(firstBuilding.Position, base.Map, 0.2f);
                    firstBuilding.TakeDamage(damageInfo);
                }
            }
        }
Пример #28
0
 public override AcceptanceReport CanDesignateCell(IntVec3 loc)
 {
     if (!GenGrid.InBounds(loc))
     {
         return(false);
     }
     if (GridsUtility.Fogged(loc))
     {
         return(false);
     }
     if (Find.DesignationManager.DesignationAt(loc, DefDatabase <DesignationDef> .GetNamed("MD2CollectSand")) != null)
     {
         return(false);
     }
     if (Find.TerrainGrid.TerrainAt(loc) != TerrainDefOf.Sand)
     {
         return("DesignatorCollectSandReportString".Translate());
     }
     return(AcceptanceReport.WasAccepted);
 }
Пример #29
0
        private static void TrySetCellAsWall(IntVec3 c, Map map, ThingDef stuffDef)
        {
            List <Thing> thingList = GridsUtility.GetThingList(c, map);

            for (int i = 0; i < thingList.Count; i++)
            {
                if (!thingList[i].def.destroyable)
                {
                    return;
                }
            }
            for (int j = thingList.Count - 1; j >= 0; j--)
            {
                thingList[j].Destroy(0);
            }
            map.terrainGrid.SetTerrain(c, BaseGenUtility.CorrespondingTerrainDef(stuffDef, true));
            Thing thing = ThingMaker.MakeThing(ThingDefOf.Wall, stuffDef);

            GenSpawn.Spawn(thing, c, map);
        }
Пример #30
0
        private new bool CurrentlyCultivated()
        {
            if (!this.def.plant.Sowable)
            {
                return(false);
            }
            Zone zone = Find.get_ZoneManager().ZoneAt(this.Position);

            if (zone != null && zone is Zone_Growing)
            {
                return(true);
            }
            Building edifice = GridsUtility.GetEdifice(this.Position);

            if (edifice != null)
            {
                return(edifice.def.building.SupportsPlants);
            }
            return(false);
        }