public IEnumerable <FloatMenuOption> GetTransportPodsFloatMenuOptionsAt(int tile, GlobalTargetInfo target)
        {
            MapParent mapParent = target.WorldObject as MapParent;

            if (mapParent != null && mapParent.HasMap)
            {
                yield return(new FloatMenuOption("TM_SelectTargetOnMap".Translate(mapParent.LabelCap), delegate
                {
                    Map map = mapParent.Map;
                    Current.Game.CurrentMap = map;
                    CameraJumper.TryHideWorld();
                    Find.Targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x)
                    {
                        destCell = x.Cell;
                        destTile = map.Tile;
                        LaunchLightPod(destTile, destCell, null);
                    }, null);
                }));
            }

            if (!Find.World.Impassable(tile))
            {
                yield return(new FloatMenuOption("FormCaravanHere".Translate(), delegate
                {
                    LaunchLightPod(target.Tile, default(IntVec3), new TransportPodsArrivalAction_FormCaravan());
                }));
            }
        }
Пример #2
0
 public override IEnumerable <FloatMenuOption> GetShuttleFloatMenuOptions(IEnumerable <IThingHolder> pods, Action <int, TransportPodsArrivalAction> launchAction)
 {
     if (!TransportPodsArrivalAction_LandInSpecificCell.CanLandInSpecificCell(pods, this))
     {
         yield break;
     }
     yield return(new FloatMenuOption("LandInExistingMap".Translate(Label), delegate
     {
         Map map = Map;
         Current.Game.CurrentMap = map;
         CameraJumper.TryHideWorld();
         Find.Targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x)
         {
             launchAction(base.Tile, new TransportPodsArrivalAction_LandInSpecificCell(this, x.Cell, landInShuttle: true));
         }, delegate(LocalTargetInfo x)
         {
             RoyalTitlePermitWorker_CallShuttle.DrawShuttleGhost(x, Map);
         }, delegate(LocalTargetInfo x)
         {
             AcceptanceReport acceptanceReport = RoyalTitlePermitWorker_CallShuttle.ShuttleCanLandHere(x, Map);
             if (!acceptanceReport.Accepted)
             {
                 Messages.Message(acceptanceReport.Reason, new LookTargets(this), MessageTypeDefOf.RejectInput, historical: false);
             }
             return acceptanceReport.Accepted;
         }, null, null, CompLaunchable.TargeterMouseAttachment);
     }));
 }
 public LockGizmo(ThingWithComps thing, LockComp lockComp)
 {
     lockThing       = thing;
     this.lockComp   = lockComp;
     targetingParams = new TargetingParameters
     {
         thingCategory      = ThingCategory.Building,
         canTargetPawns     = false,
         canTargetBuildings = true,
         canTargetItems     = false,
         onlyTargetFactions = new List <Faction>(1)
         {
             Find.FactionManager.OfPlayer
         },
         validator = delegate(TargetInfo target)
         {
             var t = target.Thing as ThingWithComps;
             if (t != null && t.HasDoorLock(out _))
             {
                 return(true);
             }
             return(false);
         }
     };
     action = delegate(Thing door)
     {
         var manager = door.Map.designationManager;
         var desig   = manager.DesignationOn(door, DesignationDefOf.ModifyDoorLock);
         if (desig == null)
         {
             door.Map.designationManager.AddDesignation(new Designation(door, DesignationDefOf.ModifyDoorLock));
         }
     };
 }
Пример #4
0
 public override IEnumerable <FloatMenuOption> GetTransportPodsFloatMenuOptions(IEnumerable <IThingHolder> pods, CompLaunchable representative)
 {
     foreach (FloatMenuOption o in base.GetTransportPodsFloatMenuOptions(pods, representative))
     {
         yield return(o);
     }
     if (TransportPodsArrivalAction_LandInSpecificCell.CanLandInSpecificCell(pods, this))
     {
         yield return(new FloatMenuOption("LandInExistingMap".Translate(new object[]
         {
             this.Label
         }), delegate()
         {
             Map myMap = representative.parent.Map;
             Map map = this.Map;
             Current.Game.CurrentMap = map;
             CameraJumper.TryHideWorld();
             Find.Targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x)
             {
                 representative.TryLaunch(this.Tile, new TransportPodsArrivalAction_LandInSpecificCell(this.$this, x.Cell));
             }, null, delegate()
             {
                 if (Find.Maps.Contains(myMap))
                 {
                     Current.Game.CurrentMap = myMap;
                 }
             }, CompLaunchable.TargeterMouseAttachment);
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
     }
     yield break;
 }
 public void CreateVerb()
 {
     verb_ShootWeaponAbility = new Verb_ShootWeaponAbility
     {
         verbTracker = new VerbTracker(GetPawn()),
         caster      = GetPawn(),
         verbProps   = new VerbProperties
         {
             accuracyTouch      = 1f,
             accuracyShort      = 1f,
             accuracyMedium     = 1f,
             accuracyLong       = 1f,
             verbClass          = typeof(Verb_ShootWeaponAbility),
             hasStandardCommand = true,
             defaultProjectile  = Props.AbilityProjectile,
             warmupTime         = Props.WarmupTime,
             range                  = Props.Range,
             soundCast              = Props.AbilitySound,
             burstShotCount         = Props.BurstShotCount,
             ticksBetweenBurstShots = Props.TicksBetweenBurstShots,
             muzzleFlashScale       = 0,
             forcedMissRadius       = 0f,
         },
         cannotMiss = Props.cannotMiss,
         ammunition = Props.usesAmmunition
     };
     verb_ShootWeaponAbility.verbProps.targetParams = TargetingParameters.ForAttackAny();
     if (Props.targetingParameters != null)
     {
         verb_ShootWeaponAbility.verbProps.targetParams = Props.targetingParameters;
     }
 }
Пример #6
0
 public override IEnumerable <FloatMenuOption> GetTransportPodsFloatMenuOptions(IEnumerable <IThingHolder> pods, CompLaunchable representative)
 {
     foreach (FloatMenuOption transportPodsFloatMenuOption in base.GetTransportPodsFloatMenuOptions(pods, representative))
     {
         yield return(transportPodsFloatMenuOption);
     }
     if (!TransportPodsArrivalAction_LandInSpecificCell.CanLandInSpecificCell(pods, this))
     {
         yield break;
     }
     yield return(new FloatMenuOption("LandInExistingMap".Translate(Label), delegate
     {
         Map myMap = representative.parent.Map;
         Map map = Map;
         Current.Game.CurrentMap = map;
         CameraJumper.TryHideWorld();
         Find.Targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x)
         {
             representative.TryLaunch(base.Tile, new TransportPodsArrivalAction_LandInSpecificCell(this, x.Cell, representative.parent.TryGetComp <CompShuttle>() != null));
         }, null, delegate
         {
             if (Find.Maps.Contains(myMap))
             {
                 Current.Game.CurrentMap = myMap;
             }
         }, CompLaunchable.TargeterMouseAttachment);
     }));
 }
Пример #7
0
        static void Postfix(Vector3 clickPos, Pawn pawn, ref List <FloatMenuOption> opts)
        {
            IntVec3 c = IntVec3.FromVector3(clickPos);

            foreach (LocalTargetInfo current in GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn), true))
            {
                if (pawn.equipment.TryGetOffHandEquipment(out ThingWithComps eq))
                {
                    FloatMenuOption unequipOffHandOption = new FloatMenuOption("DW_DropOffHand".Translate(eq.LabelShort), new Action(delegate {
                        pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, eq));
                    })); //TODO translation
                    opts.Add(unequipOffHandOption);
                }
            }

            if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                if (pawn.equipment != null)
                {
                    ThingWithComps equipment = null;
                    List <Thing>   thingList = c.GetThingList(pawn.Map);
                    for (int i = 0; i < thingList.Count; i++)
                    {
                        if (thingList[i].TryGetComp <CompEquippable>() != null)
                        {
                            equipment = (ThingWithComps)thingList[i];
                            FloatMenuOption equipOffHandOption = GetEquipOffHandOption(pawn, equipment);
                            opts.Add(equipOffHandOption);
                        }
                    }
                }
            }
        }
Пример #8
0
        public static IEnumerable <LocalTargetInfo> TargetsAt(Vector3 clickPos, TargetingParameters clickParams, bool thingsOnly = false)
        {
            List <Thing> clickableList = GenUI.ThingsUnderMouse(clickPos, 0.8f, clickParams);
            int          i             = 0;

            if (i < clickableList.Count)
            {
                yield return((LocalTargetInfo)clickableList[i]);

                /*Error: Unable to find new state assignment for yield return*/;
            }
            if (thingsOnly)
            {
                yield break;
            }
            IntVec3 cellTarg = UI.MouseCell();

            if (!cellTarg.InBounds(Find.VisibleMap))
            {
                yield break;
            }
            if (!clickParams.CanTarget(new TargetInfo(cellTarg, Find.VisibleMap, false)))
            {
                yield break;
            }
            yield return((LocalTargetInfo)cellTarg);

            /*Error: Unable to find new state assignment for yield return*/;
        }
Пример #9
0
        private static Gizmo GetSquadAttackGizmo(Pawn pawn)
        {
            Command_Target command_Target = new Command_Target();

            command_Target.defaultLabel    = "CommandSquadAttack".Translate();
            command_Target.defaultDesc     = "CommandSquadAttackDesc".Translate();
            command_Target.targetingParams = TargetingParameters.ForAttackAny();
            command_Target.hotKey          = KeyBindingDefOf.Misc4;
            command_Target.icon            = TexCommand.SquadAttack;
            string str;

            if (FloatMenuUtility.GetAttackAction(pawn, LocalTargetInfo.Invalid, out str) == null)
            {
                command_Target.Disable(str.CapitalizeFirst() + ".");
            }
            command_Target.action = delegate(Thing target)
            {
                IEnumerable <Pawn> enumerable = Find.Selector.SelectedObjects.Where(delegate(object x)
                {
                    Pawn pawn3 = x as Pawn;
                    return(pawn3 != null && pawn3.IsColonistPlayerControlled && pawn3.Drafted);
                }).Cast <Pawn>();
                foreach (Pawn pawn2 in enumerable)
                {
                    string text;
                    Action attackAction = FloatMenuUtility.GetAttackAction(pawn2, target, out text);
                    if (attackAction != null)
                    {
                        attackAction();
                    }
                }
            };
            return(command_Target);
        }
Пример #10
0
        public void TriggerLaser()
        {
            TargetingParameters targetingParams = new TargetingParameters()
            {
                canTargetLocations = true
            };

            Find.Targeter.BeginTargeting(targetingParams, delegate(LocalTargetInfo target)
            {
                IntVec3 _LocationCell = new IntVec3(target.Cell.x, target.Cell.y, target.Cell.z);

                if (!IsValidForActivation())
                {
                    return;
                }
                this.ShowLaserVisually(_LocationCell);

                GenSpawn.Spawn(ThingDef.Named("SteamGeyser"), _LocationCell, this.parent.Map);

                this.m_RequiresShipResourcesComp.UseResources();
                Messages.Message("SteamGeyser Created.", MessageTypeDefOf.TaskCompletion);
                this.parent.Destroy(DestroyMode.Vanish);
            }, delegate(LocalTargetInfo target)
            {
                //Highlght action

                GenDraw.DrawRadiusRing(target.Cell, 0.1f);
                GenDraw.DrawRadiusRing(new IntVec3(target.Cell.x + 1, target.Cell.y, target.Cell.z), 0.1f);
                GenDraw.DrawRadiusRing(new IntVec3(target.Cell.x, target.Cell.y, target.Cell.z + 1), 0.1f);
                GenDraw.DrawRadiusRing(new IntVec3(target.Cell.x + 1, target.Cell.y, target.Cell.z + 1), 0.1f);
            }, null, null, null);
        }
Пример #11
0
        static TargetingParameters TargetParms()
        {
            TargetingParameters targetingParameters = new TargetingParameters();

            targetingParameters.canTargetPawns     = true;
            targetingParameters.canTargetBuildings = false;
            targetingParameters.mapObjectTargetsMustBeAutoAttackable = false;
            targetingParameters.validator = delegate(TargetInfo targ)
            {
                if (!targ.HasThing)
                {
                    return(false);
                }
                Pawn pawn = targ.Thing as Pawn;
                if (pawn == null)
                {
                    return(false);
                }
                if (pawn.Downed)
                {
                    return(false);
                }
                if (!pawn.GetQuestPawn(out QuestPawn questPawn))
                {
                    return(false);
                }
                return(true);
            };
            return(targetingParameters);
        }
Пример #12
0
        public static TargetingParameters ForPawn(Pawn caller = null, float?radius = null)
        {
            TargetingParameters targetingParameters = new TargetingParameters();

            targetingParameters.canTargetPawns = true;
            targetingParameters.validator      = (TargetInfo target) => target.Thing is Pawn;
            return(targetingParameters);
        }
Пример #13
0
 public void BeginTargetingWithVerb(TMAbilityDef verbToAdd, TargetingParameters targetParams, Action <LocalTargetInfo> action, Pawn caster = null, Action actionWhenFinished = null, Texture2D mouseAttachment = null)
 {
     AccessTools.Field(typeof(Targeter), "action").SetValue(Find.Targeter, action);
     AccessTools.Field(typeof(Targeter), "targetParams").SetValue(Find.Targeter, targetParams);
     AccessTools.Field(typeof(Targeter), "caster").SetValue(Find.Targeter, caster);
     AccessTools.Field(typeof(Targeter), "actionWhenFinished").SetValue(Find.Targeter, actionWhenFinished);
     AccessTools.Field(typeof(Targeter), "mouseAttachment").SetValue(Find.Targeter, mouseAttachment);
 }
Пример #14
0
        public bool ChoseWorldTarget(GlobalTargetInfo target)
        {
            if (!target.IsValid)
            {
                Messages.Message("SWeaponTargetInvalid".Translate(), MessageTypeDefOf.RejectInput, true);
                return(false);
            }

            /*
             * int num = Find.WorldGrid.TraversalDistanceBetween(base.Map.Tile, target.Tile, true, int.MaxValue);
             * if (this.MaxLaunchDistance < 200 && num > this.MaxLaunchDistance)
             * {
             *  Messages.Message("MissileRangeBad".Translate(), MessageTypeDefOf.RejectInput, true);
             *  return false;
             * }
             */
            MapParent mapParent = target.WorldObject as MapParent;

            if (mapParent != null && mapParent.HasMap)
            {
                Map map = mapParent.Map;
                Current.Game.CurrentMap = map;
                Targeter targeter           = Find.Targeter;
                Action   actionWhenFinished = delegate
                {
                    if (Find.Maps.Contains(base.Map))
                    {
                        Current.Game.CurrentMap = base.Map;
                    }
                };

                /*
                 * int range = 0;
                 * switch (getType()) {
                 *  case SuperWeaponType.Soviet:range = 56;break;
                 *  case SuperWeaponType.Allied: range = 30; break;
                 *  default:range=10;break;
                 * }
                 */

                Texture2D ic = ContentFinder <Texture2D> .Get("ra2/World/ra2_SuperWeaponIcon_" + getType());

                TargetingParameters tg = new TargetingParameters();
                tg.canTargetLocations = true;
                tg.canTargetItems     = true;
                tg.canTargetBuildings = true;
                tg.canTargetPawns     = true;
                tg.canTargetFires     = true;
                targeter.BeginTargeting(tg, delegate(LocalTargetInfo x)
                {
                    //GenDraw.DrawRadiusRing(UI.MouseCell(), range);
                    this.TryLaunch(x.ToGlobalTargetInfo(map));
                }, null, actionWhenFinished, ic);
                return(true);
            }
            this.TryLaunch(target);
            return(true);
        }
Пример #15
0
        public void Transmogrify(Map map, Pawn pawn = null, int count = 3)
        {
            if (count <= 0)
            {
                return;
            }
            //No pawn? Okay, find one.

            if (pawn == null)
            {
                pawn = PetsToTransmogrify(map).RandomElement();
            }

            Messages.Message("Cults_TransmogrifyAnimalsOnly".Translate(
                                 pawn.LabelShort
                                 ), MessageTypeDefOf.NeutralEvent);


            var parms = new TargetingParameters
            {
                canTargetPawns = true
            };
            var foundTarget = false;
            var thisCount   = count;

            Find.Targeter.BeginTargeting(parms, delegate(LocalTargetInfo t)
            {
                if (t.Thing is not Pawn tP)
                {
                    return;
                }

                if (!(tP.RaceProps?.Animal ?? false))
                {
                    return;
                }

                pawn          = tP;
                var compTrans = tP.GetComp <CompTransmogrified>();
                if (compTrans == null)
                {
                    return;
                }

                compTrans.IsTransmogrified = true;
                foundTarget = true;
                Messages.Message("Cults_TransmogrifyMessage".Translate(
                                     pawn.LabelShort
                                     ), MessageTypeDefOf.PositiveEvent);
            }, null, delegate
            {
                if (!foundTarget)
                {
                    LongEventHandler.QueueLongEvent(delegate { Transmogrify(map, pawn, thisCount - 1); },
                                                    "transmogrify", false, null);
                }
            });
        }
Пример #16
0
 public static IEnumerable <LocalTargetInfo> OurTargetsAt(Vector3 clickPos,
                                                          TargetingParameters clickParams, bool thingsOnly = false)
 {
     if (blockAHlONonItems)
     {
         return(Enumerable.Empty <LocalTargetInfo>());                 //yield break;
     }
     return(GenUI.TargetsAt_NewTemp(clickPos, clickParams, thingsOnly, null));
 }
Пример #17
0
 static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
 {
     foreach (LocalTargetInfo current in GenUI.TargetsAt(clickPos, TargetingParameters.ForAttackHostile(), true))
     {
         if ((current.Thing is Pawn target) && target.RaceProps.Animal)
         {
             GUC_FloatMenuUtility.AddMountingOptions(target, pawn, opts);
         }
     }
 }
        private bool ChoseWorldTarget(GlobalTargetInfo target)
        {
            bool result;

            if (!this.ReadyToTransport)
            {
                result = true;
            }
            else if (!target.IsValid)
            {
                Messages.Message("MessageTransportPodsDestinationIsInvalid".Translate(), MessageTypeDefOf.RejectInput);
                result = false;
            }
            else
            {
                MapParent mapParent = target.WorldObject as MapParent;
                if (mapParent != null && mapParent.HasMap)
                {
                    Map myMap = this.parent.Map;
                    Map map   = mapParent.Map;
                    Current.Game.CurrentMap = map;
                    Targeter targeter           = Find.Targeter;
                    Action   actionWhenFinished = delegate()
                    {
                        if (Find.Maps.Contains(myMap))
                        {
                            Current.Game.CurrentMap = myMap;
                        }
                    };
                    TargetingParameters targetParams = new TargetingParameters
                    {
                        canTargetPawns     = true,
                        canTargetItems     = false,
                        canTargetSelf      = false,
                        canTargetLocations = false,
                        canTargetBuildings = false,
                        canTargetFires     = false
                    };
                    targeter.BeginTargeting(targetParams, delegate(LocalTargetInfo x)
                    {
                        if (this.ReadyToTransport)
                        {
                            this.TryTransport(x.ToGlobalTargetInfo(map));
                        }
                    }, null, actionWhenFinished, CompTeleporter.TargeterMouseAttachment);
                    result = true;
                }
                else
                {
                    Messages.Message("RD_YouCannotLock".Translate(), MessageTypeDefOf.RejectInput);                     //"You cannot lock onto anything there."
                    result = false;
                }
            }
            return(result);
        }
Пример #19
0
 // RimWorld.Targeter
 public void BeginTargetingWithVerb(Verb_UseAbility verbToAdd, TargetingParameters targetParams, Action <LocalTargetInfo> action, Pawn caster = null, Action actionWhenFinished = null, Texture2D mouseAttachment = null)
 {
     verbToAdd.timeSavingActionVariable         = this.action;
     Find.Targeter.targetingVerb                = verbToAdd;
     Find.Targeter.targetingVerbAdditionalPawns = null;
     AccessTools.Field(typeof(Targeter), "action").SetValue(Find.Targeter, action);
     AccessTools.Field(typeof(Targeter), "targetParams").SetValue(Find.Targeter, targetParams);
     AccessTools.Field(typeof(Targeter), "caster").SetValue(Find.Targeter, caster);
     AccessTools.Field(typeof(Targeter), "actionWhenFinished").SetValue(Find.Targeter, actionWhenFinished);
     AccessTools.Field(typeof(Targeter), "mouseAttachment").SetValue(Find.Targeter, mouseAttachment);
 }
Пример #20
0
 public void BeginTargeting(TargetingParameters targetParams, Action <LocalTargetInfo> action, VehicleTurret cannon, Action actionWhenFinished = null, Texture2D mouseAttachment = null)
 {
     this.action       = action;
     this.targetParams = targetParams;
     vehicle           = cannon.vehicle;
     Cannon            = cannon;
     Cannon.SetTarget(LocalTargetInfo.Invalid);
     this.actionWhenFinished = actionWhenFinished;
     this.mouseAttachment    = mouseAttachment;
     map = cannon.vehicle.Map;
 }
        public void Transmogrify(Map map, Pawn pawn = null, int count = 3)
        {
            if (count <= 0)
            {
                return;
            }
            //No pawn? Okay, find one.

            if (pawn == null)
            {
                pawn = PetsToTransmogrify(map).RandomElement <Pawn>();
            }

            Messages.Message("Cults_TransmogrifyAnimalsOnly".Translate(new object[]
            {
                pawn.LabelShort
            }), MessageTypeDefOf.NeutralEvent);


            TargetingParameters parms = new TargetingParameters();

            parms.canTargetPawns = true;
            bool foundTarget = false;
            int  thisCount   = count;

            Find.Targeter.BeginTargeting(parms, delegate(LocalTargetInfo t)
            {
                if (t.Thing is Pawn tP)
                {
                    if (tP?.RaceProps?.Animal ?? false)
                    {
                        pawn = tP;
                        CompTransmogrified compTrans = tP.GetComp <CompTransmogrified>();
                        if (compTrans != null)
                        {
                            compTrans.IsTransmogrified = true;
                            foundTarget = true;
                            Messages.Message("Cults_TransmogrifyMessage".Translate(
                                                 new object[] //Cults_AspectOfCthulhu_TargetACharacter
                            {
                                pawn.LabelShort
                            }), MessageTypeDefOf.PositiveEvent);
                        }
                    }
                }
            }, null, delegate
            {
                if (!foundTarget)
                {
                    LongEventHandler.QueueLongEvent(delegate { this.Transmogrify(map, pawn, thisCount - 1); },
                                                    "transmogrify", false, null);
                }
            }, null);
        }
Пример #22
0
        public static void StartTargeting(Def def, Map map = null)
        {
            TargetingParameters targetingParameters = new TargetingParameters();

            targetingParameters.canTargetLocations = true;
            targetingParameters.canTargetSelf      = true;
            targetingParameters.canTargetFires     = true;
            targetingParameters.canTargetItems     = true;
            AirStrikeDef       airStrike       = def as AirStrikeDef;
            ArtilleryStrikeDef artilleryStrike = def as ArtilleryStrikeDef;
            OrbitalStrikeDef   orbitalStrike   = def as OrbitalStrikeDef;

            if (airStrike != null)
            {
                Find.Targeter.BeginTargeting(targetingParameters, delegate(LocalTargetInfo x)
                {
                    SpawnAirStrike(map, x.Cell, airStrike);
                }, null, delegate
                {
                    if (map != null && Find.Maps.Contains(map))
                    {
                        Current.Game.CurrentMap = map;
                    }
                }, CompLaunchable.TargeterMouseAttachment);
            }
            else
            if (artilleryStrike != null)
            {
                Find.Targeter.BeginTargeting(targetingParameters, delegate(LocalTargetInfo x)
                {
                    SpawnArtilleryStrike(map, x.Cell, artilleryStrike);
                }, null, delegate
                {
                    if (map != null && Find.Maps.Contains(map))
                    {
                        Current.Game.CurrentMap = map;
                    }
                }, CompLaunchable.TargeterMouseAttachment);
            }
            else
            if (orbitalStrike != null)
            {
                Find.Targeter.BeginTargeting(targetingParameters, delegate(LocalTargetInfo x)
                {
                    SpawnOrbitalStrike(map, x.Cell, orbitalStrike);
                }, null, delegate
                {
                    if (map != null && Find.Maps.Contains(map))
                    {
                        Current.Game.CurrentMap = map;
                    }
                }, CompLaunchable.TargeterMouseAttachment);
            }
        }
Пример #23
0
 public void BeginTargeting(TargetingParameters targetParams, Action <LocalTargetInfo> action, CannonHandler cannon, Action actionWhenFinished = null, Texture2D mouseAttachment = null)
 {
     this.action       = action;
     this.targetParams = targetParams;
     caster            = cannon.pawn;
     this.cannon       = cannon;
     this.cannon.SetTarget(LocalTargetInfo.Invalid);
     this.actionWhenFinished = actionWhenFinished;
     this.mouseAttachment    = mouseAttachment;
     map = cannon.pawn.Map;
 }
        private bool OnChoseWorldTarget(GlobalTargetInfo target)
        {
            // Invalid target.
            if (!target.IsValid)
            {
                Messages.Message("AA.MegInvalidWorldTarget".Translate(), MessageTypeDefOf.RejectInput);
                return(false);
            }

            // Out of range.
            if (Find.WorldGrid.TraversalDistanceBetween(base.Map.Tile, target.Tile) > WORLD_MAP_RANGE)
            {
                Messages.Message("AA.MegOutOfRange".Translate(), this, MessageTypeDefOf.RejectInput);
                return(false);
            }

            // Make sure that the map is generated. Cannot fire into a null map.
            MapParent mapParent = target.WorldObject as MapParent;

            if (mapParent == null || !mapParent.HasMap)
            {
                Messages.Message("AA.MegNeedsMap".Translate(), MessageTypeDefOf.RejectInput);
                return(false);
            }

            // Can't attack own map.
            var targetMap = mapParent.Map;

            if (targetMap == this.Map)
            {
                Messages.Message("AA.MegCantTargetSelf".Translate(), MessageTypeDefOf.RejectInput);
                return(false);
            }

            // Allow targeting everything.
            var targParams = new TargetingParameters
            {
                canTargetPawns     = true,
                canTargetBuildings = true,
                canTargetLocations = true,
                canTargetAnimals   = true
            };

            Current.Game.CurrentMap = targetMap;
            Find.Targeter.BeginTargeting(targParams, (localTarg) =>
            {
                GlobalTargetInfo globalTargetInfo = localTarg.ToGlobalTargetInfo(targetMap);
                StartAttackSequence(globalTargetInfo, LocalTargetInfo.Invalid);
            });

            //Messages.Message("Not working yet.", MessageTypeDefOf.RejectInput, true);
            return(true);
        }
 public void BeginTargeting(TargetingParameters targetParams, Action <IEnumerable <IntVec3>, Pair <IntVec3, IntVec3> > action, ThingDef bomber, BombingType bombType, Map map, Pawn caster = null, Action actionWhenFinished = null, Texture2D mouseAttachment = null)
 {
     this.action             = action;
     this.targetParams       = targetParams;
     this.caster             = caster;
     this.actionWhenFinished = actionWhenFinished;
     this.mouseAttachment    = mouseAttachment;
     this.selections         = new List <LocalTargetInfo>();
     this.bomber             = bomber;
     this.map      = map;
     this.bombType = bombType;
 }
Пример #26
0
        internal TargetingParameters ForLeapDestination()
        {
            TargetingParameters targetingParameters = new TargetingParameters();

            targetingParameters.canTargetLocations = true;
            targetingParameters.canTargetSelf      = false;
            targetingParameters.canTargetPawns     = false;
            targetingParameters.canTargetFires     = false;
            targetingParameters.canTargetBuildings = false;
            targetingParameters.canTargetItems     = false;
            targetingParameters.validator          = (TargetInfo x) => IsRightSpot(x);
            return(targetingParameters);
        }
        public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            var selftargets = GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn));

            foreach (LocalTargetInfo t in selftargets)
            {
                if (t.Pawn == pawn && pawn.HasMenstruationComp())
                {
                    opts.AddDistinct(MakeSelfMenu(pawn, t));
                }
                break;
            }
        }
        private TargetingParameters ForShipDestination()
        {
            TargetingParameters targetingParameters = new TargetingParameters();

            targetingParameters.canTargetLocations = true;
            targetingParameters.canTargetSelf      = false;
            targetingParameters.canTargetPawns     = false;
            targetingParameters.canTargetFires     = false;
            targetingParameters.canTargetBuildings = false;
            targetingParameters.canTargetItems     = false;
            targetingParameters.validator          = (TargetInfo x) => ship.CanTeleportTo(x.Cell);
            return(targetingParameters);
        }
Пример #29
0
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            bool   disabled       = false;
            string disabledReason = "";

            if (GetPawn == null)
            {
                disabled       = true;
                disabledReason = "DisabledNotEquipped".Translate(parent.def.label);
            }
            else if (!GetPawn.equipment.AllEquipmentListForReading.Contains(parent))
            {
                disabled       = true;
                disabledReason = "DisabledNotEquipped".Translate(parent.def.label);
            }
            TargetingParameters targetingParameters = TargetingParameters.ForAttackAny();

            if (stolenTraitDef == null)
            {
                yield return(new Command_Target
                {
                    defaultLabel = Props.AbilityLabelSteal,
                    defaultDesc = Props.AbilityDescSteal,
                    icon = IconAbilitySteal,
                    targetingParams = targetingParameters,
                    action = delegate(Thing target)
                    {
                        IEnumerable <Pawn> enumerable = Find.Selector.SelectedObjects.Where(delegate(object x)
                        {
                            Pawn pawn3 = x as Pawn;
                            return pawn3 != null && pawn3.IsColonistPlayerControlled && pawn3.Drafted;
                        }).Cast <Pawn>();
                        DoEffectOn(target);
                    },
                    disabled = disabled,
                    disabledReason = disabledReason
                });
            }
            else
            {
                yield return(new Command_Action
                {
                    defaultLabel = Props.AbilityLabelConsume,
                    defaultDesc = "AbilityDescConsumeAura".Translate(stolenTraitDef.label),
                    icon = IconAbilityConsume,
                    action = ConsumeStolenAura,
                    disabled = disabled,
                    disabledReason = disabledReason
                });
            }
        }
Пример #30
0
        //跳跃用Tp
        public static TargetingParameters JumpTP()
        {
            var tp = new TargetingParameters
            {
                canTargetBuildings = false,
                canTargetFires     = true,
                canTargetItems     = true,
                canTargetLocations = true,
                canTargetPawns     = true,
                canTargetSelf      = false
            };

            return(tp);
        }