public float GetFactorForHireable(Hireable hireable) { if (!deadCount.ContainsKey(hireable)) { deadCount.Add(hireable, new List <ExposablePair>()); } var pairs = deadCount[hireable]; float factor = 0; for (var i = pairs.Count - 1; i >= 0; i--) { if (Find.TickManager.TicksAbs > (int)pairs[i].value) { pairs.RemoveAt(i); } else { factor += 0.05f * (int)pairs[i].key; } } return(factor); }
public void SetNewContract(int days, List <Pawn> pawns, Hireable hireable, HireableFactionDef faction = null, float price = 0) { endTicks = Find.TickManager.TicksAbs + days * GenDate.TicksPerDay; this.pawns = pawns; this.hireable = hireable; factionDef = faction; this.price = price; }
public void EndContract() { var deadPeople = 0; for (var index = pawns.Count - 1; index >= 0; index--) { var pawn = pawns[index]; if (pawn.Dead || Faction.OfPlayer.kidnapped.KidnappedPawnsListForReading.Contains(pawn)) { deadPeople++; pawns.Remove(pawn); } else if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Moving)) { if (pawn.Map != null && pawn.CurJobDef != VFEDefOf.VFEC_LeaveMap) { pawn.jobs.StopAll(); if (!CellFinder.TryFindRandomPawnExitCell(pawn, out IntVec3 exit)) { if (!CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => !pawn.Map.roofGrid.Roofed(c) && c.WalkableBy(pawn.Map, pawn) && pawn.CanReach(c, PathEndMode.OnCell, Danger.Deadly, canBashDoors: true, canBashFences: true, TraverseMode.PassDoors), pawn.Map, 0f, out exit)) { this.BreakContract(); return; } } pawn.jobs.TryTakeOrderedJob(new Job(VFEDefOf.VFEC_LeaveMap, exit)); } else if (pawn.GetCaravan() != null) { pawn.GetCaravan().RemovePawn(pawn); pawns.Remove(pawn); } } } if (deadPeople > 0) { if (!deadCount.ContainsKey(hireable)) { deadCount.Add(hireable, new List <ExposablePair>()); } deadCount[hireable].Add(new ExposablePair(deadPeople, Find.TickManager.TicksAbs + GenDate.TicksPerYear)); } if (this.pawns.Count <= 0) { this.hireable = null; } }
public void BreakContract() { if (this.pawns.Count > 0) { if (!deadCount.ContainsKey(hireable)) { deadCount.Add(hireable, new List <ExposablePair>()); } deadCount[hireable].Add(new ExposablePair(this.pawns.Count, Find.TickManager.TicksAbs + GenDate.TicksPerYear)); foreach (Pawn pawn in this.pawns) { if (!pawn.Dead) { if (pawn.Map != null) { pawn.jobs.StopAll(); pawn.SetFaction(Faction.OfAncientsHostile); RaidStrategyDefOf.ImmediateAttack.Worker.MakeLords(new IncidentParms() { target = pawn.Map, faction = Faction.OfAncientsHostile, canTimeoutOrFlee = false }, new List <Pawn>() { pawn }); } else if (pawn.GetCaravan() != null) { pawn.GetCaravan().RemovePawn(pawn); } } } } this.hireable = null; this.pawns.Clear(); }
public override int GetHashCode() { unchecked { var hashCode = (Login != null ? Login.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Id.GetHashCode(); hashCode = (hashCode * 397) ^ (NodeId != null ? NodeId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AvatarUrl != null ? AvatarUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (GravatarId != null ? GravatarId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Url != null ? Url.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (HtmlUrl != null ? HtmlUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FollowersUrl != null ? FollowersUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FollowingUrl != null ? FollowingUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (GistsUrl != null ? GistsUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (StarredUrl != null ? StarredUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SubscriptionsUrl != null ? SubscriptionsUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OrganizationsUrl != null ? OrganizationsUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ReposUrl != null ? ReposUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (EventsUrl != null ? EventsUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ReceivedEventsUrl != null ? ReceivedEventsUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0); hashCode = (hashCode * 397) ^ SiteAdmin.GetHashCode(); hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Company != null ? Company.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Blog != null ? Blog.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Location != null ? Location.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Email != null ? Email.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Hireable != null ? Hireable.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Bio != null ? Bio.GetHashCode() : 0); hashCode = (hashCode * 397) ^ PublicRepos.GetHashCode(); hashCode = (hashCode * 397) ^ PublicGists.GetHashCode(); hashCode = (hashCode * 397) ^ Followers.GetHashCode(); hashCode = (hashCode * 397) ^ Following.GetHashCode(); hashCode = (hashCode * 397) ^ CreatedAt.GetHashCode(); hashCode = (hashCode * 397) ^ UpdatedAt.GetHashCode(); return(hashCode); } }
public override int GetHashCode() { unchecked { return((Login != null ? Login.GetHashCode() : 0) ^ (Id != null ? Id.GetHashCode() : 0) ^ (AvatarUrl != null ? AvatarUrl.GetHashCode() : 0) ^ (GravatarId != null ? GravatarId.GetHashCode() : 0) ^ (Url != null ? Url.GetHashCode() : 0) ^ (Name != null ? Name.GetHashCode() : 0) ^ (Company != null ? Company.GetHashCode() : 0) ^ (Blog != null ? Blog.GetHashCode() : 0) ^ (Location != null ? Location.GetHashCode() : 0) ^ (Email != null ? Email.GetHashCode() : 0) ^ (Hireable != null ? Hireable.GetHashCode() : 0) ^ (Bio != null ? Bio.GetHashCode() : 0) ^ (PublicRepos != null ? PublicRepos.GetHashCode() : 0) ^ (PublicGists != null ? PublicGists.GetHashCode() : 0) ^ (Followers != null ? Followers.GetHashCode() : 0) ^ (Following != null ? Following.GetHashCode() : 0) ^ (HtmlUrl != null ? HtmlUrl.GetHashCode() : 0) ^ (CreatedAt != null ? CreatedAt.GetHashCode() : 0) ^ (Type != null ? Type.GetHashCode() : 0)); } }