diff --git a/1.5/Defs/JobDefs/Jobs_Learning.xml b/1.5/Defs/JobDefs/Jobs_Learning.xml
new file mode 100644
index 00000000..16aabb5b
--- /dev/null
+++ b/1.5/Defs/JobDefs/Jobs_Learning.xml
@@ -0,0 +1,10 @@
+
+
+
+
+ AdmiringSpace
+ SaveOurShip2.JobDriver_AdmireSpace
+ admiring space.
+
+
+
\ No newline at end of file
diff --git a/1.5/Defs/LearningDesireDefs/LearningDesires.xml b/1.5/Defs/LearningDesireDefs/LearningDesires.xml
new file mode 100644
index 00000000..ad3c6fd4
--- /dev/null
+++ b/1.5/Defs/LearningDesireDefs/LearningDesires.xml
@@ -0,0 +1,11 @@
+
+
+
+ AdmiringSpace
+
+ Space is so beautiful. Many kids admire it and dream of future life among the stars. Requires some kind of telescope.
+ UI/Icons/Learning/Radiotalking
+ SaveOurShip2.LearningGiver_AdmiringSpace
+ AdmiringSpace
+
+
\ No newline at end of file
diff --git a/Source/1.5/HarmonyPatches.cs b/Source/1.5/HarmonyPatches.cs
index b5534fad..5cdd0c88 100644
--- a/Source/1.5/HarmonyPatches.cs
+++ b/Source/1.5/HarmonyPatches.cs
@@ -4908,6 +4908,32 @@ public static void Postfix(Pawn pawn, ref bool __result)
}
}
+ // Biotech - when on space map, disomle kids learning options that don't work
+ [HarmonyPatch(typeof(Pawn_LearningTracker), "AddNewLearningDesire")]
+ public static class ProperLearningNeedsInSpace
+ {
+ public static bool Prefix(Pawn_LearningTracker __instance)
+ {
+ List learningOptions = DefDatabase.AllDefsListForReading.Where((LearningDesireDef ld) => !__instance.active.Contains(ld) && ld.Worker.CanGiveDesire).ToList();
+ if (__instance.Pawn.Map != null && __instance.Pawn.Map.IsSpace())
+ {
+ learningOptions = learningOptions.Where((LearningDesireDef ld) => ld.defName != "NatureRunning" && ld.defName != "Skydreaming").ToList();
+ if ((__instance.Pawn.Map.listerBuildings.allBuildingsColonist.Any((Building b) => b.def.defName == "Telescope" || b.def.defName == "TelescopeSpace")) &&
+ !__instance.active.Any((LearningDesireDef ld) => ld.defName == "AdmiringSpace"))
+ {
+ learningOptions.Add(DefDatabase.AllDefsListForReading.First((LearningDesireDef ld) => ld.defName == "AdmiringSpace"));
+ }
+ }
+ LearningDesireDef newDesire = learningOptions.RandomElementByWeight((LearningDesireDef ld) => ld.selectionWeight);
+ if (__instance.active.Count >= 2)
+ {
+ __instance.active.RemoveAt(0);
+ }
+ __instance.active.Add(newDesire);
+ return false;
+ }
+ }
+
// Biotech - disable "Summon diabolus available" letters for comm consoles on enemy ships
[HarmonyPatch(typeof(CompUseEffect_CallBossgroup), "PostSpawnSetup")]
public static class DisableMechSpawnAvailableLetter
diff --git a/Source/1.5/Jobs/JobDriver_AdmireSpace.cs b/Source/1.5/Jobs/JobDriver_AdmireSpace.cs
new file mode 100644
index 00000000..7b9486a3
--- /dev/null
+++ b/Source/1.5/Jobs/JobDriver_AdmireSpace.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Verse;
+using Verse.AI;
+using Verse.Sound;
+using RimWorld;
+
+namespace SaveOurShip2
+{
+ class JobDriver_AdmireSpace : JobDriver
+ {
+ public Building telescope => (Building)base.TargetThingA;
+
+ public override bool TryMakePreToilReservations(bool errorOnFailed)
+ {
+ return pawn.Reserve(base.TargetA, job, 1, -1, null, errorOnFailed);
+ }
+
+ protected override IEnumerable MakeNewToils()
+ {
+ this.FailOnDespawnedOrNull(TargetIndex.A);
+ this.FailOnSomeonePhysicallyInteracting(TargetIndex.A);
+ this.FailOnChildLearningConditions();
+ this.FailOn(() => telescope.IsForbidden(pawn));
+ yield return Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.InteractionCell).FailOn(() => telescope.IsForbidden(pawn));
+ Toil toil = ToilMaker.MakeToil("MakeNewToils");
+ toil.tickAction = delegate
+ {
+ pawn.rotationTracker.FaceTarget(base.TargetA);
+ LearningUtility.LearningTickCheckEnd(pawn);
+ };
+ // toil.WithEffect(EffecterDefOf.Radiotalking, TargetIndex.A);
+ toil.handlingFacing = true;
+ toil.defaultCompleteMode = ToilCompleteMode.Never;
+ yield return toil;
+ }
+ }
+}
diff --git a/Source/1.5/Jobs/LearningGiver_AdmiringSpace.cs b/Source/1.5/Jobs/LearningGiver_AdmiringSpace.cs
new file mode 100644
index 00000000..b8710463
--- /dev/null
+++ b/Source/1.5/Jobs/LearningGiver_AdmiringSpace.cs
@@ -0,0 +1,61 @@
+using RimWorld;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Verse;
+using Verse.AI;
+
+namespace SaveOurShip2
+{
+ public class LearningGiver_AdmiringSpace : LearningGiver
+ {
+ // Cannot work properly because context is not passed to this function.
+ // So will just return false, but this desire will be added manually in harmony patch?
+ public override bool CanGiveDesire
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ private bool TryFindTelescope(Pawn pawn, out Thing telescopeResult)
+ {
+ Thing spaceTelecope = null;
+ Thing telecope = null;
+ if (pawn != null)
+ {
+ spaceTelecope = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(ThingDef.Named("TelescopeSpace")), PathEndMode.InteractionCell, TraverseParms.For(pawn), 9999f, (Thing t) => t is Building b && pawn.CanReserve(b) && !b.IsForbidden(pawn));
+ telecope = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(ThingDef.Named("Telescope")), PathEndMode.InteractionCell, TraverseParms.For(pawn), 9999f, (Thing t) => t is Building b && pawn.CanReserve(b) && !b.IsForbidden(pawn));
+ }
+ if (spaceTelecope != null)
+ {
+ telescopeResult = spaceTelecope;
+ }
+ else
+ {
+ telescopeResult = telecope;
+ }
+ return telescopeResult != null;
+ }
+
+ public override bool CanDo(Pawn pawn)
+ {
+ if (!base.CanDo(pawn))
+ {
+ return false;
+ }
+ return TryFindTelescope(pawn, out var telecope);
+ }
+
+ public override Job TryGiveJob(Pawn pawn)
+ {
+ if (!TryFindTelescope(pawn, out var telesope))
+ {
+ return null;
+ }
+ return JobMaker.MakeJob(def.jobDef, telesope);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Source/1.5/RimworldMod.csproj b/Source/1.5/RimworldMod.csproj
index 463ce2d8..6ac3bffb 100644
--- a/Source/1.5/RimworldMod.csproj
+++ b/Source/1.5/RimworldMod.csproj
@@ -262,6 +262,7 @@
+
@@ -291,6 +292,7 @@
+