Ejemplo n.º 1
0
 public static List <Pawn> GetAllTameAnimalsInOrderWithName(string name)
 {
     return(Find.Maps.SelectMany(map => map.mapPawns.AllPawnsSpawned)
            .Where(pawn => pawn.Faction == Faction.OfPlayer &&
                   pawn.RaceProps.Animal &&
                   ThingSelectionUtility.SelectableByHotkey(pawn) &&
                   pawn.Name.ToStringFull.ToLower().Equals(name.ToLower()))
            .OrderBy(pawn => pawn.Map?.uniqueID ?? pawn.GetCaravan()?.ID + 500 ?? -1)
            .ThenBy(pawn => pawn.kindDef.label)
            .ThenBy(pawn => pawn.Label)
            .ToList());
 }
Ejemplo n.º 2
0
        private bool AllowsThingSelection(ThingSelection selection, Thing thing)
        {
            if (selection == ThingSelection.None)
            {
                return(false);
            }
            else if (selection == ThingSelection.NeedsHauling)
            {
                return(thing.Map.listerHaulables.ThingsPotentiallyNeedingHauling().Contains(thing));
            }
            else if (selection == ThingSelection.Selectable)
            {
                return(ThingSelectionUtility.SelectableByMapClick(thing));
            }
            else if (selection == ThingSelection.Everything)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        protected override bool TryCastShot()
        {
            bool result = false;
            bool arg_40_0;

            CompAbilityUserMight comp = this.CasterPawn.GetComp <CompAbilityUserMight>();

            pwr    = comp.MightData.MightPowerSkill_PhaseStrike.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PhaseStrike_pwr");
            ver    = comp.MightData.MightPowerSkill_PhaseStrike.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PhaseStrike_ver");
            verVal = ver.level;
            pwrVal = pwr.level;
            if (base.CasterPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
            {
                MightPowerSkill mver = comp.MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                MightPowerSkill mpwr = comp.MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                verVal = mver.level;
                pwrVal = mpwr.level;
            }
            if (this.CasterPawn.equipment.Primary != null && !this.CasterPawn.equipment.Primary.def.IsRangedWeapon)
            {
                this.dmgNum = GetWeaponDmg(this.CasterPawn);
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                if (!this.CasterPawn.IsColonist && settingsRef.AIHardMode)
                {
                    this.dmgNum += 10;
                }

                if (this.currentTarget != null && base.CasterPawn != null)
                {
                    arg_29_0 = this.currentTarget.Cell;
                    Vector3 vector = this.currentTarget.CenterVector3;
                    arg_40_0 = this.currentTarget.Cell.IsValid;
                    arg_41_0 = vector.InBounds(base.CasterPawn.Map);
                    arg_42_0 = true; // vector.ToIntVec3().Standable(base.CasterPawn.Map);
                }
                else
                {
                    arg_40_0 = false;
                }
                bool flag  = arg_40_0;
                bool flag2 = arg_41_0;
                bool flag3 = arg_42_0;
                if (flag)
                {
                    if (flag2 & flag3)
                    {
                        Pawn    p    = this.CasterPawn;
                        Map     map  = this.CasterPawn.Map;
                        IntVec3 pLoc = this.CasterPawn.Position;
                        if (p.IsColonist)
                        {
                            try
                            {
                                ThingSelectionUtility.SelectNextColonist();
                                this.CasterPawn.DeSpawn();
                                //p.SetPositionDirect(this.currentTarget.Cell);
                                SearchForTargets(arg_29_0, (2f + (float)(.5f * verVal)), map, p);
                                GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                                DrawBlade(p.Position.ToVector3Shifted(), 4f + (float)(verVal));
                                p.drafter.Drafted = true;
                                ThingSelectionUtility.SelectPreviousColonist();
                            }
                            catch
                            {
                                if (!CasterPawn.Spawned)
                                {
                                    GenSpawn.Spawn(p, pLoc, map);
                                    p.drafter.Drafted = true;
                                    Log.Message("Phase strike threw exception - despawned pawn has been recovered at casting location");
                                }
                            }
                            this.Ability.PostAbilityAttempt();
                        }
                        else
                        {
                            this.CasterPawn.DeSpawn();
                            SearchForTargets(arg_29_0, (2f + (float)(.5f * verVal)), map, p);
                            GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                            DrawBlade(p.Position.ToVector3Shifted(), 4f + (float)(verVal));
                        }

                        //this.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                        //base.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                        //this.CasterPawn.pather.ResetToCurrentPosition();
                        result = true;
                    }
                    else
                    {
                        Messages.Message("InvalidTargetLocation".Translate(), MessageTypeDefOf.RejectInput);
                    }
                }
            }
            else
            {
                Messages.Message("MustHaveMeleeWeapon".Translate(new object[]
                {
                    this.CasterPawn.LabelCap
                }), MessageTypeDefOf.RejectInput);
                return(false);
            }

            this.burstShotsLeft = 0;
            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            return(result);
        }
Ejemplo n.º 4
0
        protected override bool TryCastShot()
        {
            bool result = false;
            bool arg_40_0;

            CompAbilityUserMight comp = this.CasterPawn.GetComp <CompAbilityUserMight>();

            verVal = TM_Calc.GetMightSkillLevel(this.CasterPawn, comp.MightData.MightPowerSkill_PhaseStrike, "TM_PhaseStrike", "_ver", true);
            pwrVal = TM_Calc.GetMightSkillLevel(this.CasterPawn, comp.MightData.MightPowerSkill_PhaseStrike, "TM_PhaseStrike", "_pwr", true);
            //pwr = comp.MightData.MightPowerSkill_PhaseStrike.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PhaseStrike_pwr");
            //ver = comp.MightData.MightPowerSkill_PhaseStrike.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PhaseStrike_ver");
            //verVal = ver.level;
            //pwrVal = pwr.level;
            //if (base.CasterPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
            //{
            //    MightPowerSkill mver = comp.MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
            //    MightPowerSkill mpwr = comp.MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
            //    verVal = mver.level;
            //    pwrVal = mpwr.level;
            //}
            if (this.CasterPawn.equipment.Primary != null && !this.CasterPawn.equipment.Primary.def.IsRangedWeapon)
            {
                TMAbilityDef ad = (TMAbilityDef)this.Ability.Def;
                this.dmgNum = Mathf.RoundToInt(comp.weaponDamage * ad.weaponDamageFactor);
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                if (!this.CasterPawn.IsColonist && settingsRef.AIHardMode)
                {
                    this.dmgNum += 10;
                }

                if (this.currentTarget != null && base.CasterPawn != null)
                {
                    arg_29_0 = this.currentTarget.Cell;
                    Vector3 vector = this.currentTarget.CenterVector3;
                    arg_40_0 = this.currentTarget.Cell.IsValid;
                    arg_41_0 = vector.InBounds(base.CasterPawn.Map);
                    arg_42_0 = true; // vector.ToIntVec3().Standable(base.CasterPawn.Map);
                }
                else
                {
                    arg_40_0 = false;
                }
                bool flag  = arg_40_0;
                bool flag2 = arg_41_0;
                bool flag3 = arg_42_0;
                if (flag)
                {
                    if (flag2 & flag3)
                    {
                        Pawn    p       = this.CasterPawn;
                        Map     map     = this.CasterPawn.Map;
                        IntVec3 pLoc    = this.CasterPawn.Position;
                        bool    drafted = p.Drafted;
                        if (p.IsColonist)
                        {
                            try
                            {
                                ThingSelectionUtility.SelectNextColonist();
                                this.CasterPawn.DeSpawn();
                                //p.SetPositionDirect(this.currentTarget.Cell);
                                SearchForTargets(arg_29_0, (2f + (float)(.5f * verVal)), map, p);
                                GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                                DrawBlade(p.Position.ToVector3Shifted(), 4f + (float)(verVal));
                                p.drafter.Drafted = drafted;
                                CameraJumper.TryJumpAndSelect(p);
                                TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_BladeSweep"), this.CasterPawn.DrawPos, this.CasterPawn.Map, 1.4f + .4f * ver.level, .04f, 0f, .18f, 1000, 0, 0, Rand.Range(0, 360));
                            }
                            catch
                            {
                                if (!CasterPawn.Spawned)
                                {
                                    GenSpawn.Spawn(p, pLoc, map);
                                    p.drafter.Drafted = true;
                                    Log.Message("Phase strike threw exception - despawned pawn has been recovered at casting location");
                                }
                            }
                        }
                        else
                        {
                            this.CasterPawn.DeSpawn();
                            SearchForTargets(arg_29_0, (2f + (float)(.5f * verVal)), map, p);
                            GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                            DrawBlade(p.Position.ToVector3Shifted(), 4f + (float)(verVal));
                        }

                        //this.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                        //base.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                        //this.CasterPawn.pather.ResetToCurrentPosition();
                        result = true;
                    }
                    else
                    {
                        Messages.Message("InvalidTargetLocation".Translate(), MessageTypeDefOf.RejectInput);
                    }
                }
            }
            else
            {
                Messages.Message("MustHaveMeleeWeapon".Translate(
                                     this.CasterPawn.LabelCap
                                     ), MessageTypeDefOf.RejectInput);
                return(false);
            }

            this.burstShotsLeft = 0;
            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            return(result);
        }
Ejemplo n.º 5
0
        protected override bool TryCastShot()
        {
            bool result = false;
            bool arg_40_0;

            if (this.currentTarget != null && base.CasterPawn != null)
            {
                IntVec3 arg_29_0 = this.currentTarget.Cell;
                Vector3 vector   = this.currentTarget.CenterVector3;
                arg_40_0 = this.currentTarget.Cell.IsValid;
                arg_41_0 = vector.InBounds(base.CasterPawn.Map);
                arg_42_0 = true; // vector.ToIntVec3().Standable(base.CasterPawn.Map);
            }
            else
            {
                arg_40_0 = false;
            }
            bool flag  = arg_40_0;
            bool flag2 = arg_41_0;
            bool flag3 = arg_42_0;

            if (flag)
            {
                if (flag2 & flag3)
                {
                    Pawn    p    = this.CasterPawn;
                    Map     map  = this.CasterPawn.Map;
                    IntVec3 cell = this.CasterPawn.Position;
                    try
                    {
                        if (this.CasterPawn.IsColonist)
                        {
                            ThingSelectionUtility.SelectNextColonist();
                            this.CasterPawn.DeSpawn();
                            //p.SetPositionDirect(this.currentTarget.Cell);
                            GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                            p.drafter.Drafted = true;
                            ThingSelectionUtility.SelectPreviousColonist();
                        }
                        else
                        {
                            this.CasterPawn.DeSpawn();
                            GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                        }
                    }
                    catch
                    {
                        if (!this.CasterPawn.Spawned)
                        {
                            GenSpawn.Spawn(p, cell, map);
                            Log.Message("Exception occured when trying to blink - recovered pawn at position ability was used from.");
                        }
                    }
                    //this.Ability.PostAbilityAttempt();
                    //this.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                    //base.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                    //this.CasterPawn.pather.ResetToCurrentPosition();
                    result = true;
                }
                else
                {
                    Messages.Message("InvalidTargetLocation".Translate(), MessageTypeDefOf.RejectInput);
                }
            }
            else
            {
                Log.Warning("failed to TryCastShot");
            }
            this.burstShotsLeft = 0;
            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            return(result);
        }
Ejemplo n.º 6
0
        public override IEnumerable <Gizmo> GetWornGizmos()
        {
            //  base.GetWornGizmos();
            if (Find.Selector.SingleSelectedThing != base.Wearer)
            {
                yield break;
            }

            //tanya
            if (base.Wearer.kindDef.defName == "ra2_AlliedTanya")
            {
                yield return new Command_Action
                       {
                           icon          = ContentFinder <Texture2D> .Get(!tanyaHandWeapon()?DefDatabase <ThingDef> .GetNamed("ra2_Gun_Tanya", true).graphicData.texPath : DefDatabase <ThingDef> .GetNamed("ra2_TanyaC4Bomb", true).graphicData.texPath, true),
                           defaultLabel  = "TanyaChangeWeapon".Translate(),
                           activateSound = DefDatabase <SoundDef> .GetNamed("ra2_tanya_select", true),
                           action        = delegate
                           {
                               Pawn_EquipmentTracker pe = base.Wearer.equipment;
                               ThingDef tempDef         = DefDatabase <ThingDef> .GetNamed(tanyaHandWeapon()? "ra2_TanyaC4Bomb" : "ra2_Gun_Tanya", true);

                               pe.Remove(pe.Primary);
                               pe.AddEquipment((ThingWithComps)ThingMaker.MakeThing(tempDef));
                           }
                       }
            }
            ;

            //chrono
            TargetingParameters tp = new TargetingParameters();

            tp.canTargetBuildings = false;
            tp.canTargetFires     = false;
            tp.canTargetLocations = true;
            tp.canTargetPawns     = false;
            tp.canTargetSelf      = false;


            if (base.Wearer.kindDef.defName == "ra2_AlliedChrono")
            {
                yield return new Command_TargetPlus
                       {
                           icon            = ContentFinder <Texture2D> .Get("ra2/Things/Misc/ChTeleport", true),
                           defaultLabel    = "ChronoTeleport".Translate(),
                           activateSound   = DefDatabase <SoundDef> .GetNamed("ra2_Chrono_select", true),
                           targetingParams = tp,
                           hotKey          = KeyBindingDefOf.Misc4,
                           disabled        = !base.Wearer.drafter.Drafted || base.Wearer.stances.stunner.Stunned,
                           aimIcon         = ContentFinder <Texture2D> .Get("ra2/Things/Misc/ChTeleport", true),
                           action          = delegate(LocalTargetInfo target)
                           {
                               Pawn casterPawn = base.Wearer;
                               Map  map        = base.Wearer.Map;

                               IEnumerable <Thing> thi = map.thingGrid.ThingsAt(target.Cell);
                               foreach (Thing th in thi)
                               {
                                   if (th is Building)
                                   {
                                       Messages.Message("ChronoNotToBuild".Translate(), MessageTypeDefOf.RejectInput);
                                       return;
                                   }
                               }

                               MoteMaker.ThrowExplosionCell(target.Cell, map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1, 1, 1));
                               // MoteMaker.ThrowExplosionCell(target.Cell, map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1,1,1));
                               for (int asd = 0; asd < 60; asd++)
                               {
                                   MoteMaker.ThrowExplosionCell(casterPawn.Position, map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1f - asd * 0.1f, asd * 0.1f, 1f - asd * 0.05f));
                               }


                               double dist = Math.Sqrt(Math.Pow(casterPawn.Position.x - target.Cell.x, 2) + Math.Pow(casterPawn.Position.z - target.Cell.z, 2));

                               if (dist < 20)
                               {
                                   dist = 20;
                               }


                               ThingSelectionUtility.SelectNextColonist();
                               base.Wearer.DeSpawn(DestroyMode.Vanish);
                               GenSpawn.Spawn(casterPawn, target.Cell, map, WipeMode.Vanish);
                               casterPawn.drafter.Drafted = true;
                               ThingSelectionUtility.SelectPreviousColonist();
                               SoundStarter.PlayOneShot(DefDatabase <SoundDef> .GetNamed("ra2_Chrono_move", true), casterPawn);
                               SoundStarter.PlayOneShotOnCamera(DefDatabase <SoundDef> .GetNamed("ra2_Chrono_movesay", true));

                               DamageInfo dinfo = new DamageInfo(DamageDefOf.Stun, (int)(dist * 0.1), -1, 1, null, null, base.Wearer.equipment.Primary.def, DamageInfo.SourceCategory.ThingOrUnknown, casterPawn);
                               casterPawn.TakeDamage(dinfo);
                               // Log.Warning(target+"VV");
                           }
                       }
            }
            ;

            //yuri
            bool isYuri = false;

            if (this.Wearer != null)
            {
                Pawn pawn = this.Wearer;

                if (pawn.kindDef.defName.EqualsIgnoreCase("ra2_yuriyuri"))
                {
                    isYuri = true;
                }
            }

            if (isYuri)
            {
                bool canCast = this.ticks <= 0 && this.Wearer.drafter.Drafted && !this.Wearer.stances.stunner.Stunned;
                yield return(new Command_YuriAction
                {
                    defaultLabel = "YuriExpTitle".Translate(),
                    icon = ContentFinder <Texture2D> .Get("ra2/Things/Misc/yuriExpIcon", true),
                    disabled = !canCast,
                    caster = this.Wearer,
                    hotKey = KeyBindingDefOf.Misc4,
                    action = delegate
                    {
                        Pawn pawn = this.Wearer;
                        DamageDef df = DefDatabase <DamageDef> .GetNamed("YuriExp", true);

                        foreach (IntVec3 cell in CellsAround(pawn.Position, pawn.Map, 7))
                        {
                            // if (!cell.IsValid) continue;
                            List <Thing> list = (pawn.Map.thingGrid.ThingsListAt(cell));
                            try
                            {
                                if (list.Count < 1)
                                {
                                    continue;
                                }
                                for (int i = 0; i < list.Count; i++)
                                {
                                    Pawn p;
                                    if ((p = (list[i] as Pawn)) != null)
                                    {
                                        if (p.kindDef.defName.EqualsIgnoreCase("ra2_yuriyuri"))
                                        {
                                            continue;
                                        }
                                        if (p.RaceProps.IsFlesh)
                                        {
                                            {
                                                p.Kill(new DamageInfo(df, 0, 0, -1, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null), null);
                                            }

                                            if (!(p.Faction == Faction.OfPlayer && p.kindDef.defName.StartsWith("ra2_")))
                                            {
                                                p.Corpse.Kill(null);
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception e) { Log.Warning(e + "233"); }
                        }

                        pawn.stances.stunner.StunFor(120, null);
                        this.ticks = 300;
                        GenExplosion.DoExplosion(pawn.Position, pawn.Map, 7f, df, pawn, 0, -1, null, null, null, null, null, 0, 1, false, null, 0, 1, 0, false);
                    }
                });
            }



            yield break;
        }
    }
}
Ejemplo n.º 7
0
        protected override bool TryCastShot()
        {
            bool result = false;
            bool arg_40_0;

            CompAbilityUserMight comp = this.CasterPawn.GetComp <CompAbilityUserMight>();

            pwr = comp.MightData.MightPowerSkill_PhaseStrike.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PhaseStrike_pwr");
            ver = comp.MightData.MightPowerSkill_PhaseStrike.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PhaseStrike_ver");
            str = comp.MightData.MightPowerSkill_global_strength.FirstOrDefault((MightPowerSkill x) => x.label == "TM_global_strength_pwr");

            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 = (.8f + (.025f * str.level));
                dmgNum          = Mathf.RoundToInt(skillMultiplier * dmgMultiplier * (pawnDPS + weaponDPS));
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                if (!this.CasterPawn.IsColonistPlayerControlled && settingsRef.AIHardMode)
                {
                    dmgNum += 10;
                }

                if (this.currentTarget != null && base.CasterPawn != null)
                {
                    arg_29_0 = this.currentTarget.Cell;
                    Vector3 vector = this.currentTarget.CenterVector3;
                    arg_40_0 = this.currentTarget.Cell.IsValid;
                    arg_41_0 = vector.InBounds(base.CasterPawn.Map);
                    arg_42_0 = true; // vector.ToIntVec3().Standable(base.CasterPawn.Map);
                }
                else
                {
                    arg_40_0 = false;
                }
                bool flag  = arg_40_0;
                bool flag2 = arg_41_0;
                bool flag3 = arg_42_0;
                if (flag)
                {
                    if (flag2 & flag3)
                    {
                        Pawn    p    = this.CasterPawn;
                        Map     map  = this.CasterPawn.Map;
                        IntVec3 pLoc = this.CasterPawn.Position;
                        if (p.IsColonistPlayerControlled)
                        {
                            try
                            {
                                ThingSelectionUtility.SelectNextColonist();
                                this.CasterPawn.DeSpawn();
                                //p.SetPositionDirect(this.currentTarget.Cell);
                                SearchForTargets(arg_29_0, (2f + (float)(.5f * ver.level)), map, p);
                                GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                                DrawBlade(p.Position.ToVector3Shifted(), 4f + (float)(ver.level));
                                p.drafter.Drafted = true;
                                ThingSelectionUtility.SelectPreviousColonist();
                            }
                            catch
                            {
                                if (!CasterPawn.Spawned)
                                {
                                    GenSpawn.Spawn(p, pLoc, map);
                                    p.drafter.Drafted = true;
                                    Log.Message("Phase strike threw exception - despawned pawn has been recovered at casting location");
                                }
                            }
                            this.Ability.PostAbilityAttempt();
                        }
                        else
                        {
                            this.CasterPawn.DeSpawn();
                            SearchForTargets(arg_29_0, (2f + (float)(.5f * ver.level)), map, p);
                            GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                            DrawBlade(p.Position.ToVector3Shifted(), 4f + (float)(ver.level));
                        }

                        //this.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                        //base.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                        //this.CasterPawn.pather.ResetToCurrentPosition();
                        result = true;
                    }
                    else
                    {
                        Messages.Message("InvalidTargetLocation".Translate(), MessageTypeDefOf.RejectInput);
                    }
                }
            }
            else
            {
                Messages.Message("MustHaveMeleeWeapon".Translate(new object[]
                {
                    this.CasterPawn.LabelCap
                }), MessageTypeDefOf.RejectInput);
                return(false);
            }

            this.burstShotsLeft = 0;
            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            return(result);
        }
Ejemplo n.º 8
0
        public override IEnumerable <Gizmo> GetWornGizmos()
        {
            //  base.GetWornGizmos();
            if (Find.Selector.SingleSelectedThing != Wearer)
            {
                yield break;
            }

            //tanya
            if (Wearer.kindDef.defName == "ra2_AlliedTanya")
            {
                yield return(new Command_Action
                {
                    icon = ContentFinder <Texture2D> .Get(!tanyaHandWeapon()
                                                          ?DefDatabase <ThingDef> .GetNamed("ra2_Gun_Tanya").graphicData.texPath
                                                          : DefDatabase <ThingDef> .GetNamed("ra2_TanyaC4Bomb").graphicData.texPath),
                    defaultLabel = "TanyaChangeWeapon".Translate(),
                    activateSound = DefDatabase <SoundDef> .GetNamed("ra2_tanya_select"),
                    action = delegate
                    {
                        var pe = Wearer.equipment;
                        var tempDef =
                            DefDatabase <ThingDef> .GetNamed(tanyaHandWeapon()? "ra2_TanyaC4Bomb" : "ra2_Gun_Tanya");

                        pe.Remove(pe.Primary);
                        pe.AddEquipment((ThingWithComps)ThingMaker.MakeThing(tempDef));
                    }
                });
            }

            //chrono
            var tp = new TargetingParameters
            {
                canTargetBuildings = false,
                canTargetFires     = false,
                canTargetLocations = true,
                canTargetPawns     = false,
                canTargetSelf      = false
            };


            if (Wearer.kindDef.defName == "ra2_AlliedChrono")
            {
                yield return(new Command_TargetPlus
                {
                    icon = ContentFinder <Texture2D> .Get("ra2/Things/Misc/ChTeleport"),
                    defaultLabel = "ChronoTeleport".Translate(),
                    activateSound = DefDatabase <SoundDef> .GetNamed("ra2_Chrono_select"),
                    targetingParams = tp,
                    hotKey = KeyBindingDefOf.Misc4,
                    disabled = !Wearer.drafter.Drafted || Wearer.stances.stunner.Stunned,
                    aimIcon = ContentFinder <Texture2D> .Get("ra2/Things/Misc/ChTeleport"),
                    action = delegate(LocalTargetInfo target)
                    {
                        var casterPawn = Wearer;
                        var map = Wearer.Map;

                        var thi = map.thingGrid.ThingsAt(target.Cell);
                        foreach (var th in thi)
                        {
                            if (th is not Building)
                            {
                                continue;
                            }

                            Messages.Message("ChronoNotToBuild".Translate(), MessageTypeDefOf.RejectInput);
                            return;
                        }

                        FleckMaker.ThrowExplosionCell(target.Cell, map, FleckDefOf.ExplosionFlash, new Color(1, 1, 1));
                        // MoteMaker.ThrowExplosionCell(target.Cell, map, ThingDefOf.Mote_ExplosionFlash, new UnityEngine.Color(1,1,1));
                        for (var asd = 0; asd < 60; asd++)
                        {
                            FleckMaker.ThrowExplosionCell(casterPawn.Position, map, FleckDefOf.ExplosionFlash,
                                                          new Color(1f - (asd * 0.1f), asd * 0.1f, 1f - (asd * 0.05f)));
                        }


                        var dist = Math.Sqrt(Math.Pow(casterPawn.Position.x - target.Cell.x, 2) +
                                             Math.Pow(casterPawn.Position.z - target.Cell.z, 2));

                        if (dist < 20)
                        {
                            dist = 20;
                        }


                        ThingSelectionUtility.SelectNextColonist();
                        Wearer.DeSpawn();
                        GenSpawn.Spawn(casterPawn, target.Cell, map);
                        casterPawn.drafter.Drafted = true;
                        ThingSelectionUtility.SelectPreviousColonist();
                        DefDatabase <SoundDef> .GetNamed("ra2_Chrono_move").PlayOneShot(casterPawn);

                        DefDatabase <SoundDef> .GetNamed("ra2_Chrono_movesay").PlayOneShotOnCamera();

                        var dinfo = new DamageInfo(DamageDefOf.Stun, (int)(dist * 0.1), -1, 1, null, null,
                                                   Wearer.equipment.Primary.def, DamageInfo.SourceCategory.ThingOrUnknown, casterPawn);
                        casterPawn.TakeDamage(dinfo);
                        // Log.Warning(target+"VV");
                    }
                });
Ejemplo n.º 9
0
        protected override bool TryCastShot()
        {
            bool result = false;
            bool arg_40_0;

            if (this.currentTarget != null && base.CasterPawn != null)
            {
                IntVec3 arg_29_0 = this.currentTarget.Cell;
                Vector3 vector   = this.currentTarget.CenterVector3;
                arg_40_0 = this.currentTarget.Cell.IsValid;
                arg_41_0 = vector.InBounds(base.CasterPawn.Map);
                arg_42_0 = true; // vector.ToIntVec3().Standable(base.CasterPawn.Map);
            }
            else
            {
                arg_40_0 = false;
            }
            bool flag  = arg_40_0;
            bool flag2 = arg_41_0;
            bool flag3 = arg_42_0;

            if (flag)
            {
                if (flag2 & flag3)
                {
                    Pawn    p         = this.CasterPawn;
                    Map     map       = this.CasterPawn.Map;
                    IntVec3 cell      = this.CasterPawn.Position;
                    bool    draftFlag = this.CasterPawn.Drafted;
                    try
                    {
                        if (this.CasterPawn.IsColonist)
                        {
                            ModOptions.Constants.SetPawnInFlight(true);
                            ThingSelectionUtility.SelectNextColonist();
                            this.CasterPawn.DeSpawn();
                            //p.SetPositionDirect(this.currentTarget.Cell);
                            GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                            p.drafter.Drafted = draftFlag;
                            if (base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_ver").level >= 1)
                            {
                                List <Pawn> eList = TM_Calc.FindPawnsNearTarget(p, 2, this.currentTarget.Cell, true);
                                if (eList != null && eList.Count > 0)
                                {
                                    for (int i = 0; i < eList.Count; i++)
                                    {
                                        Pawn e = eList[i];
                                        TM_Action.DamageEntities(e, null, 5f, DamageDefOf.Stun, p);
                                    }
                                }
                            }
                            CameraJumper.TryJumpAndSelect(p);
                            ModOptions.Constants.SetPawnInFlight(false);
                        }
                        else
                        {
                            ModOptions.Constants.SetPawnInFlight(true);
                            this.CasterPawn.DeSpawn();
                            GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                            ModOptions.Constants.SetPawnInFlight(false);
                        }
                    }
                    catch
                    {
                        if (!this.CasterPawn.Spawned)
                        {
                            GenSpawn.Spawn(p, cell, map);
                            Log.Message("Exception occured when trying to blink - recovered pawn at position ability was used from.");
                        }
                    }
                    //this.Ability.PostAbilityAttempt();
                    //this.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                    //base.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                    //this.CasterPawn.pather.ResetToCurrentPosition();
                    result = true;
                }
                else
                {
                    Messages.Message("InvalidTargetLocation".Translate(), MessageTypeDefOf.RejectInput);
                }
            }
            else
            {
                Log.Warning("failed to TryCastShot");
            }
            this.burstShotsLeft = 0;
            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            return(result);
        }