private void HostileDefeated() { // Killed all hostiles - Win outcome if (!GenHostility.AnyHostileActiveThreatTo(((MapParent)parent).Map, Faction.OfPlayer)) { active = false; DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(Find.AnyPlayerHomeMap), Find.AnyPlayerHomeMap, rewards, 110, false, true, true); parent.Faction.TryAffectGoodwillWith(Faction.OfPlayer, +15, false, true); if (!Find.WorldObjects.Settlements.Where(s => s.Faction == enemy && !s.Faction.def.hidden && Find.WorldReachability.CanReach(Find.AnyPlayerHomeMap.Tile, s.Tile)).TryRandomElement(out Settlement enemySet)) { Find.LetterStack.ReceiveLetter("LetterLabelOutpostdefensesuccess".Translate(), TranslatorFormattedStringExtensions.Translate("Outpostdefensesuccess", parent.Faction.leader, parent.Faction.def.leaderTitle, GenLabel.ThingsLabel(rewards, string.Empty)), EndGameDefOf.FE_JointRaid.letterDef, null, parent.Faction, null); active = false; return; } List <Thing> rewardsNew = ThingSetMakerDefOf.Reward_StandardByDropPod.root.Generate(new ThingSetMakerParams() { totalMarketValueRange = new FloatRange?(SiteTuning.BanditCampQuestRewardMarketValueRange * SiteTuning.QuestRewardMarketValueThreatPointsFactor.Evaluate(StorytellerUtility.DefaultSiteThreatPointsNow() + 500f)) }); Thing silver = ThingMaker.MakeThing(ThingDefOf.Silver); silver.stackCount = (int)FE_IncidentWorker_Jointraid.SilverBonusRewardCurve.Evaluate(parent.Faction.PlayerGoodwill); int random = new IntRange(Global.DayInTicks * 15, Global.DayInTicks * 25).RandomInRange; enemySet.GetComponent <WorldComp_JointRaid>().StartComp(random, parent.Faction, rewardsNew, silver); string text = TranslatorFormattedStringExtensions.Translate("OutpostdefensesuccessJointRaid", parent.Faction.leader, parent.Faction.def.leaderTitle, GenLabel.ThingsLabel(rewardsNew, string.Empty), random.ToStringTicksToPeriod(), GenThing.GetMarketValue(rewards).ToStringMoney(null), silver.stackCount.ToString(), GenLabel.ThingsLabel(rewards, string.Empty)).CapitalizeFirst(); GenThing.TryAppendSingleRewardInfo(ref text, rewards); Find.LetterStack.ReceiveLetter(EndGameDefOf.FE_JointRaid.letterLabel, text, EndGameDefOf.FE_JointRaid.letterDef, enemySet, parent.Faction, null); } }
public static void MakeExit(Pawn pawn) { bool flag = (pawn.mindState.duty != null && pawn.mindState.duty.canDig && !pawn.CanReachMapEdge()) || (!pawn.CanReachMapEdge()) || (pawn.Faction != null && GenHostility.AnyHostileActiveThreatTo(pawn.Map, pawn.Faction, countDormantPawnsAsHostile: true)); if (!TryFindGoodExitDest(pawn, flag, out IntVec3 dest)) { return; } if (flag) { using (PawnPath path = pawn.Map.pathFinder.FindPath(pawn.Position, dest, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings))) { IntVec3 cellBefore; Thing thing = path.FirstBlockingBuilding(out cellBefore, pawn); if (thing != null) { Job job = DigUtility.PassBlockerJob(pawn, thing, cellBefore, canMineMineables: true, canMineNonMineables: true); if (job != null) { pawn.jobs.TryTakeOrderedJob(job); return; } } } } Job job2 = JobMaker.MakeJob(JobDefOf.Goto, dest); job2.exitMapOnArrival = true; job2.locomotionUrgency = LocomotionUrgency.Jog; job2.expiryInterval = 1000; job2.canBashDoors = true; pawn.jobs.TryTakeOrderedJob(job2); }
public override void Tick() { base.Tick(); if (this.IsHashIntervalTick(THREAT_CHECK_TICKS)) { if (Settings.spawnOnlyOnThreat) { bool isThreatOnMap = ParentHolder is Map && GenHostility.AnyHostileActiveThreatTo(MapHeld, Faction) //|| Map.listerThings.ThingsOfDef(ThingDefOf.Tornado).Any() //|| Map.listerThings.ThingsOfDef(ThingDefOf.DropPodIncoming).Any() ; if (isThreatOnMap) { // only spawn all pawns when the threat is first detected if (!ThreatActive) { //cusp.SpawnPawnsUntilPoints(Settings.maxSpawnerPoints); cusp.SpawnUntilFullSpeedMultiplier = Settings.spawnOnThreatSpeedMultiplier; } ThreatActive = true; cusp.Dormant = false; } else { ThreatActive = false; cusp.Dormant = true; } } else { ThreatActive = false; cusp.Dormant = false; } } if (this.IsHashIntervalTick(THREAT_OVER_DESTROY_PAWNS_TICKS)) { if (Settings.spawnOnlyOnThreat && !ThreatActive) { cusp.RemoveAllSpawnedPawns(); } } }
public static bool TryGiveJob(JobGiver_ExitMap __instance, ref Job __result, Pawn pawn) { Pawn_MindState mindState = pawn.mindState; bool canDig = __instance.forceCanDig || (mindState != null && mindState.duty != null) && mindState.duty.canDig && !pawn.CanReachMapEdge() || __instance.forceCanDigIfCantReachMapEdge && !pawn.CanReachMapEdge() || __instance.forceCanDigIfAnyHostileActiveThreat && pawn.Faction != null && GenHostility.AnyHostileActiveThreatTo(pawn.Map, pawn.Faction, true); IntVec3 dest; if (!__instance.TryFindGoodExitDest(pawn, canDig, out dest)) { __result = null; return(false); } if (canDig) { using (PawnPath path = pawn.Map.pathFinder.FindPath(pawn.Position, (LocalTargetInfo)dest, TraverseParms.For(pawn, mode: TraverseMode.PassAllDestroyableThings))) { IntVec3 cellBefore; Thing blocker = path.FirstBlockingBuilding(out cellBefore, pawn); if (blocker != null) { Job job = DigUtility.PassBlockerJob(pawn, blocker, cellBefore, true, true); if (job != null) { __result = job; return(false); } } } } Job job1 = JobMaker.MakeJob(JobDefOf.Goto, (LocalTargetInfo)dest); job1.exitMapOnArrival = true; job1.failIfCantJoinOrCreateCaravan = __instance.failIfCantJoinOrCreateCaravan; job1.locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, __instance.defaultLocomotion, LocomotionUrgency.Jog); job1.expiryInterval = __instance.jobMaxDuration; job1.canBashDoors = __instance.canBash; __result = job1; return(false); }
private bool HostileDefeated() { if (parent.GetComponent <TimedForcedExit>().ForceExitAndRemoveMapCountdownActive) { return(false); } MapParent map = (MapParent)parent; if (map.HasMap && map.Faction == ally && survivors && !GenHostility.AnyHostileActiveThreatTo(map.Map, map.Faction)) { parent.Faction.TryAffectGoodwillWith(Faction.OfPlayer, 12); DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(Find.AnyPlayerHomeMap), Find.AnyPlayerHomeMap, rewards, 110, false, true, true); string text = TranslatorFormattedStringExtensions.Translate("SettlementDefenderWon", parent, TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(Global.DayInTicks), parent.Faction.leader) + GenLabel.ThingsLabel(rewards, string.Empty); GenThing.TryAppendSingleRewardInfo(ref text, rewards); Find.LetterStack.ReceiveLetter("LetterLabelSettlementDefenderWon".Translate(), text, LetterDefOf.PositiveEvent, parent, null, null); map.Map.Parent.GetComponent <TimedForcedExit>().StartForceExitAndRemoveMapCountdown(Global.DayInTicks); return(true); } return(false); }
private bool HostileDefeated() { MapParent map = (MapParent)parent; if (map.HasMap && !GenHostility.AnyHostileActiveThreatTo(map.Map, Faction.OfPlayer)) { active = false; List <Pawn> prisoner = map.Map.mapPawns.AllPawns.Where(x => !x.Dead && !x.Downed && (x.IsPrisoner || x.kindDef == PawnKindDefOf.Slave)).ToList(); int pawnSaved = prisoner.Count(x => !x.Dead); if (pawnSaved == 0) { Find.LetterStack.ReceiveLetter("LetterLabelSettlementRescueFail".Translate(), TranslatorFormattedStringExtensions.Translate("SettlementRescueFail", parent.Faction, TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(Global.DayInTicks), ally.leader, ally.def.pawnsPlural), LetterDefOf.NegativeEvent, parent, null, null); return(true); } else { prisoner[0].Faction.TryAffectGoodwillWith(Faction.OfPlayer, 10 * pawnSaved); } foreach (Pawn p in prisoner) { if (Rand.Chance(UnWillingChance)) { pawnStaying++; p.mindState.WillJoinColonyIfRescued = false; } } if (pawnStaying >= 3) { resurrectSet = true; } DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(Find.AnyPlayerHomeMap), Find.AnyPlayerHomeMap, new Gift_RewardGeneratorBasedTMagic().Generate(500, new List <Thing>()), 110, false, true, true); string text = TranslatorFormattedStringExtensions.Translate("SettlementRescueWin", parent.Faction, TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(Global.DayInTicks), ally.leader, ally.def.leaderTitle) + GenLabel.ThingsLabel(new Gift_RewardGeneratorBasedTMagic().Generate(500, new List <Thing>()), string.Empty); Find.LetterStack.ReceiveLetter("LetterLabelSettlementRescue".Translate(), text, LetterDefOf.PositiveEvent, parent, null, null); return(true); } return(false); }
public override StateGraph CreateGraph() { StateGraph stateGraph = new StateGraph(); string noFulfilledTradeMsg = "IR.LordJobFulfillItemRequest.NoFulfillTrade".Translate(); string partiallyFulfilledTradeMsg = "IR.LordJobFulfillItemRequest.NoFulfillAllTrade".Translate(); string addedMessageText = faction.RelationKindWith(playerFaction) == FactionRelationKind.Neutral ? "IR.LordJobFulfillItemRequest.AttackingOutOfAnger".Translate() : "IR.LordJobFulfillItemRequest.RelationsDropped".Translate(); TransitionAction_Custom clearCaravanRequest = new TransitionAction_Custom(() => { Find.World.GetComponent <RequestSession>().CloseOpenDealWith(faction); }); // =================== // TOILS // =================== LordToil_Travel moving = new LordToil_Travel(chillSpot); stateGraph.StartingToil = moving; LordToil_DefendPoint defending = new LordToil_DefendTraderCaravan(); stateGraph.AddToil(defending); LordToil_DefendPoint defendingChillPoint = new LordToil_DefendTraderCaravan(chillSpot, 40); stateGraph.AddToil(defendingChillPoint); LordToil_ExitMapAndEscortCarriers exitingAndEscorting = new LordToil_ExitMapAndEscortCarriers(); stateGraph.AddToil(exitingAndEscorting); LordToil_ExitMap exiting = new LordToil_ExitMap(); stateGraph.AddToil(exiting); LordToil_ExitMap urgentExiting = new LordToil_ExitMap(LocomotionUrgency.Walk, true); stateGraph.AddToil(urgentExiting); LordToil_ExitMapTraderFighting exitWhileFighting = new LordToil_ExitMapTraderFighting(); stateGraph.AddToil(exitWhileFighting); // =================== // TRANSITIONS // =================== Transition leaveIfDangerousTemp = new Transition(moving, exitingAndEscorting); leaveIfDangerousTemp.AddSources(new LordToil[] { defending, defendingChillPoint }); leaveIfDangerousTemp.AddTrigger(new Trigger_PawnExperiencingDangerousTemperatures()); leaveIfDangerousTemp.AddPreAction(new TransitionAction_Message("MessageVisitorsDangerousTemperature".Translate(faction.def.pawnsPlural.CapitalizeFirst(), faction.Name))); leaveIfDangerousTemp.AddPostAction(new TransitionAction_EndAllJobs()); leaveIfDangerousTemp.AddPostAction(clearCaravanRequest); stateGraph.AddTransition(leaveIfDangerousTemp); Transition leaveIfTrapped = new Transition(moving, urgentExiting); leaveIfTrapped.AddSources(new LordToil[] { defending, defendingChillPoint, exitingAndEscorting, exiting, exitWhileFighting }); leaveIfTrapped.AddTrigger(new Trigger_PawnCannotReachMapEdge()); leaveIfTrapped.AddPostAction(new TransitionAction_Message("MessageVisitorsTrappedLeaving".Translate(faction.def.pawnsPlural.CapitalizeFirst(), faction.Name))); leaveIfTrapped.AddPostAction(new TransitionAction_WakeAll()); leaveIfTrapped.AddPostAction(new TransitionAction_EndAllJobs()); leaveIfTrapped.AddPostAction(clearCaravanRequest); stateGraph.AddTransition(leaveIfTrapped); Transition fightIfTrapped = new Transition(urgentExiting, exitWhileFighting); fightIfTrapped.AddTrigger(new Trigger_PawnCanReachMapEdge()); fightIfTrapped.AddPostAction(new TransitionAction_EndAllJobs()); fightIfTrapped.AddPostAction(clearCaravanRequest); stateGraph.AddTransition(fightIfTrapped); Transition fightIfFractionPawnsLost = new Transition(moving, exitWhileFighting); fightIfFractionPawnsLost.AddSources(new LordToil[] { defending, defendingChillPoint, exitingAndEscorting, exiting }); fightIfFractionPawnsLost.AddTrigger(new Trigger_FractionPawnsLost(0.2f)); fightIfFractionPawnsLost.AddPostAction(new TransitionAction_EndAllJobs()); fightIfFractionPawnsLost.AddPostAction(clearCaravanRequest); stateGraph.AddTransition(fightIfFractionPawnsLost); Transition defendIfPawnHarmed = new Transition(moving, defending); defendIfPawnHarmed.AddTrigger(new Trigger_PawnHarmed()); defendIfPawnHarmed.AddPreAction(new TransitionAction_SetDefendTrader()); defendIfPawnHarmed.AddPostAction(new TransitionAction_WakeAll()); defendIfPawnHarmed.AddPostAction(new TransitionAction_EndAllJobs()); stateGraph.AddTransition(defendIfPawnHarmed); Transition returnToNormalAfterTimePasses = new Transition(defending, moving); returnToNormalAfterTimePasses.AddTrigger(new Trigger_TicksPassedWithoutHarm(1200)); stateGraph.AddTransition(returnToNormalAfterTimePasses); Transition stayPutAtSpot = new Transition(moving, defendingChillPoint); stayPutAtSpot.AddTrigger(new Trigger_Memo("TravelArrived")); stateGraph.AddTransition(stayPutAtSpot); Transition leaveIfRequestFulfilled = new Transition(moving, exitingAndEscorting); leaveIfRequestFulfilled.AddSources(new LordToil[] { defending, defendingChillPoint, }); leaveIfRequestFulfilled.AddTrigger(new Trigger_Memo(MemoOnFulfilled)); leaveIfRequestFulfilled.AddPreAction(new TransitionAction_Message("IR.LordJobFulfillItemRequest.RequestedCaravanLeaving".Translate(faction.Name))); leaveIfRequestFulfilled.AddPostAction(new TransitionAction_WakeAll()); stateGraph.AddTransition(leaveIfRequestFulfilled); int ticksUntilBadThings = Rand.Range( Mathf.RoundToInt(CaravanManager.fullDayInTicks / 2), // 0.5 days CaravanManager.fullDayInTicks + Mathf.RoundToInt(CaravanManager.fullDayInTicks / 4)); // 1.25 days // Determine actions if request goes unfulfilled based on faction relation Trigger_TicksPassed ticksPassed = new Trigger_TicksPassed(ticksUntilBadThings); TransitionAction_Message actionMessage = new TransitionAction_Message("IR.LordJobFulfillItemRequest.FactionInsulted".Translate(faction.Name) + "\n" + addedMessageText); TransitionAction_Message leavingMessage = new TransitionAction_Message("IR.LordJobFulfillItemRequest.RequestedCaravanLeaving".Translate(faction.Name)); if (isFactionNeutral) { Action setFactionToHostile = () => faction.TrySetRelationKind(playerFaction, FactionRelationKind.Hostile, true, noFulfilledTradeMsg); Transition attackIfNotEnoughSilver = new Transition(moving, defending, true); attackIfNotEnoughSilver.AddSources(new LordToil[] { defending, defendingChillPoint, exiting, exitingAndEscorting }); attackIfNotEnoughSilver.AddTrigger(new Trigger_Memo(MemoOnUnfulfilled)); attackIfNotEnoughSilver.AddPreAction(new TransitionAction_Message("IR.LordJobFulfillItemRequest.TradersAttacking".Translate(faction.Name))); attackIfNotEnoughSilver.AddPreAction(new TransitionAction_Custom(setFactionToHostile)); attackIfNotEnoughSilver.AddPostAction(new TransitionAction_WakeAll()); attackIfNotEnoughSilver.AddPostAction(new TransitionAction_SetDefendLocalGroup()); stateGraph.AddTransition(attackIfNotEnoughSilver, true); Transition attackIfRequestUnfulfilled = new Transition(defendingChillPoint, defending); attackIfRequestUnfulfilled.AddTrigger(ticksPassed); attackIfRequestUnfulfilled.AddPreAction(actionMessage); attackIfRequestUnfulfilled.AddPreAction(new TransitionAction_Custom(setFactionToHostile)); attackIfRequestUnfulfilled.AddPostAction(new TransitionAction_WakeAll()); attackIfRequestUnfulfilled.AddPostAction(new TransitionAction_SetDefendLocalGroup()); stateGraph.AddTransition(attackIfRequestUnfulfilled, true); Transition leaveAfterAttacking = new Transition(defendingChillPoint, exitingAndEscorting); leaveAfterAttacking.AddSource(defending); leaveAfterAttacking.AddTrigger(new Trigger_TicksPassed(ticksUntilBadThings + 10000)); leaveAfterAttacking.AddPreAction(leavingMessage); leaveAfterAttacking.AddPostAction(new TransitionAction_EndAllJobs()); stateGraph.AddTransition(leaveAfterAttacking); } else { Transition leaveIfRequestUnfulfilled = new Transition(moving, exitingAndEscorting); leaveIfRequestUnfulfilled.AddSources(new LordToil[] { defending, defendingChillPoint }); leaveIfRequestUnfulfilled.AddTrigger(new Trigger_Memo(MemoOnUnfulfilled)); leaveIfRequestUnfulfilled.AddTrigger(ticksPassed); leaveIfRequestUnfulfilled.AddPreAction(actionMessage); leaveIfRequestUnfulfilled.AddPreAction(new TransitionAction_Custom(() => { faction.TryAffectGoodwillWith(playerFaction, -30, true, false, noFulfilledTradeMsg); })); leaveIfRequestUnfulfilled.AddPostAction(leavingMessage); leaveIfRequestUnfulfilled.AddPostAction(new TransitionAction_WakeAll()); stateGraph.AddTransition(leaveIfRequestUnfulfilled); } // Partial fulfillment Transition leaveIfRequestMostlyFulfilled = new Transition(moving, exiting); leaveIfRequestMostlyFulfilled.AddSources(new LordToil[] { defending, defendingChillPoint }); leaveIfRequestMostlyFulfilled.AddTrigger(new Trigger_Memo(MemoOnPartiallyFulfilled_S)); leaveIfRequestMostlyFulfilled.AddPreAction(new TransitionAction_Message("IR.LordJobFulfillItemRequest.DisappointedTraders".Translate(faction.Name), MessageTypeDefOf.CautionInput)); leaveIfRequestMostlyFulfilled.AddPreAction(new TransitionAction_Custom(() => { faction.TryAffectGoodwillWith(playerFaction, -5, true, false, partiallyFulfilledTradeMsg); })); leaveIfRequestMostlyFulfilled.AddPostAction(leavingMessage); leaveIfRequestMostlyFulfilled.AddPostAction(new TransitionAction_WakeAll()); stateGraph.AddTransition(leaveIfRequestMostlyFulfilled); Transition leaveIfRequestSomewhatFulfilled = new Transition(moving, exiting); leaveIfRequestSomewhatFulfilled.AddSources(new LordToil[] { defending, defendingChillPoint }); leaveIfRequestSomewhatFulfilled.AddTrigger(new Trigger_Memo(MemoOnPartiallyFulfilled_M)); leaveIfRequestSomewhatFulfilled.AddPreAction(new TransitionAction_Message("IR.LordJobFulfillItemRequest.AnnoyedTraders".Translate(faction.Name), MessageTypeDefOf.CautionInput)); leaveIfRequestSomewhatFulfilled.AddPreAction(new TransitionAction_Custom(() => { faction.TryAffectGoodwillWith(playerFaction, -10, true, false, partiallyFulfilledTradeMsg); })); leaveIfRequestSomewhatFulfilled.AddPostAction(leavingMessage); leaveIfRequestSomewhatFulfilled.AddPostAction(new TransitionAction_WakeAll()); stateGraph.AddTransition(leaveIfRequestSomewhatFulfilled); Transition leaveIfRequestHardlyFulfilled = new Transition(moving, exiting); leaveIfRequestHardlyFulfilled.AddSources(new LordToil[] { defending, defendingChillPoint }); leaveIfRequestHardlyFulfilled.AddTrigger(new Trigger_Memo(MemoOnPartiallyFulfilled_L)); leaveIfRequestHardlyFulfilled.AddPreAction(new TransitionAction_Message("IR.LordJobFulfillItemRequest.OutragedTraders".Translate(faction.Name), MessageTypeDefOf.CautionInput)); leaveIfRequestHardlyFulfilled.AddPreAction(new TransitionAction_Custom(() => { faction.TryAffectGoodwillWith(playerFaction, -20, true, false, partiallyFulfilledTradeMsg); })); leaveIfRequestHardlyFulfilled.AddPostAction(leavingMessage); leaveIfRequestHardlyFulfilled.AddPostAction(new TransitionAction_WakeAll()); stateGraph.AddTransition(leaveIfRequestHardlyFulfilled); Transition continueToLeaveMap = new Transition(exitingAndEscorting, exitingAndEscorting, true); continueToLeaveMap.AddTrigger(new Trigger_PawnLost()); continueToLeaveMap.AddTrigger(new Trigger_TickCondition(() => LordToil_ExitMapAndEscortCarriers.IsAnyDefendingPosition(lord.ownedPawns) && !GenHostility.AnyHostileActiveThreatTo(Map, faction), 60)); continueToLeaveMap.AddPostAction(clearCaravanRequest); stateGraph.AddTransition(continueToLeaveMap); Transition finishLeavingMap = new Transition(exitingAndEscorting, exiting); finishLeavingMap.AddTrigger(new Trigger_TicksPassed(60000)); finishLeavingMap.AddPostAction(new TransitionAction_WakeAll()); finishLeavingMap.AddPostAction(clearCaravanRequest); stateGraph.AddTransition(finishLeavingMap); Transition leaveIfBadThingsHappen = new Transition(defendingChillPoint, exitingAndEscorting); leaveIfBadThingsHappen.AddSources(new LordToil[] { moving, defending }); leaveIfBadThingsHappen.AddTrigger(new Trigger_ImportantTraderCaravanPeopleLost()); leaveIfBadThingsHappen.AddPostAction(new TransitionAction_WakeAll()); leaveIfBadThingsHappen.AddPostAction(new TransitionAction_EndAllJobs()); leaveIfBadThingsHappen.AddPostAction(clearCaravanRequest); stateGraph.AddTransition(leaveIfBadThingsHappen); return(stateGraph); }
// Token: 0x06003EB7 RID: 16055 RVA: 0x001D76A8 File Offset: 0x001D5AA8 protected override Job TryGiveJob(Pawn pawn) { bool flag = false; if (this.forceCanDig || (pawn.mindState.duty != null && pawn.mindState.duty.canDig) || (this.forceCanDigIfCantReachMapEdge && !pawn.CanReachMapEdge()) || (this.forceCanDigIfAnyHostileActiveThreat && pawn.Faction != null && GenHostility.AnyHostileActiveThreatTo(pawn.Map, pawn.Faction))) { flag = true; } IntVec3 c; if (pawn.xenomorph().HiveLoc == null) { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("{0} no hiveloc", pawn)); } return(null); } if (!pawn.xenomorph().HiveLoc.IsValid) { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("{0} no hiveloc", pawn)); } return(null); } if (pawn.xenomorph().HiveLoc == IntVec3.Zero) { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("{0} hiveloc zero", pawn)); } return(null); } c = pawn.xenomorph().HiveLoc; if (!c.IsValid) { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("{0} no c", pawn)); } return(null); } if (c == IntVec3.Zero) { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("{0} c zero", pawn)); } return(null); } if (flag) { using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, c, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings, false), PathEndMode.OnCell)) { IntVec3 cellBeforeBlocker; Thing thing = pawnPath.FirstBlockingBuilding(out cellBeforeBlocker, pawn); if (thing != null) { if (!thing.def.defName.Contains("Xenomorph_Hive")) { Job job = DigUtility.PassBlockerJob(pawn, thing, cellBeforeBlocker, true, true); if (job != null) { return(job); } } } } } /* * // Log.Message("TryGiveJob 6"); * // Log.Message(string.Format("TryGiveJob 6 {0}, {1}", pawn.Map, c)); * if (c.GetFirstBuilding(pawn.Map)!=null) * { * // Log.Message(string.Format("TryGiveJob 6 {0}, {1} Building == {2}", pawn.Map, c, c.GetFirstBuilding(pawn.Map))); * if (c.GetFirstBuilding(pawn.Map).def == XenomorphDefOf.RRY_Xenomorph_Hive) * { * // Log.Message("TryGiveJob 6 1"); * return null; * } * } * else * { * // Log.Message(string.Format("TryGiveJob 6 {0}, {1} Building == Null", pawn.Map, c)); * if (c.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_Xenomorph_Hive) != null) * { * // Log.Message(string.Format("TryGiveJob 6 {0}, {1} Building == {2}", pawn.Map, c, c.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_Xenomorph_Hive))); * if (c.GetFirstBuilding(pawn.Map).def == ) * { * // Log.Message("TryGiveJob 6 1"); * return null; * } * } * else * { * // Log.Message(string.Format("TryGiveJob 6 {0}, {1} Building == Null", pawn.Map, c)); * } * } * // Log.Message("TryGiveJob 7"); */ return(new Job(JobDefOf.Goto, c) { exitMapOnArrival = false, failIfCantJoinOrCreateCaravan = this.failIfCantJoinOrCreateCaravan, locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, this.defaultLocomotion, LocomotionUrgency.Jog), expiryInterval = this.jobMaxDuration, canBash = this.canBash }); }
public override void CompTick() { base.CompTick(); if (ShouldRemoveWorldObjectNow) { Find.WorldObjects.Remove(parent); } if (state == RuinedBaseState.Inactive) { return; } if (!ParentHasMap) { //base "do maradeur" act chance is once per 1.5 game days, but high activity can make it as often as once per game hour if (Rand.Chance(0.00001f + (float)raidersActivity / 50000000.0f) || raidersActivity * 4 > currentCapCost / 2) { int stolenAmount = (int)(Rand.Range(0.05f, 0.2f) * (raidersActivity / 12000.0f) * currentCapCost); currentCapCost -= Math.Max(stolenAmount, (int)(raidersActivity * 4)); raidersActivity = raidersActivity / Rand.Range(2.0f, 5.0f); } raidersActivity += Rand.Range(-.1f, 0.25f) * currentCapCost / 100000.0f; if (raidersActivity < 0) { raidersActivity = 0; } if ((currentCapCost < 20000 && Rand.Chance(0.00001f)) || currentCapCost <= 100) { state = RuinedBaseState.ScavengedCompletely; } } //Do not remember if faction of pristine ruins does matter somehow. It actually shouldn't. //This should be removed, but just in case it is needed for some reason, I'll leave it, but add check fro reformingType = 1 (instant reforing), because for other modes this yields caravan items unloading. if (ParentHasMap && parent.Faction != Faction.OfPlayer && RealRuins_ModSettings.caravanReformType == 1) { if (!GenHostility.AnyHostileActiveThreatToPlayer((parent as MapParent).Map)) { //show letter about enemies defeated Debug.Log(Debug.Generic, "pristine ruins was cleared, changing faction"); parent.SetFaction(Faction.OfPlayer); // parent as MapParent } } if (RealRuins_ModSettings.caravanReformType == 2 && ParentHasMap) { if (state == RuinedBaseState.FightingWaves) { CheckTriggers(); } else if (state == RuinedBaseState.WaitingForEnemiesToBeDefeated) { //AnyHostileActiveThreatToPlayer is a proxy call to AnyHostileActiveThreatTo, but it is postfixed with additional check by this mod. //Here I want to do original check, without my postfix, so I call directly the checking method. So-so solution, but cant think of anything better AND worthwhile if (!GenHostility.AnyHostileActiveThreatTo((parent as MapParent).Map, Faction.OfPlayer)) { unlockTargetTime = Find.TickManager.TicksGame + Rand.Range(30000, 30000 + currentCapCost); state = RuinedBaseState.WaitingTimeoutAfterEnemiesDefeat; //Debug.Message("no more hostiles. time: {0}, unlocktime: {1}", Find.TickManager.TicksGame, unlockTargetTime); } } else if (state == RuinedBaseState.WaitingTimeoutAfterEnemiesDefeat) { if (Find.TickManager.TicksGame > unlockTargetTime) { state = RuinedBaseState.WaitingToBeInformed; string text = "RealRuins.NoMoreEnemies".Translate(); Messages.Message(text, parent, MessageTypeDefOf.PositiveEvent); state = RuinedBaseState.InformedWaitingForLeaving; } } } }
protected override Job TryGiveJob(Pawn pawn) { bool flag = false; if (this.forceCanDig || (pawn.mindState.duty != null && pawn.mindState.duty.canDig) || (this.forceCanDigIfCantReachMapEdge && !pawn.CanReachMapEdge()) || (this.forceCanDigIfAnyHostileActiveThreat && pawn.Faction != null && GenHostility.AnyHostileActiveThreatTo(pawn.Map, pawn.Faction))) { flag = true; } IntVec3 c; if (!this.TryFindGoodExitDest(pawn, flag, out c)) { return(null); } if (flag) { using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, c, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings, false), PathEndMode.OnCell)) { IntVec3 cellBeforeBlocker; Thing thing = pawnPath.FirstBlockingBuilding(out cellBeforeBlocker, pawn); if (thing != null) { Job job = DigUtility.PassBlockerJob(pawn, thing, cellBeforeBlocker, true, true); if (job != null) { return(job); } } } } return(new Job(JobDefOf.Goto, c) { exitMapOnArrival = true, failIfCantJoinOrCreateCaravan = this.failIfCantJoinOrCreateCaravan, locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, this.defaultLocomotion, LocomotionUrgency.Jog), expiryInterval = this.jobMaxDuration, canBash = this.canBash }); }
protected override Job TryGiveJob(Pawn pawn) { bool flag = forceCanDig || (pawn.mindState.duty != null && pawn.mindState.duty.canDig && !pawn.CanReachMapEdge()) || (forceCanDigIfCantReachMapEdge && !pawn.CanReachMapEdge()) || (forceCanDigIfAnyHostileActiveThreat && pawn.Faction != null && GenHostility.AnyHostileActiveThreatTo(pawn.Map, pawn.Faction, countDormantPawnsAsHostile: true)); if (!TryFindGoodExitDest(pawn, flag, out IntVec3 dest)) { return(null); } if (flag) { using (PawnPath path = pawn.Map.pathFinder.FindPath(pawn.Position, dest, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings))) { IntVec3 cellBefore; Thing thing = path.FirstBlockingBuilding(out cellBefore, pawn); if (thing != null) { Job job = DigUtility.PassBlockerJob(pawn, thing, cellBefore, canMineMineables: true, canMineNonMineables: true); if (job != null) { return(job); } } } } Job job2 = JobMaker.MakeJob(JobDefOf.Goto, dest); job2.exitMapOnArrival = true; job2.failIfCantJoinOrCreateCaravan = failIfCantJoinOrCreateCaravan; job2.locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, defaultLocomotion, LocomotionUrgency.Jog); job2.expiryInterval = jobMaxDuration; job2.canBash = canBash; return(job2); }
// Token: 0x06003DA3 RID: 15779 RVA: 0x0016D63C File Offset: 0x0016B83C protected override Job TryGiveJob(Pawn pawn) { Room room = pawn.GetRoom(RegionType.Set_Passable); if (room.PsychologicallyOutdoors && room.TouchesMapEdge) { return(null); } if (!pawn.CanReachMapEdge()) { return(null); } bool flag = this.forceCanDig || (pawn.mindState.duty != null && pawn.mindState.duty.canDig && !pawn.CanReachMapEdge()) || (this.forceCanDigIfCantReachMapEdge && !pawn.CanReachMapEdge()) || (this.forceCanDigIfAnyHostileActiveThreat && pawn.Faction != null && GenHostility.AnyHostileActiveThreatTo(pawn.Map, pawn.Faction, true)); IntVec3 c; if (!this.TryFindGoodExitDest(pawn, flag, out c)) { return(null); } if (flag) { using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, c, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings, false), PathEndMode.OnCell)) { IntVec3 cellBeforeBlocker; Thing thing = pawnPath.FirstBlockingBuilding(out cellBeforeBlocker, pawn); if (thing.def == XenomorphDefOf.RRY_Xenomorph_Hive_Wall) { CellRect rect = new CellRect(thing.Position.x - 1, thing.Position.y - 1, 3, 3); foreach (IntVec3 cell in rect) { if (cell.InBounds(thing.Map)) { if (cell.GetThingList(thing.Map).All(x => x.def != XenomorphDefOf.RRY_Xenomorph_Hive_Wall)) { thing = cell.GetFirstMineable(thing.Map); break; } } } } if (thing != null && thing.def != XenomorphDefOf.RRY_Xenomorph_Hive_Wall) { Job job = DigUtility.PassBlockerJob(pawn, thing, cellBeforeBlocker, true, true); if (job != null) { return(job); } } } } return(null); }