public static void Postfix(ref Thought_Memory newThought, ref Pawn otherPawn) { Pawn pawn = newThought.pawn; ThoughtDef knowColonistDied = ThoughtDefOf.KnowColonistDied; ThoughtDef thoughtToGet = SS_ThoughtDefOf.KnowSlaveDied; if (newThought.def == knowColonistDied) { // Remove colonist death thoughts if (SlaveUtility.IsPawnColonySlave(otherPawn) || (SlaveUtility.IsPawnColonySlave(pawn) && !SlaveUtility.IsPawnColonySlave(otherPawn))) { pawn.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(knowColonistDied, otherPawn); } // Add slave death thoughts if (SlaveUtility.IsPawnColonySlave(otherPawn) && pawn.MapHeld == otherPawn.MapHeld) { //string thoughtToGet = "KnowSlaveDied"; if (SlaveUtility.IsPawnColonySlave(pawn)) { thoughtToGet = SS_ThoughtDefOf.KnowFellowSlaveDied; } pawn.needs.mood.thoughts.memories.TryGainMemory(thoughtToGet, otherPawn); } } }
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 ShouldShowRestraintsInfo_Patch(ref Pawn pawn, ref bool __result) { if (RestraintsUtility.InRestraints(pawn) && SlaveUtility.IsPawnColonySlave(pawn)) { __result = true; } }
public static void BestKindLabel_Patch(ref string __result, ref Pawn pawn, ref bool mustNoteGender) { if (mustNoteGender && pawn.gender != Gender.None && SlaveUtility.IsPawnColonySlave(pawn)) { __result = "PawnMainDescGendered".Translate(pawn.Named("PAWN"), "LabelWordSlave".Translate()); //Z- ( new object[] { pawn.gender.GetLabel() ->(pawn.Named("PAWN") } }
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; } }
public static void TryGiveJob_Patch(ref Pawn pawn, ref Job __result) { if (__result == null) { return; } if ((SlaveUtility.IsPawnColonySlave(pawn) && __result.targetA.Thing != null && SlaveUtility.IsSlaveCollar(__result.targetA.Thing as Apparel) && SlaveUtility.HasSlaveCollar(pawn)) || (!SlaveUtility.IsPawnColonySlave(pawn) && pawn.IsColonist && __result.targetA.Thing != null && SlaveUtility.IsSlaveCollar(__result.targetA.Thing as Apparel))) { __result = null; } }
protected override ThoughtState CurrentStateInternal(Pawn p) { Pawn pawn = p; if (pawn.story.traits.HasTrait(TraitDef.Named("Kind")) && pawn.Map.mapPawns.FreeColonistsAndPrisonersSpawned.ToList().Find( x => SlaveUtility.IsPawnColonySlave(x) && x.Faction == pawn.Faction) != null) { return(ThoughtState.ActiveDefault); } return(ThoughtState.Inactive); }
public override void ExposeData() { base.ExposeData(); Scribe_Values.Look <float>(ref savedWillpower, "savedWillpower"); Scribe_Collections.Look <WorkTypeDef, int>(ref savedWorkPriorities, "savedWorkPriorities"); Scribe_References.Look <Area>(ref savedRestrictedArea, "savedRestrictedArea"); Scribe_Values.Look <sbyte>(ref savedMedicalCare, "savedMedicalCare"); Scribe_Values.Look(ref wasColonySlave, "wasColonySlave"); if (pawn != null && SlaveUtility.IsPawnColonySlave(pawn)) { wasColonySlave = true; } }
protected override ThoughtState CurrentStateInternal(Pawn p) { Pawn pawn = p; if (SlaveUtility.HasSlaveCollar(pawn) && SlaveUtility.GetSlaveCollar(pawn).def.thingClass == typeof(SlaveCollar_Explosive)) { if ((SlaveUtility.GetSlaveCollar(pawn) as SlaveCollar_Explosive).armed) { return(ThoughtState.ActiveAtStage(1)); } return(SlaveUtility.IsPawnColonySlave(pawn) ? ThoughtState.ActiveAtStage(0) : ThoughtState.ActiveAtStage(2)); } return(ThoughtState.Inactive); }
static IEnumerable <Pawn> sellableSlaves(Map map, IEnumerable <Pawn> previous) { foreach (Pawn pawn in map.mapPawns.FreeColonistsSpawned) { if (SlaveUtility.IsPawnColonySlave(pawn) && !previous.Contains(pawn)) { yield return(pawn); } } foreach (Pawn pawn in previous) { yield return(pawn); } }
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 Beaten(Pawn __instance, ref DamageInfo dinfo) { // Check if the pawn is enslaved if (SlaveUtility.IsPawnColonySlave(__instance)) { Hediff_Enslaved enslaved_def = (Hediff_Enslaved)__instance.health.hediffSet.GetFirstHediffOfDef(SS_HediffDefOf.Enslaved); // Is the beating coming from the faction owning the slave? if (dinfo.Instigator != null) { if (dinfo.Instigator.Faction == enslaved_def.slaverFaction) { enslaved_def.TakeWillpowerHit(dinfo.Amount / 100f); } } } }
public static void IsVisible_Patch(ref ITab_Pawn_Prisoner __instance, ref bool __result) { var pawn = Find.Selector.SingleSelectedThing; if (pawn == null || pawn.GetType() != typeof(Pawn)) { return; } if (__result == true) { if (SlaveUtility.IsPawnColonySlave(pawn as Pawn)) { __result = false; } } }
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 } }
static IEnumerable <Thing> sellableThingsAndSlaves(Pawn playerNegotiator, IEnumerable <Thing> previous) { foreach (Thing thing in previous) { yield return(thing); } Caravan caravan = playerNegotiator.GetCaravan(); List <Pawn> caravanPawns = caravan.PawnsListForReading; foreach (Pawn pawn in caravanPawns) { if (SlaveUtility.IsPawnColonySlave(pawn) && !previous.Contains(pawn)) { yield return(pawn); } } }
public static void EnslavePawn(Pawn pawn, Apparel collar = null) { if (pawn == null) { Log.Error("[SimpleSlavery] Error: Tried to enslave null pawn."); return; } if (!pawn.RaceProps.Humanlike) { Log.Error("[SimpleSlavery] Error: Tried to enslave a non-humanlike pawn."); return; } if (!SlaveUtility.IsPawnColonySlave(pawn)) { SlaveUtility.GiveSlaveCollar(pawn, collar); pawn.health.AddHediff(SS_HediffDefOf.Enslaved); } }
public static bool DoesMapHaveSlaves(Map map) { if (map == null) { return(false); } bool slaveExists = false; foreach (Pawn pawn in map.mapPawns.FreeColonists) { if (SlaveUtility.IsPawnColonySlave(pawn)) { slaveExists = true; break; } } return(slaveExists); }
public static List <Pawn> ClearOutSlavesFromColonistBar(List <Pawn> pawns) { if (SimpleSlavery.ShowSlavesInColonistBar) { return(pawns); } var newList = new List <Pawn> { }; foreach (Pawn pawn in pawns) { if (!SlaveUtility.IsPawnColonySlave(pawn)) { newList.Add(pawn); } } return(newList); }
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); } } } } }
public static void RenderPortrait_Patch(ref PawnRenderer __instance) { Pawn pawn = __instance.graphics.pawn; if (!SlaveUtility.IsPawnColonySlave(pawn)) { return; } Apparel collar = pawn.apparel.WornApparel.Find(SlaveUtility.IsSlaveCollar); var chainColour = new Color(0.5f, 0.5f, 0.5f, 0.5f); if (collar != null) { chainColour = collar.DrawColor; } Mesh mesh = MeshPool.humanlikeHeadSet.MeshAt(Rot4.South); Material mat = GraphicDatabase.Get <Graphic_Single>("Things/Pawn/Humanlike/Apparel/SlaveCollar/Chain", ShaderDatabase.CutoutComplex, new Vector2(1, 1), chainColour).MatAt(Rot4.South); mat.mainTexture.wrapMode = TextureWrapMode.Clamp; mat.mainTextureScale = new Vector2(1.75f, 1.75f); mat.mainTextureOffset = new Vector2(-0.37f, -0.10f); GenDraw.DrawMeshNowOrLater(mesh, new Vector3(0, 0.85f, 0), Quaternion.identity, mat, true); }