Esempio n. 1
0
        public static Job TrashJob(Pawn pawn, Thing t)
        {
            Plant plant = t as Plant;

            if (plant != null)
            {
                Job job = new Job(JobDefOf.Ignite, t);
                TrashUtility.FinalizeTrashJob(job);
                return(job);
            }
            if (pawn.equipment != null && Rand.Value < 0.699999988079071)
            {
                foreach (Verb allEquipmentVerb in pawn.equipment.AllEquipmentVerbs)
                {
                    if (allEquipmentVerb.verbProps.ai_IsBuildingDestroyer)
                    {
                        Job job2 = new Job(JobDefOf.UseVerbOnThing, t);
                        job2.verbToUse = allEquipmentVerb;
                        TrashUtility.FinalizeTrashJob(job2);
                        return(job2);
                    }
                }
            }
            Job   job3  = null;
            float value = Rand.Value;

            job3 = ((!(value < 0.34999999403953552) || pawn.natives.IgniteVerb == null || !t.FlammableNow || t.IsBurning() || t is Building_Door) ? new Job(JobDefOf.AttackMelee, t) : new Job(JobDefOf.Ignite, t));
            TrashUtility.FinalizeTrashJob(job3);
            return(job3);
        }
        public static bool ShouldTrashBuilding(Pawn pawn, Building b, bool attackAllInert = false)
        {
            bool result;

            if (!b.def.useHitPoints)
            {
                result = false;
            }
            else if (pawn.mindState.spawnedByInfestationThingComp && b.GetComp <CompCreatesInfestations>() != null)
            {
                result = false;
            }
            else
            {
                if ((b.def.building.isInert && !attackAllInert) || b.def.building.isTrap)
                {
                    int num         = GenLocalDate.HourOfDay(pawn) / 3;
                    int specialSeed = b.GetHashCode() * 612361 ^ pawn.GetHashCode() * 391 ^ num * 73427324;
                    if (!Rand.ChanceSeeded(0.008f, specialSeed))
                    {
                        return(false);
                    }
                }
                result = ((!b.def.building.isTrap || !((Building_Trap)b).Armed) && TrashUtility.CanTrash(pawn, b) && pawn.HostileTo(b));
            }
            return(result);
        }
Esempio n. 3
0
        public static bool ShouldTrashBuilding(Pawn pawn, Building b, bool attackAllInert = false)
        {
            if (!b.def.useHitPoints)
            {
                return(false);
            }
            if (b.def.building.isInert && !attackAllInert)
            {
                goto IL_0042;
            }
            if (b.def.building.isTrap)
            {
                goto IL_0042;
            }
            goto IL_007f;
IL_0042:
            int num = GenLocalDate.HourOfDay(pawn) / 3;
            int specialSeed = b.GetHashCode() * 612361 ^ pawn.GetHashCode() * 391 ^ num * 734273247;

            if (!Rand.ChanceSeeded(0.008f, specialSeed))
            {
                return(false);
            }
            goto IL_007f;
IL_007f:
            if (b.def.building.isTrap && ((Building_Trap)b).Armed)
            {
                return(false);
            }
            if (TrashUtility.CanTrash(pawn, b) && pawn.HostileTo(b))
            {
                return(true);
            }
            return(false);
        }
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (!pawn.HostileTo(Faction.OfPlayer))
            {
                return(null);
            }
            bool     flag     = pawn.natives.IgniteVerb != null && pawn.natives.IgniteVerb.IsStillUsableBy(pawn) && pawn.HostileTo(Faction.OfPlayer);
            CellRect cellRect = CellRect.CenteredOn(pawn.Position, 5);

            for (int i = 0; i < 35; i++)
            {
                IntVec3 randomCell = cellRect.RandomCell;
                if (!randomCell.InBounds(pawn.Map))
                {
                    continue;
                }
                Building edifice = randomCell.GetEdifice(pawn.Map);
                if (edifice != null && TrashUtility.ShouldTrashBuilding(pawn, edifice) && GenSight.LineOfSight(pawn.Position, randomCell, pawn.Map))
                {
                    if (DebugViewSettings.drawDestSearch && Find.CurrentMap == pawn.Map)
                    {
                        Find.CurrentMap.debugDrawer.FlashCell(randomCell, 1f, "trash bld");
                    }
                    Job job = TrashUtility.TrashJob(pawn, edifice);
                    if (job != null)
                    {
                        return(job);
                    }
                }
                if (flag)
                {
                    Plant plant = randomCell.GetPlant(pawn.Map);
                    if (plant != null && TrashUtility.ShouldTrashPlant(pawn, plant) && GenSight.LineOfSight(pawn.Position, randomCell, pawn.Map))
                    {
                        if (DebugViewSettings.drawDestSearch && Find.CurrentMap == pawn.Map)
                        {
                            Find.CurrentMap.debugDrawer.FlashCell(randomCell, 0.5f, "trash plant");
                        }
                        Job job2 = TrashUtility.TrashJob(pawn, plant);
                        if (job2 != null)
                        {
                            return(job2);
                        }
                    }
                }
                if (DebugViewSettings.drawDestSearch && Find.CurrentMap == pawn.Map)
                {
                    Find.CurrentMap.debugDrawer.FlashCell(randomCell, 0f, "trash no");
                }
            }
            return(null);
        }
        // Token: 0x0600048F RID: 1167 RVA: 0x0002F174 File Offset: 0x0002D574
        protected override Job TryGiveJob(Pawn pawn)
        {
            Map map = pawn.Map;

            if (!pawn.HostileTo(Faction.OfPlayer))
            {
                return(null);
            }
            bool            flag     = pawn.HostileTo(Faction.OfPlayer);
            CellRect        cellRect = CellRect.CenteredOn(pawn.Position, 5);
            List <Building> list     = map.listerBuildings.allBuildingsColonist.FindAll(x => x.TryGetComp <CompPowerPlant>() != null || x.TryGetComp <CompPowerBattery>() != null);

            for (int i = 0; i < 35; i++)
            {
                IntVec3 randomCell = cellRect.RandomCell;
                if (randomCell.InBounds(pawn.Map))
                {
                    Building edifice = randomCell.GetEdifice(pawn.Map);
                    if (flag)
                    {
                        if (edifice != null && TrashUtility.ShouldTrashBuilding(pawn, edifice, false) && GenSight.LineOfSight(pawn.Position, randomCell, pawn.Map, false, null, 0, 0) && (edifice.TryGetComp <CompPowerPlant>() != null || edifice.TryGetComp <CompPowerBattery>() != null || edifice.TryGetComp <CompPowerTransmitter>() != null))
                        {
                            if (DebugViewSettings.drawDestSearch && Find.CurrentMap == pawn.Map)
                            {
                                Find.CurrentMap.debugDrawer.FlashCell(randomCell, 1f, "trash bld", 50);
                            }
                            Job job;

                            Building building = edifice as Building;
                            bool     flagb    = building != null && building.def.building.isInert;
                            if (flagb)
                            {
                                return(null);
                            }
                            job = new Job(JobDefOf.AttackMelee, edifice);
                            if (job != null)
                            {
                                return(job);
                            }
                        }
                    }
                    if (DebugViewSettings.drawDestSearch && Find.CurrentMap == pawn.Map)
                    {
                        Find.CurrentMap.debugDrawer.FlashCell(randomCell, 0f, "trash no", 50);
                    }
                }
            }
            return(null);
        }
Esempio n. 6
0
 public static bool ShouldTrashPlant(Pawn pawn, Plant p)
 {
     if (!p.sown || p.def.plant.IsTree || !p.FlammableNow || !TrashUtility.CanTrash(pawn, p))
     {
         return(false);
     }
     CellRect.CellRectIterator iterator = CellRect.CenteredOn(p.Position, 2).ClipInsideMap(p.Map).GetIterator();
     while (!iterator.Done())
     {
         IntVec3 current = iterator.Current;
         if (current.InBounds(p.Map) && current.ContainsStaticFire(p.Map))
         {
             return(false);
         }
         iterator.MoveNext();
     }
     return(p.Position.Roofed(p.Map) || p.Map.weatherManager.RainRate <= 0.25f);
 }
Esempio n. 7
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            List <Building> allBuildingsColonist = pawn.Map.listerBuildings.allBuildingsColonist;

            if (allBuildingsColonist.Count == 0)
            {
                return(null);
            }
            for (int i = 0; i < 75; i++)
            {
                Building building = allBuildingsColonist.RandomElement <Building>();
                if (TrashUtility.ShouldTrashBuilding(pawn, building, this.attackAllInert))
                {
                    return(TrashUtility.TrashJob(pawn, building));
                }
            }
            return(null);
        }
Esempio n. 8
0
        public static Job TrashJob(Pawn pawn, Thing t, bool allowPunchingInert = false)
        {
            Plant plant = t as Plant;

            if (plant != null)
            {
                Job job = new Job(JobDefOf.Ignite, t);
                TrashUtility.FinalizeTrashJob(job);
                return(job);
            }
            if (pawn.equipment != null && Rand.Value < 0.7f)
            {
                foreach (Verb current in pawn.equipment.AllEquipmentVerbs)
                {
                    if (current.verbProps.ai_IsBuildingDestroyer)
                    {
                        Job job2 = new Job(JobDefOf.UseVerbOnThing, t);
                        job2.verbToUse = current;
                        TrashUtility.FinalizeTrashJob(job2);
                        return(job2);
                    }
                }
            }
            float value = Rand.Value;
            Job   job3;

            if (value < 0.35f && pawn.natives.IgniteVerb != null && pawn.natives.IgniteVerb.IsStillUsableBy(pawn) && t.FlammableNow && !t.IsBurning() && !(t is Building_Door))
            {
                job3 = new Job(JobDefOf.Ignite, t);
            }
            else
            {
                Building building = t as Building;
                bool     flag     = building != null && building.def.building.isInert;
                if (flag && !allowPunchingInert)
                {
                    return(null);
                }
                job3 = new Job(JobDefOf.AttackMelee, t);
            }
            TrashUtility.FinalizeTrashJob(job3);
            return(job3);
        }
Esempio n. 9
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (pawn.mindState.duty == null || !pawn.mindState.duty.focus.IsValid)
            {
                return(null);
            }
            LocalTargetInfo focus = pawn.mindState.duty.focus;

            if (focus.ThingDestroyed || !pawn.HostileTo(focus.Thing) || !pawn.CanReach(focus, PathEndMode.Touch, Danger.Deadly))
            {
                return(null);
            }
            Job job = TrashUtility.TrashJob_NewTemp(pawn, focus.Thing, allowPunchingInert: false, killIncappedTarget: true);

            if (job != null)
            {
                return(job);
            }
            return(null);
        }
Esempio n. 10
0
        public static Job TrashJob(Pawn pawn, Thing t)
        {
            Plant plant = t as Plant;
            Job   result;

            if (plant != null)
            {
                Job job = new Job(JobDefOf.Ignite, t);
                TrashUtility.FinalizeTrashJob(job);
                result = job;
            }
            else
            {
                if (pawn.equipment != null && Rand.Value < 0.7f)
                {
                    foreach (Verb verb in pawn.equipment.AllEquipmentVerbs)
                    {
                        if (verb.verbProps.ai_IsBuildingDestroyer)
                        {
                            Job job2 = new Job(JobDefOf.UseVerbOnThing, t);
                            job2.verbToUse = verb;
                            TrashUtility.FinalizeTrashJob(job2);
                            return(job2);
                        }
                    }
                }
                float value = Rand.Value;
                Job   job3;
                if (value < 0.35f && pawn.natives.IgniteVerb != null && pawn.natives.IgniteVerb.IsStillUsableBy(pawn) && t.FlammableNow && !t.IsBurning() && !(t is Building_Door))
                {
                    job3 = new Job(JobDefOf.Ignite, t);
                }
                else
                {
                    job3 = new Job(JobDefOf.AttackMelee, t);
                }
                TrashUtility.FinalizeTrashJob(job3);
                result = job3;
            }
            return(result);
        }