public static void DoModalDialogIfNotKnown(ConceptDef conc, params string[] input) { if (!PlayerKnowledgeDatabase.IsComplete(conc)) { DoModalDialogIfNotKnownInner(conc, string.Format(conc.HelpTextAdjusted, input)); } }
// Token: 0x0600295A RID: 10586 RVA: 0x00139AB0 File Offset: 0x00137EB0 private void HarmRandomPlantInRadius(float radius) { IntVec3 c = this.parent.Position + (Rand.InsideUnitCircleVec3 * radius).ToIntVec3(); if (!c.InBounds(this.parent.Map)) { return; } Plant plant = c.GetPlant(this.parent.Map); bool flag = c.GetThingList(this.parent.Map).Any(x => x.def.defName.Contains("RRY_Plant_Neomorph_Fungus")); if (plant != null && !flag) { if (Rand.Value < this.LeaflessPlantKillChance) { Thing thing2; if (!PlayerKnowledgeDatabase.IsComplete(XenomorphConceptDefOf.RRY_Concept_Fungus)) { thing2 = ThingMaker.MakeThing(XenomorphDefOf.RRY_Plant_Neomorph_Fungus_Hidden); } else { thing2 = ThingMaker.MakeThing(XenomorphDefOf.RRY_Plant_Neomorph_Fungus); } IntVec3 vec3 = plant.Position; GenSpawn.Spawn(thing2, vec3, plant.Map, WipeMode.Vanish); // plant.Destroy(); // GenSpawn.Spawn(ThingMaker.MakeThing(this.def), vec3, this.Map); } } }
public static void DoModalDialogWithArgsIfNotKnown(ConceptDef conc, params NamedArgument[] args) { if (!PlayerKnowledgeDatabase.IsComplete(conc)) { DoModalDialogIfNotKnownInner(conc, conc.HelpTextAdjusted.Formatted(args)); } }
public static string DebugString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("RelaxDesire: " + LessonAutoActivator.RelaxDesire); IEnumerable <ConceptDef> allDefs = DefDatabase <ConceptDef> .AllDefs; if (LessonAutoActivator.< > f__mg$cache0 == null) { LessonAutoActivator.< > f__mg$cache0 = new Func <ConceptDef, float>(LessonAutoActivator.GetDesire); } foreach (ConceptDef conceptDef in allDefs.OrderByDescending(LessonAutoActivator.< > f__mg$cache0)) { if (PlayerKnowledgeDatabase.IsComplete(conceptDef)) { stringBuilder.AppendLine(conceptDef.defName + " complete"); } else { stringBuilder.AppendLine(string.Concat(new string[] { conceptDef.defName, "\n know ", PlayerKnowledgeDatabase.GetKnowledge(conceptDef).ToString("F3"), "\n need ", LessonAutoActivator.opportunities[conceptDef].ToString("F3"), "\n des ", LessonAutoActivator.GetDesire(conceptDef).ToString("F3") })); } } return(stringBuilder.ToString()); }
public static void Notify_KnowledgeDemonstrated(ConceptDef conc) { if (PlayerKnowledgeDatabase.IsComplete(conc)) { LessonAutoActivator.opportunities[conc] = 0f; } }
public static string DebugString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("RelaxDesire: " + LessonAutoActivator.RelaxDesire); foreach (ConceptDef current in DefDatabase <ConceptDef> .AllDefs.OrderByDescending(new Func <ConceptDef, float>(LessonAutoActivator.GetDesire))) { if (PlayerKnowledgeDatabase.IsComplete(current)) { stringBuilder.AppendLine(current.defName + " complete"); } else { stringBuilder.AppendLine(string.Concat(new string[] { current.defName, "\n know ", PlayerKnowledgeDatabase.GetKnowledge(current).ToString("F3"), "\n need ", LessonAutoActivator.opportunities[current].ToString("F3"), "\n des ", LessonAutoActivator.GetDesire(current).ToString("F3") })); } } return(stringBuilder.ToString()); }
public static string DebugString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("RelaxDesire: " + LessonAutoActivator.RelaxDesire); foreach (ConceptDef conceptDef in from co in DefDatabase <ConceptDef> .AllDefs orderby LessonAutoActivator.GetDesire(co) descending select co) { if (PlayerKnowledgeDatabase.IsComplete(conceptDef)) { stringBuilder.AppendLine(conceptDef.defName + " complete"); } else { stringBuilder.AppendLine(string.Concat(new string[] { conceptDef.defName, "\n know ", PlayerKnowledgeDatabase.GetKnowledge(conceptDef).ToString("F3"), "\n need ", LessonAutoActivator.opportunities[conceptDef].ToString("F3"), "\n des ", LessonAutoActivator.GetDesire(conceptDef).ToString("F3") })); } } return(stringBuilder.ToString()); }
public static void LessonAutoActivatorUpdate() { if (TutorSystem.AdaptiveTrainingEnabled && Current.Game != null && !Find.Tutor.learningReadout.ShowAllMode) { timeSinceLastLesson += RealTime.realDeltaTime; if (Current.ProgramState != ProgramState.Playing || (!(Time.timeSinceLevelLoad < 8f) && !(Find.WindowStack.SecondsSinceClosedGameStartDialog < 8f) && !Find.TickManager.NotPlaying)) { for (int num = alertingConcepts.Count - 1; num >= 0; num--) { if (PlayerKnowledgeDatabase.IsComplete(alertingConcepts[num])) { alertingConcepts.RemoveAt(num); } } if (Time.frameCount % 15 == 0 && Find.ActiveLesson.Current == null) { for (int i = 0; i < DefDatabase <ConceptDef> .AllDefsListForReading.Count; i++) { ConceptDef conceptDef = DefDatabase <ConceptDef> .AllDefsListForReading[i]; if (!PlayerKnowledgeDatabase.IsComplete(conceptDef)) { float knowledge = PlayerKnowledgeDatabase.GetKnowledge(conceptDef); knowledge -= 0.00015f * Time.deltaTime * 15f; if (knowledge < 0f) { knowledge = 0f; } PlayerKnowledgeDatabase.SetKnowledge(conceptDef, knowledge); if (conceptDef.opportunityDecays) { float opportunity = GetOpportunity(conceptDef); opportunity -= 0.4f * Time.deltaTime * 15f; if (opportunity < 0f) { opportunity = 0f; } opportunities[conceptDef] = opportunity; } } } if (Find.Tutor.learningReadout.ActiveConceptsCount < 3) { ConceptDef conceptDef2 = MostDesiredConcept(); if (conceptDef2 != null) { float desire = GetDesire(conceptDef2); if (desire > 0.1f && RelaxDesire < desire) { TryInitiateLesson(conceptDef2); } } } else { SetLastLessonTimeToNow(); } } } } }
private static float GetDesire(ConceptDef conc) { float result; if (PlayerKnowledgeDatabase.IsComplete(conc)) { result = 0f; } else if (Find.Tutor.learningReadout.IsActive(conc)) { result = 0f; } else if (Current.ProgramState != conc.gameMode) { result = 0f; } else if (conc.needsOpportunity && LessonAutoActivator.GetOpportunity(conc) < 0.1f) { result = 0f; } else { float num = 0f; num += conc.priority; num += LessonAutoActivator.GetOpportunity(conc) / 100f * 60f; num *= 1f - PlayerKnowledgeDatabase.GetKnowledge(conc); result = num; } return(result); }
public static void TeachOpportunity(ConceptDef conc, Thing subject, OpportunityType opp) { if (TutorSystem.AdaptiveTrainingEnabled && !PlayerKnowledgeDatabase.IsComplete(conc)) { float value = 999f; switch (opp) { case OpportunityType.GoodToKnow: value = 60f; break; case OpportunityType.Important: value = 80f; break; case OpportunityType.Critical: value = 100f; break; default: Log.Error("Unknown need", false); break; } LessonAutoActivator.opportunities[conc] = value; if (opp >= OpportunityType.Important || Find.Tutor.learningReadout.ActiveConceptsCount < 4) { LessonAutoActivator.TryInitiateLesson(conc); } } }
public override void LessonUpdate() { base.LessonUpdate(); if (PlayerKnowledgeDatabase.IsComplete(base.def.concept)) { Find.ActiveLesson.Deactivate(); } }
public static void DoModalDialogWithArgsIfNotKnown(ConceptDef conc, string buttonAText, Action buttonAAction, string buttonBText = null, Action buttonBAction = null, params NamedArgument[] args) { if (!PlayerKnowledgeDatabase.IsComplete(conc)) { Find.WindowStack.Add(new Dialog_MessageBox(conc.HelpTextAdjusted.Formatted(args), buttonAText, buttonAAction, buttonBText, buttonBAction)); PlayerKnowledgeDatabase.KnowledgeDemonstrated(conc, KnowledgeAmount.Total); } }
public void ExposeData() { Scribe_Collections.Look <ConceptDef>(ref this.activeConcepts, "activeConcepts", LookMode.Undefined, new object[0]); Scribe_Defs.Look <ConceptDef>(ref this.selectedConcept, "selectedConcept"); if (Scribe.mode == LoadSaveMode.PostLoadInit) { this.activeConcepts.RemoveAll((ConceptDef c) => PlayerKnowledgeDatabase.IsComplete(c)); } }
public static void DoModalDialogIfNotKnown(ConceptDef conc) { if (!PlayerKnowledgeDatabase.IsComplete(conc)) { string helpTextAdjusted = conc.HelpTextAdjusted; Find.WindowStack.Add(new Dialog_MessageBox(helpTextAdjusted, null, null, null, null, null, false, null, null)); PlayerKnowledgeDatabase.KnowledgeDemonstrated(conc, KnowledgeAmount.Total); } }
// Token: 0x06002673 RID: 9843 RVA: 0x001240D8 File Offset: 0x001224D8 public override void SpawnSetup(Map map, bool respawningAfterLoad) { if (!PlayerKnowledgeDatabase.IsComplete(XenomorphConceptDefOf.RRY_Concept_HiveLike) && this.def == XenomorphDefOf.RRY_Xenomorph_Hive) { LessonAutoActivator.TeachOpportunity(XenomorphConceptDefOf.RRY_Concept_HiveLike, OpportunityType.Important); } base.SpawnSetup(map, respawningAfterLoad); if (base.Faction == null) { this.SetFaction(OfFaction, null); } if (this.getsQueen && hiveNode) { Pawn newQueen = PawnGenerator.GeneratePawn(new PawnGenerationRequest(XenomorphDefOf.RRY_Xenomorph_Queen, factionInt)); this.innerContainer.TryAdd(newQueen); } if (!respawningAfterLoad && this.active && canSpawnPawns) { this.SpawnInitialPawns(); } else { spawnablePawnKinds = OfPawnKinds; } MapComponent_HiveGrid hiveGrid = map.HiveGrid(); if (hiveGrid != null) { if (this.def == XenomorphDefOf.RRY_Xenomorph_Hive) { if (!hiveGrid.Hivelist.Contains(this)) { hiveGrid.Hivelist.Add(this); } if (!hiveGrid.HiveLoclist.Contains(this.Position)) { hiveGrid.HiveLoclist.Add(this.Position); } } if (this.def == XenomorphDefOf.RRY_Xenomorph_Hive_Child) { if (!hiveGrid.Hivelist.Contains(this)) { hiveGrid.Hivelist.Add(this); } if (!hiveGrid.HiveLoclist.Contains(this.Position)) { hiveGrid.HiveLoclist.Add(this.Position); } } } }
private Rect DrawConceptListRow(float x, float y, float width, ConceptDef conc) { float knowledge = PlayerKnowledgeDatabase.GetKnowledge(conc); bool flag = PlayerKnowledgeDatabase.IsComplete(conc); bool flag2 = !flag && knowledge > 0f; float num = Text.CalcHeight(conc.LabelCap, width); if (flag2) { num = num; } Rect rect = new Rect(x, y, width, num); if (flag2) { Rect rect2 = new Rect(rect); rect2.yMin += 1f; rect2.yMax -= 1f; Widgets.FillableBar(rect2, PlayerKnowledgeDatabase.GetKnowledge(conc), LearningReadout.ProgressBarFillTex, LearningReadout.ProgressBarBGTex, false); } if (flag) { GUI.DrawTexture(rect, BaseContent.GreyTex); } if (this.selectedConcept == conc) { GUI.DrawTexture(rect, TexUI.HighlightSelectedTex); } Widgets.DrawHighlightIfMouseover(rect); if (this.MatchesSearchString(conc)) { Widgets.DrawHighlight(rect); } Widgets.Label(rect, conc.LabelCap); if (Mouse.IsOver(rect) && this.selectedConcept == null) { this.mouseoverConcept = conc; } if (Widgets.ButtonInvisible(rect, true)) { if (this.selectedConcept == conc) { this.selectedConcept = null; } else { this.selectedConcept = conc; } SoundDefOf.PageChange.PlayOneShotOnCamera(null); } return(rect); }
private Rect DrawConceptListRow(float x, float y, float width, ConceptDef conc) { float knowledge = PlayerKnowledgeDatabase.GetKnowledge(conc); bool num = PlayerKnowledgeDatabase.IsComplete(conc); bool num2 = !num && knowledge > 0f; float num3 = Text.CalcHeight(conc.LabelCap, width); if (num2) { num3 += 0f; } Rect rect = new Rect(x, y, width, num3); if (num2) { Rect rect2 = new Rect(rect); rect2.yMin += 1f; rect2.yMax -= 1f; Widgets.FillableBar(rect2, PlayerKnowledgeDatabase.GetKnowledge(conc), ProgressBarFillTex, ProgressBarBGTex, doBorder: false); } if (num) { GUI.DrawTexture(rect, BaseContent.GreyTex); } if (selectedConcept == conc) { GUI.DrawTexture(rect, TexUI.HighlightSelectedTex); } Widgets.DrawHighlightIfMouseover(rect); if (MatchesSearchString(conc)) { Widgets.DrawHighlight(rect); } Widgets.Label(rect, conc.LabelCap); if (Mouse.IsOver(rect) && selectedConcept == null) { mouseoverConcept = conc; } if (Widgets.ButtonInvisible(rect)) { if (selectedConcept == conc) { selectedConcept = null; } else { selectedConcept = conc; } SoundDefOf.PageChange.PlayOneShotOnCamera(); } return rect; }
public static string DebugString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("RelaxDesire: " + RelaxDesire); foreach (ConceptDef item in DefDatabase <ConceptDef> .AllDefs.OrderByDescending((ConceptDef co) => GetDesire(co))) { if (PlayerKnowledgeDatabase.IsComplete(item)) { stringBuilder.AppendLine(item.defName + " complete"); continue; } stringBuilder.AppendLine(item.defName + "\n know " + PlayerKnowledgeDatabase.GetKnowledge(item).ToString("F3") + "\n need " + opportunities[item].ToString("F3") + "\n des " + GetDesire(item).ToString("F3")); } return(stringBuilder.ToString()); }
public static string DebugString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("RelaxDesire: " + LessonAutoActivator.RelaxDesire); foreach (ConceptDef item in DefDatabase <ConceptDef> .AllDefs.OrderByDescending(LessonAutoActivator.GetDesire)) { if (PlayerKnowledgeDatabase.IsComplete(item)) { stringBuilder.AppendLine(item.defName + " complete"); } else { stringBuilder.AppendLine(item.defName + "\n know " + PlayerKnowledgeDatabase.GetKnowledge(item).ToString("F3") + "\n need " + LessonAutoActivator.opportunities[item].ToString("F3") + "\n des " + LessonAutoActivator.GetDesire(item).ToString("F3")); } } return(stringBuilder.ToString()); }
// Token: 0x06002673 RID: 9843 RVA: 0x001240D8 File Offset: 0x001224D8 public override void SpawnSetup(Map map, bool respawningAfterLoad) { if (!PlayerKnowledgeDatabase.IsComplete(XenomorphConceptDefOf.RRY_Concept_Neomorphs) && this.def == XenomorphDefOf.RRY_XenomorphHive) { LessonAutoActivator.TeachOpportunity(XenomorphConceptDefOf.RRY_Concept_Neomorphs, OpportunityType.Important); } base.SpawnSetup(map, respawningAfterLoad); if (base.Faction == null) { this.SetFaction(OfFaction, null); } if (!respawningAfterLoad && this.active) { this.SpawnInitialPawns(); } else { spawnablePawnKinds = OfPawnKinds; } }
private static float GetDesire(ConceptDef conc) { if (PlayerKnowledgeDatabase.IsComplete(conc)) { return(0f); } if (Find.Tutor.learningReadout.IsActive(conc)) { return(0f); } if (Current.ProgramState != conc.gameMode) { return(0f); } if (conc.needsOpportunity && GetOpportunity(conc) < 0.1f) { return(0f); } return((0f + conc.priority + GetOpportunity(conc) / 100f * 60f) * (1f - PlayerKnowledgeDatabase.GetKnowledge(conc))); }
// Token: 0x06000A30 RID: 2608 RVA: 0x0004FE58 File Offset: 0x0004E258 protected override ThoughtState CurrentStateInternal(Pawn p) { Hediff firstHediffOfDef = p.health.hediffSet.GetFirstHediffOfDef(this.def.hediff, false); if (firstHediffOfDef == null || firstHediffOfDef.def.stages == null) { return(ThoughtState.Inactive); } if (!PlayerKnowledgeDatabase.IsComplete(XenomorphConceptDefOf.RRY_Concept_Chestbursters) && p.Spawned && p.IsColonist) { return(ThoughtState.Inactive); } int stageIndex = Mathf.Min(new int[] { firstHediffOfDef.CurStageIndex, firstHediffOfDef.def.stages.Count - 1, this.def.stages.Count - 1 }); return(ThoughtState.ActiveAtStage(stageIndex)); }
private static float GetDesire(ConceptDef conc) { if (PlayerKnowledgeDatabase.IsComplete(conc)) { return(0f); } if (Find.Tutor.learningReadout.IsActive(conc)) { return(0f); } if (Current.ProgramState != conc.gameMode) { return(0f); } if (conc.needsOpportunity && LessonAutoActivator.GetOpportunity(conc) < 0.10000000149011612) { return(0f); } float num = 0f; num += conc.priority; num = (float)(num + LessonAutoActivator.GetOpportunity(conc) / 100.0 * 60.0); return((float)(num * (1.0 - PlayerKnowledgeDatabase.GetKnowledge(conc)))); }
private static bool <ExposeData> m__0(ConceptDef c) { return(PlayerKnowledgeDatabase.IsComplete(c)); }
private Rect DrawInfoPane(ConceptDef conc) { float knowledge = PlayerKnowledgeDatabase.GetKnowledge(conc); bool complete = PlayerKnowledgeDatabase.IsComplete(conc); bool drawProgressBar = !complete && knowledge > 0f; Text.Font = GameFont.Medium; float titleHeight = Text.CalcHeight(conc.LabelCap, 276f); Text.Font = GameFont.Small; float textHeight = Text.CalcHeight(conc.HelpTextAdjusted, 296f); float num = titleHeight + textHeight + 14f + 5f; if (this.selectedConcept == conc) { num += 40f; } if (drawProgressBar) { num += 30f; } Rect outRect = new Rect((float)UI.screenWidth - 8f - 200f - 8f - 310f, 8f, 310f, num); Rect outRect2 = outRect; Find.WindowStack.ImmediateWindow(987612111, outRect, WindowLayer.Super, delegate { outRect = outRect.AtZero(); Rect rect = outRect.ContractedBy(7f); Widgets.DrawShadowAround(outRect); Widgets.DrawWindowBackgroundTutor(outRect); Rect rect2 = rect; rect2.width -= 20f; rect2.height = titleHeight + 5f; Text.Font = GameFont.Medium; Widgets.Label(rect2, conc.LabelCap); Text.Font = GameFont.Small; Rect rect3 = rect; rect3.yMin = rect2.yMax; rect3.height = textHeight; Widgets.Label(rect3, conc.HelpTextAdjusted); if (drawProgressBar) { Rect rect4 = rect; rect4.yMin = rect3.yMax; rect4.height = 30f; Widgets.FillableBar(rect4, PlayerKnowledgeDatabase.GetKnowledge(conc), LearningReadout.ProgressBarFillTex); } if (this.selectedConcept == conc) { if (Widgets.CloseButtonFor(outRect)) { this.selectedConcept = null; SoundDefOf.PageChange.PlayOneShotOnCamera(null); } Rect rect5 = new Rect(rect.center.x - 70f, rect.yMax - 30f, 140f, 30f); if (!complete) { if (Widgets.ButtonText(rect5, "MarkLearned".Translate(), true, false, true)) { this.selectedConcept = null; SoundDefOf.PageChange.PlayOneShotOnCamera(null); PlayerKnowledgeDatabase.SetKnowledge(conc, 1f); } } else { GUI.color = new Color(1f, 1f, 1f, 0.5f); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect5, "AlreadyLearned".Translate()); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; } } }, false, false, 1f); return(outRect2); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; this.ResolveRaidPoints(parms); if (!this.TryResolveRaidFaction(parms)) { return(false); } PawnGroupKindDef combat = PawnGroupKindDefOf.Combat; this.ResolveRaidStrategy(parms, combat); this.ResolveRaidArriveMode(parms); if (!parms.raidArrivalMode.Worker.TryResolveRaidSpawnCenter(parms)) { return(false); } parms.points = IncidentWorker_Raid.AdjustedRaidPoints(parms.points, parms.raidArrivalMode, parms.raidStrategy, parms.faction, combat); PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(combat, parms, false); List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms, true).ToList <Pawn>(); if (list.Count == 0) { Log.Error("Got no pawns spawning raid from parms " + parms, false); return(false); } parms.raidArrivalMode.Worker.Arrive(list, parms); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Points = " + parms.points.ToString("F0")); foreach (Pawn pawn in list) { string str = (pawn.equipment == null || pawn.equipment.Primary == null) ? "unarmed" : pawn.equipment.Primary.LabelCap; stringBuilder.AppendLine(pawn.KindLabel + " - " + str); } string letterLabel = this.GetLetterLabel(parms); string letterText = this.GetLetterText(parms, list); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref letterLabel, ref letterText, this.GetRelatedPawnsInfoLetterText(parms), true, true); List <TargetInfo> list2 = new List <TargetInfo>(); if (parms.pawnGroups != null) { List <List <Pawn> > list3 = IncidentParmsUtility.SplitIntoGroups(list, parms.pawnGroups); List <Pawn> list4 = list3.MaxBy((List <Pawn> x) => x.Count); if (list4.Any <Pawn>()) { list2.Add(list4[0]); } for (int i = 0; i < list3.Count; i++) { if (list3[i] != list4) { if (list3[i].Any <Pawn>()) { list2.Add(list3[i][0]); } } } } else if (list.Any <Pawn>()) { list2.Add(list[0]); } Find.LetterStack.ReceiveLetter(letterLabel, letterText, this.GetLetterDef(), list2, parms.faction, stringBuilder.ToString()); parms.raidStrategy.Worker.MakeLords(parms, list); AvoidGridMaker.RegenerateAvoidGridsFor(parms.faction, map); LessonAutoActivator.TeachOpportunity(ConceptDefOf.EquippingWeapons, OpportunityType.Critical); if (!PlayerKnowledgeDatabase.IsComplete(ConceptDefOf.ShieldBelts)) { for (int j = 0; j < list.Count; j++) { Pawn pawn2 = list[j]; if (pawn2.apparel.WornApparel.Any((Apparel ap) => ap is ShieldBelt)) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.ShieldBelts, OpportunityType.Critical); break; } } } return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; this.ResolveRaidPoints(parms); if (!this.TryResolveRaidFaction(parms)) { return(false); } this.ResolveRaidStrategy(parms); this.ResolveRaidArriveMode(parms); if (!this.ResolveRaidSpawnCenter(parms)) { return(false); } IncidentParmsUtility.AdjustPointsForGroupArrivalParams(parms); PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(parms, false); List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(PawnGroupKindDefOf.Normal, defaultPawnGroupMakerParms, true).ToList(); if (list.Count == 0) { Log.Error("Got no pawns spawning raid from parms " + parms); return(false); } TargetInfo target = TargetInfo.Invalid; if (parms.raidArrivalMode == PawnsArriveMode.CenterDrop || parms.raidArrivalMode == PawnsArriveMode.EdgeDrop) { DropPodUtility.DropThingsNear(parms.spawnCenter, map, list.Cast <Thing>(), parms.raidPodOpenDelay, false, true, true, false); target = new TargetInfo(parms.spawnCenter, map, false); } else { foreach (Pawn item in list) { IntVec3 loc = CellFinder.RandomClosewalkCellNear(parms.spawnCenter, map, 8, null); GenSpawn.Spawn(item, loc, map, parms.spawnRotation, false); target = item; } } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Points = " + parms.points.ToString("F0")); foreach (Pawn item2 in list) { string str = (item2.equipment == null || item2.equipment.Primary == null) ? "unarmed" : item2.equipment.Primary.LabelCap; stringBuilder.AppendLine(item2.KindLabel + " - " + str); } string letterLabel = this.GetLetterLabel(parms); string letterText = this.GetLetterText(parms, list); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref letterLabel, ref letterText, this.GetRelatedPawnsInfoLetterText(parms), true, true); Find.LetterStack.ReceiveLetter(letterLabel, letterText, this.GetLetterDef(), target, stringBuilder.ToString()); if (this.GetLetterDef() == LetterDefOf.ThreatBig) { TaleRecorder.RecordTale(TaleDefOf.RaidArrived); } Lord lord = LordMaker.MakeNewLord(parms.faction, parms.raidStrategy.Worker.MakeLordJob(parms, map), map, list); AvoidGridMaker.RegenerateAvoidGridsFor(parms.faction, map); LessonAutoActivator.TeachOpportunity(ConceptDefOf.EquippingWeapons, OpportunityType.Critical); if (!PlayerKnowledgeDatabase.IsComplete(ConceptDefOf.ShieldBelts)) { for (int i = 0; i < list.Count; i++) { Pawn pawn = list[i]; if (pawn.apparel.WornApparel.Any((Apparel ap) => ap is ShieldBelt)) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.ShieldBelts, OpportunityType.Critical); break; } } } if (DebugViewSettings.drawStealDebug && parms.faction.HostileTo(Faction.OfPlayer)) { Log.Message("Market value threshold to start stealing: " + StealAIUtility.StartStealingMarketValueThreshold(lord) + " (colony wealth = " + map.wealthWatcher.WealthTotal + ")"); } return(true); }
public static void LessonAutoActivatorUpdate() { if (TutorSystem.AdaptiveTrainingEnabled && Current.Game != null && !Find.Tutor.learningReadout.ShowAllMode) { LessonAutoActivator.timeSinceLastLesson += RealTime.realDeltaTime; if (Current.ProgramState == ProgramState.Playing) { if (Time.timeSinceLevelLoad < 8f || Find.WindowStack.SecondsSinceClosedGameStartDialog < 8f || Find.TickManager.NotPlaying) { return; } } for (int i = LessonAutoActivator.alertingConcepts.Count - 1; i >= 0; i--) { if (PlayerKnowledgeDatabase.IsComplete(LessonAutoActivator.alertingConcepts[i])) { LessonAutoActivator.alertingConcepts.RemoveAt(i); } } if (Time.frameCount % 15 == 0 && Find.ActiveLesson.Current == null) { for (int j = 0; j < DefDatabase <ConceptDef> .AllDefsListForReading.Count; j++) { ConceptDef conceptDef = DefDatabase <ConceptDef> .AllDefsListForReading[j]; if (!PlayerKnowledgeDatabase.IsComplete(conceptDef)) { float num = PlayerKnowledgeDatabase.GetKnowledge(conceptDef); num -= 0.00015f * Time.deltaTime * 15f; if (num < 0f) { num = 0f; } PlayerKnowledgeDatabase.SetKnowledge(conceptDef, num); if (conceptDef.opportunityDecays) { float num2 = LessonAutoActivator.GetOpportunity(conceptDef); num2 -= 0.4f * Time.deltaTime * 15f; if (num2 < 0f) { num2 = 0f; } LessonAutoActivator.opportunities[conceptDef] = num2; } } } if (Find.Tutor.learningReadout.ActiveConceptsCount < 3) { ConceptDef conceptDef2 = LessonAutoActivator.MostDesiredConcept(); if (conceptDef2 != null) { float desire = LessonAutoActivator.GetDesire(conceptDef2); if (desire > 0.1f && LessonAutoActivator.RelaxDesire < desire) { LessonAutoActivator.TryInitiateLesson(conceptDef2); } } } else { LessonAutoActivator.SetLastLessonTimeToNow(); } } } }
protected override bool TryExecuteWorker(IncidentParms parms) { ResolveRaidPoints(parms); if (!TryResolveRaidFaction(parms)) { return(false); } PawnGroupKindDef combat = PawnGroupKindDefOf.Combat; ResolveRaidStrategy(parms, combat); ResolveRaidArriveMode(parms); parms.raidStrategy.Worker.TryGenerateThreats(parms); if (!parms.raidArrivalMode.Worker.TryResolveRaidSpawnCenter(parms)) { return(false); } float points = parms.points; parms.points = AdjustedRaidPoints(parms.points, parms.raidArrivalMode, parms.raidStrategy, parms.faction, combat); List <Pawn> list = parms.raidStrategy.Worker.SpawnThreats(parms); if (list == null) { list = PawnGroupMakerUtility.GeneratePawns(IncidentParmsUtility.GetDefaultPawnGroupMakerParms(combat, parms)).ToList(); if (list.Count == 0) { Log.Error("Got no pawns spawning raid from parms " + parms); return(false); } parms.raidArrivalMode.Worker.Arrive(list, parms); } GenerateRaidLoot(parms, points, list); TaggedString letterLabel = GetLetterLabel(parms); TaggedString letterText = GetLetterText(parms, list); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref letterLabel, ref letterText, GetRelatedPawnsInfoLetterText(parms), informEvenIfSeenBefore: true); List <TargetInfo> list2 = new List <TargetInfo>(); if (parms.pawnGroups != null) { List <List <Pawn> > list3 = IncidentParmsUtility.SplitIntoGroups(list, parms.pawnGroups); List <Pawn> list4 = list3.MaxBy((List <Pawn> x) => x.Count); if (list4.Any()) { list2.Add(list4[0]); } for (int i = 0; i < list3.Count; i++) { if (list3[i] != list4 && list3[i].Any()) { list2.Add(list3[i][0]); } } } else if (list.Any()) { foreach (Pawn item in list) { list2.Add(item); } } SendStandardLetter(letterLabel, letterText, GetLetterDef(), parms, list2); parms.raidStrategy.Worker.MakeLords(parms, list); LessonAutoActivator.TeachOpportunity(ConceptDefOf.EquippingWeapons, OpportunityType.Critical); if (!PlayerKnowledgeDatabase.IsComplete(ConceptDefOf.ShieldBelts)) { for (int j = 0; j < list.Count; j++) { if (list[j].apparel.WornApparel.Any((Apparel ap) => ap is ShieldBelt)) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.ShieldBelts, OpportunityType.Critical); break; } } } return(true); }