private static void VerbGiverExtended(ref IEnumerable <Gizmo> __result, Pawn_DraftController __instance) { List <Gizmo> gizmos = new List <Gizmo>(__result); // normal gizmos List <Gizmo> toggleGizmos = new List <Gizmo>(); List <Gizmo> rangedVerbGizmos = new List <Gizmo>(); // iterates over verbgivercomps foreach (HediffComp_VerbGiverExtended verbGiverExtended in __instance.pawn.health.hediffSet.GetAllComps().Where(c => c is HediffComp_VerbGiverExtended)) { // create a gizmo Command_Toggle command_HediffToggle = new Command_Toggle { isActive = () => verbGiverExtended.canAutoAttack, toggleAction = () => verbGiverExtended.canAutoAttack = !verbGiverExtended.canAutoAttack, defaultLabel = verbGiverExtended.Props.toggleLabel, defaultDesc = verbGiverExtended.Props.toggleDescription.CapitalizeFirst(), icon = PCF_VanillaExtender.GetIcon(verbGiverExtended.Pawn.GetUniqueLoadID() + "_" + verbGiverExtended.parent.GetUniqueLoadID(), verbGiverExtended.Props.toggleIconPath), iconAngle = verbGiverExtended.Props.toggleIconAngle, iconOffset = verbGiverExtended.Props.toggleIconOffset }; if (__instance.pawn.Faction != Faction.OfPlayer) // disable show on enemies { command_HediffToggle.Disable("CannotOrderNonControlled".Translate()); } if (__instance.pawn.Downed) // disable on downed { command_HediffToggle.Disable("IsIncapped".Translate(__instance.pawn.LabelShort, __instance.pawn)); } toggleGizmos.Add(command_HediffToggle); // add to list of toggles // command to use verb Command_HediffVerbRanged command_HediffVerbRanged = new Command_HediffVerbRanged { rangedComp = verbGiverExtended, defaultLabel = verbGiverExtended.rangedVerbLabel, defaultDesc = verbGiverExtended.rangedVerbDescription.CapitalizeFirst(), icon = PCF_VanillaExtender.GetIcon(verbGiverExtended.Pawn.GetUniqueLoadID() + "_" + verbGiverExtended.rangedVerb.loadID, verbGiverExtended.rangedVerbIconPath), iconAngle = verbGiverExtended.rangedVerbIconAngle, iconOffset = verbGiverExtended.rangedVerbIconOffset }; if (__instance.pawn.Faction != Faction.OfPlayer) { command_HediffVerbRanged.Disable("CannotOrderNonControlled".Translate()); } else if (__instance.pawn.IsColonist) { if (__instance.pawn.story.DisabledWorkTagsBackstoryAndTraits.HasFlag(WorkTags.Violent)) { command_HediffVerbRanged.Disable("IsIncapableOfViolence".Translate(__instance.pawn.LabelShort, __instance.pawn)); } else if (!__instance.pawn.drafter.Drafted) { command_HediffVerbRanged.Disable("IsNotDrafted".Translate(__instance.pawn.LabelShort, __instance.pawn)); } } rangedVerbGizmos.Add(command_HediffVerbRanged); } __result = gizmos.Concat(toggleGizmos).Concat(rangedVerbGizmos); }
private static void DisableCommandIfMechanoidPowerLow(Pawn_DraftController __instance, Command_Toggle toggleCommand) { ExtendedDataStorage store = Base.Instance.GetExtendedDataStorage(); if (store != null) { if (__instance.pawn.ShouldRecharge()) { toggleCommand.Disable("WTH_Reason_PowerLow".Translate()); } if (__instance.pawn.ShouldBeMaintained()) { toggleCommand.Disable("WTH_Reason_MaintenanceLow".Translate()); } } }
internal IEnumerable <Gizmo> GetGizmos() { Command_Toggle draft = new Command_Toggle(); draft.hotKey = KeyBindingDefOf.Command_ColonistDraft; draft.isActive = new Func <bool>(this.get_Drafted); draft.toggleAction = delegate() { this.Drafted = !this.Drafted; PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Drafting, KnowledgeAmount.SpecificInteraction); if (this.Drafted) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.QueueOrders, OpportunityType.GoodToKnow); } }; draft.defaultDesc = "CommandToggleDraftDesc".Translate(); draft.icon = TexCommand.Draft; draft.turnOnSound = SoundDefOf.DraftOn; draft.turnOffSound = SoundDefOf.DraftOff; if (!this.Drafted) { draft.defaultLabel = "CommandDraftLabel".Translate(); } if (this.pawn.Downed) { draft.Disable("IsIncapped".Translate(new object[] { this.pawn.LabelShort })); } if (!this.Drafted) { draft.tutorTag = "Draft"; } else { draft.tutorTag = "Undraft"; } yield return(draft); if (this.Drafted && this.pawn.equipment.Primary != null && this.pawn.equipment.Primary.def.IsRangedWeapon) { yield return(new Command_Toggle { hotKey = KeyBindingDefOf.Misc6, isActive = new Func <bool>(this.get_FireAtWill), toggleAction = delegate() { this.FireAtWill = !this.FireAtWill; }, icon = TexCommand.FireAtWill, defaultLabel = "CommandFireAtWillLabel".Translate(), defaultDesc = "CommandFireAtWillDesc".Translate(), tutorTag = "FireAtWillToggle" }); } yield break; }
public override IEnumerable <Gizmo> GetGizmos() { foreach (Gizmo g in base.GetGizmos()) { yield return(g); } if (this.def.building.bed_humanlike && base.Faction == Faction.OfPlayer) { Command_Toggle pris = new Command_Toggle(); pris.defaultLabel = "CommandBedSetForPrisonersLabel".Translate(); pris.defaultDesc = "CommandBedSetForPrisonersDesc".Translate(); pris.icon = ContentFinder <Texture2D> .Get("UI/Commands/ForPrisoners", true); pris.isActive = new Func <bool>(this.get_ForPrisoners); pris.toggleAction = delegate() { this.ToggleForPrisonersByInterface(); }; if (!Building_Bed.RoomCanBePrisonCell(this.GetRoom(RegionType.Set_Passable)) && !this.ForPrisoners) { pris.Disable("CommandBedSetForPrisonersFailOutdoors".Translate()); } pris.hotKey = KeyBindingDefOf.Misc3; pris.turnOffSound = null; pris.turnOnSound = null; yield return(pris); yield return(new Command_Toggle { defaultLabel = "CommandBedSetAsMedicalLabel".Translate(), defaultDesc = "CommandBedSetAsMedicalDesc".Translate(), icon = ContentFinder <Texture2D> .Get("UI/Commands/AsMedical", true), isActive = new Func <bool>(this.get_Medical), toggleAction = delegate() { this.Medical = !this.Medical; }, hotKey = KeyBindingDefOf.Misc2 }); if (!this.ForPrisoners && !this.Medical) { yield return(new Command_Action { defaultLabel = "CommandBedSetOwnerLabel".Translate(), icon = ContentFinder <Texture2D> .Get("UI/Commands/AssignOwner", true), defaultDesc = "CommandBedSetOwnerDesc".Translate(), action = delegate() { Find.WindowStack.Add(new Dialog_AssignBuildingOwner(this)); }, hotKey = KeyBindingDefOf.Misc3 }); } } yield break; }
/// <summary> /// Draft gizmos for VehiclePawn /// </summary> /// <param name="drafter"></param> public static IEnumerable <Gizmo> DraftGizmos(Pawn_DraftController drafter) { Command_Toggle command_Toggle = new Command_Toggle(); command_Toggle.hotKey = KeyBindingDefOf.Command_ColonistDraft; command_Toggle.isActive = (() => drafter.Drafted); command_Toggle.toggleAction = delegate() { drafter.Drafted = !drafter.Drafted; PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Drafting, KnowledgeAmount.SpecificInteraction); if (drafter.Drafted) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.QueueOrders, OpportunityType.GoodToKnow); } }; command_Toggle.defaultDesc = "CommandToggleDraftDesc".Translate(); command_Toggle.icon = TexCommand.Draft; command_Toggle.turnOnSound = SoundDefOf.DraftOn; command_Toggle.turnOffSound = SoundDefOf.DraftOff; if (!drafter.Drafted) { command_Toggle.defaultLabel = "CommandDraftLabel".Translate(); } if (drafter.pawn.Downed) { command_Toggle.Disable("IsIncapped".Translate(drafter.pawn.LabelShort, drafter.pawn)); } if (!drafter.Drafted) { command_Toggle.tutorTag = "Draft"; } else { command_Toggle.tutorTag = "Undraft"; } yield return(command_Toggle); if (drafter.Drafted && drafter.pawn.equipment.Primary != null && drafter.pawn.equipment.Primary.def.IsRangedWeapon) { yield return(new Command_Toggle { hotKey = KeyBindingDefOf.Misc6, isActive = (() => drafter.FireAtWill), toggleAction = delegate() { drafter.FireAtWill = !drafter.FireAtWill; }, icon = TexCommand.FireAtWill, defaultLabel = "CommandFireAtWillLabel".Translate(), defaultDesc = "CommandFireAtWillDesc".Translate(), tutorTag = "FireAtWillToggle" }); } yield break; }
internal IEnumerable <Gizmo> GetGizmos() { Command_Toggle command_Toggle = new Command_Toggle(); command_Toggle.hotKey = KeyBindingDefOf.Command_ColonistDraft; command_Toggle.isActive = (() => Drafted); command_Toggle.toggleAction = delegate { Drafted = !Drafted; PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Drafting, KnowledgeAmount.SpecificInteraction); if (Drafted) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.QueueOrders, OpportunityType.GoodToKnow); } }; command_Toggle.defaultDesc = "CommandToggleDraftDesc".Translate(); command_Toggle.icon = TexCommand.Draft; command_Toggle.turnOnSound = SoundDefOf.DraftOn; command_Toggle.turnOffSound = SoundDefOf.DraftOff; if (!Drafted) { command_Toggle.defaultLabel = "CommandDraftLabel".Translate(); } if (pawn.Downed) { command_Toggle.Disable("IsIncapped".Translate(pawn.LabelShort, pawn)); } if (!Drafted) { command_Toggle.tutorTag = "Draft"; } else { command_Toggle.tutorTag = "Undraft"; } yield return(command_Toggle); if (Drafted && pawn.equipment.Primary != null && pawn.equipment.Primary.def.IsRangedWeapon) { Command_Toggle command_Toggle2 = new Command_Toggle(); command_Toggle2.hotKey = KeyBindingDefOf.Misc6; command_Toggle2.isActive = (() => FireAtWill); command_Toggle2.toggleAction = delegate { FireAtWill = !FireAtWill; }; command_Toggle2.icon = TexCommand.FireAtWill; command_Toggle2.defaultLabel = "CommandFireAtWillLabel".Translate(); command_Toggle2.defaultDesc = "CommandFireAtWillDesc".Translate(); command_Toggle2.tutorTag = "FireAtWillToggle"; yield return(command_Toggle2); } }
public IEnumerable <Gizmo> GetGizmos() { if (pawn.Drafted) { int count = 0; bool anyCanRelease = false; foreach (Pawn item in PawnUtility.SpawnedMasteredPawns(pawn)) { if (item.training.HasLearned(TrainableDefOf.Release)) { anyCanRelease = true; if (ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(item)) { count++; } } } if (anyCanRelease) { Command_Toggle c = new Command_Toggle { defaultLabel = "CommandReleaseAnimalsLabel".Translate() + ((count == 0) ? string.Empty : (" (" + count + ")")), defaultDesc = "CommandReleaseAnimalsDesc".Translate(), icon = TexCommand.ReleaseAnimals, hotKey = KeyBindingDefOf.Misc7, isActive = (() => ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_016b: stateMachine*/)._0024this.animalsReleased), toggleAction = delegate { ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0182: stateMachine*/)._0024this.animalsReleased = !((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0182: stateMachine*/)._0024this.animalsReleased; if (((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0182: stateMachine*/)._0024this.animalsReleased) { foreach (Pawn item2 in PawnUtility.SpawnedMasteredPawns(((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0182: stateMachine*/)._0024this.pawn)) { if (item2.caller != null) { item2.caller.Notify_Released(); } item2.jobs.EndCurrentJob(JobCondition.InterruptForced); } } } }; if (count == 0) { c.Disable("CommandReleaseAnimalsFail_NoAnimals".Translate()); } yield return((Gizmo)c); /*Error: Unable to find new state assignment for yield return*/; } } }
public IEnumerable <Gizmo> GetGizmos() { if (!pawn.Drafted) { yield break; } int num = 0; bool flag = false; foreach (Pawn item in PawnUtility.SpawnedMasteredPawns(pawn)) { if (item.training.HasLearned(TrainableDefOf.Release)) { flag = true; if (ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(item)) { num++; } } } if (!flag) { yield break; } Command_Toggle command_Toggle = new Command_Toggle(); command_Toggle.defaultLabel = "CommandReleaseAnimalsLabel".Translate() + ((num != 0) ? (" (" + num + ")") : ""); command_Toggle.defaultDesc = "CommandReleaseAnimalsDesc".Translate(); command_Toggle.icon = TexCommand.ReleaseAnimals; command_Toggle.hotKey = KeyBindingDefOf.Misc7; command_Toggle.isActive = () => animalsReleased; command_Toggle.toggleAction = delegate { animalsReleased = !animalsReleased; if (animalsReleased) { foreach (Pawn item2 in PawnUtility.SpawnedMasteredPawns(pawn)) { if (item2.caller != null) { item2.caller.Notify_Released(); } item2.jobs.EndCurrentJob(JobCondition.InterruptForced); } } }; if (num == 0) { command_Toggle.Disable("CommandReleaseAnimalsFail_NoAnimals".Translate()); } yield return(command_Toggle); }
private static void DisableCommandIfMechanoidPowerLow(Pawn_DraftController __instance, Command_Toggle toggleCommand) { Need_Power powerNeed = __instance.pawn.needs.TryGetNeed(WTH_DefOf.WTH_Mechanoid_Power) as Need_Power; ExtendedDataStorage store = Base.Instance.GetExtendedDataStorage(); if (powerNeed != null && store != null) { ExtendedPawnData pawnData = store.GetExtendedDataFor(__instance.pawn); if (pawnData.shouldAutoRecharge && powerNeed.CurCategory >= PowerCategory.LowPower) { toggleCommand.Disable("WTH_Reason_PowerLow".Translate()); } } }
public IEnumerable <Gizmo> GetGizmos() { if (this.pawn.Drafted) { int count = 0; bool anyCanRelease = false; foreach (Pawn pawn in PawnUtility.SpawnedMasteredPawns(this.pawn)) { if (pawn.training.HasLearned(TrainableDefOf.Release)) { anyCanRelease = true; if (ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn)) { count++; } } } if (anyCanRelease) { Command_Toggle c = new Command_Toggle(); c.defaultLabel = "CommandReleaseAnimalsLabel".Translate() + ((count == 0) ? string.Empty : (" (" + count + ")")); c.defaultDesc = "CommandReleaseAnimalsDesc".Translate(); c.icon = TexCommand.ReleaseAnimals; c.hotKey = KeyBindingDefOf.Misc7; c.isActive = (() => this.animalsReleased); c.toggleAction = delegate() { this.animalsReleased = !this.animalsReleased; if (this.animalsReleased) { foreach (Pawn pawn2 in PawnUtility.SpawnedMasteredPawns(this.pawn)) { if (pawn2.caller != null) { pawn2.caller.Notify_Released(); } pawn2.jobs.EndCurrentJob(JobCondition.InterruptForced, true); } } }; if (count == 0) { c.Disable("CommandReleaseAnimalsFail_NoAnimals".Translate()); } yield return(c); } } yield break; }
public override IEnumerable <Gizmo> CompGetGizmos() { Command_Toggle painstopper = new Command_Toggle { isActive = (() => this.Painstopper), toggleAction = delegate() { this.Painstopper = !this.Painstopper; }, defaultLabel = this.Props.label, defaultDesc = this.Props.description.CapitalizeFirst(), icon = MSE_VanillaExtender.GetIcon(base.Pawn.GetUniqueLoadID() + "_" + this.parent.GetUniqueLoadID(), this.Props.uiIconPath) }; if (base.Pawn.Faction != Faction.OfPlayer) { painstopper.Disable("CannotOrderNonControlled".Translate()); } if (base.Pawn.Downed) { painstopper.Disable("IsIncapped".Translate(base.Pawn.LabelShort, base.Pawn)); } yield return(painstopper); }
public override IEnumerable <Gizmo> GetGizmos() { using (IEnumerator <Gizmo> enumerator = base.GetGizmos().GetEnumerator()) { if (enumerator.MoveNext()) { Gizmo g = enumerator.Current; yield return(g); /*Error: Unable to find new state assignment for yield return*/; } } if (!base.def.building.bed_humanlike) { yield break; } if (base.Faction != Faction.OfPlayer) { yield break; } Command_Toggle pris = new Command_Toggle { defaultLabel = "CommandBedSetForPrisonersLabel".Translate(), defaultDesc = "CommandBedSetForPrisonersDesc".Translate(), icon = ContentFinder <Texture2D> .Get("UI/Commands/ForPrisoners", true), isActive = this.get_ForPrisoners, toggleAction = delegate { ((_003CGetGizmos_003Ec__Iterator1) /*Error near IL_0158: stateMachine*/)._0024this.ToggleForPrisonersByInterface(); } }; if (!Building_Bed.RoomCanBePrisonCell(this.GetRoom(RegionType.Set_Passable)) && !this.ForPrisoners) { pris.Disable("CommandBedSetForPrisonersFailOutdoors".Translate()); } pris.hotKey = KeyBindingDefOf.Misc3; pris.turnOffSound = null; pris.turnOnSound = null; yield return((Gizmo)pris); /*Error: Unable to find new state assignment for yield return*/; IL_0355: /*Error near IL_0356: Unexpected return in MoveNext()*/; }
internal IEnumerable <Gizmo> GetGizmos() { Command_Toggle draft = new Command_Toggle { hotKey = KeyBindingDefOf.Command_ColonistDraft, isActive = this.get_Drafted, toggleAction = delegate { ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0062: stateMachine*/)._0024this.Drafted = !((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0062: stateMachine*/)._0024this.Drafted; PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Drafting, KnowledgeAmount.SpecificInteraction); if (((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0062: stateMachine*/)._0024this.Drafted) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.QueueOrders, OpportunityType.GoodToKnow); } }, defaultDesc = "CommandToggleDraftDesc".Translate(), icon = TexCommand.Draft, turnOnSound = SoundDefOf.DraftOn, turnOffSound = SoundDefOf.DraftOff }; if (!Drafted) { draft.defaultLabel = "CommandDraftLabel".Translate(); } if (pawn.Downed) { draft.Disable("IsIncapped".Translate(pawn.LabelShort, pawn)); } if (!Drafted) { draft.tutorTag = "Draft"; } else { draft.tutorTag = "Undraft"; } yield return((Gizmo)draft); /*Error: Unable to find new state assignment for yield return*/; }
public override IEnumerable <Gizmo> GetGizmos() { foreach (Gizmo gizmo in base.GetGizmos()) { yield return(gizmo); } if (def.building.bed_humanlike && base.Faction == Faction.OfPlayer) { Command_Toggle command_Toggle = new Command_Toggle(); command_Toggle.defaultLabel = "CommandBedSetForPrisonersLabel".Translate(); command_Toggle.defaultDesc = "CommandBedSetForPrisonersDesc".Translate(); command_Toggle.icon = ContentFinder <Texture2D> .Get("UI/Commands/ForPrisoners"); command_Toggle.isActive = () => ForPrisoners; command_Toggle.toggleAction = delegate { ToggleForPrisonersByInterface(); }; if (!RoomCanBePrisonCell(this.GetRoom()) && !ForPrisoners) { command_Toggle.Disable("CommandBedSetForPrisonersFailOutdoors".Translate()); } command_Toggle.hotKey = KeyBindingDefOf.Misc3; command_Toggle.turnOffSound = null; command_Toggle.turnOnSound = null; yield return(command_Toggle); Command_Toggle command_Toggle2 = new Command_Toggle(); command_Toggle2.defaultLabel = "CommandBedSetAsMedicalLabel".Translate(); command_Toggle2.defaultDesc = "CommandBedSetAsMedicalDesc".Translate(); command_Toggle2.icon = ContentFinder <Texture2D> .Get("UI/Commands/AsMedical"); command_Toggle2.isActive = () => Medical; command_Toggle2.toggleAction = delegate { Medical = !Medical; }; command_Toggle2.hotKey = KeyBindingDefOf.Misc2; yield return(command_Toggle2); } }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: draft = new Command_Toggle(); draft.hotKey = KeyBindingDefOf.Command_ColonistDraft; draft.isActive = new Func <bool>(base.get_Drafted); draft.toggleAction = delegate() { base.Drafted = !base.Drafted; PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Drafting, KnowledgeAmount.SpecificInteraction); if (base.Drafted) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.QueueOrders, OpportunityType.GoodToKnow); } }; draft.defaultDesc = "CommandToggleDraftDesc".Translate(); draft.icon = TexCommand.Draft; draft.turnOnSound = SoundDefOf.DraftOn; draft.turnOffSound = SoundDefOf.DraftOff; if (!base.Drafted) { draft.defaultLabel = "CommandDraftLabel".Translate(); } if (this.pawn.Downed) { draft.Disable("IsIncapped".Translate(new object[] { this.pawn.LabelShort })); } if (!base.Drafted) { draft.tutorTag = "Draft"; } else { draft.tutorTag = "Undraft"; } this.$current = draft; if (!this.$disposing) { this.$PC = 1; } return(true); case 1u: if (base.Drafted && this.pawn.equipment.Primary != null && this.pawn.equipment.Primary.def.IsRangedWeapon) { Command_Toggle toggleFireAtWill = new Command_Toggle(); toggleFireAtWill.hotKey = KeyBindingDefOf.Misc6; toggleFireAtWill.isActive = new Func <bool>(base.get_FireAtWill); toggleFireAtWill.toggleAction = delegate() { base.FireAtWill = !base.FireAtWill; }; toggleFireAtWill.icon = TexCommand.FireAtWill; toggleFireAtWill.defaultLabel = "CommandFireAtWillLabel".Translate(); toggleFireAtWill.defaultDesc = "CommandFireAtWillDesc".Translate(); toggleFireAtWill.tutorTag = "FireAtWillToggle"; this.$current = toggleFireAtWill; if (!this.$disposing) { this.$PC = 2; } return(true); } break; case 2u: break; default: return(false); } this.$PC = -1; return(false); }
private static void Postfix(ref Pawn __instance, ref IEnumerable <Gizmo> __result) { var output = __result.ToList(); if (__result == null || __instance?.Faction == null || !output.Any() || !(__instance.Map.Parent is WorldSettlementFC)) { return; } var found = __instance; var pawnDraftController = __instance.drafter ?? new Pawn_DraftController(__instance); var settlementFc = (WorldSettlementFC)__instance.Map.Parent; if (__instance.Faction.Equals(FactionColonies.getPlayerColonyFaction())) { var draftColonists = new Command_Toggle { hotKey = KeyBindingDefOf.Command_ColonistDraft, isActive = () => false, toggleAction = () => { if (pawnDraftController.pawn.Faction.Equals(Faction.OfPlayer)) { return; } pawnDraftController.pawn.SetFaction(Faction.OfPlayer); pawnDraftController.Drafted = true; }, defaultDesc = "CommandToggleDraftDesc".Translate(), icon = TexCommand.Draft, turnOnSound = SoundDefOf.DraftOn, groupKey = 81729172, defaultLabel = "CommandDraftLabel".Translate() }; if (pawnDraftController.pawn.Downed) { draftColonists.Disable("IsIncapped".Translate( (NamedArgument)pawnDraftController.pawn.LabelShort, (NamedArgument)pawnDraftController.pawn)); } draftColonists.tutorTag = "Draft"; output.Add(draftColonists); } else if (__instance.Faction.Equals(Faction.OfPlayer) && __instance.Drafted && !settlementFc.supporting.Any(caravan => caravan.pawns.Any(pawn => pawn.Equals(found)))) { foreach (Command_Toggle action in output.Where(gizmo => gizmo is Command_Toggle)) { if (action.hotKey != KeyBindingDefOf.Command_ColonistDraft) { continue; } var index = output.IndexOf(action); action.toggleAction = () => { found.SetFaction(FactionColonies.getPlayerColonyFaction()); //settlementFc.worldSettlement.defenderLord.AddPawn(__instance); }; output[index] = action; break; } } __result = output; }
// RimWorld.Building_Grave //public override Graphic Graphic public override IEnumerable <Gizmo> GetGizmos() { if (this.AllComps != null) { for (int i = 0; i < AllComps.Count; i++) { foreach (Gizmo item in AllComps[i].CompGetGizmosExtra()) { yield return(item); } } } if (((def.BuildableByPlayer && def.passability != Traversability.Impassable && !def.IsDoor) || def.building.forceShowRoomStats) && Gizmo_RoomStats.GetRoomToShowStatsFor(this) != null && Find.Selector.SingleSelectedObject == this) { yield return(new Gizmo_RoomStats(this)); } if (def.Minifiable && base.Faction == Faction.OfPlayer) { yield return(InstallationDesignatorDatabase.DesignatorFor(def)); } Command command = BuildCopyCommandUtility.BuildCopyCommand(def, base.Stuff); if (command != null) { yield return(command); } if (base.Faction == Faction.OfPlayer) { foreach (Command item in BuildFacilityCommandUtility.BuildFacilityCommands(def)) { yield return(item); } } var p = Corpse?.InnerPawn ?? (Pawn)(innerContainer.FirstOrDefault()) ?? null; if ((p?.IsVampire() ?? false) || (p?.HasVampireHediffs() ?? false)) { foreach (Gizmo y in HarmonyPatches.GraveGizmoGetter(p, this)) { yield return(y); } } if (this.GetComps <CompVampBed>().FirstOrDefault() is CompVampBed vbed) { if (vbed.Bed != null) { if (vbed.Bed.def.building.bed_humanlike && base.Faction == Faction.OfPlayer) { Command_Toggle command_Toggle0 = new Command_Toggle(); command_Toggle0.defaultLabel = "ROMV_VampiresOnly".Translate(); command_Toggle0.defaultDesc = "ROMV_VampiresOnlyDesc".Translate(); command_Toggle0.icon = TexButton.ROMV_VampiresOnly; command_Toggle0.isActive = (() => vbed.VampiresOnly); command_Toggle0.toggleAction = delegate { vbed.VampiresOnly = !vbed.VampiresOnly; }; command_Toggle0.hotKey = KeyBindingDefOf.Misc2; yield return(command_Toggle0); Command_Toggle command_Toggle = new Command_Toggle(); command_Toggle.defaultLabel = "CommandBedSetForPrisonersLabel".Translate(); command_Toggle.defaultDesc = "CommandBedSetForPrisonersDesc".Translate(); command_Toggle.icon = ContentFinder <Texture2D> .Get("UI/Commands/ForPrisoners"); command_Toggle.isActive = (() => vbed.Bed.ForPrisoners); command_Toggle.toggleAction = delegate { AccessTools.Method(typeof(Building_Bed), "ToggleForPrisonersByInterface").Invoke(vbed.Bed, null); }; if (!((bool)(AccessTools.Method(typeof(Building_Bed), "RoomCanBePrisonCell").Invoke(vbed.Bed, new object[] { this.GetRoom() }))) && !vbed.Bed.ForPrisoners) { command_Toggle.Disable("CommandBedSetForPrisonersFailOutdoors".Translate()); } command_Toggle.hotKey = KeyBindingDefOf.Misc3; command_Toggle.turnOffSound = null; command_Toggle.turnOnSound = null; yield return(command_Toggle); Command_Toggle command_Toggle2 = new Command_Toggle(); command_Toggle2.defaultLabel = "CommandBedSetAsMedicalLabel".Translate(); command_Toggle2.defaultDesc = "CommandBedSetAsMedicalDesc".Translate(); command_Toggle2.icon = ContentFinder <Texture2D> .Get("UI/Commands/AsMedical"); command_Toggle2.isActive = (() => vbed.Bed.Medical); command_Toggle2.toggleAction = delegate { vbed.Bed.Medical = !vbed.Bed.Medical; }; command_Toggle2.hotKey = KeyBindingDefOf.Misc2; yield return(command_Toggle2); if (!vbed.Bed.ForPrisoners && !vbed.Bed.Medical) { Command_Action command_Action = new Command_Action(); command_Action.defaultLabel = "CommandThingSetOwnerLabel".Translate(); command_Action.icon = ContentFinder <Texture2D> .Get("UI/Commands/AssignOwner"); command_Action.defaultDesc = "CommandBedSetOwnerDesc".Translate(); command_Action.action = delegate { Find.WindowStack.Add(new Dialog_AssignBuildingOwner(vbed.Bed.CompAssignableToPawn)); }; command_Action.hotKey = KeyBindingDefOf.Misc3; yield return(command_Action); } } } } }