private void HandleColonistClicks(Rect rect, Pawn colonist) { if (Mouse.IsOver(rect) && Event.current.type == EventType.MouseDown) { if (clickedColonist == colonist && Time.time - clickedAt < ColBarSettings.DoubleClickTime) { // use event so it doesn't bubble through Event.current.Use(); JumpToTargetUtility.TryJump(colonist); clickedColonist = null; } else { clickedColonist = colonist; clickedAt = Time.time; } } if (Mouse.IsOver(rect) && Event.current.button == 1) { if (Event.current.type == EventType.MouseDown) { List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>(); if (clickedColonist != null && SelPawn != null && SelPawn != clickedColonist) { foreach (FloatMenuOption choice in FloatMenuMakerMap.ChoicesAtFor(clickedColonist.TrueCenter(), SelPawn)) { floatOptionList.Add(choice); } floatOptionList.Add(new FloatMenuOption("--------------------", delegate { })); } floatOptionList.Add(new FloatMenuOption("CBKF.Settings.Vanilla".Translate(), delegate { ColBarSettings.SortBy = vanilla; ((UIRootMap)Find.UIRoot).colonistBar.MarkColonistsListDirty(); })); floatOptionList.Add(new FloatMenuOption("CBKF.Settings.ByName".Translate(), delegate { ColBarSettings.SortBy = byName; ((UIRootMap)Find.UIRoot).colonistBar.MarkColonistsListDirty(); })); floatOptionList.Add(new FloatMenuOption("CBKF.Settings.SexAge".Translate(), delegate { ColBarSettings.SortBy = sexage; ((UIRootMap)Find.UIRoot).colonistBar.MarkColonistsListDirty(); })); floatOptionList.Add(new FloatMenuOption("CBKF.Settings.Mood".Translate(), delegate { ColBarSettings.SortBy = mood; ((UIRootMap)Find.UIRoot).colonistBar.MarkColonistsListDirty(); })); floatOptionList.Add(new FloatMenuOption("CBKF.Settings.Health".Translate(), delegate { ColBarSettings.SortBy = health; ((UIRootMap)Find.UIRoot).colonistBar.MarkColonistsListDirty(); })); floatOptionList.Add(new FloatMenuOption("CBKF.Settings.Medic".Translate(), delegate { ColBarSettings.SortBy = medic; ((UIRootMap)Find.UIRoot).colonistBar.MarkColonistsListDirty(); })); floatOptionList.Add(new FloatMenuOption("CBKF.Settings.Weapons".Translate(), delegate { ColBarSettings.SortBy = weapons; ((UIRootMap)Find.UIRoot).colonistBar.MarkColonistsListDirty(); })); floatOptionList.Add(new FloatMenuOption("CBKF.Settings.SettingsColonistBar".Translate(), delegate { Find.WindowStack.Add(new ColonistBarKF_Settings()); })); FloatMenu window = new FloatMenu(floatOptionList, "CBKF.Settings.SortingOptions".Translate()); Find.WindowStack.Add(window); // use event so it doesn't bubble through Event.current.Use(); } } }
private bool ChoseWorldTarget(GlobalTargetInfo target) { int tile; if (this.parentLandedShip != null) { tile = this.parentLandedShip.Tile; } else { tile = this.Map.Tile; } bool canBomb = true; if (!target.IsValid) { Messages.Message("MessageTransportPodsDestinationIsInvalid".Translate(), MessageSound.RejectInput); return(false); } if (this.LaunchAsFleet) { List <int> distances = new List <int>(); for (int i = 0; i < DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Count; i++) { ShipBase ship = DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID)[i]; if (ship.compShip.cargoLoadingActive) { Messages.Message("MessageFleetLaunchImpossible".Translate(), MessageSound.RejectInput); return(false); } int num = (Find.WorldGrid.TraversalDistanceBetween(tile, target.Tile)); if (num > ship.MaxLaunchDistance(true)) { Messages.Message("MessageFleetLaunchImpossible".Translate(), MessageSound.RejectInput); return(false); } if (!(2 * num > ship.MaxLaunchDistance(true))) { canBomb = false; } } } else { int num = Find.WorldGrid.TraversalDistanceBetween(tile, target.Tile); if (num > this.MaxLaunchDistance(this.LaunchAsFleet)) { Messages.Message("MessageTransportPodsDestinationIsTooFar".Translate(new object[] { CompLaunchable.FuelNeededToLaunchAtDist((float)num).ToString("0.#") }), MessageSound.RejectInput); return(false); } if (!(2 * num > this.MaxLaunchDistance(true))) { canBomb = false; } } MapParent mapParent = target.WorldObject as MapParent; if (mapParent != null && mapParent.HasMap) { Map myMap = this.Map; Map map = mapParent.Map; Current.Game.VisibleMap = map; Targeter targeter = Find.Targeter; Action actionWhenFinished = delegate { if (Find.Maps.Contains(myMap)) { Current.Game.VisibleMap = myMap; } }; targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x) { if (!this.ReadyForTakeoff || this.LaunchAsFleet && DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Any(s => !s.ReadyForTakeoff)) { return; } this.TryLaunch(x.ToGlobalTargetInfo(map), PawnsArriveMode.Undecided, TravelingShipArrivalAction.EnterMapFriendly); }, null, actionWhenFinished, DropShipUtility.TargeterShipAttachment); return(true); } if (target.WorldObject is FactionBase && target.WorldObject.Faction != Faction.OfPlayer) { FactionBase factionBase = target.WorldObject as FactionBase; Find.WorldTargeter.closeWorldTabWhenFinished = false; List <FloatMenuOption> list = new List <FloatMenuOption>(); if (!target.WorldObject.Faction.HostileTo(Faction.OfPlayer)) { list.Add(new FloatMenuOption("VisitFactionBase".Translate(new object[] { target.WorldObject.Label }), delegate { if (!this.ReadyForTakeoff || this.LaunchAsFleet && DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Any(s => !s.ReadyForTakeoff)) { return; } this.TryLaunch(target, PawnsArriveMode.Undecided, TravelingShipArrivalAction.StayOnWorldMap); JumpToTargetUtility.CloseWorldTab(); }, MenuOptionPriority.Default, null, null, 0f, null, null)); } list.Add(new FloatMenuOption("DropAtEdge".Translate(), delegate { if (!this.ReadyForTakeoff || this.LaunchAsFleet && DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Any(s => !s.ReadyForTakeoff)) { return; } this.TryLaunch(target, PawnsArriveMode.EdgeDrop, TravelingShipArrivalAction.EnterMapFriendly); JumpToTargetUtility.CloseWorldTab(); }, MenuOptionPriority.Default, null, null, 0f, null, null)); list.Add(new FloatMenuOption("DropInCenter".Translate(), delegate { if (!this.ReadyForTakeoff || this.LaunchAsFleet && DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Any(s => !s.ReadyForTakeoff)) { return; } this.TryLaunch(target, PawnsArriveMode.CenterDrop, TravelingShipArrivalAction.EnterMapFriendly); JumpToTargetUtility.CloseWorldTab(); }, MenuOptionPriority.Default, null, null, 0f, null, null)); list.Add(new FloatMenuOption("AttackFactionBaseAerial".Translate(), delegate { if (!this.ReadyForTakeoff || this.LaunchAsFleet && DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Any(s => !s.ReadyForTakeoff)) { return; } this.TryLaunch(target, PawnsArriveMode.CenterDrop, TravelingShipArrivalAction.EnterMapAssault); JumpToTargetUtility.CloseWorldTab(); }, MenuOptionPriority.Default, null, null, 0f, null, null)); if (canBomb && (DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Any(x => x.installedTurrets.Any(y => y.Key.slotType == WeaponSystemType.Bombing && y.Value != null))) || this.loadedBombs.Any()) { list.Add(new FloatMenuOption("BombFactionBase".Translate(), delegate { if (!this.ReadyForTakeoff || this.LaunchAsFleet && DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Any(s => !s.ReadyForTakeoff)) { return; } this.performBombingRun = true; this.TryLaunch(target, PawnsArriveMode.CenterDrop, TravelingShipArrivalAction.BombingRun); JumpToTargetUtility.CloseWorldTab(); }, MenuOptionPriority.Default, null, null, 0f, null, null)); } Find.WindowStack.Add(new FloatMenu(list)); return(true); } if (Find.World.Impassable(target.Tile)) { Messages.Message("MessageTransportPodsDestinationIsInvalid".Translate(), MessageSound.RejectInput); return(false); } this.TryLaunch(target, PawnsArriveMode.Undecided, TravelingShipArrivalAction.StayOnWorldMap); return(true); }