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;
            }
        }
Beispiel #2
0
 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
     }
 }
Beispiel #3
0
        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);
                        }
                    }
                }
            }
        }