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 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); }
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); }
private static void PawnAttackGizmoUtility_GetSquadAttackGizmoPostfix(Pawn pawn, ref Gizmo __result) { Command_Target command_Target = (Command_Target)__result; bool flag = false; List <object> selectedObjectsListForReading = Find.Selector.SelectedObjectsListForReading; if (selectedObjectsListForReading.Count > 1) { for (int i = 0; i < selectedObjectsListForReading.Count; i++) { Pawn pawn2 = selectedObjectsListForReading[i] as Pawn; if (pawn2 != null && pawn2.IsColonistPlayerControlled && pawn2.GetComp <VEF_Comp_Pawn_RangedVerbs>().CurRangedVerb != null && pawn2.GetComp <VEF_Comp_Pawn_RangedVerbs>().CurRangedVerb.IsStillUsableBy(pawn2) && (pawn2.GetComp <VEF_Comp_Pawn_RangedVerbs>().CurRangedVerb.EquipmentSource == null || pawn2.GetComp <VEF_Comp_Pawn_RangedVerbs>().CurRangedVerb.EquipmentSource != pawn2.equipment.Primary)) { flag = true; } } } if (flag || (VEF_Comp_Pawn_RangedVerbs.ShouldUseSquadAttackGizmo())) { command_Target.defaultLabel = "CommandSquadEquipmentAttack".Translate(); command_Target.defaultDesc = "CommandSquadEquipmentAttackDesc".Translate(); if (FloatMenuUtility.GetAttackAction(pawn, LocalTargetInfo.Invalid, out string str) == null) { command_Target.Disable(str.CapitalizeFirst() + "."); } command_Target.action = delegate(Thing target) { IEnumerable <Pawn> pawns = 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 pawns) { if (pawn2.equipment != null && pawn2.equipment.Primary != null && !pawn2.equipment.PrimaryEq.PrimaryVerb.IsMeleeAttack && (pawn2.GetComp <VEF_Comp_Pawn_RangedVerbs>().CurRangedVerb.EquipmentSource == null || pawn2.GetComp <VEF_Comp_Pawn_RangedVerbs>().CurRangedVerb.EquipmentSource.def != pawn2.equipment.Primary.def)) { pawn2.GetComp <VEF_Comp_Pawn_RangedVerbs>().SetCurRangedVerb(pawn2.equipment.PrimaryEq.PrimaryVerb, null); } string text; FloatMenuUtility.GetAttackAction(pawn2, target, out text)?.Invoke(); } }; __result = command_Target; } return; }
private static Gizmo GetRemoteControlActivateGizmo(Pawn pawn) { Command_Target command_Target = new Command_Target(); command_Target.defaultLabel = "WTH_Gizmo_RemoteControlActivate_Label".Translate(); command_Target.defaultDesc = "WTH_Gizmo_RemoteControlActivate_Description".Translate(); command_Target.targetingParams = GetTargetingParametersForHacking(); command_Target.hotKey = KeyBindingDefOf.Misc5; if (pawn.Drafted) { command_Target.Disable("WTH_Reason_PawnCannotBeDrafted".Translate()); } command_Target.icon = ContentFinder <Texture2D> .Get(("Things/MechControllerBelt")); command_Target.action = delegate(Thing target) { if (target is Pawn) { pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, false); Pawn mech = (Pawn)target; ExtendedPawnData pawnData = Base.Instance.GetExtendedDataStorage().GetExtendedDataFor(pawn); ExtendedPawnData mechData = Base.Instance.GetExtendedDataStorage().GetExtendedDataFor(mech); pawnData.remoteControlLink = mech; mechData.remoteControlLink = pawn; mechData.isActive = true; mech.drafter.Drafted = true; Find.Selector.ClearSelection(); Find.Selector.Select(mech); if (pawn.GetLord() == null || pawn.GetLord().LordJob == null) { LordMaker.MakeNewLord(Faction.OfPlayer, new LordJob_ControlMechanoid(), pawn.Map, new List <Pawn> { pawn }); pawn.mindState.duty.focus = mech; } } }; return(command_Target); }