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.Misc1; 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); }
private static Gizmo GetMeleeAttackGizmo(Pawn pawn) { Command_Target command_Target = new Command_Target(); command_Target.defaultLabel = "CommandMeleeAttack".Translate(); command_Target.defaultDesc = "CommandMeleeAttackDesc".Translate(); command_Target.targetingParams = TargetingParameters.ForAttackAny(); command_Target.hotKey = KeyBindingDefOf.Misc2; command_Target.icon = TexCommand.AttackMelee; if (FloatMenuUtility.GetMeleeAttackAction(pawn, LocalTargetInfo.Invalid, out string failStr) == null) { command_Target.Disable(failStr.CapitalizeFirst() + "."); } command_Target.action = delegate(Thing target) { IEnumerable <Pawn> enumerable = Find.Selector.SelectedObjects.Where(delegate(object x) { Pawn pawn2 = x as Pawn; return(pawn2 != null && pawn2.IsColonistPlayerControlled && pawn2.Drafted); }).Cast <Pawn>(); foreach (Pawn item in enumerable) { FloatMenuUtility.GetMeleeAttackAction(item, target, out string _)?.Invoke(); } }; return(command_Target); }
private static Gizmo GetMeleeAttackGizmo(Pawn pawn) { Command_Target command_Target = new Command_Target(); command_Target.defaultLabel = "CommandMeleeAttack".Translate(); command_Target.defaultDesc = "CommandMeleeAttackDesc".Translate(); command_Target.targetingParams = TargetingParameters.ForAttackAny(); command_Target.hotKey = KeyBindingDefOf.Misc2; command_Target.icon = TexCommand.AttackMelee; if (FloatMenuUtility.GetMeleeAttackAction(pawn, LocalTargetInfo.Invalid, out var failStr) == null) { command_Target.Disable(failStr.CapitalizeFirst() + "."); } command_Target.action = delegate(Thing target) { foreach (Pawn item in Find.Selector.SelectedObjects.Where(delegate(object x) { Pawn pawn2 = x as Pawn; return(pawn2 != null && pawn2.IsColonistPlayerControlled && pawn2.Drafted); }).Cast <Pawn>()) { string failStr2; Action meleeAttackAction = FloatMenuUtility.GetMeleeAttackAction(item, target, out failStr2); if (meleeAttackAction != null) { meleeAttackAction(); } else if (!failStr2.NullOrEmpty()) { Messages.Message(failStr2, target, MessageTypeDefOf.RejectInput, historical: false); } } }; return(command_Target); }