public override void Tick()
        {
            base.Tick();

            if ((this.Severity < 1) && (tickerInterval >= 18))
            {
                //GenExplosion.DoExplosion(this.pawn.Position, this.pawn.Map, 5f, DamageDefOf.Smoke, this.pawn, -1, null, null, null, ThingDefOf.Gas_Smoke, 1f, 1, false, null, 0f, 1, 0f, false);

                List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized();
                for (int i = 0; i < 8; i++)
                {
                    IntVec3 c2 = this.pawn.Position + list[i];
                    if (c2.InBounds(pawn.Map))
                    {
                        Thing thing = ThingMaker.MakeThing(ThingDef.Named("GR_Gas_Dust"), null);

                        GenSpawn.Spawn(thing, c2, pawn.Map);
                    }
                }



                tickerInterval = 0;
            }
            tickerInterval++;
        }
        static private IntVec3 FindSpawnPosition(Thing spawningThing)
        {
            if (Prefs.DevMode && MeeseeksMod.settings.screenShotDebug)
            {
                return(spawningThing.Position + new IntVec3(-1, 0, 0));
            }

            IntVec3        spawnPosition = spawningThing.Position;
            List <IntVec3> randomOffsets = GenAdj.AdjacentCells8WayRandomized();

            foreach (IntVec3 randomOffset in randomOffsets)
            {
                spawnPosition = spawningThing.Position + randomOffset;
                if (spawnPosition.InBounds(spawningThing.Map) && spawnPosition.Walkable(spawningThing.Map))
                {
                    Building_Door building_Door = spawnPosition.GetEdifice(spawningThing.Map) as Building_Door;
                    // TODO: Could anything other than a pawn summon a meeseeks this way? If so, change this function to use Pawn
                    if (building_Door == null)// || building_Door.CanPhysicallyPass(caster))
                    {
                        return(spawnPosition);
                    }
                }
            }

            return(spawningThing.Position);
        }
        public override Job JobOnCell(Pawn pawn, IntVec3 c, bool forced = false)
        {
            var job = base.JobOnCell(pawn, c, forced);

            // plant has seeds, if there is a seed return a job, otherwise prevent it. Seeds with no category are forbidden.
            var seed = job?.plantDefToSow?.blueprintDef;

            if (seed != null && !seed.thingCategories.NullOrEmpty())
            {
                // Clear the area some...
                var zone = c.GetZone(pawn.Map);
                if (zone != null)
                {
                    foreach (var corner in GenAdj.AdjacentCells8WayRandomized())
                    {
                        var cell = c + corner;
                        if (zone.ContainsCell(cell))
                        {
                            foreach (var thing in pawn.Map.thingGrid.ThingsAt(cell))
                            {
                                if (thing.def != job.plantDefToSow && thing.def.BlocksPlanting(true) && pawn.CanReserve(thing) && !thing.IsForbidden(pawn))
                                {
                                    if (thing.def.category == ThingCategory.Plant)
                                    {
                                        return(new Job(JobDefOf.CutPlant, thing));
                                    }
                                    if (thing.def.EverHaulable)
                                    {
                                        return(HaulAIUtility.HaulAsideJobFor(pawn, thing));
                                    }
                                }
                            }
                        }
                    }
                }

                Predicate <Thing> predicate = (Thing tempThing) =>
                                              !ForbidUtility.IsForbidden(tempThing, pawn.Faction) &&
                                              ForbidUtility.InAllowedArea(tempThing.Position, pawn) &&
                                              PawnLocalAwareness.AnimalAwareOf(pawn, tempThing) &&
                                              ReservationUtility.CanReserve(pawn, tempThing, 1);

                Thing bestSeedThingForSowing = GenClosest.ClosestThingReachable(
                    c, pawn.Map, ThingRequest.ForDef(job.plantDefToSow.blueprintDef),
                    PathEndMode.ClosestTouch, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 9999,
                    predicate);

                if (bestSeedThingForSowing != null)
                {
                    return(new Job(ResourceBank.JobDefOf.SowWithSeeds, c, bestSeedThingForSowing)
                    {
                        plantDefToSow = job.plantDefToSow,
                        count = SEEDS_TO_CARRY
                    });
                }
                return(null);
            }

            return(job);
        }
        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);
        }
Esempio n. 5
0
        private static bool MakeFilth(IntVec3 c, Map map, ThingDef filthDef, IEnumerable <string> sources, bool shouldPropagate)
        {
            Filth filth = (Filth)(from t in c.GetThingList(map)
                                  where t.def == filthDef
                                  select t).FirstOrDefault <Thing>();
            bool result;

            if (!c.Walkable(map) || (filth != null && !filth.CanBeThickened))
            {
                if (shouldPropagate)
                {
                    List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized();
                    for (int i = 0; i < 8; i++)
                    {
                        IntVec3 c2 = c + list[i];
                        if (c2.InBounds(map))
                        {
                            if (FilthMaker.MakeFilth(c2, map, filthDef, sources, false))
                            {
                                return(true);
                            }
                        }
                    }
                }
                if (filth != null)
                {
                    filth.AddSources(sources);
                }
                result = false;
            }
            else
            {
                if (filth != null)
                {
                    filth.ThickenFilth();
                    filth.AddSources(sources);
                }
                else
                {
                    Filth filth2 = (Filth)ThingMaker.MakeThing(filthDef, null);
                    filth2.AddSources(sources);
                    GenSpawn.Spawn(filth2, c, map, WipeMode.Vanish);
                }
                FilthMonitor.Notify_FilthSpawned();
                result = true;
            }
            return(result);
        }
Esempio n. 6
0
        // Token: 0x06004C58 RID: 19544 RVA: 0x001987D8 File Offset: 0x001969D8
        private static bool TryMakeFilth(IntVec3 c, Map map, ThingDef filthDef, IEnumerable <string> sources, bool shouldPropagate, FilthSourceFlags additionalFlags = FilthSourceFlags.None)
        {
            Filth filth = (Filth)(from t in c.GetThingList(map)
                                  where t.def == filthDef
                                  select t).FirstOrDefault <Thing>();

            if (!c.Walkable(map) || (filth != null && !filth.CanBeThickened))
            {
                if (shouldPropagate)
                {
                    List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized();
                    for (int i = 0; i < 8; i++)
                    {
                        IntVec3 c2 = c + list[i];
                        if (c2.InBounds(map) && AvP_Pawn_HealthTracker_DropBloodFilth_Xenoblood_Patch.TryMakeFilth(c2, map, filthDef, sources, false, FilthSourceFlags.None))
                        {
                            return(true);
                        }
                    }
                }
                if (filth != null)
                {
                    filth.AddSources(sources);
                }
                return(false);
            }
            if (filth != null)
            {
                filth.ThickenFilth();
                filth.AddSources(sources);
            }
            else
            {
                if (!FilthMaker.CanMakeFilth(c, map, filthDef, additionalFlags))
                {
                    return(false);
                }
                Filth filth2 = (Filth)ThingMaker.MakeThing(filthDef, null);
                filth2.AddSources(sources);
                Filth_AddAcidDamage filth_ = filth2 as Filth_AddAcidDamage;
                filth_.destroyTick = 600;
                GenSpawn.Spawn(filth2, c, map, WipeMode.Vanish);
            }
            //	FilthMonitor.Notify_FilthSpawned();
            return(true);
        }
        public static bool TryMakeFilth(IntVec3 c, Map map, ThingDef filthDef, IEnumerable <string> sources, Color color, bool shouldPropagate, FilthSourceFlags additionalFlags = FilthSourceFlags.None)
        {
            Filth_Colored filth = (Filth_Colored)(from t in c.GetThingList(map)
                                                  where t.def == filthDef
                                                  select t).FirstOrDefault <Thing>();

            if (!c.Walkable(map) || (filth != null && !filth.CanBeThickened))
            {
                if (shouldPropagate)
                {
                    List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized();
                    for (int i = 0; i < 8; i++)
                    {
                        IntVec3 c2 = c + list[i];
                        if (c2.InBounds(map) && TryMakeFilth(c2, map, filthDef, sources, color, false, FilthSourceFlags.None))
                        {
                            return(true);
                        }
                    }
                }
                if (filth != null)
                {
                    filth.AddSources(sources);
                }
                return(false);
            }
            if (filth != null)
            {
                filth.ThickenFilth();
                filth.AddSources(sources);
            }
            else
            {
                if (!FilthMaker.CanMakeFilth(c, map, filthDef, additionalFlags))
                {
                    return(false);
                }
                Filth_Colored filth2 = (Filth_Colored)ThingMaker.MakeThing(filthDef, null);
                filth2.DrawColor = color;
                filth2.AddSources(sources);
                GenSpawn.Spawn(filth2, c, map, WipeMode.Vanish);
            }
            //FilthMonitor.Notify_FilthSpawned();
            return(true);
        }
Esempio n. 8
0
        private static bool TryMakeFilth(IntVec3 c, Map map, ThingDef filthDef, IEnumerable <string> sources, bool shouldPropagate, FilthSourceFlags additionalFlags = FilthSourceFlags.None)
        {
            Filth filth = (Filth)(from t in c.GetThingList(map)
                                  where t.def == filthDef
                                  select t).FirstOrDefault();

            if (!c.Walkable(map) || (filth != null && !filth.CanBeThickened))
            {
                if (shouldPropagate)
                {
                    List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized();
                    for (int i = 0; i < 8; i++)
                    {
                        IntVec3 c2 = c + list[i];
                        if (c2.InBounds(map) && TryMakeFilth(c2, map, filthDef, sources, shouldPropagate: false))
                        {
                            return(true);
                        }
                    }
                }
                filth?.AddSources(sources);
                return(false);
            }
            if (filth != null)
            {
                filth.ThickenFilth();
                filth.AddSources(sources);
            }
            else
            {
                if (!CanMakeFilth(c, map, filthDef, additionalFlags))
                {
                    return(false);
                }
                Filth obj = (Filth)ThingMaker.MakeThing(filthDef);
                obj.AddSources(sources);
                GenSpawn.Spawn(obj, c, map);
            }
            FilthMonitor.Notify_FilthSpawned();
            return(true);
        }
        private static bool MakeFilth(IntVec3 c, Map map, ThingDef filthDef, IEnumerable <string> sources, bool shouldPropagate)
        {
            Filth filth = (Filth)(from t in c.GetThingList(map)
                                  where t.def == filthDef
                                  select t).FirstOrDefault();

            if (c.Walkable(map) && (filth == null || filth.CanBeThickened))
            {
                if (filth != null)
                {
                    filth.ThickenFilth();
                    filth.AddSources(sources);
                }
                else
                {
                    Filth filth2 = (Filth)ThingMaker.MakeThing(filthDef, null);
                    filth2.AddSources(sources);
                    GenSpawn.Spawn(filth2, c, map);
                }
                return(true);
            }
            if (shouldPropagate)
            {
                List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized();
                for (int i = 0; i < 8; i++)
                {
                    IntVec3 c2 = c + list[i];
                    if (c2.InBounds(map) && FilthMaker.MakeFilth(c2, map, filthDef, sources, false))
                    {
                        return(true);
                    }
                }
            }
            if (filth != null)
            {
                filth.AddSources(sources);
            }
            return(false);
        }
        public override void Tick()
        {
            base.Tick();

            if ((this.Severity < 1) && (tickerInterval >= 18))
            {
                List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized();
                for (int i = 0; i < 8; i++)
                {
                    IntVec3 c2 = this.pawn.Position + list[i];
                    if (c2.InBounds(pawn.Map))
                    {
                        Thing thing = ThingMaker.MakeThing(InternalDefOf.GR_Gas_Dust, null);
                        GenSpawn.Spawn(thing, c2, pawn.Map);
                    }
                }



                tickerInterval = 0;
            }
            tickerInterval++;
        }
Esempio n. 11
0
        protected override bool TryCastShot()
        {
            bool flag10 = false;

            this.TargetsAoE.Clear();
            this.UpdateTargets();
            int  shotsPerBurst = this.ShotsPerBurst;
            bool flag2         = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1;

            if (flag2)
            {
                this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1);
            }
            for (int i = 0; i < this.TargetsAoE.Count; i++)
            {
                bool?flag3    = this.TryLaunchProjectile(this.verbProps.defaultProjectile, this.TargetsAoE[i]);
                bool hasValue = flag3.HasValue;
                if (hasValue)
                {
                    bool flag4 = flag3 == true;
                    if (flag4)
                    {
                        flag10 = true;
                    }
                    bool flag5 = flag3 == false;
                    if (flag5)
                    {
                        flag10 = false;
                    }
                }
            }

            CellRect cellRect = CellRect.CenteredOn(base.CasterPawn.Position, 1);
            Map      map      = base.CasterPawn.Map;

            cellRect.ClipInsideMap(map);

            IntVec3 centerCell        = cellRect.CenterCell;
            CompAbilityUserMight comp = this.CasterPawn.GetComp <CompAbilityUserMight>();

            pwr = comp.MightData.MightPowerSkill_Cleave.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Cleave_pwr");
            str = comp.MightData.MightPowerSkill_global_strength.FirstOrDefault((MightPowerSkill x) => x.label == "TM_global_strength_pwr");
            ver = comp.MightData.MightPowerSkill_Cleave.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Cleave_ver");
            int dmgNum = 0;

            if (this.CasterPawn.equipment.Primary != null && !this.CasterPawn.equipment.Primary.def.IsRangedWeapon)
            {
                weaponComp      = base.CasterPawn.equipment.Primary;
                weaponDPS       = weaponComp.GetStatValue(StatDefOf.MeleeWeapon_AverageDPS, false) * .7f;
                dmgMultiplier   = weaponComp.GetStatValue(StatDefOf.MeleeWeapon_DamageMultiplier, false);
                pawnDPS         = base.CasterPawn.GetStatValue(StatDefOf.MeleeDPS, false);
                skillMultiplier = (1.2f + (.025f * str.level));
                dmgNum          = Mathf.RoundToInt(skillMultiplier * dmgMultiplier * (pawnDPS + weaponDPS));
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                if (!this.CasterPawn.IsColonist && settingsRef.AIHardMode)
                {
                    dmgNum += 10;
                }
            }
            else
            {
                dmgNum = 4;
            }

            for (int i = 0; i < 8; i++)
            {
                IntVec3 searchCell = base.CasterPawn.Position + GenAdj.AdjacentCells8WayRandomized()[i];
                Pawn    victim     = searchCell.GetFirstPawn(map);
                if (victim != null && base.CasterPawn != null & dmgNum != 0 && victim.Faction != base.CasterPawn.Faction)
                {
                    dinfo = new DamageInfo(TMDamageDefOf.DamageDefOf.TM_Cleave, dmgNum, 0, (float)-1, this.CasterPawn, null, null, DamageInfo.SourceCategory.ThingOrUnknown);
                    ApplyCleaveDamage(dinfo, this.CasterPawn, victim, map, ver.level);
                    DrawCleaving(victim, base.CasterPawn, 10);
                    i = 8;
                }
            }

            this.burstShotsLeft = 0;
            this.PostCastShot(flag10, out flag10);
            return(flag10);
        }
Esempio n. 12
0
        protected override bool TryCastShot()
        {
            CompAbilityUserMight comp     = this.CasterPawn.GetComp <CompAbilityUserMight>();
            MightPowerSkill      ver      = comp.MightData.MightPowerSkill_SeismicSlash.FirstOrDefault((MightPowerSkill x) => x.label == "TM_SeismicSlash_ver");
            CellRect             cellRect = CellRect.CenteredOn(base.CasterPawn.Position, 1);
            Map map = base.CasterPawn.Map;

            cellRect.ClipInsideMap(map);

            IntVec3 centerCell = cellRect.CenterCell;

            this.origin        = base.CasterPawn.Position.ToVector3();
            this.destination   = this.currentTarget.Cell.ToVector3Shifted();
            this.ticksToImpact = Mathf.RoundToInt((this.origin - this.destination).magnitude);

            if (this.CasterPawn.equipment.Primary != null && !this.CasterPawn.equipment.Primary.def.IsRangedWeapon)
            {
                int dmgNum = GetWeaponDmg(this.CasterPawn);
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                if (!this.CasterPawn.IsColonist && settingsRef.AIHardMode)
                {
                    dmgNum += 10;
                }

                Vector3 strikeVec = this.origin;
                DrawBlade(strikeVec, 0);
                for (int i = 0; i < this.StartingTicksToImpact; i++)
                {
                    strikeVec = this.ExactPosition;
                    Pawn victim = strikeVec.ToIntVec3().GetFirstPawn(map);
                    if (victim != null && victim.Faction != base.CasterPawn.Faction)
                    {
                        DrawStrike(strikeVec.ToIntVec3(), strikeVec, map);
                        damageEntities(victim, null, dmgNum, DamageDefOf.Cut);
                    }
                    MoteMaker.ThrowTornadoDustPuff(strikeVec, map, .6f, Color.white);
                    for (int j = 0; j < 2 + (2 * verVal); j++)
                    {
                        IntVec3 searchCell = strikeVec.ToIntVec3() + GenAdj.AdjacentCells8WayRandomized()[j];
                        MoteMaker.ThrowTornadoDustPuff(searchCell.ToVector3(), map, .1f, Color.gray);
                        victim = searchCell.GetFirstPawn(map);
                        if (victim != null && victim.Faction != base.CasterPawn.Faction)
                        {
                            DrawStrike(searchCell, searchCell.ToVector3(), map);
                            damageEntities(victim, null, dmgNum, DamageDefOf.Cut);
                        }
                    }
                    this.ticksToImpact--;
                }
            }
            else
            {
                Messages.Message("MustHaveMeleeWeapon".Translate(new object[]
                {
                    this.CasterPawn.LabelCap
                }), MessageTypeDefOf.RejectInput);
                return(false);
            }

            this.burstShotsLeft = 0;
            this.PostCastShot(flag10, out flag10);
            return(flag10);
        }
Esempio n. 13
0
        protected override bool TryCastShot()
        {
            CompAbilityUserMight comp = this.CasterPawn.GetComp <CompAbilityUserMight>();
            MightPowerSkill      ver  = comp.MightData.MightPowerSkill_SeismicSlash.FirstOrDefault((MightPowerSkill x) => x.label == "TM_SeismicSlash_ver");

            pwrVal = TM_Calc.GetMightSkillLevel(this.CasterPawn, comp.MightData.MightPowerSkill_SeismicSlash, "TM_SeismicSlash", "_pwr", true);
            CellRect cellRect = CellRect.CenteredOn(base.CasterPawn.Position, 1);
            Map      map      = base.CasterPawn.Map;

            cellRect.ClipInsideMap(map);

            IntVec3 centerCell = cellRect.CenterCell;

            this.origin        = base.CasterPawn.Position.ToVector3();
            this.destination   = this.currentTarget.Cell.ToVector3Shifted();
            this.ticksToImpact = Mathf.RoundToInt((this.origin - this.destination).magnitude);

            if (this.CasterPawn.equipment.Primary != null && !this.CasterPawn.equipment.Primary.def.IsRangedWeapon)
            {
                TMAbilityDef           ad          = (TMAbilityDef)this.Ability.Def;
                int                    dmgNum      = Mathf.RoundToInt(comp.weaponDamage * ad.weaponDamageFactor * (1 + (.1f * pwrVal)));
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                if (!this.CasterPawn.IsColonist && settingsRef.AIHardMode)
                {
                    dmgNum += 10;
                }

                Vector3 strikeVec = this.origin;
                DrawBlade(strikeVec, 0);
                for (int i = 0; i < this.StartingTicksToImpact; i++)
                {
                    strikeVec = this.ExactPosition;
                    Pawn victim = strikeVec.ToIntVec3().GetFirstPawn(map);
                    if (victim != null && victim.Faction != base.CasterPawn.Faction)
                    {
                        DrawStrike(strikeVec.ToIntVec3(), strikeVec, map);
                        damageEntities(victim, null, dmgNum, DamageDefOf.Cut);
                    }
                    float angle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.CasterPawn.DrawPos, this.currentTarget.CenterVector3)).ToAngleFlat();
                    TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_DirectionalDirt"), strikeVec, this.CasterPawn.Map, .3f + (.08f * i), .05f, .15f, .38f, 0, 5f - (.2f * i), angle, angle);
                    if (i == 2)
                    {
                        TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Cleave"), strikeVec, this.CasterPawn.Map, .6f + (.05f * i), .05f, .04f + (.03f * i), .15f, -10000, 30, angle, angle);
                    }
                    //MoteMaker.ThrowTornadoDustPuff(strikeVec, map, .6f, Color.white);
                    for (int j = 0; j < 2 + (2 * verVal); j++)
                    {
                        IntVec3 searchCell = strikeVec.ToIntVec3() + GenAdj.AdjacentCells8WayRandomized()[j];
                        TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_DirectionalDirt"), searchCell.ToVector3Shifted(), this.CasterPawn.Map, .1f + (.04f * i), .05f, .04f, .28f, 0, 4f - (.2f * i), angle, angle);
                        //MoteMaker.ThrowTornadoDustPuff(searchCell.ToVector3(), map, .4f, Color.gray);
                        victim = searchCell.GetFirstPawn(map);
                        if (victim != null && victim.Faction != base.CasterPawn.Faction)
                        {
                            DrawStrike(searchCell, searchCell.ToVector3(), map);
                            damageEntities(victim, null, dmgNum, DamageDefOf.Cut);
                        }
                    }
                    this.ticksToImpact--;
                }
            }
            else
            {
                Messages.Message("MustHaveMeleeWeapon".Translate(
                                     this.CasterPawn.LabelCap
                                     ), MessageTypeDefOf.RejectInput);
                return(false);
            }

            this.burstShotsLeft = 0;
            this.PostCastShot(flag10, out flag10);
            return(flag10);
        }
Esempio n. 14
0
        public static void AddGizmo(Pawn __instance, ref IEnumerable <Gizmo> __result)
        {
            //I want access to the pawn object, and want to modify the original method's result
            var pawn   = __instance;
            var gizmos = __result.ToList();
            // First two flags detect if the pawn is mine, and if it is

            bool flagIsCreatureMine      = pawn.Faction != null && pawn.Faction.IsPlayer;
            bool flagIsCreatureDraftable = (pawn.TryGetComp <CompDraftable>() != null);

            /* I check these flags only inside flagIsCreatureDraftable true to avoid errors due to pawn.TryGetComp<CompDraftable>() being null in most pawns. The code inside
             * the conditional only executes if it isn't*/
            bool flagIsCreatureRageable         = false;
            bool flagIsCreatureExplodable       = false;
            bool flagIsCreatureChickenRimPox    = false;
            bool flagCanCreatureCarryMore       = false;
            bool flagCanCreatureAdrenalineBurst = false;
            bool flagCanCanDoInsectClouds       = false;
            bool flagCanStampede         = false;
            bool flagCanDoPoisonousCloud = false;
            bool flagCanBurrow           = false;
            bool flagCanStamina          = false;
            bool flagCanHorrorize        = false;
            bool flagCanMechaBlast       = false;
            bool flagCanKeenSenses       = false;
            bool flagCanCatReflexes      = false;



            bool flagIsMindControlBuildingPresent = false;

            if (flagIsCreatureDraftable)
            {
                /*Inside here, I check if the Building is present in the map. I only want to do the check for
                 * hybrids, or it will do this iterator for every creature in the map
                 */
                foreach (Thing t in pawn.Map.listerThings.ThingsOfDef(ThingDef.Named("GR_AnimalControlHub")))
                {
                    Thing mindcontrolhub = t as Thing;
                    if (t != null)
                    {
                        flagIsCreatureRageable         = pawn.TryGetComp <CompDraftable>().GetRage;
                        flagIsCreatureExplodable       = pawn.TryGetComp <CompDraftable>().GetExplodable;
                        flagIsCreatureChickenRimPox    = pawn.TryGetComp <CompDraftable>().GetChickenRimPox;
                        flagCanCreatureCarryMore       = pawn.TryGetComp <CompDraftable>().GetCanCarryMore;
                        flagCanCreatureAdrenalineBurst = pawn.TryGetComp <CompDraftable>().GetAdrenalineBurst;
                        flagCanCanDoInsectClouds       = pawn.TryGetComp <CompDraftable>().GetCanDoInsectClouds;
                        flagCanStampede         = pawn.TryGetComp <CompDraftable>().GetCanStampede;
                        flagCanDoPoisonousCloud = pawn.TryGetComp <CompDraftable>().GetCanDoPoisonousCloud;
                        flagCanBurrow           = pawn.TryGetComp <CompDraftable>().GetCanBurrow;
                        flagCanStamina          = pawn.TryGetComp <CompDraftable>().HasDinoStamina;
                        flagCanHorrorize        = pawn.TryGetComp <CompDraftable>().GetHorror;
                        flagCanMechaBlast       = pawn.TryGetComp <CompDraftable>().GetMechablast;
                        flagCanKeenSenses       = pawn.TryGetComp <CompDraftable>().GetKeenSenses;
                        flagCanCatReflexes      = pawn.TryGetComp <CompDraftable>().GetCatReflexes;


                        flagIsMindControlBuildingPresent = true;
                    }
                }
            }


            /*Is the creature part of the colony, and draftable (the custom comp class)? Then display the drafting gizmo, called
             * Mind Control. It's action is just calling on toggle the Drafted method in the pawn's drafter, which
             * we initialized in the first Harmony Postfix
             */
            if ((pawn.drafter != null) && flagIsCreatureMine && flagIsCreatureDraftable && flagIsMindControlBuildingPresent || pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Action GR_Gizmo_MindControl = new Command_Action();
                GR_Gizmo_MindControl.action = delegate
                {
                    pawn.drafter.Drafted = !pawn.drafter.Drafted;
                };
                GR_Gizmo_MindControl.defaultLabel = "GR_CreatureMindControl".Translate();
                GR_Gizmo_MindControl.defaultDesc  = "GR_CreatureMindControlDesc".Translate();
                GR_Gizmo_MindControl.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_ControlAnimal", true);

                gizmos.Insert(0, GR_Gizmo_MindControl);
            }

            /*If the creature is draftable, drafted at the moment and the rage property (which is passed through XML and the custom comp class) is true,
             * we add a second gizmo, which copies the code from melee attacks, and thus allows targeting melee attacks
             */
            if ((pawn.drafter != null) && flagIsCreatureRageable && flagIsCreatureMine && pawn.drafter.Drafted && flagIsMindControlBuildingPresent)
            {
                Command_Target GR_Gizmo_AttackRage = new Command_Target();
                GR_Gizmo_AttackRage.defaultLabel    = "GR_CreatureRageAttack".Translate();
                GR_Gizmo_AttackRage.defaultDesc     = "GR_CreatureRageAttackDesc".Translate();
                GR_Gizmo_AttackRage.targetingParams = TargetingParameters.ForAttackAny();
                GR_Gizmo_AttackRage.icon            = ContentFinder <Texture2D> .Get("Things/Item/AnimalPaws", true);

                GR_Gizmo_AttackRage.action = delegate(Thing target)
                {
                    IEnumerable <Pawn> enumerable = Find.Selector.SelectedObjects.Where(delegate(object x)
                    {
                        Pawn pawn2 = x as Pawn;
                        return(pawn2 != null && pawn2.Drafted);
                    }).Cast <Pawn>();
                    foreach (Pawn current in enumerable)
                    {
                        Job  job   = new Job(JobDefOf.AttackMelee, target);
                        Pawn pawn2 = target as Pawn;
                        if (pawn2 != null)
                        {
                            job.killIncappedTarget = pawn2.Downed;
                        }
                        pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_AttackRage);
            }

            /*This adds a gizmo that makes the creature attack once, and then cause a Hediff disease (GR_ChickenRimPox), then cancels the draft. I used a custom Jobdriver class for that
             */
            if ((pawn.drafter != null) && flagIsCreatureChickenRimPox && flagIsCreatureMine && pawn.drafter.Drafted && flagIsMindControlBuildingPresent || pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Target GR_Gizmo_AttackPox = new Command_Target();
                GR_Gizmo_AttackPox.defaultLabel    = "GR_InflictChickenRimPox".Translate();
                GR_Gizmo_AttackPox.defaultDesc     = "GR_InflictChickenRimPoxDesc".Translate();
                GR_Gizmo_AttackPox.targetingParams = TargetingParameters.ForAttackAny();
                GR_Gizmo_AttackPox.icon            = ContentFinder <Texture2D> .Get("ui/commands/GR_ChickenRimPox", true);

                GR_Gizmo_AttackPox.action = delegate(Thing target)
                {
                    IEnumerable <Pawn> enumerable = Find.Selector.SelectedObjects.Where(delegate(object x)
                    {
                        Pawn pawn2 = x as Pawn;
                        return(pawn2 != null && pawn2.Drafted);
                    }).Cast <Pawn>();
                    foreach (Pawn current in enumerable)
                    {
                        Job  job   = new Job(DefDatabase <JobDef> .GetNamed("GR_AttackMeleeOnceAndChickenRimPox", true), target);
                        Pawn pawn2 = target as Pawn;
                        if (pawn2 != null)
                        {
                            job.killIncappedTarget = pawn2.Downed;
                        }
                        pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_AttackPox);
            }

            /*If the creature is explodable, we add this gizmo, which causes a Heddif called "sudden explosion" (GR_Kamikaze), and increases severity to
             * 1 to make the creature die. This only works if the creature also has DeathActionWorker.
             */
            if ((pawn.drafter != null) && flagIsCreatureExplodable && flagIsCreatureMine && flagIsMindControlBuildingPresent)
            {
                Command_Action GR_Gizmo_Detonate = new Command_Action();
                GR_Gizmo_Detonate.action = delegate
                {
                    pawn.health.AddHediff(HediffDef.Named("GR_Kamikaze"));
                    HealthUtility.AdjustSeverity(pawn, HediffDef.Named("GR_Kamikaze"), 1);
                };
                GR_Gizmo_Detonate.defaultLabel = "GR_DetonateChemfuel".Translate();
                GR_Gizmo_Detonate.defaultDesc  = "GR_DetonateChemfuelDesc".Translate();
                GR_Gizmo_Detonate.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Detonate", true);

                gizmos.Insert(1, GR_Gizmo_Detonate);
            }

            /* This is a dummy gizmo. It only displays, but does nothing on click. The processing is done below in another Harmony patch to MassUtility.Capacity
             */
            if ((pawn.drafter != null) && flagCanCreatureCarryMore && flagIsCreatureMine && flagIsMindControlBuildingPresent)
            {
                Command_Action GR_Gizmo_Carry = new Command_Action();
                GR_Gizmo_Carry.action = delegate
                {
                };
                GR_Gizmo_Carry.defaultLabel = "GR_CarryMore".Translate();
                GR_Gizmo_Carry.defaultDesc  = "GR_CarryMoreDesc".Translate();
                GR_Gizmo_Carry.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_IncreasedCarry", true);

                gizmos.Insert(1, GR_Gizmo_Carry);
            }

            /*This gizmo applies a Hediff that makes the pawn move faster for a while
             */
            if ((pawn.drafter != null) && flagCanCreatureAdrenalineBurst && flagIsCreatureMine && flagIsMindControlBuildingPresent || pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Action GR_Gizmo_AdrenalineBurst = new Command_Action();
                GR_Gizmo_AdrenalineBurst.defaultLabel = "GR_StartAdrenalineBurst".Translate();
                GR_Gizmo_AdrenalineBurst.defaultDesc  = "GR_StartAdrenalineBurstDesc".Translate();
                GR_Gizmo_AdrenalineBurst.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_AdrenalineBurst", true);

                GR_Gizmo_AdrenalineBurst.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_AdrenalineBurst")))
                    {
                        pawn.health.AddHediff(HediffDef.Named("GR_AdrenalineBurst"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_AdrenalineBurst);
            }

            /*This gizmo applies a Hediff that makes the pawn release insect clouds for a while
             */
            if ((pawn.drafter != null) && flagCanCanDoInsectClouds && flagIsCreatureMine && flagIsMindControlBuildingPresent)
            {
                Command_Action GR_Gizmo_InsectClouds = new Command_Action();
                GR_Gizmo_InsectClouds.defaultLabel = "GR_ReleaseInsectClouds".Translate();
                GR_Gizmo_InsectClouds.defaultDesc  = "GR_ReleaseInsectCloudsDesc".Translate();
                GR_Gizmo_InsectClouds.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_Insectclouds", true);

                GR_Gizmo_InsectClouds.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_InsectClouds")))

                    {
                        pawn.health.AddHediff(HediffDef.Named("GR_InsectClouds"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_InsectClouds);
            }

            /*This gizmo applies a Hediff that makes the pawn generate stampede clouds for a while
             */
            if ((pawn.drafter != null) && flagCanStampede && flagIsCreatureMine && flagIsMindControlBuildingPresent || pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Action GR_Gizmo_Stampede = new Command_Action();
                GR_Gizmo_Stampede.defaultLabel = "GR_StartStampede".Translate();
                GR_Gizmo_Stampede.defaultDesc  = "GR_StartStampedeDesc".Translate();
                GR_Gizmo_Stampede.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_StampedeClouds", true);

                GR_Gizmo_Stampede.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_Stampeding")))
                    {
                        pawn.health.AddHediff(HediffDef.Named("GR_Stampeding"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_Stampede);
            }

            /*This gizmo adds an attack that spawns a poison cloud at a target's location
             */
            if ((pawn.drafter != null) && flagCanDoPoisonousCloud && flagIsCreatureMine && flagIsMindControlBuildingPresent)
            {
                Command_Target GR_Gizmo_PoisonCloud = new Command_Target();
                GR_Gizmo_PoisonCloud.defaultLabel    = "GR_CreatePoisonousCloud".Translate();
                GR_Gizmo_PoisonCloud.defaultDesc     = "GR_CreatePoisonousCloudDesc".Translate();
                GR_Gizmo_PoisonCloud.targetingParams = TargetingParameters.ForAttackAny();
                GR_Gizmo_PoisonCloud.icon            = ContentFinder <Texture2D> .Get("ui/commands/GR_PoisonousCloud", true);

                GR_Gizmo_PoisonCloud.action = delegate(Thing target)
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_CausedPoisonCloud")))
                    {
                        Pawn pawn2 = target as Pawn;
                        if (pawn2 != null)
                        {
                            if (pawn.Position.InHorDistOf(pawn2.Position, 10))
                            {
                                List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized();
                                for (int i = 0; i < 8; i++)
                                {
                                    IntVec3 c2 = pawn2.Position + list[i];
                                    if (c2.InBounds(pawn2.Map))
                                    {
                                        Thing thing = ThingMaker.MakeThing(ThingDef.Named("GR_Poison_Cloud"), null);

                                        GenSpawn.Spawn(thing, c2, pawn2.Map);
                                    }
                                }
                                pawn.health.AddHediff(HediffDef.Named("GR_CausedPoisonCloud"));
                            }
                            else
                            {
                                Messages.Message("GR_PoisonCloudRange".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                            }
                        }
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_PoisonCloud);
            }

            /*This gizmo puts the creature into burrowing mode
             */
            if ((pawn.drafter != null) && flagCanBurrow && flagIsCreatureMine && flagIsMindControlBuildingPresent || pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Action GR_Gizmo_Burrowing = new Command_Action();
                GR_Gizmo_Burrowing.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_Burrowing")))
                    {
                        pawn.health.AddHediff(HediffDef.Named("GR_Burrowing"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                GR_Gizmo_Burrowing.defaultLabel = "GR_StartBurrowing".Translate();
                GR_Gizmo_Burrowing.defaultDesc  = "GR_StartBurrowingDesc".Translate();
                GR_Gizmo_Burrowing.icon         = ContentFinder <Texture2D> .Get("Things/Pawn/Animal/Special/GR_Special_Burrowing", true);

                gizmos.Insert(1, GR_Gizmo_Burrowing);
            }

            /*This gizmo makes the animal more resistant for a while
             */
            if ((pawn.drafter != null) && flagCanStamina && flagIsCreatureMine && flagIsMindControlBuildingPresent)
            {
                Command_Action GR_Gizmo_Stamina = new Command_Action();
                GR_Gizmo_Stamina.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_Stamina")))
                    {
                        pawn.health.AddHediff(HediffDef.Named("GR_Stamina"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                GR_Gizmo_Stamina.defaultLabel = "GR_StartStamina".Translate();
                GR_Gizmo_Stamina.defaultDesc  = "GR_StartStaminaDesc".Translate();
                GR_Gizmo_Stamina.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_Stamina", true);

                gizmos.Insert(1, GR_Gizmo_Stamina);
            }

            /*This gizmo makes the animal more aware (sight and consciousness) for a while
             */
            if ((pawn.drafter != null) && flagCanKeenSenses && flagIsCreatureMine && flagIsMindControlBuildingPresent)
            {
                Command_Action GR_Gizmo_KeenSenses = new Command_Action();
                GR_Gizmo_KeenSenses.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_KeenSenses")))
                    {
                        pawn.health.AddHediff(HediffDef.Named("GR_KeenSenses"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                GR_Gizmo_KeenSenses.defaultLabel = "GR_StartKeenSenses".Translate();
                GR_Gizmo_KeenSenses.defaultDesc  = "GR_StartKeenSensesDesc".Translate();
                GR_Gizmo_KeenSenses.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_KeenSenses", true);

                gizmos.Insert(1, GR_Gizmo_KeenSenses);
            }

            /*This gizmo activates cat reflexes, improving melee combat
             */
            if ((pawn.drafter != null) && flagCanCatReflexes && flagIsCreatureMine && flagIsMindControlBuildingPresent || pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Action GR_Gizmo_CatReflexes = new Command_Action();
                GR_Gizmo_CatReflexes.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_CatReflexes")))
                    {
                        pawn.health.AddHediff(HediffDef.Named("GR_CatReflexes"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                GR_Gizmo_CatReflexes.defaultLabel = "GR_StartCatReflexes".Translate();
                GR_Gizmo_CatReflexes.defaultDesc  = "GR_StartCatReflexesDesc".Translate();
                GR_Gizmo_CatReflexes.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_CatReflexes", true);

                gizmos.Insert(1, GR_Gizmo_CatReflexes);
            }

            /*This gizmo makes the animal cast a horror ability
             */
            if ((pawn.drafter != null) && flagCanHorrorize && flagIsCreatureMine && flagIsMindControlBuildingPresent)
            {
                Command_Target GR_Gizmo_Horror = new Command_Target();
                GR_Gizmo_Horror.defaultLabel    = "GR_StartInvokingInsanity".Translate();
                GR_Gizmo_Horror.defaultDesc     = "GR_StartInvokingInsanityDesc".Translate();
                GR_Gizmo_Horror.targetingParams = TargetingParameters.ForAttackAny();
                GR_Gizmo_Horror.icon            = ContentFinder <Texture2D> .Get("Item/Weapon/MiGoCasterWeapon/MiGoCasterWeaponA", true);

                GR_Gizmo_Horror.action = delegate(Thing target)
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_CausedHorror")))
                    {
                        Pawn pawn2 = target as Pawn;
                        if (pawn2 != null)
                        {
                            if (pawn.Position.InHorDistOf(pawn2.Position, 10))
                            {
                                List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized();
                                for (int i = 0; i < 8; i++)
                                {
                                    IntVec3 c2 = pawn2.Position + list[i];
                                    if (c2.InBounds(pawn2.Map))
                                    {
                                        Thing thing = ThingMaker.MakeThing(ThingDef.Named("GR_Insanity_Cloud"), null);

                                        GenSpawn.Spawn(thing, c2, pawn2.Map);
                                    }
                                }
                                pawn.health.AddHediff(HediffDef.Named("GR_CausedHorror"));
                            }
                            else
                            {
                                Messages.Message("GR_InvokingInsanityRange".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                            }
                        }
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_Horror);
            }

            /*This gizmo makes the animal release a burning explosion
             */
            if ((pawn.drafter != null) && flagCanMechaBlast && flagIsCreatureMine && flagIsMindControlBuildingPresent || pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Action GR_Gizmo_MechaBlast = new Command_Action();
                GR_Gizmo_MechaBlast.action = delegate
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_VentedExhaust")))
                    {
                        foreach (IntVec3 c in GenAdj.CellsAdjacent8Way(pawn))
                        {
                            GenExplosion.DoExplosion(c, pawn.Map, (float)0.25, DamageDefOf.Flame, pawn, 25, 5, null, null, null, null, ThingDef.Named("Filth_Ash"), .7f, 1, false, null, 0f, 1);
                        }


                        pawn.health.AddHediff(HediffDef.Named("GR_VentedExhaust"));
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                GR_Gizmo_MechaBlast.defaultLabel = "GR_StartMechaBlast".Translate();
                GR_Gizmo_MechaBlast.defaultDesc  = "GR_StartMechaBlastDesc".Translate();
                GR_Gizmo_MechaBlast.icon         = ContentFinder <Texture2D> .Get("ui/commands/GR_MechaBlast", true);

                gizmos.Insert(1, GR_Gizmo_MechaBlast);
            }

            /*This gizmo activates the orbital beam
             */
            if ((pawn.drafter != null) && flagIsCreatureMine && pawn.def.defName == "GR_ArchotechCentipede")
            {
                Command_Target GR_Gizmo_Orbital = new Command_Target();
                GR_Gizmo_Orbital.defaultLabel    = "GR_Orbital".Translate();
                GR_Gizmo_Orbital.defaultDesc     = "GR_OrbitalDesc".Translate();
                GR_Gizmo_Orbital.targetingParams = TargetingParameters.ForAttackAny();
                GR_Gizmo_Orbital.icon            = ContentFinder <Texture2D> .Get("ui/commands/GR_Orbital", true);

                GR_Gizmo_Orbital.action = delegate(Thing target)
                {
                    if (!pawn.health.hediffSet.HasHediff(HediffDef.Named("GR_CausedPowerBeam")))
                    {
                        if (target.Map == pawn.Map)
                        {
                            PowerBeam powerBeam = (PowerBeam)GenSpawn.Spawn(ThingDefOf.PowerBeam, target.Position, pawn.Map, WipeMode.Vanish);
                            powerBeam.duration   = 600;
                            powerBeam.instigator = pawn;
                            powerBeam.weaponDef  = null;
                            powerBeam.StartStrike();
                            pawn.health.AddHediff(HediffDef.Named("GR_CausedPowerBeam"));
                        }
                    }
                    else
                    {
                        Messages.Message("GR_AbilityRecharging".Translate(), pawn, MessageTypeDefOf.NeutralEvent);
                    }
                };
                gizmos.Insert(1, GR_Gizmo_Orbital);
            }



            __result = gizmos;
        }
Esempio n. 15
0
        public static bool TryMakeFilth(ref bool __result, IntVec3 c, Map map, ThingDef filthDef, IEnumerable <string> sources, bool shouldPropagate, FilthSourceFlags additionalFlags = FilthSourceFlags.None)
        {
            Filth        filth     = null;
            List <Thing> thingList = c.GetThingList(map);

            for (int i = 0; i < thingList.Count; i++)
            {
                Thing thing;
                try
                {
                    thing = thingList[i];
                } catch (ArgumentOutOfRangeException)
                {
                    break;
                }
                if (thing != null && thing.def == filthDef)
                {
                    filth = (Filth)thing;
                    break;
                }
            }
            if (filth == null)
            {
                filth = (Filth)default(Thing);
            }

            if (!c.Walkable(map) || (filth != null && !filth.CanBeThickened))
            {
                if (shouldPropagate)
                {
                    List <IntVec3> list = GenAdj.AdjacentCells8WayRandomized();
                    for (int i = 0; i < 8; i++)
                    {
                        IntVec3 c2 = c + list[i];
                        //if (c2.InBounds(map) && TryMakeFilth(c2, map, filthDef, sources, shouldPropagate: false))
                        if (c2.InBounds(map))
                        {
                            bool tryMakeFilthResult = false;
                            TryMakeFilth(ref tryMakeFilthResult, c2, map, filthDef, sources, shouldPropagate: false);
                            if (tryMakeFilthResult)
                            {
                                __result = true;
                                return(false);
                            }
                        }
                    }
                }

                filth?.AddSources(sources);
                __result = false;
                return(false);
            }

            if (filth != null)
            {
                filth.ThickenFilth();
                filth.AddSources(sources);
            }
            else
            {
                if (!FilthMaker.CanMakeFilth(c, map, filthDef, additionalFlags))
                {
                    __result = false;
                    return(false);
                }

                Filth obj = (Filth)ThingMaker.MakeThing(filthDef);
                obj.AddSources(sources);
                GenSpawn.Spawn(obj, c, map);
            }

            FilthMonitor2.Notify_FilthSpawned();
            __result = true;
            return(false);
        }