protected override ThoughtState CurrentStateInternal(Pawn p) { if (p.health.hediffSet.HasHediff(HediffDef.Named("Enslaved"))) { Hediff_Enslaved enslaved_def = SlaveUtility.GetEnslavedHediff(p); if (enslaved_def.ageTicks < 2500 * 3.5f && enslaved_def.SlaveWillpower > 0) // Gets some flavour text just after being enslaved { return(ThoughtState.ActiveAtStage(0)); } if (enslaved_def.SlaveWillpower > 75) { return(ThoughtState.ActiveAtStage(1)); } else if (enslaved_def.SlaveWillpower > 50) { return(ThoughtState.ActiveAtStage(2)); } else if (enslaved_def.SlaveWillpower > 25 || (enslaved_def.SlaveWillpower <= 50 && IsSteadfast(p))) { return(ThoughtState.ActiveAtStage(3)); } else if (Math.Round(enslaved_def.SlaveWillpower) <= 1) { return(ThoughtState.ActiveAtStage(4)); } } return(ThoughtState.Inactive); }
public void SaveMemory() { if (pawn.workSettings == null) // Caused by an issue in Prison Labor, see https://github.com/Aviuz/PrisonLabor/issues/137 { pawn.workSettings = new Pawn_WorkSettings(pawn); pawn.workSettings.EnableAndInitialize(); } foreach (WorkTypeDef work in DefDatabase <WorkTypeDef> .AllDefs) { if (!savedWorkPriorities.ContainsKey(work)) { savedWorkPriorities.Add(work, pawn.workSettings.GetPriority(work)); } else { savedWorkPriorities[work] = pawn.workSettings.GetPriority(work); } } if (pawn.playerSettings != null && pawn.playerSettings.AreaRestriction != null) { savedRestrictedArea = pawn.playerSettings.AreaRestriction; } savedMedicalCare = (sbyte)pawn.playerSettings.medCare; if (SlaveUtility.GetEnslavedHediff(pawn) != null) { savedWillpower = SlaveUtility.GetEnslavedHediff(pawn).SlaveWillpower; } }
public override IEnumerable <Gizmo> CompGetGizmosExtra() { if (parent == null) { yield break; } var pawn = parent as Pawn; if (SlaveUtility.IsPawnColonySlave(pawn)) { var hediff = SlaveUtility.GetEnslavedHediff(pawn); var freeSlave = new Command_Toggle(); freeSlave.isActive = () => hediff.toBeFreed; freeSlave.defaultLabel = "LabelWordEmancipate".Translate(); freeSlave.defaultDesc = "CommandDescriptionEmancipate".Translate(pawn.Name.ToStringShort); freeSlave.toggleAction = () => hediff.toBeFreed = !hediff.toBeFreed; freeSlave.alsoClickIfOtherInGroupClicked = true; freeSlave.activateSound = SoundDefOf.Click; freeSlave.icon = ContentFinder <Texture2D> .Get("UI/Commands/Emancipate", true); yield return(freeSlave); var shackleSlave = new Command_Toggle(); shackleSlave.isActive = () => hediff.shackledGoal; shackleSlave.defaultLabel = "LabelWordShackle".Translate(); shackleSlave.defaultDesc = "CommandDescriptionShackle".Translate(pawn.Name.ToStringShort); shackleSlave.toggleAction = () => hediff.shackledGoal = !hediff.shackledGoal; shackleSlave.alsoClickIfOtherInGroupClicked = true; shackleSlave.activateSound = SoundDefOf.Click; shackleSlave.icon = ContentFinder <Texture2D> .Get("UI/Commands/Shackle", true); yield return(shackleSlave); } }
public static void InRestraints_Patch(ref Pawn pawn, ref bool __result) { // Pawn is a shackled slave if (SlaveUtility.IsPawnColonySlave(pawn)) { __result = SlaveUtility.GetEnslavedHediff(pawn).shackled; } }
private void UpdateSlaveHediffs(Pawn pawn) { var hediff = SlaveUtility.GetEnslavedHediff(pawn); hediff?.SetWillpowerDirect(hediff.SlaveWillpower / 100f); var memoryHediff = SlaveUtility.GetSlaveMemoryHediff(pawn); if (memoryHediff != null) { memoryHediff.savedWillpower /= 100f; } }
public static float ArrestChance(Pawn pawn) { if (pawn.mindState.mentalStateHandler.CurStateDef == SS_MentalStateDefOf.CryptoStasis) { return(1f); } if (SlaveUtility.IsPawnColonySlave(pawn)) { return(1f - SlaveUtility.GetEnslavedHediff(pawn).SlaveWillpower); } else { return(0.6f); } }
public static void PreTraded_Patch(ref Pawn __instance, ref TradeAction action) { // Slave wearing a slave collar if (action == TradeAction.PlayerBuys && __instance.RaceProps.Humanlike && __instance.apparel.WornApparel.Find(SlaveUtility.IsSlaveCollar) != null) { // Add the enslaved tracker __instance.health.AddHediff(SS_HediffDefOf.Enslaved); // Set willpower to zero SlaveUtility.GetEnslavedHediff(__instance).SetWillpowerDirect(0f); // Re-force wearing of the collar so the new slave does not drop it, freeing themselves __instance.outfits.forcedHandler.SetForced(__instance.apparel.WornApparel.Find(SlaveUtility.IsSlaveCollar), true); } else if (action == TradeAction.PlayerSells && SlaveUtility.IsPawnColonySlave(__instance)) { SlaveUtility.GetSlaveMemoryHediff(__instance).wasColonySlave = false; // Make sold slaves not count as previously being controlled by the colony } }
internal static IEnumerable <Gizmo> SlaveGizmos(Pawn pawn) { var slaveMemory = SlaveUtility.GetSlaveMemoryHediff(pawn); if (slaveMemory == null || !slaveMemory.wasColonySlave) // Only display the apparel gizmos if the pawn was previously a colony slave { yield break; } if (SlaveUtility.IsPawnColonySlave(pawn)) { var hediff = SlaveUtility.GetEnslavedHediff(pawn); if (hediff.waitingInJail) { var timeout = new Command_Action(); timeout.defaultLabel = "Label_Timeout".Translate(); timeout.defaultDesc = "Desc_Timeout".Translate(); timeout.icon = ContentFinder <Texture2D> .Get("UI/Commands/DetonateCollar", true); timeout.disabled = true; yield return(timeout); } } if (pawn.apparel != null) { foreach (var apparel in pawn.apparel.WornApparel) { var slaveApparel = apparel as SlaveApparel; if (slaveApparel != null) { foreach (var g in slaveApparel.SlaveGizmos()) { yield return(g); } } } } }