Example #1
0
 // Token: 0x06000015 RID: 21 RVA: 0x00002438 File Offset: 0x00000638
 public override void Tick()
 {
     if (this.Armed)
     {
         List <Thing> thingList = GridsUtility.GetThingList(base.Position, base.Map);
         for (int i = 0; i < thingList.Count; i++)
         {
             Pawn pawn = thingList[i] as Pawn;
             if (pawn != null && !this.touchingPawns.Contains(pawn))
             {
                 this.touchingPawns.Add(pawn);
                 this.CheckSpring(pawn);
             }
         }
     }
     for (int j = 0; j < this.touchingPawns.Count; j++)
     {
         Pawn pawn2 = this.touchingPawns[j];
         if (!pawn2.Spawned || pawn2.Position != base.Position)
         {
             this.touchingPawns.Remove(pawn2);
         }
     }
     base.Tick();
 }
Example #2
0
        private Thing GetValidThingStack()
        {
            List <IntVec3> _Cells = Enumerable.ToList <IntVec3>(Enumerable.Where <IntVec3>(GenAdj.CellsAdjacentCardinal((Thing)this), (Func <IntVec3, bool>)(c => GenGrid.InBounds(c, this.Map))));

            List <Thing> _closeThings = new List <Thing>();

            foreach (IntVec3 _Cell in _Cells)
            {
                _closeThings.AddRange(GridsUtility.GetThingList(_Cell, this.Map));
            }

            foreach (Thing _TempThing in _closeThings)
            {
                if (_TempThing.stackCount >= Building_MolecularReinforcementCompressor.STUFF_AMMOUNT_REQUIRED)
                {
                    ThingDef _ReinforcedVersion = this.GetReinforcedVersion(_TempThing);

                    if (_ReinforcedVersion != null)
                    {
                        return(_TempThing);
                    }
                }
            }

            return(null);
        }
Example #3
0
            public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
            {
                Pawn pawn2 = GridsUtility.GetThingList(IntVec3.FromVector3(clickPos), pawn.Map)
                             .FirstOrDefault((Thing x) => x is Pawn) as Pawn;
                var mapComp  = pawn.Map.GetComponent <MapComponentZLevel>();
                var ZTracker = ZUtils.ZTracker;

                if (pawn2 != null && ZTracker.ZLevelsTracker[pawn.Map.Tile].ZLevels.Count > 1)
                {
                    TaggedString    toCheck         = "Rescue".Translate(pawn2.LabelCap, pawn2);
                    FloatMenuOption floatMenuOption = opts.FirstOrDefault((FloatMenuOption x) => x.Label.Contains
                                                                              (toCheck));
                    if (floatMenuOption != null)
                    {
                        opts.Remove(floatMenuOption);
                        opts.Add(AddHumanlikeOrders_Patch.AddRescueOption(pawn, pawn2));
                    }
                    TaggedString    toCheck2         = "Capture".Translate(pawn2.LabelCap, pawn2);
                    FloatMenuOption floatMenuOption2 = opts.FirstOrDefault((FloatMenuOption x) => x.Label.Contains
                                                                               (toCheck2));
                    if (floatMenuOption2 != null)
                    {
                        opts.Remove(floatMenuOption2);
                        opts.Add(AddHumanlikeOrders_Patch.AddCaptureOption(pawn, pawn2));
                    }
                }
            }
        // Token: 0x06000010 RID: 16 RVA: 0x000025EC File Offset: 0x000007EC
        public virtual void AcceptIngredientsForNextRecipe()
        {
            List <ThingDefCountClass> ingredients = this.Extension.ingredients;
            List <IntVec3>            source      = this.AdjacentCells.ToList <IntVec3>();
            IEnumerable <Thing>       enumerable  = source.SelectMany((IntVec3 c) => GridsUtility.GetThingList(c, base.Map));

            foreach (Thing thing in enumerable)
            {
                foreach (Building_AutomatedVat._ThingCountClass thingCountClass in from x in this.localRecord
                         where x.count > 0
                         select x)
                {
                    bool flag = thing.def == thingCountClass.thingDef;
                    if (flag)
                    {
                        bool flag2 = thingCountClass.count >= thing.stackCount;
                        if (flag2)
                        {
                            thingCountClass.count -= thing.stackCount;
                            thing.Destroy(0);
                            return;
                        }
                        thing.stackCount     -= thingCountClass.count;
                        thingCountClass.count = 0;
                        return;
                    }
                }
            }
        }
 // Token: 0x06000067 RID: 103 RVA: 0x00004390 File Offset: 0x00002590
 protected virtual void Impact(Thing hitThing)
 {
     if (hitThing == null)
     {
         Pawn pawn;
         if ((pawn = (GridsUtility.GetThingList(base.Position, base.Map).FirstOrDefault((Thing x) => x == this.usedTarget) as Pawn)) != null)
         {
             hitThing = pawn;
         }
     }
     if (this.impactDamage != null)
     {
         if (this.damageLaunched)
         {
             this.FlyingPawn.TakeDamage(this.impactDamage.Value);
         }
         else
         {
             hitThing.TakeDamage(this.impactDamage.Value);
         }
     }
     this.RespawnPawn();
     if (this.def.projectile.explosionRadius > 0)
     {
         GenExplosion.DoExplosion(base.Position, base.Map, this.def.projectile.explosionRadius, this.def.projectile.damageDef, FlyingPawn, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
     }
     this.Destroy(0);
 }
        // 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)
        {
            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("AdeptusMechanicus.PlaceWorker_OnTopOfWalls")));
                }
            }
            return(true);

            /*
             * 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("AdeptusMechanicus.PlaceWorker_OnTopOfWalls"));
             * }
             * return result;
             */
        }
Example #7
0
        public override void CompTickRare()
        {
            base.CompTickRare();
            float num = 15f;

            if (this.parent.MapHeld != null)
            {
                num = GridsUtility.GetTemperature(this.parent.PositionHeld, this.parent.MapHeld);
            }
            CompEquippable comp = this.parent.GetComp <CompEquippable>();

            if (comp != null)
            {
                Pawn casterPawn = comp.PrimaryVerb.CasterPawn;
                if (casterPawn != null)
                {
                    num = GridsUtility.GetTemperature(casterPawn.PositionHeld, casterPawn.MapHeld);
                }
            }
            if (this.parent.Spawned)
            {
                List <Thing> thingList = GridsUtility.GetThingList(this.parent.PositionHeld, this.parent.MapHeld);
                for (int i = 0; i < thingList.Count; i++)
                {
                    bool flag4 = thingList[i] is Building_Refrigerator;
                    if (flag4)
                    {
                        Building_Refrigerator building_Refrigerator = thingList[i] as Building_Refrigerator;
                        num = building_Refrigerator.Temp;
                        break;
                    }
                }
            }
            this.Temp += (num - this.Temp) * 0.05f;
        }
Example #8
0
        public override string CompInspectStringExtra()
        {
            StringBuilder sb = new StringBuilder();

            switch (base.Stage)
            {
            case RotStage.Fresh:
                sb.Append("RotStateFresh".Translate());
                break;

            case RotStage.Rotting:
                sb.Append("RotStateRotting".Translate());
                break;

            case RotStage.Dessicated:
                sb.Append("RotStateDessicated".Translate());
                break;
            }
            float num = (float)this.PropsRot.TicksToRotStart - base.RotProgress;

            if (num > 0f)
            {
                float        num2      = GenTemperature.GetTemperatureForCell(this.parent.PositionHeld, this.parent.Map);
                List <Thing> thingList = GridsUtility.GetThingList(this.parent.PositionHeld, this.parent.Map);
                for (int i = 0; i < thingList.Count; i++)
                {
                    if (thingList[i] is Building_Refrigerator)
                    {
                        Building_Refrigerator building_Refrigerator = thingList[i] as Building_Refrigerator;
                        num2 = building_Refrigerator.CurrentTemp;
                        break;
                    }
                }
                num2 = (float)Mathf.RoundToInt(num2);
                float num3 = GenTemperature.RotRateAtTemperature(num2);
                int   ticksUntilRotAtCurrentTemp = base.TicksUntilRotAtCurrentTemp;
                if (num3 < 0.001f)
                {
                    sb.Append(Translator.Translate("CurrentlyFrozen") + ".");
                }
                else
                {
                    if (num3 < 0.999f)
                    {
                        sb.Append(Translator.Translate("CurrentlyRefrigerated", new object[]
                        {
                            GenDate.ToStringTicksToPeriodVague(ticksUntilRotAtCurrentTemp)
                        }) + ".");
                    }
                    else
                    {
                        sb.Append(Translator.Translate("NotRefrigerated", new object[]
                        {
                            GenDate.ToStringTicksToPeriodVague(ticksUntilRotAtCurrentTemp)
                        }) + ".");
                    }
                }
            }
            return(sb.ToString().TrimEndNewlines());
        }
        private bool TryGetPowerCell(bool charged)
        {
            List <IntVec3> _Cells = Enumerable.ToList <IntVec3>(Enumerable.Where <IntVec3>(GenAdj.CellsAdjacentCardinal((Thing)this), (Func <IntVec3, bool>)(c => GenGrid.InBounds(c))));

            List <Thing> _CloseThings = new List <Thing>();

            foreach (IntVec3 _Cell in _Cells)
            {
                _CloseThings.AddRange(GridsUtility.GetThingList(_Cell));
            }

            foreach (Thing _CloseThing in _CloseThings)
            {
                Log.Message(_CloseThing.def.defName);
                if (charged)
                {
                    if (string.Equals(_CloseThing.def.defName, "PowerCellCharged"))
                    {
                        _CloseThing.SplitOff(1);
                        return(true);
                    }
                }
                else
                {
                    if (string.Equals(_CloseThing.def.defName, "PowerCellDischarged"))
                    {
                        _CloseThing.SplitOff(1);
                        return(true);
                    }
                }
            }

            return(false);
        }
        // Token: 0x0600000D RID: 13 RVA: 0x00002DF8 File Offset: 0x00000FF8
        private static Building_XenomorphCryptosleepCasket TryMakeCasket(CellRect mapRect, Map map, ThingDef thingDef)
        {
            mapRect.ClipInsideMap(map);
            CellRect cellRect;

            cellRect = new CellRect(mapRect.BottomLeft.x + 1, mapRect.BottomLeft.z + 1, 2, 1);
            cellRect.ClipInsideMap(map);
            foreach (IntVec3 intVec in cellRect)
            {
                List <Thing> thingList = GridsUtility.GetThingList(intVec, map);
                for (int i = 0; i < thingList.Count; i++)
                {
                    bool flag = !thingList[i].def.destroyable;
                    if (flag)
                    {
                        return(null);
                    }
                }
            }
            Building_XenomorphCryptosleepCasket building_CryptosleepCasket = (Building_XenomorphCryptosleepCasket)ThingMaker.MakeThing(thingDef, null);

            building_CryptosleepCasket.SetPositionDirect(cellRect.BottomLeft);
            bool flag2 = Rand.Value < 0.5f;

            if (flag2)
            {
                building_CryptosleepCasket.Rotation = Rot4.East;
            }
            else
            {
                building_CryptosleepCasket.Rotation = Rot4.North;
            }
            return(building_CryptosleepCasket);
        }
Example #11
0
 public static void Notify_CleaningAreaChanged(IntVec3 c)
 {
     if (!Find.AreaCleaning[c])
     {
         for (int i = FilthWithinZone.Count - 1; i >= 0; i--)
         {
             if (FilthWithinZone[i].Position == c)
             {
                 FilthWithinZone.RemoveAt(i);
             }
         }
     }
     else
     {
         foreach (Thing thing in GridsUtility.GetThingList(c).Where(( Thing s ) =>
         {
             if (s.def.thingClass == typeof(Filth))
             {
                 return(true);
             }
             return(s.def.thingClass == typeof(RimWorld.Filth));
         }))
         {
             FilthWithinZone.Add(thing);
         }
     }
 }
Example #12
0
        public IntVec3 ResolvedNeighborPos()
        {
            this.resolvingCurrently = true;
            IntVec3 intVec = this.NextValidPlacementSpot;
            bool    flag   = !GenGrid.Walkable(intVec, base.MapHeld);

            if (flag)
            {
                this.nextValidPlacementSpot = default(IntVec3);
                intVec = this.NextValidPlacementSpot;
                for (int i = 0; i < 9; i++)
                {
                    bool flag2 = GridsUtility.GetThingList(intVec, base.Map).FirstOrDefault((Thing x) => x is Building_XenomorphCocoon) != null;
                    if (!flag2)
                    {
                        break;
                    }
                    this.nextValidPlacementSpot = default(IntVec3);
                    intVec = this.NextValidPlacementSpot;
                    bool flag3 = !GenConstruct.CanPlaceBlueprintAt(this.def, intVec, Rot4.North, base.Map, false, null).Accepted;
                    if (!flag3)
                    {
                        break;
                    }
                    this.nextValidPlacementSpot = default(IntVec3);
                    intVec = this.NextValidPlacementSpot;
                }
            }
            this.resolvingCurrently = false;
            return(intVec);
        }
        // Token: 0x06000025 RID: 37 RVA: 0x00002E68 File Offset: 0x00001068
        public void TickTack()
        {
            bool destroyed = base.Destroyed;

            if (!destroyed)
            {
                Thing_AddsHediffDef thing_AddsHediffDef = this.def as Thing_AddsHediffDef;
                bool flag = thing_AddsHediffDef.addHediff != null;
                if (flag)
                {
                    List <Thing> thingList = GridsUtility.GetThingList(base.Position, base.Map);
                    for (int i = 0; i < thingList.Count; i++)
                    {
                        Pawn pawn  = thingList[i] as Pawn;
                        bool flag2 = pawn != null && !this.touchingPawns.Contains(pawn);
                        if (flag2)
                        {
                            this.touchingPawns.Add(pawn);
                            this.addHediffToPawn(pawn, thing_AddsHediffDef.addHediff, thing_AddsHediffDef.hediffAddChance, thing_AddsHediffDef.hediffSeverity, thing_AddsHediffDef.onlyAffectLungs);
                        }
                    }
                    for (int j = 0; j < this.touchingPawns.Count; j++)
                    {
                        Pawn pawn2 = this.touchingPawns[j];
                        bool flag3 = !pawn2.Spawned || pawn2.Position != base.Position;
                        if (flag3)
                        {
                            this.touchingPawns.Remove(pawn2);
                        }
                    }
                }
                this.cachedLabelMouseover = null;
            }
        }
 public override float GetScore(Room room)
 {
     if (room.OpenRoofCount > 0)
     {
         return(0.0f);
     }
     using (IEnumerator <IntVec3> enumerator1 = room.Cells.GetEnumerator())
     {
         while (((IEnumerator)enumerator1).MoveNext())
         {
             IntVec3 current1 = enumerator1.Current;
             bool    flag     = false;
             using (List <Thing> .Enumerator enumerator2 = GridsUtility.GetThingList(current1, room.Map).GetEnumerator())
             {
                 while (enumerator2.MoveNext())
                 {
                     Thing current2 = enumerator2.Current;
                     if (current2 is Building && (current2 as Building).def.building.shipPart)
                     {
                         flag = true;
                     }
                 }
             }
             if (!flag)
             {
                 return(0.0f);
             }
         }
     }
     return(float.MaxValue);
 }
Example #15
0
        public override void CompTickRare()
        {
            base.CompTickRare();
            float num = 15f;

            if (parent.MapHeld != null)
            {
                num = GridsUtility.GetTemperature(parent.PositionHeld, parent.MapHeld);
            }
            CompEquippable comp = parent.GetComp <CompEquippable>();

            if (comp != null)
            {
                Pawn casterPawn = comp.PrimaryVerb.CasterPawn;
                if (casterPawn != null)
                {
                    num = GridsUtility.GetTemperature(casterPawn.PositionHeld, casterPawn.MapHeld);
                }
            }
            if (parent.Spawned)
            {
                List <Thing> thingList = GridsUtility.GetThingList(parent.PositionHeld, parent.MapHeld);
                for (int i = 0; i < thingList.Count; i++)
                {
                    CompRefrigerator fridge = ThingCompUtility.TryGetComp <CompRefrigerator>(thingList[i]);
                    if (fridge != null)
                    {
                        num = fridge.currentTemp;
                        break;
                    }
                }
            }
            temperature += (num - temperature) * 0.05f;
        }
Example #16
0
        internal static bool            _HasEnoughFeedstockInHoppers(this Building_NutrientPasteDispenser obj)
        {
            int costPerDispense = obj.def.building.foodCostPerDispense;

            /* Research Project cut from A13
             * if( ResearchProjectDef.Named( "NutrientResynthesis" ).IsFinished )
             * {
             *  costPerDispense--;
             * }
             */
            // Check for generic hoppers
            var CompHopperUser = obj.TryGetComp <CompHopperUser>();

            if (CompHopperUser != null)
            {
                if (CompHopperUser.EnoughResourcesInHoppers(costPerDispense))
                {
                    return(true);
                }
            }
            // Check for vanilla hoppers
            var adjCells      = _AdjCellsCardinalInBounds(obj);
            int resourceCount = 0;

            for (int cellIndex = 0; cellIndex < adjCells.Count; ++cellIndex)
            {
                IntVec3      c         = adjCells[cellIndex];
                Thing        resource  = (Thing)null;
                Thing        hopper    = (Thing)null;
                List <Thing> thingList = GridsUtility.GetThingList(c);
                for (int thingIndex = 0; thingIndex < thingList.Count; ++thingIndex)
                {
                    Thing thisThing = thingList[thingIndex];
                    if (Building_NutrientPasteDispenser.IsAcceptableFeedstock(thisThing.def))
                    {
                        resource = thisThing;
                    }
                    if (thisThing.def == ThingDefOf.Hopper)
                    {
                        hopper = thisThing;
                    }
                }
                if (
                    (resource != null) &&
                    (hopper != null)
                    )
                {
                    resourceCount += resource.stackCount;
                }
                if (resourceCount >= costPerDispense)
                {
                    return(true);
                }
            }
            return(false);
        }
        public override void TickRare()
        {
            if (this.CurrentTemp < -2000f)
            {
                this.CurrentTemp = GridsUtility.GetTemperature(base.Position, base.Map);
            }
            foreach (IntVec3 cell in this.AllSlotCells())
            {
                foreach (Thing thing in GridsUtility.GetThingList(cell, base.Map))
                {
                    CompRottable rottable = ThingCompUtility.TryGetComp <CompRottable>(thing);
                    if (rottable != null && !(rottable is CompBetterRottable))
                    {
                        ThingWithComps     thingWithComps     = thing as ThingWithComps;
                        CompBetterRottable compBetterRottable = new CompBetterRottable();
                        thingWithComps.AllComps.Remove(rottable);
                        thingWithComps.AllComps.Add(compBetterRottable);
                        compBetterRottable.props       = rottable.props;
                        compBetterRottable.parent      = thingWithComps;
                        compBetterRottable.RotProgress = rottable.RotProgress;
                    }

                    if (ThingCompUtility.TryGetComp <CompFrosty>(thing) == null && thing.def.defName == "Beer")
                    {
                        ThingWithComps thingWithComps = thing as ThingWithComps;
                        CompFrosty     compFrosty     = new CompFrosty();
                        thingWithComps.AllComps.Add(compFrosty);
                        compFrosty.props  = CompProperties_Frosty.Beer;
                        compFrosty.parent = thingWithComps;
                        ((TickList)typeof(TickManager).GetField("tickListRare", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Find.TickManager)).RegisterThing(thingWithComps);
                    }
                }
            }

            float roomTemperature   = GridsUtility.GetTemperature(base.Position, base.Map);
            float changetemperature = (roomTemperature - this.CurrentTemp) * 0.01f;
            float changeEnergy      = -changetemperature;
            float powerMultiplier   = 0f;

            if (this.CurrentTemp + changetemperature > this.DesiredTemp)
            {
                float change = Mathf.Max(this.DesiredTemp - (this.CurrentTemp + changetemperature), -1f);
                if (this.powerComp != null && this.powerComp.PowerOn)
                {
                    changetemperature += change;
                    changeEnergy      -= change * 1.25f;
                }
                powerMultiplier = change * -1f;
            }
            this.CurrentTemp += changetemperature;
            IntVec3 pos = base.Position + IntVec3.North.RotatedBy(base.Rotation);

            GenTemperature.PushHeat(pos, base.Map, changeEnergy * 1.25f);
            this.powerComp.PowerOutput = -((CompProperties_Power)this.powerComp.props).basePowerConsumption * (powerMultiplier * 0.9f + 0.1f);
        }
 // Token: 0x0600000C RID: 12 RVA: 0x00002D80 File Offset: 0x00000F80
 private static void ClearMapRect(CellRect mapRect, Map map)
 {
     foreach (IntVec3 intVec in mapRect)
     {
         List <Thing> thingList = GridsUtility.GetThingList(intVec, map);
         for (int i = 0; i < thingList.Count; i++)
         {
             thingList[i].Destroy(0);
         }
     }
 }
Example #19
0
        public void SpawnIvy(IntVec3 dir)
        {
            if (GenCollection.Any <Thing>(GridsUtility.GetThingList(dir, Map),
                                          (Thing t) => (t.def.IsBuildingArtificial || t.def.IsNonResourceNaturalRock)))
            {
                return;
            }
            Plant newivy = new Plant();

            newivy = (Plant)ThingMaker.MakeThing(PurpleIvyDefOf.PurpleIvy);
            GenSpawn.Spawn(newivy, dir, this.Map);
        }
Example #20
0
        public static void SpawnNests(Thing spawner)
        {
            int            nestCount = 0;
            List <IntVec3> freeTiles = new List <IntVec3>();

            foreach (IntVec3 dir in GenRadial.RadialCellsAround(spawner.Position, 50, true))
            {
                if (GenGrid.InBounds(dir, spawner.Map) && spawner.Map.fertilityGrid.FertilityAt(dir) >= 0.5)
                {
                    var plant = dir.GetPlant(spawner.Map);
                    if (plant?.def == PurpleIvyDefOf.PI_Nest)
                    {
                        nestCount++;
                    }
                    if (plant?.Faction != PurpleIvyData.AlienFaction && !GenCollection.Any <Thing>
                            (GridsUtility.GetThingList(dir, spawner.Map), (Thing t) =>
                            (t.def.IsBuildingArtificial || t.def.IsNonResourceNaturalRock)))
                    {
                        if (freeTiles.Count < 50)
                        {
                            freeTiles.Add(dir);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                if (nestCount == 4)
                {
                    break;
                }
            }
            if (nestCount < 4)
            {
                var rnd = new System.Random();
                foreach (IntVec3 current in freeTiles.OrderBy(x => rnd.Next()).Take(4 - nestCount))
                {
                    var plant = current.GetPlant(spawner.Map);
                    if (plant == null)
                    {
                        Thing newNest = ThingMaker.MakeThing(ThingDef.Named("PI_Nest"));
                        GenSpawn.Spawn(newNest, current, spawner.Map);
                    }
                    else
                    {
                        plant.Destroy();
                        Thing newNest = ThingMaker.MakeThing(ThingDef.Named("PI_Nest"));
                        GenSpawn.Spawn(newNest, current, spawner.Map);
                    }
                }
            }
        }
Example #21
0
        public void TryCreatePipeNet(IntVec3 pipe, PipeType type)
        {
            if (!pipe.InBounds(map) || PipeNetAt(pipe) != null)
            {
                return;
            }

            int pipeTypeInt = (int)type;

            PipelineNet newNet = new PipelineNet
            {
                GasManager = this,
                NetType    = type
            };

            Predicate <IntVec3> predicate = delegate(IntVec3 c)
            {
                foreach (var item in GridsUtility.GetThingList(c, map))
                {
                    CompPipe compPipe2 = item.TryGetComp <CompPipe>();
                    if (compPipe2 != null)
                    {
                        if (compPipe2.PipeType == type)
                        {
                            compPipe2.pipeNet = newNet;
                            newNet.PipesThings.Add(compPipe2.parent);

                            CellRect cellRect = compPipe2.parent.OccupiedRect();
                            foreach (var cell in cellRect)
                            {
                                int num = map.cellIndices.CellToIndex(cell.x, cell.z);
                                PipeGrid[pipeTypeInt, map.cellIndices.CellToIndex(c)] = 1;
                                PipeNets[num] = newNet;
                            }
                        }

                        if (compPipe2.GasProps.ConnectEverything)
                        {
                            newNet.PipesThings.Add(compPipe2.parent);
                        }
                        return(true);
                    }
                }
                return(false);
            };

            map.floodFiller.FloodFill(pipe, predicate, delegate(IntVec3 x) { });
            PipelineSet[type].Add(newNet);
            AllPipeNets.Add(newNet);

            newNet.InitNet();
        }
Example #22
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);
                        }
                    }
                }
            }
        }
        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);
        }
Example #25
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);
        }
Example #27
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);
            }
        }
Example #28
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);
        }
Example #29
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);
        }