private Building_Grave FindBestGrave(Pawn p, Corpse corpse)
        {
            Predicate <Thing> predicate = delegate(Thing m)
            {
                if (!m.IsForbidden(p) && p.CanReserveNew(m))
                {
                    if (!((Building_Grave)m).Accepts(corpse))
                    {
                        return(false);
                    }
                    return(true);
                }
                return(false);
            };

            if (corpse.InnerPawn.ownership != null && corpse.InnerPawn.ownership.AssignedGrave != null)
            {
                Building_Grave assignedGrave = corpse.InnerPawn.ownership.AssignedGrave;
                if (predicate(assignedGrave) && p.Map.reachability.CanReach(corpse.Position, assignedGrave, PathEndMode.ClosestTouch, TraverseParms.For(p, Danger.Deadly, TraverseMode.ByPawn, false)))
                {
                    return(assignedGrave);
                }
            }
            Func <Thing, float> priorityGetter = (Thing t) => (float)(int)((IStoreSettingsParent)t).GetStoreSettings().Priority;
            IntVec3             position       = corpse.Position;
            Map               map            = corpse.Map;
            List <Thing>      searchSet      = corpse.Map.listerThings.ThingsInGroup(ThingRequestGroup.Grave);
            PathEndMode       peMode         = PathEndMode.ClosestTouch;
            TraverseParms     traverseParams = TraverseParms.For(p, Danger.Deadly, TraverseMode.ByPawn, false);
            Predicate <Thing> validator      = predicate;

            return((Building_Grave)GenClosest.ClosestThing_Global_Reachable(position, map, searchSet, peMode, traverseParams, 9999f, validator, priorityGetter));
        }
示例#2
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            MentalState_CorpseObsession mentalState_CorpseObsession = pawn.MentalState as MentalState_CorpseObsession;

            if (mentalState_CorpseObsession == null || mentalState_CorpseObsession.corpse == null || mentalState_CorpseObsession.alreadyHauledCorpse)
            {
                return(null);
            }
            Corpse         corpse         = mentalState_CorpseObsession.corpse;
            Building_Grave building_Grave = mentalState_CorpseObsession.corpse.ParentHolder as Building_Grave;

            if (building_Grave != null)
            {
                if (!pawn.CanReserveAndReach(building_Grave, PathEndMode.InteractionCell, Danger.Deadly))
                {
                    return(null);
                }
            }
            else if (!pawn.CanReserveAndReach(corpse, PathEndMode.Touch, Danger.Deadly))
            {
                return(null);
            }
            Job job = JobMaker.MakeJob(JobDefOf.HaulCorpseToPublicPlace, corpse, building_Grave);

            job.count = 1;
            return(job);
        }
示例#3
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            MentalState_CorpseObsession mentalState_CorpseObsession = pawn.MentalState as MentalState_CorpseObsession;
            Job result;

            if (mentalState_CorpseObsession == null || mentalState_CorpseObsession.corpse == null)
            {
                result = null;
            }
            else
            {
                Corpse         corpse         = mentalState_CorpseObsession.corpse;
                Building_Grave building_Grave = mentalState_CorpseObsession.corpse.ParentHolder as Building_Grave;
                if (building_Grave != null)
                {
                    if (!pawn.CanReserveAndReach(building_Grave, PathEndMode.InteractionCell, Danger.Deadly, 1, -1, null, false))
                    {
                        return(null);
                    }
                }
                else if (!pawn.CanReserveAndReach(corpse, PathEndMode.Touch, Danger.Deadly, 1, -1, null, false))
                {
                    return(null);
                }
                result = new Job(JobDefOf.HaulCorpseToPublicPlace, corpse, building_Grave)
                {
                    count = 1
                };
            }
            return(result);
        }
        public override Job TryGiveJob(Pawn pawn)
        {
            bool allowedOutside        = JoyUtility.EnjoyableOutsideNow(pawn, null);
            IEnumerable <Thing> source = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Grave).Where(delegate(Thing x)
            {
                Building_Grave building_Grave = (Building_Grave)x;
                return(x.Faction == Faction.OfPlayer && building_Grave.HasCorpse && !building_Grave.IsForbidden(pawn) && building_Grave.Corpse.InnerPawn.Faction == Faction.OfPlayer && (allowedOutside || building_Grave.Position.Roofed(building_Grave.Map)) && pawn.CanReserveAndReach(x, PathEndMode.Touch, Danger.None, 1, -1, null, false) && building_Grave.IsPoliticallyProper(pawn));
            });
            Thing t;
            Job   result;

            if (!source.TryRandomElementByWeight(delegate(Thing x)
            {
                float lengthHorizontal = (x.Position - pawn.Position).LengthHorizontal;
                return(Mathf.Max(150f - lengthHorizontal, 5f));
            }, out t))
            {
                result = null;
            }
            else
            {
                result = new Job(this.def.jobDef, t);
            }
            return(result);
        }
示例#5
0
 public override string GetExplanation(Thing parent)
 {
     if (CanApply(parent))
     {
         Building_Grave building_Grave = parent as Building_Grave;
         return("StatsReport_GraveFull".Translate(building_Grave.Corpse.InnerPawn.LabelShortCap) + ": " + GetOffset(parent).ToStringWithSign("0%"));
     }
     return(GetExplanationAbstract());
 }
        public override bool CanApply(Thing parent, Pawn user = null)
        {
            Building_Grave building_Grave = parent as Building_Grave;

            if (parent.Spawned && building_Grave != null && building_Grave.HasCorpse && building_Grave.Corpse.InnerPawn.RaceProps.Humanlike)
            {
                return(building_Grave.Corpse.InnerPawn.relations.PotentiallyRelatedPawns.Contains(user));
            }
            return(false);
        }
 public void ClaimGrave(Building_Grave newGrave)
 {
     if (newGrave.assignedPawn != this.pawn)
     {
         this.UnclaimGrave();
         if (newGrave.assignedPawn != null)
         {
             newGrave.assignedPawn.ownership.UnclaimBed();
         }
         newGrave.assignedPawn = this.pawn;
         this.AssignedGrave    = newGrave;
     }
 }
示例#8
0
 public void ClaimGrave(Building_Grave newGrave)
 {
     if (newGrave.assignedPawn != this.pawn)
     {
         this.UnclaimGrave();
         if (newGrave.assignedPawn != null)
         {
             newGrave.assignedPawn.ownership.UnclaimBed();
         }
         newGrave.assignedPawn = this.pawn;
         newGrave.GetStoreSettings().Priority = StoragePriority.Critical;
         this.AssignedGrave = newGrave;
     }
 }
示例#9
0
        public void ExposeData()
        {
            Building_Grave  refee  = AssignedGrave;
            Building_Throne refee2 = AssignedThrone;
            Building        refee3 = AssignedMeditationSpot;

            Scribe_References.Look(ref intOwnedBed, "ownedBed");
            Scribe_References.Look(ref refee3, "assignedMeditationSpot");
            Scribe_References.Look(ref refee, "assignedGrave");
            Scribe_References.Look(ref refee2, "assignedThrone");
            AssignedGrave          = refee;
            AssignedThrone         = refee2;
            AssignedMeditationSpot = refee3;
            if (Scribe.mode != LoadSaveMode.PostLoadInit)
            {
                return;
            }
            if (intOwnedBed != null)
            {
                CompAssignableToPawn compAssignableToPawn = intOwnedBed.TryGetComp <CompAssignableToPawn>();
                if (compAssignableToPawn != null && !compAssignableToPawn.AssignedPawns.Contains(pawn))
                {
                    Building_Bed newBed = intOwnedBed;
                    UnclaimBed();
                    ClaimBedIfNonMedical(newBed);
                }
            }
            if (AssignedGrave != null)
            {
                CompAssignableToPawn compAssignableToPawn2 = AssignedGrave.TryGetComp <CompAssignableToPawn>();
                if (compAssignableToPawn2 != null && !compAssignableToPawn2.AssignedPawns.Contains(pawn))
                {
                    Building_Grave assignedGrave = AssignedGrave;
                    UnclaimGrave();
                    ClaimGrave(assignedGrave);
                }
            }
            if (AssignedThrone != null)
            {
                CompAssignableToPawn compAssignableToPawn3 = AssignedThrone.TryGetComp <CompAssignableToPawn>();
                if (compAssignableToPawn3 != null && !compAssignableToPawn3.AssignedPawns.Contains(pawn))
                {
                    Building_Throne assignedThrone = AssignedThrone;
                    UnclaimThrone();
                    ClaimThrone(assignedThrone);
                }
            }
        }
示例#10
0
 public bool ClaimGrave(Building_Grave newGrave)
 {
     if (newGrave.AssignedPawn == pawn)
     {
         return(false);
     }
     UnclaimGrave();
     if (newGrave.AssignedPawn != null)
     {
         newGrave.AssignedPawn.ownership.UnclaimGrave();
     }
     newGrave.CompAssignableToPawn.ForceAddPawn(pawn);
     newGrave.GetStoreSettings().Priority = StoragePriority.Critical;
     AssignedGrave = newGrave;
     return(true);
 }
示例#11
0
 public override void Notify_PawnKilled(Pawn pawn, DamageInfo?dinfo)
 {
     if (lentColonists.Contains(pawn))
     {
         Building_Grave assignedGrave = null;
         if (pawn.ownership != null)
         {
             assignedGrave = pawn.ownership.AssignedGrave;
         }
         Corpse val = pawn.MakeCorpse(assignedGrave, inBed: false, 0f);
         lentColonists.Remove(pawn);
         Map anyPlayerHomeMap = Find.AnyPlayerHomeMap;
         if (anyPlayerHomeMap != null)
         {
             DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(anyPlayerHomeMap), anyPlayerHomeMap, Gen.YieldSingle(val), 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: true, forbid: false);
         }
     }
 }
示例#12
0
        public void ExposeData()
        {
            Building_Grave assignedGrave = this.AssignedGrave;

            Scribe_References.Look <Building_Bed>(ref this.intOwnedBed, "ownedBed", false);
            Scribe_References.Look <Building_Grave>(ref assignedGrave, "assignedGrave", false);
            this.AssignedGrave = assignedGrave;
            if (Scribe.mode == LoadSaveMode.PostLoadInit)
            {
                if (this.AssignedGrave != null)
                {
                    this.AssignedGrave.assignedPawn = this.pawn;
                }
                if (this.OwnedBed != null)
                {
                    this.OwnedBed.owners.Add(this.pawn);
                    this.OwnedBed.SortOwners();
                }
            }
        }
示例#13
0
        public void ExposeData()
        {
            Building_Grave refee = AssignedGrave;

            Scribe_References.Look(ref intOwnedBed, "ownedBed");
            Scribe_References.Look(ref refee, "assignedGrave");
            AssignedGrave = refee;
            if (Scribe.mode == LoadSaveMode.PostLoadInit)
            {
                if (AssignedGrave != null)
                {
                    AssignedGrave.assignedPawn = pawn;
                }
                if (OwnedBed != null)
                {
                    OwnedBed.owners.Add(pawn);
                    OwnedBed.SortOwners();
                }
            }
        }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Corpse corpse = t as Corpse;

            if (corpse == null)
            {
                return(null);
            }
            if (!HaulAIUtility.PawnCanAutomaticallyHaul(pawn, t, forced))
            {
                return(null);
            }
            Building_Grave building_Grave = this.FindBestGrave(pawn, corpse);

            if (building_Grave == null)
            {
                JobFailReason.Is("NoEmptyGraveLower".Translate());
                return(null);
            }
            Job job = new Job(JobDefOf.BuryCorpse, t, building_Grave);

            job.count = corpse.stackCount;
            return(job);
        }
            internal bool <> m__0(Thing x)
            {
                Building_Grave building_Grave = (Building_Grave)x;

                return(x.Faction == Faction.OfPlayer && building_Grave.HasCorpse && !building_Grave.IsForbidden(this.pawn) && building_Grave.Corpse.InnerPawn.Faction == Faction.OfPlayer && (this.allowedOutside || building_Grave.Position.Roofed(building_Grave.Map)) && this.pawn.CanReserveAndReach(x, PathEndMode.Touch, Danger.None, 1, -1, null, false) && building_Grave.IsPoliticallyProper(this.pawn));
            }