//
        // Methods
        //
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            var slave = (Pawn)t;

            if (pawn == slave)
            {
                return(null);
            }

            if (!SlaveUtility.IsPawnColonySlave(slave) || !pawn.CanReserve(slave) || SlaveUtility.GetEnslavedHediff(slave).shackledGoal == SlaveUtility.GetEnslavedHediff(slave).shackled || slave.InAggroMentalState)
            {
                return(null);
            }
            return(JobMaker.MakeJob(SS_JobDefOf.ShackleSlave, slave));
        }
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            Hediff_Enslaved hediff = SlaveUtility.GetEnslavedHediff(pawn);

            Text.Anchor = TextAnchor.MiddleCenter;
            if (hediff.SlaveWillpower == 0)
            {
                Widgets.Label(rect, "broken".Translate());
            }
            else
            {
                Widgets.Label(rect, GenText.ToStringPercent(hediff.SlaveWillpower));
            }
            Text.Anchor = TextAnchor.UpperLeft;
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(TargetIndex.A);
            this.FailOn(() => !SlaveUtility.IsPawnColonySlave(Victim));
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_General.WaitWith(TargetIndex.A, shackleDuration, true));

            yield return(new Toil {
                initAction = delegate {
                    SlaveUtility.GetEnslavedHediff(Victim).shackled = SlaveUtility.GetEnslavedHediff(Victim).shackledGoal;
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });
        }
 protected override bool GetValue(Pawn pawn)
 {
     return(SlaveUtility.GetEnslavedHediff(pawn).shackledGoal);
 }
 protected override void SetValue(Pawn pawn, bool value)
 {
     SlaveUtility.GetEnslavedHediff(pawn).shackledGoal = value;
 }
Beispiel #6
0
        //[DebuggerHidden]
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(TargetIndex.A);
            this.FailOnDestroyedOrNull(TargetIndex.B);
            this.FailOnForbidden(TargetIndex.B);
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            yield return(Toils_Reserve.Reserve(TargetIndex.B));

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.Touch));

            yield return(new Toil {
                initAction = delegate {
                    pawn.jobs.curJob.count = 1;
                }
            });

            yield return(Toils_Haul.StartCarryThing(TargetIndex.B));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_General.WaitWith(TargetIndex.A, enslaveDuration, true));

            yield return(new Toil {
                initAction = delegate {
                    Thing slaveCollar = null;
                    pawn.carryTracker.TryDropCarriedThing(pawn.PositionHeld, ThingPlaceMode.Direct, out slaveCollar, null);
                    if (slaveCollar != null)
                    {
                        var collar = (Apparel)slaveCollar;
                        // Do enslave attempt
                        bool success = true;

                        if (!Victim.jobs.curDriver.asleep &&
                            !Victim.story.traits.HasTrait(TraitDef.Named("Wimp")) &&
                            !Victim.InMentalState &&
                            !Victim.Downed
                            )
                        {
                            if (Victim.story.traits.HasTrait(TraitDefOf.Nerves) &&
                                (Victim.story.traits.GetTrait(TraitDefOf.Nerves).Degree == -2 && Rand.Value > 0.66f) ||
                                Victim.needs.mood.CurInstantLevelPercentage < Rand.Range(0f, 0.33f)
                                )
                            {
                                success = false;
                            }
                        }
                        if (success)
                        {
                            Log.Message("Enslaved " + Victim.Name.ToStringShort);                             //Z- NameStringShort -> Name.ToStringShort
                            SlaveUtility.EnslavePawn(Victim, collar);
                            if (slaveCollar.Stuff.stuffProps.categories.Contains(StuffCategoryDefOf.Metallic) && !Victim.health.hediffSet.HasHediff(SS_HediffDefOf.SlaveMemory))
                            {
                                SlaveUtility.GetEnslavedHediff(Victim).TakeWillpowerHit(1.5f);
                            }
                            Messages.Message("EnslavedPrisonerSuccess".Translate(pawn.Name.ToStringShort, Victim.Name.ToStringShort), MessageTypeDefOf.PositiveEvent);                             //Z- NameStringShort -> Name.ToStringShort
                            AddEndCondition(() => JobCondition.Succeeded);
                        }
                        else
                        {
                            Victim.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk, "ReasonFailedEnslave".Translate(pawn.Name.ToStringShort, Victim.Name.ToStringShort));                             //Z- NameStringShort -> Name.ToStringShort
                            AddEndCondition(() => JobCondition.Incompletable);
                        }
                    }
                    else
                    {
                        AddEndCondition(() => JobCondition.Incompletable);
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });
        }
 protected override bool GetValue(Pawn pawn)
 {
     return(SlaveUtility.GetEnslavedHediff(pawn).toBeFreed);
 }
 protected override void SetValue(Pawn pawn, bool value)
 {
     SlaveUtility.GetEnslavedHediff(pawn).toBeFreed = value;
 }
 public override int Compare(Pawn a, Pawn b)
 {
     return(SlaveUtility.GetEnslavedHediff(a).SlaveWillpower.CompareTo(SlaveUtility.GetEnslavedHediff(b).SlaveWillpower));
 }