diff --git a/Assemblies/PrisonLabor.dll b/Assemblies/PrisonLabor.dll index ee12004d..0b975022 100644 Binary files a/Assemblies/PrisonLabor.dll and b/Assemblies/PrisonLabor.dll differ diff --git a/IdDev.txt b/IdDev.txt deleted file mode 100644 index d823590d..00000000 --- a/IdDev.txt +++ /dev/null @@ -1 +0,0 @@ -1133240814 \ No newline at end of file diff --git a/IdMain.txt b/IdMain.txt deleted file mode 100644 index e62e8796..00000000 --- a/IdMain.txt +++ /dev/null @@ -1 +0,0 @@ -972057888 \ No newline at end of file diff --git a/Old sources/PrisonLabor v0.3/Source/ConceptDef_PrisonLaborInstruction.cs b/Old sources/PrisonLabor v0.3/Source/ConceptDef_PrisonLaborInstruction.cs deleted file mode 100644 index acc52ab7..00000000 --- a/Old sources/PrisonLabor v0.3/Source/ConceptDef_PrisonLaborInstruction.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -namespace PrisonLabor -{ - class ConceptDef_PrisonLaborInstruction : ConceptDef - { - - } -} diff --git a/Old sources/PrisonLabor v0.3/Source/InfoDialog.cs b/Old sources/PrisonLabor v0.3/Source/InfoDialog.cs deleted file mode 100644 index 2b2a4716..00000000 --- a/Old sources/PrisonLabor v0.3/Source/InfoDialog.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using UnityEngine; - -namespace PrisonLabor -{ - class InfoDialog : Window - { - private string searchName = string.Empty; - - private string[] searchWords; - - private List cachedNames; - - public override Vector2 InitialSize - { - get - { - return new Vector2(400f, 650f); - } - } - - public InfoDialog() - { - this.doCloseButton = true; - this.absorbInputAroundWindow = true; - this.cachedNames = (from n in (from b in SolidBioDatabase.allBios - select b.name).Concat(PawnNameDatabaseSolid.AllNames()) - orderby n.Last descending - select n).ToList(); - } - - public override void DoWindowContents(Rect inRect) - { - Listing_Standard listing_Standard = new Listing_Standard(); - listing_Standard.Begin(inRect); - listing_Standard.Label("TypeFirstNickOrLastName".Translate(), -1f); - string text = listing_Standard.TextEntry(this.searchName, 1); - if (text.Length < 20) - { - this.searchName = text; - this.searchWords = this.searchName.Replace("'", string.Empty).Split(new char[] - { - ' ' - }); - } - listing_Standard.Gap(4f); - if (this.searchName.Length > 1) - { - foreach (NameTriple current in this.cachedNames.Where(new Func(this.FilterMatch))) - { - if (listing_Standard.ButtonText(current.ToString(), null)) - { - this.TryChooseName(current); - } - if (listing_Standard.CurHeight + 30f > inRect.height - (this.CloseButSize.y + 8f)) - { - break; - } - } - } - listing_Standard.End(); - } - - private bool FilterMatch(NameTriple n) - { - if (n.First == "Tynan" && n.Last == "Sylvester") - { - return false; - } - if (this.searchWords.Length == 0) - { - return false; - } - if (this.searchWords.Length == 1) - { - return n.Last.StartsWith(this.searchName, StringComparison.OrdinalIgnoreCase) || n.First.StartsWith(this.searchName, StringComparison.OrdinalIgnoreCase) || n.Nick.StartsWith(this.searchName, StringComparison.OrdinalIgnoreCase); - } - return this.searchWords.Length == 2 && n.First.EqualsIgnoreCase(this.searchWords[0]) && (n.Last.StartsWith(this.searchWords[1], StringComparison.OrdinalIgnoreCase) || n.Nick.StartsWith(this.searchWords[1], StringComparison.OrdinalIgnoreCase)); - } - - private void TryChooseName(NameTriple name) - { - if (this.AlreadyPreferred(name)) - { - Messages.Message("MessageAlreadyPreferredName".Translate(), MessageSound.RejectInput); - } - else - { - Prefs.PreferredNames.Add(name.ToString()); - this.Close(true); - } - } - - private bool AlreadyPreferred(NameTriple name) - { - return Prefs.PreferredNames.Contains(name.ToString()); - } - } -} diff --git a/Old sources/PrisonLabor v0.3/Source/Initialization.cs b/Old sources/PrisonLabor v0.3/Source/Initialization.cs deleted file mode 100644 index 5f5e5dee..00000000 --- a/Old sources/PrisonLabor v0.3/Source/Initialization.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Harmony; -using System.Reflection; -using System.Reflection.Emit; - -namespace PrisonLabor -{ - [StaticConstructorOnStartup] - class Initialization - { - public static int version = 3; - public static bool oldPlayerNotification = false; - - static Initialization() - { - var harmony = HarmonyInstance.Create("Harmony_PrisonLabor"); - harmony.PatchAll(Assembly.GetExecutingAssembly()); - - PrisonLaborPrefs.Init(); - checkVersion(); - } - - private static void checkVersion() - { - if(PrisonLaborPrefs.Version < 3) - { - // only way to check if mod was installed before - if (PlayerKnowledgeDatabase.IsComplete(DefDatabase.GetNamed("PrisonLabor"))) - { - Log.Message("Detected older version of PrisonLabor"); - oldPlayerNotification = true; - } - } - else - { - Log.Message("Detected PrisonLabor v" + PrisonLaborPrefs.Version); - } - PrisonLaborPrefs.Version = 3; - PrisonLaborPrefs.Save(); - } - } - - [HarmonyPatch(typeof(PrisonerInteractionModeUtility))] - [HarmonyPatch("GetLabel")] - [HarmonyPatch(new Type[] { typeof(PrisonerInteractionModeDef) })] - class Patch - { - static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable instr) - { - // create our WORK label - Label jumpTo = gen.DefineLabel(); - yield return new CodeInstruction(OpCodes.Ldarg_0); - yield return new CodeInstruction(OpCodes.Call, typeof(Patch).GetMethod("getLabelWork")); - //yield return new CodeInstruction(OpCodes.Dup); - yield return new CodeInstruction(OpCodes.Ldstr, "Work"); - yield return new CodeInstruction(OpCodes.Bne_Un, jumpTo); - yield return new CodeInstruction(OpCodes.Ldstr, "Work"); - yield return new CodeInstruction(OpCodes.Ret); - - bool first = true; - foreach (CodeInstruction ci in instr) - { - if (first) - { - first = false; - ci.labels.Add(jumpTo); - } - //debug - //Log.Message("CODE: ToString():" + ci.ToString() + " || labels:" + ci.labels + " || opcode:" + ci.opcode.ToString()); - yield return ci; - } - } - - public static string getLabelWork(PrisonerInteractionModeDef def) - { - if(def == DefDatabase.GetNamed("PrisonLabor_workOption")) - return "Work"; - return ""; - } - } -} diff --git a/Old sources/PrisonLabor v0.3/Source/JobDriver_Supervise.cs b/Old sources/PrisonLabor v0.3/Source/JobDriver_Supervise.cs deleted file mode 100644 index e6fad431..00000000 --- a/Old sources/PrisonLabor v0.3/Source/JobDriver_Supervise.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Verse.AI; - -namespace PrisonLabor -{ - class JobDriver_Supervise : JobDriver - { - protected Pawn Prisoner - { - get - { - return (Pawn)base.CurJob.targetA.Thing; - } - } - - protected override IEnumerable MakeNewToils() - { - this.FailOnDespawnedOrNull(TargetIndex.A); - this.FailOnMentalState(TargetIndex.A); - this.FailOnNotAwake(TargetIndex.A); - this.FailOn(() => !Prisoner.IsPrisonerOfColony || !Prisoner.guest.PrisonerIsSecure); - - yield return Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null); - //yield return Toils_Interpersonal.GotoPrisoner(this.pawn, this.Prisoner, this.Prisoner.guest.interactionMode); - yield return MakeWatchToil(Prisoner); - for(int i = 0; i < 80; i++) - yield return Toils_General.Wait(10).FailOn(() => Prisoner.GetRoom() != pawn.GetRoom()); - yield return MakeWatchToil(Prisoner); - for (int i = 0; i < 80; i++) - yield return Toils_General.Wait(10).FailOn(() => Prisoner.GetRoom() != pawn.GetRoom()); - yield return Toils_Interpersonal.SetLastInteractTime(TargetIndex.A); - } - - protected Toil MakeWatchToil(Pawn prisoner) - { - Toil toil = new Toil(); - toil.initAction = delegate - { - Pawn actor = toil.actor; - IntVec3 ind; - if (Prisoner.GetRoom().Cells.Any(cell => cell.DistanceTo(Prisoner.InteractionCell) < 7 && cell.DistanceTo(Prisoner.InteractionCell) > 4)) - ind = prisoner.GetRoom().Cells.Where(cell => cell.DistanceTo(prisoner.InteractionCell) < 7 && cell.DistanceTo(prisoner.InteractionCell) > 4).RandomElement(); - else - ind = prisoner.GetRoom().Cells.RandomElement(); - actor.pather.StartPath(ind, PathEndMode.OnCell); - }; - toil.defaultCompleteMode = ToilCompleteMode.PatherArrival; - return toil; - } - } -} diff --git a/Old sources/PrisonLabor v0.3/Source/JobGiver_Labor.cs b/Old sources/PrisonLabor v0.3/Source/JobGiver_Labor.cs deleted file mode 100644 index 4ab08a8b..00000000 --- a/Old sources/PrisonLabor v0.3/Source/JobGiver_Labor.cs +++ /dev/null @@ -1,281 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Verse.AI; - -namespace PrisonLabor -{ - public class JobGiver_Labor : ThinkNode - { - public bool emergency; - - public override ThinkNode DeepCopy(bool resolve = true) - { - JobGiver_Labor jobGiver_Work = (JobGiver_Labor)base.DeepCopy(resolve); - jobGiver_Work.emergency = this.emergency; - return jobGiver_Work; - } - - public override float GetPriority(Pawn pawn) - { - if (pawn.workSettings == null || !pawn.workSettings.EverWork) - { - return 0f; - } - TimeAssignmentDef timeAssignmentDef = (pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything; - if (timeAssignmentDef == TimeAssignmentDefOf.Anything) - { - return 5.5f; - } - if (timeAssignmentDef == TimeAssignmentDefOf.Work) - { - return 9f; - } - if (timeAssignmentDef == TimeAssignmentDefOf.Sleep) - { - return 2f; - } - if (timeAssignmentDef == TimeAssignmentDefOf.Joy) - { - return 2f; - } - throw new NotImplementedException(); - } - - public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams) - { - //Check laziness - if( Laziness.pawn(pawn).IsLazy) - { - return ThinkResult.NoJob; - } - if (this.emergency && pawn.mindState.priorityWork.IsPrioritized) - { - List workGiversByPriority = pawn.mindState.priorityWork.WorkType.workGiversByPriority; - for (int i = 0; i < workGiversByPriority.Count; i++) - { - WorkGiver worker = workGiversByPriority[i].Worker; - Job job = this.GiverTryGiveJobPrioritized(pawn, worker, pawn.mindState.priorityWork.Cell); - if (job != null) - { - job.playerForced = true; - return new ThinkResult(job, this, new JobTag?(workGiversByPriority[i].tagToGive)); - } - } - pawn.mindState.priorityWork.Clear(); - } - //Work prisoners will do - List typeNameList = new List { "Cooking", "Mining", "PlantCutting", "Crafting", "Hauling", "Cleaning" }; - List typeList = new List(); - List workList = new List(); - foreach (String workTypeName in typeNameList) - typeList.Add(DefDatabase.GetNamed(workTypeName, true)); - foreach(WorkTypeDef workType in typeList.OrderBy(type => -pawn.skills.AverageOfRelevantSkillsFor(type))) - { - if (!pawn.story.WorkTypeIsDisabled(workType)) - { - for (int m = 0; m < workType.workGiversByPriority.Count; m++) - { - WorkGiver worker = workType.workGiversByPriority[m].Worker; - if (!worker.def.emergency) - { - workList.Add(worker); - } - } - } - } - - int num = -999; - TargetInfo targetInfo = TargetInfo.Invalid; - WorkGiver_Scanner workGiver_Scanner = null; - for (int j = 0; j < workList.Count; j++) - { - WorkGiver workGiver = workList[j]; - if (workGiver.def.priorityInType != num && targetInfo.IsValid) - { - break; - } - if (this.PawnCanUseWorkGiver(pawn, workGiver)) - { - try - { - Job job2 = workGiver.NonScanJob(pawn); - if (job2 != null) - { - return new ThinkResult(job2, this, new JobTag?(workList[j].def.tagToGive)); - } - WorkGiver_Scanner scanner = workGiver as WorkGiver_Scanner; - if (scanner != null) - { - if (workGiver.def.scanThings) - { - Predicate predicate = (Thing t) => !t.IsForbidden(pawn) && scanner.HasJobOnThing(pawn, t, false); - IEnumerable enumerable = scanner.PotentialWorkThingsGlobal(pawn); - Thing thing; - if (scanner.Prioritized) - { - IEnumerable enumerable2 = enumerable; - if (enumerable2 == null) - { - enumerable2 = pawn.Map.listerThings.ThingsMatching(scanner.PotentialWorkThingRequest); - } - Predicate validator = predicate; - thing = GenClosest.ClosestThing_Global_Reachable(pawn.Position, pawn.Map, enumerable2, scanner.PathEndMode, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator, (Thing x) => scanner.GetPriority(pawn, x)); - } - else - { - Predicate validator = predicate; - bool forceGlobalSearch = enumerable != null; - thing = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, scanner.PotentialWorkThingRequest, scanner.PathEndMode, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator, enumerable, 0, scanner.LocalRegionsToScanFirst, forceGlobalSearch, RegionType.Set_Passable, false); - } - if (thing != null) - { - targetInfo = thing; - workGiver_Scanner = scanner; - } - } - if (workGiver.def.scanCells) - { - IntVec3 position = pawn.Position; - float num2 = 99999f; - float num3 = -3.40282347E+38f; - bool prioritized = scanner.Prioritized; - foreach (IntVec3 current in scanner.PotentialWorkCellsGlobal(pawn)) - { - bool flag = false; - float num4 = (float)(current - position).LengthHorizontalSquared; - if (prioritized) - { - if (!current.IsForbidden(pawn) && scanner.HasJobOnCell(pawn, current)) - { - float priority = scanner.GetPriority(pawn, current); - if (priority > num3 || (priority == num3 && num4 < num2)) - { - flag = true; - num3 = priority; - } - } - } - else if (num4 < num2 && !current.IsForbidden(pawn) && scanner.HasJobOnCell(pawn, current)) - { - flag = true; - } - if (flag) - { - targetInfo = new TargetInfo(current, pawn.Map, false); - workGiver_Scanner = scanner; - num2 = num4; - } - } - } - } - } - catch (Exception ex) - { - Log.Error(string.Concat(new object[] - { - pawn, - " threw exception in WorkGiver ", - workGiver.def.defName, - ": ", - ex.ToString() - })); - } - finally - { - } - if (targetInfo.IsValid) - { - pawn.mindState.lastGivenWorkType = workGiver.def.workType; - Job job3; - if (targetInfo.HasThing) - { - job3 = workGiver_Scanner.JobOnThing(pawn, targetInfo.Thing, false); - } - else - { - job3 = workGiver_Scanner.JobOnCell(pawn, targetInfo.Cell); - } - if (job3 != null) - { - return new ThinkResult(job3, this, new JobTag?(workList[j].def.tagToGive)); - } - Log.ErrorOnce(string.Concat(new object[] - { - workGiver_Scanner, - " provided target ", - targetInfo, - " but yielded no actual job for pawn ", - pawn, - ". The CanGiveJob and JobOnX methods may not be synchronized." - }), 6112651); - } - num = workGiver.def.priorityInType; - } - } - return ThinkResult.NoJob; - } - - private bool PawnCanUseWorkGiver(Pawn pawn, WorkGiver giver) - { - return !giver.ShouldSkip(pawn) && (giver.def.canBeDoneByNonColonists || pawn.IsPrisoner) && (pawn.story == null || !pawn.story.WorkTagIsDisabled(giver.def.workTags)) && giver.MissingRequiredCapacity(pawn) == null; - } - - private Job GiverTryGiveJobPrioritized(Pawn pawn, WorkGiver giver, IntVec3 cell) - { - if (!this.PawnCanUseWorkGiver(pawn, giver)) - { - return null; - } - try - { - Job job = giver.NonScanJob(pawn); - if (job != null) - { - Job result = job; - return result; - } - WorkGiver_Scanner scanner = giver as WorkGiver_Scanner; - if (scanner != null) - { - if (giver.def.scanThings) - { - Predicate predicate = (Thing t) => !t.IsForbidden(pawn) && scanner.HasJobOnThing(pawn, t, false); - List thingList = cell.GetThingList(pawn.Map); - for (int i = 0; i < thingList.Count; i++) - { - Thing thing = thingList[i]; - if (scanner.PotentialWorkThingRequest.Accepts(thing) && predicate(thing)) - { - pawn.mindState.lastGivenWorkType = giver.def.workType; - Job result = scanner.JobOnThing(pawn, thing, false); - return result; - } - } - } - if (giver.def.scanCells && !cell.IsForbidden(pawn) && scanner.HasJobOnCell(pawn, cell)) - { - pawn.mindState.lastGivenWorkType = giver.def.workType; - Job result = scanner.JobOnCell(pawn, cell); - return result; - } - } - } - catch (Exception ex) - { - Log.Error(string.Concat(new object[] - { - pawn, - " threw exception in GiverTryGiveJobTargeted on WorkGiver ", - giver.def.defName, - ": ", - ex.ToString() - })); - } - return null; - } - } -} diff --git a/Old sources/PrisonLabor v0.3/Source/Laziness.cs b/Old sources/PrisonLabor v0.3/Source/Laziness.cs deleted file mode 100644 index 1d1eae6a..00000000 --- a/Old sources/PrisonLabor v0.3/Source/Laziness.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -namespace PrisonLabor -{ - class Laziness - { - internal const double LAZY_LEVEL = 0.8; - internal const double NEED_INSPIRATION_LEVEL = 0.5; - internal const double LAZY_RATE = 0.03; - internal const double INSPIRE_RATE = 0.15; - public const int WARDEN_CAPACITY = (int)(INSPIRE_RATE/LAZY_RATE); - - private static Dictionary map = new Dictionary(); - private static PrisonerInteractionModeDef pimDef; - - private double level; - private bool needToBeInspired; - private bool isLazy; - - public static PrisonerInteractionModeDef PimDef - { - get - { - if (pimDef == null) - pimDef = DefDatabase.GetNamed("PrisonLabor_workOption"); - return pimDef; - } - } - - private Laziness() - { - level = 0; - needToBeInspired = false; - } - - public void change(double value) - { - level += value; - } - - public bool IsLazy - { - get - { - return isLazy; - } - } - - public bool NeedToBeInspired - { - get - { - return needToBeInspired; - } - } - - public static Laziness pawn(Pawn pawn) - { - if (map.ContainsKey(pawn)) - { - return map[pawn]; - } - else - { - Laziness laz = new Laziness(); - map.Add(pawn, laz); - return laz; - } - - } - - public static void tick(Pawn pawn) - { - Laziness laz = Laziness.pawn(pawn); - double oldValue = laz.level; - - List pawnsInRoom = new List(); - int prisonersCount = 0; - int wardensCount = 0; - foreach (IntVec3 cell in pawn.GetRoomGroup().Cells) - { - foreach (Thing thing in cell.GetThingList(pawn.Map)) - { - if (thing is Pawn) - pawnsInRoom.Add((Pawn)thing); - } - } - foreach (Pawn p in pawnsInRoom) - { - // colonist nearby - if (p.IsFreeColonist) - wardensCount++; - if (p.IsPrisoner && p.guest.interactionMode == PimDef) - prisonersCount++; - } - - laz.level = laz.level + LAZY_RATE < 1 ? laz.level + LAZY_RATE : 1; - double insipre = (wardensCount * INSPIRE_RATE) / prisonersCount; - laz.level = laz.level > insipre ? laz.level - insipre : 0; - - if (laz.level == 0) - laz.needToBeInspired = false; - if (laz.level >= NEED_INSPIRATION_LEVEL && !laz.needToBeInspired) - laz.needToBeInspired = true; - if (laz.level >= LAZY_LEVEL && !laz.isLazy && wardensCount == 0) - { - laz.isLazy = true; - Messages.Message("Your prioner got lazy!", pawn, MessageSound.Standard); - Tutorials.LazyPrisoner(); - } - else if (laz.isLazy && wardensCount > 0) - { - laz.isLazy = false; - } - - // For Denugging - //Log.Message("Laziness of " + pawn.Name + " changed from " + oldValue + " to " + laz.level); - } - } -} diff --git a/Old sources/PrisonLabor v0.3/Source/Prefs.cs b/Old sources/PrisonLabor v0.3/Source/Prefs.cs deleted file mode 100644 index ff07971a..00000000 --- a/Old sources/PrisonLabor v0.3/Source/Prefs.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Xml.Linq; -using Verse; - -namespace PrisonLabor -{ - public static class PrisonLaborPrefs - { - private static PrisonLaborPrefsData data; - private static string prefsFilePath = Path.Combine(GenFilePaths.ConfigFolderPath, "PrisonData_Prefs.xml"); - - public static int Version - { - get - { - return PrisonLaborPrefs.data.version; - } - set - { - PrisonLaborPrefs.data.version = value; - PrisonLaborPrefs.Apply(); - } - } - - public static void Init() - { - bool flag = !new FileInfo(prefsFilePath).Exists; - PrisonLaborPrefs.data = new PrisonLaborPrefsData(); - PrisonLaborPrefs.data = DirectXmlLoader.ItemFromXmlFile(prefsFilePath, true); - if (flag) - { - ; - } - } - - public static void Save() - { - try - { - XDocument xDocument = new XDocument(); - XElement content = DirectXmlSaver.XElementFromObject(PrisonLaborPrefs.data, typeof(PrisonLaborPrefsData)); - xDocument.Add(content); - xDocument.Save(prefsFilePath); - } - catch (Exception ex) - { - GenUI.ErrorDialog("ProblemSavingFile".Translate(new object[] - { - prefsFilePath, - ex.ToString() - })); - Log.Error("Exception saving prefs: " + ex); - } - } - - public static void Apply() - { - PrisonLaborPrefs.data.Apply(); - } - } -} \ No newline at end of file diff --git a/Old sources/PrisonLabor v0.3/Source/PrefsData.cs b/Old sources/PrisonLabor v0.3/Source/PrefsData.cs deleted file mode 100644 index a116a45c..00000000 --- a/Old sources/PrisonLabor v0.3/Source/PrefsData.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; - -namespace PrisonLabor -{ - public class PrisonLaborPrefsData - { - public int version = -1; - - public PrisonLaborPrefsData() - { - - } - - public void Apply() - { - } - } -} diff --git a/Old sources/PrisonLabor v0.3/Source/PrisonLabor.csproj b/Old sources/PrisonLabor v0.3/Source/PrisonLabor.csproj deleted file mode 100644 index 2531773b..00000000 --- a/Old sources/PrisonLabor v0.3/Source/PrisonLabor.csproj +++ /dev/null @@ -1,76 +0,0 @@ - - - - - Debug - AnyCPU - {97750974-4CB6-4D31-84A1-A3AA77B1E2EE} - Library - Properties - PrisonLabor - PrisonLabor - v3.5 - 512 - - - - false - none - false - ..\Assemblies\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - ..\Assemblies\0Harmony.dll - True - - - ..\..\..\RimWorldWin_Data\Managed\Assembly-CSharp.dll - False - - - - - - - - - ..\..\..\RimWorldWin_Data\Managed\UnityEngine.dll - False - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Old sources/PrisonLabor v0.3/Source/PrisonerInteractionModeOf.cs b/Old sources/PrisonLabor v0.3/Source/PrisonerInteractionModeOf.cs deleted file mode 100644 index a9326e39..00000000 --- a/Old sources/PrisonLabor v0.3/Source/PrisonerInteractionModeOf.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -//Work in progress - -namespace RimWorldd -{ - [DefOf] - public static class PrisonerInteractionModeDefOf - { - public static PrisonerInteractionModeDef NoInteraction; - - public static PrisonerInteractionModeDef Chat; - - //public static PrisonerInteractionModeDef Work; - - public static PrisonerInteractionModeDef AttemptRecruit; - - public static PrisonerInteractionModeDef Release; - - public static PrisonerInteractionModeDef Execution; - } -} diff --git a/Old sources/PrisonLabor v0.3/Source/PrisonerInteractionModeUtility.cs b/Old sources/PrisonLabor v0.3/Source/PrisonerInteractionModeUtility.cs deleted file mode 100644 index bfbbca45..00000000 --- a/Old sources/PrisonLabor v0.3/Source/PrisonerInteractionModeUtility.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -//Work in progress - -namespace RimWorldd -{ - public static class PrisonerInteractionModeUtility - { - public static string GetLabel(this PrisonerInteractionModeDef mode) - { - if (mode == PrisonerInteractionModeDefOf.NoInteraction) - { - return "PrisonerNoInteraction".Translate(); - } - if (mode == PrisonerInteractionModeDefOf.Chat) - { - return "PrisonerFriendlyChat".Translate(); - } - /* - if (mode == PrisonerInteractionModeDefOf.Work) - { - return "Work"; - } - */ - if (mode == PrisonerInteractionModeDefOf.AttemptRecruit) - { - return "PrisonerAttemptRecruit".Translate(); - } - if (mode == PrisonerInteractionModeDefOf.Release) - { - return "PrisonerRelease".Translate(); - } - if (mode == PrisonerInteractionModeDefOf.Execution) - { - return "PrisonerExecution".Translate(); - } - return "Mode needs label"; - } - } -} diff --git a/Old sources/PrisonLabor v0.3/Source/Properties/AssemblyInfo.cs b/Old sources/PrisonLabor v0.3/Source/Properties/AssemblyInfo.cs deleted file mode 100644 index 7aeb72f4..00000000 --- a/Old sources/PrisonLabor v0.3/Source/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PrisonLabor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PrisonLabor")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("97750974-4cb6-4d31-84a1-a3aa77b1e2ee")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.3.0.0")] -[assembly: AssemblyFileVersion("0.3.0.0")] diff --git a/Old sources/PrisonLabor v0.3/Source/ThinkNode_ConditionalIsForced.cs b/Old sources/PrisonLabor v0.3/Source/ThinkNode_ConditionalIsForced.cs deleted file mode 100644 index a78c2a09..00000000 --- a/Old sources/PrisonLabor v0.3/Source/ThinkNode_ConditionalIsForced.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -namespace PrisonLabor -{ - class ThinkNode_ConditionalIsForced : ThinkNode_Conditional - { - protected override bool Satisfied(Pawn pawn) - { - //can work - if (pawn.IsPrisoner) - { - //show tutorial - Tutorials.PrisonLabor(); - if (pawn.guest.interactionMode == DefDatabase.GetNamed("PrisonLabor_workOption")) - { - //can't escape - IntVec3 c; - if (pawn.guest.PrisonerIsSecure && !RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn)) - { - //shouldn't rest (medical reasons) - if (!HealthAIUtility.ShouldSeekMedicalRest(pawn)) - { - // TODO can't or don't want to change - if (true) - { - // needs satisfied (sleep, food, etc.) - // TODO add more - if (pawn.needs.food.CurCategory == HungerCategory.Fed && - pawn.needs.rest.CurCategory == RestCategory.Rested) - { - Laziness.tick(pawn); - return true; - } - } - } - } - } - } - return false; - } - } -} diff --git a/Old sources/PrisonLabor v0.3/Source/Tutorials.cs b/Old sources/PrisonLabor v0.3/Source/Tutorials.cs deleted file mode 100644 index 54911857..00000000 --- a/Old sources/PrisonLabor v0.3/Source/Tutorials.cs +++ /dev/null @@ -1,34 +0,0 @@ -using RimWorld; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Verse; - -namespace PrisonLabor -{ - class Tutorials - { - private static ConceptDef prisonLaborDef = DefDatabase.GetNamed("PrisonLabor", true); - private static ConceptDef lazyPrisonerDef = DefDatabase.GetNamed("LazyPrisoner", true); - - public static void PrisonLabor() - { - if (!PlayerKnowledgeDatabase.IsComplete(prisonLaborDef)) - Verse.Find.Tutor.learningReadout.TryActivateConcept(prisonLaborDef); - //Move it to point after map genration - if(Initialization.oldPlayerNotification) - { - Find.WindowStack.Add(new Dialog_MessageBox("PrisonLabor machanics has changed.\n\n 1. Prisoner Interaction mode must be set to \"Work\" instead of \"No Interaction\".\n 2. Now prisoners will get lazy if not supervised. Warden job will include watching prisoners to prevent that (you can always draft your colonists).", "Ok", null, null, null, "PrisonLabor - New mechanics", false)); - Initialization.oldPlayerNotification = false; - } - } - - public static void LazyPrisoner() - { - if (!PlayerKnowledgeDatabase.IsComplete(lazyPrisonerDef)) - Verse.Find.Tutor.learningReadout.TryActivateConcept(lazyPrisonerDef); - } - - } -} diff --git a/Old sources/PrisonLabor v0.3/Source/VersionChecker.cs b/Old sources/PrisonLabor v0.3/Source/VersionChecker.cs deleted file mode 100644 index 8a05cb36..00000000 --- a/Old sources/PrisonLabor v0.3/Source/VersionChecker.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Harmony; -using System.Reflection; -using System.Reflection.Emit; - -namespace PrisonLabor -{ - [StaticConstructorOnStartup] - class VersionChecker - { - static VersionChecker() - { - var harmony = HarmonyInstance.Create("Harmony_PrisonLabor"); - harmony.PatchAll(Assembly.GetExecutingAssembly()); - } - } - - [HarmonyPatch(typeof(PrisonerInteractionModeUtility))] - [HarmonyPatch("GetLabel")] - [HarmonyPatch(new Type[] { typeof(PrisonerInteractionModeDef) })] - class Patch - { - static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable instr) - { - // create our WORK label - Label jumpTo = gen.DefineLabel(); - yield return new CodeInstruction(OpCodes.Ldarg_0); - yield return new CodeInstruction(OpCodes.Call, typeof(Patch).GetMethod("getLabelWork")); - //yield return new CodeInstruction(OpCodes.Dup); - yield return new CodeInstruction(OpCodes.Ldstr, "Work"); - yield return new CodeInstruction(OpCodes.Bne_Un, jumpTo); - yield return new CodeInstruction(OpCodes.Ldstr, "Work"); - yield return new CodeInstruction(OpCodes.Ret); - - bool first = true; - foreach (CodeInstruction ci in instr) - { - if (first) - { - first = false; - ci.labels.Add(jumpTo); - } - //debug - Log.Message("CODE: ToString():" + ci.ToString() + " || labels:" + ci.labels + " || opcode:" + ci.opcode.ToString()); - yield return ci; - } - } - - public static string getLabelWork(PrisonerInteractionModeDef def) - { - if(def == DefDatabase.GetNamed("PrisonLabor_workOption")) - return "Work"; - return ""; - } - } -} diff --git a/Old sources/PrisonLabor v0.3/Source/WorkGiver_Supervise.cs b/Old sources/PrisonLabor v0.3/Source/WorkGiver_Supervise.cs deleted file mode 100644 index e6eddb98..00000000 --- a/Old sources/PrisonLabor v0.3/Source/WorkGiver_Supervise.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Verse.AI; - -namespace PrisonLabor -{ - class WorkGiver_Supervise : WorkGiver_Warden - { - public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) - { - if (!base.ShouldTakeCareOfPrisoner(pawn, t) || !Laziness.pawn((Pawn)t).NeedToBeInspired) - { - return null; - } - Pawn pawn2 = (Pawn)t; - if (pawn2.guest.interactionMode == DefDatabase.GetNamed("PrisonLabor_workOption") && (!pawn2.Downed || pawn2.InBed()) && pawn.CanReserve(t, 1, -1, null, false) && pawn2.Awake()) - { - return new Job(DefDatabase.GetNamed("PrisonerSupervise"), t); - } - return null; - } - } -} diff --git a/Old sources/PrisonLabor v0.3a/Source/ConceptDef_PrisonLaborInstruction.cs b/Old sources/PrisonLabor v0.3a/Source/ConceptDef_PrisonLaborInstruction.cs deleted file mode 100644 index acc52ab7..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/ConceptDef_PrisonLaborInstruction.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -namespace PrisonLabor -{ - class ConceptDef_PrisonLaborInstruction : ConceptDef - { - - } -} diff --git a/Old sources/PrisonLabor v0.3a/Source/InfoDialog.cs b/Old sources/PrisonLabor v0.3a/Source/InfoDialog.cs deleted file mode 100644 index 2b2a4716..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/InfoDialog.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using UnityEngine; - -namespace PrisonLabor -{ - class InfoDialog : Window - { - private string searchName = string.Empty; - - private string[] searchWords; - - private List cachedNames; - - public override Vector2 InitialSize - { - get - { - return new Vector2(400f, 650f); - } - } - - public InfoDialog() - { - this.doCloseButton = true; - this.absorbInputAroundWindow = true; - this.cachedNames = (from n in (from b in SolidBioDatabase.allBios - select b.name).Concat(PawnNameDatabaseSolid.AllNames()) - orderby n.Last descending - select n).ToList(); - } - - public override void DoWindowContents(Rect inRect) - { - Listing_Standard listing_Standard = new Listing_Standard(); - listing_Standard.Begin(inRect); - listing_Standard.Label("TypeFirstNickOrLastName".Translate(), -1f); - string text = listing_Standard.TextEntry(this.searchName, 1); - if (text.Length < 20) - { - this.searchName = text; - this.searchWords = this.searchName.Replace("'", string.Empty).Split(new char[] - { - ' ' - }); - } - listing_Standard.Gap(4f); - if (this.searchName.Length > 1) - { - foreach (NameTriple current in this.cachedNames.Where(new Func(this.FilterMatch))) - { - if (listing_Standard.ButtonText(current.ToString(), null)) - { - this.TryChooseName(current); - } - if (listing_Standard.CurHeight + 30f > inRect.height - (this.CloseButSize.y + 8f)) - { - break; - } - } - } - listing_Standard.End(); - } - - private bool FilterMatch(NameTriple n) - { - if (n.First == "Tynan" && n.Last == "Sylvester") - { - return false; - } - if (this.searchWords.Length == 0) - { - return false; - } - if (this.searchWords.Length == 1) - { - return n.Last.StartsWith(this.searchName, StringComparison.OrdinalIgnoreCase) || n.First.StartsWith(this.searchName, StringComparison.OrdinalIgnoreCase) || n.Nick.StartsWith(this.searchName, StringComparison.OrdinalIgnoreCase); - } - return this.searchWords.Length == 2 && n.First.EqualsIgnoreCase(this.searchWords[0]) && (n.Last.StartsWith(this.searchWords[1], StringComparison.OrdinalIgnoreCase) || n.Nick.StartsWith(this.searchWords[1], StringComparison.OrdinalIgnoreCase)); - } - - private void TryChooseName(NameTriple name) - { - if (this.AlreadyPreferred(name)) - { - Messages.Message("MessageAlreadyPreferredName".Translate(), MessageSound.RejectInput); - } - else - { - Prefs.PreferredNames.Add(name.ToString()); - this.Close(true); - } - } - - private bool AlreadyPreferred(NameTriple name) - { - return Prefs.PreferredNames.Contains(name.ToString()); - } - } -} diff --git a/Old sources/PrisonLabor v0.3a/Source/Initialization.cs b/Old sources/PrisonLabor v0.3a/Source/Initialization.cs deleted file mode 100644 index 5f5e5dee..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/Initialization.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Harmony; -using System.Reflection; -using System.Reflection.Emit; - -namespace PrisonLabor -{ - [StaticConstructorOnStartup] - class Initialization - { - public static int version = 3; - public static bool oldPlayerNotification = false; - - static Initialization() - { - var harmony = HarmonyInstance.Create("Harmony_PrisonLabor"); - harmony.PatchAll(Assembly.GetExecutingAssembly()); - - PrisonLaborPrefs.Init(); - checkVersion(); - } - - private static void checkVersion() - { - if(PrisonLaborPrefs.Version < 3) - { - // only way to check if mod was installed before - if (PlayerKnowledgeDatabase.IsComplete(DefDatabase.GetNamed("PrisonLabor"))) - { - Log.Message("Detected older version of PrisonLabor"); - oldPlayerNotification = true; - } - } - else - { - Log.Message("Detected PrisonLabor v" + PrisonLaborPrefs.Version); - } - PrisonLaborPrefs.Version = 3; - PrisonLaborPrefs.Save(); - } - } - - [HarmonyPatch(typeof(PrisonerInteractionModeUtility))] - [HarmonyPatch("GetLabel")] - [HarmonyPatch(new Type[] { typeof(PrisonerInteractionModeDef) })] - class Patch - { - static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable instr) - { - // create our WORK label - Label jumpTo = gen.DefineLabel(); - yield return new CodeInstruction(OpCodes.Ldarg_0); - yield return new CodeInstruction(OpCodes.Call, typeof(Patch).GetMethod("getLabelWork")); - //yield return new CodeInstruction(OpCodes.Dup); - yield return new CodeInstruction(OpCodes.Ldstr, "Work"); - yield return new CodeInstruction(OpCodes.Bne_Un, jumpTo); - yield return new CodeInstruction(OpCodes.Ldstr, "Work"); - yield return new CodeInstruction(OpCodes.Ret); - - bool first = true; - foreach (CodeInstruction ci in instr) - { - if (first) - { - first = false; - ci.labels.Add(jumpTo); - } - //debug - //Log.Message("CODE: ToString():" + ci.ToString() + " || labels:" + ci.labels + " || opcode:" + ci.opcode.ToString()); - yield return ci; - } - } - - public static string getLabelWork(PrisonerInteractionModeDef def) - { - if(def == DefDatabase.GetNamed("PrisonLabor_workOption")) - return "Work"; - return ""; - } - } -} diff --git a/Old sources/PrisonLabor v0.3a/Source/JobDriver_Supervise.cs b/Old sources/PrisonLabor v0.3a/Source/JobDriver_Supervise.cs deleted file mode 100644 index e6fad431..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/JobDriver_Supervise.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Verse.AI; - -namespace PrisonLabor -{ - class JobDriver_Supervise : JobDriver - { - protected Pawn Prisoner - { - get - { - return (Pawn)base.CurJob.targetA.Thing; - } - } - - protected override IEnumerable MakeNewToils() - { - this.FailOnDespawnedOrNull(TargetIndex.A); - this.FailOnMentalState(TargetIndex.A); - this.FailOnNotAwake(TargetIndex.A); - this.FailOn(() => !Prisoner.IsPrisonerOfColony || !Prisoner.guest.PrisonerIsSecure); - - yield return Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null); - //yield return Toils_Interpersonal.GotoPrisoner(this.pawn, this.Prisoner, this.Prisoner.guest.interactionMode); - yield return MakeWatchToil(Prisoner); - for(int i = 0; i < 80; i++) - yield return Toils_General.Wait(10).FailOn(() => Prisoner.GetRoom() != pawn.GetRoom()); - yield return MakeWatchToil(Prisoner); - for (int i = 0; i < 80; i++) - yield return Toils_General.Wait(10).FailOn(() => Prisoner.GetRoom() != pawn.GetRoom()); - yield return Toils_Interpersonal.SetLastInteractTime(TargetIndex.A); - } - - protected Toil MakeWatchToil(Pawn prisoner) - { - Toil toil = new Toil(); - toil.initAction = delegate - { - Pawn actor = toil.actor; - IntVec3 ind; - if (Prisoner.GetRoom().Cells.Any(cell => cell.DistanceTo(Prisoner.InteractionCell) < 7 && cell.DistanceTo(Prisoner.InteractionCell) > 4)) - ind = prisoner.GetRoom().Cells.Where(cell => cell.DistanceTo(prisoner.InteractionCell) < 7 && cell.DistanceTo(prisoner.InteractionCell) > 4).RandomElement(); - else - ind = prisoner.GetRoom().Cells.RandomElement(); - actor.pather.StartPath(ind, PathEndMode.OnCell); - }; - toil.defaultCompleteMode = ToilCompleteMode.PatherArrival; - return toil; - } - } -} diff --git a/Old sources/PrisonLabor v0.3a/Source/JobGiver_Labor.cs b/Old sources/PrisonLabor v0.3a/Source/JobGiver_Labor.cs deleted file mode 100644 index 4ab08a8b..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/JobGiver_Labor.cs +++ /dev/null @@ -1,281 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Verse.AI; - -namespace PrisonLabor -{ - public class JobGiver_Labor : ThinkNode - { - public bool emergency; - - public override ThinkNode DeepCopy(bool resolve = true) - { - JobGiver_Labor jobGiver_Work = (JobGiver_Labor)base.DeepCopy(resolve); - jobGiver_Work.emergency = this.emergency; - return jobGiver_Work; - } - - public override float GetPriority(Pawn pawn) - { - if (pawn.workSettings == null || !pawn.workSettings.EverWork) - { - return 0f; - } - TimeAssignmentDef timeAssignmentDef = (pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything; - if (timeAssignmentDef == TimeAssignmentDefOf.Anything) - { - return 5.5f; - } - if (timeAssignmentDef == TimeAssignmentDefOf.Work) - { - return 9f; - } - if (timeAssignmentDef == TimeAssignmentDefOf.Sleep) - { - return 2f; - } - if (timeAssignmentDef == TimeAssignmentDefOf.Joy) - { - return 2f; - } - throw new NotImplementedException(); - } - - public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams) - { - //Check laziness - if( Laziness.pawn(pawn).IsLazy) - { - return ThinkResult.NoJob; - } - if (this.emergency && pawn.mindState.priorityWork.IsPrioritized) - { - List workGiversByPriority = pawn.mindState.priorityWork.WorkType.workGiversByPriority; - for (int i = 0; i < workGiversByPriority.Count; i++) - { - WorkGiver worker = workGiversByPriority[i].Worker; - Job job = this.GiverTryGiveJobPrioritized(pawn, worker, pawn.mindState.priorityWork.Cell); - if (job != null) - { - job.playerForced = true; - return new ThinkResult(job, this, new JobTag?(workGiversByPriority[i].tagToGive)); - } - } - pawn.mindState.priorityWork.Clear(); - } - //Work prisoners will do - List typeNameList = new List { "Cooking", "Mining", "PlantCutting", "Crafting", "Hauling", "Cleaning" }; - List typeList = new List(); - List workList = new List(); - foreach (String workTypeName in typeNameList) - typeList.Add(DefDatabase.GetNamed(workTypeName, true)); - foreach(WorkTypeDef workType in typeList.OrderBy(type => -pawn.skills.AverageOfRelevantSkillsFor(type))) - { - if (!pawn.story.WorkTypeIsDisabled(workType)) - { - for (int m = 0; m < workType.workGiversByPriority.Count; m++) - { - WorkGiver worker = workType.workGiversByPriority[m].Worker; - if (!worker.def.emergency) - { - workList.Add(worker); - } - } - } - } - - int num = -999; - TargetInfo targetInfo = TargetInfo.Invalid; - WorkGiver_Scanner workGiver_Scanner = null; - for (int j = 0; j < workList.Count; j++) - { - WorkGiver workGiver = workList[j]; - if (workGiver.def.priorityInType != num && targetInfo.IsValid) - { - break; - } - if (this.PawnCanUseWorkGiver(pawn, workGiver)) - { - try - { - Job job2 = workGiver.NonScanJob(pawn); - if (job2 != null) - { - return new ThinkResult(job2, this, new JobTag?(workList[j].def.tagToGive)); - } - WorkGiver_Scanner scanner = workGiver as WorkGiver_Scanner; - if (scanner != null) - { - if (workGiver.def.scanThings) - { - Predicate predicate = (Thing t) => !t.IsForbidden(pawn) && scanner.HasJobOnThing(pawn, t, false); - IEnumerable enumerable = scanner.PotentialWorkThingsGlobal(pawn); - Thing thing; - if (scanner.Prioritized) - { - IEnumerable enumerable2 = enumerable; - if (enumerable2 == null) - { - enumerable2 = pawn.Map.listerThings.ThingsMatching(scanner.PotentialWorkThingRequest); - } - Predicate validator = predicate; - thing = GenClosest.ClosestThing_Global_Reachable(pawn.Position, pawn.Map, enumerable2, scanner.PathEndMode, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator, (Thing x) => scanner.GetPriority(pawn, x)); - } - else - { - Predicate validator = predicate; - bool forceGlobalSearch = enumerable != null; - thing = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, scanner.PotentialWorkThingRequest, scanner.PathEndMode, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator, enumerable, 0, scanner.LocalRegionsToScanFirst, forceGlobalSearch, RegionType.Set_Passable, false); - } - if (thing != null) - { - targetInfo = thing; - workGiver_Scanner = scanner; - } - } - if (workGiver.def.scanCells) - { - IntVec3 position = pawn.Position; - float num2 = 99999f; - float num3 = -3.40282347E+38f; - bool prioritized = scanner.Prioritized; - foreach (IntVec3 current in scanner.PotentialWorkCellsGlobal(pawn)) - { - bool flag = false; - float num4 = (float)(current - position).LengthHorizontalSquared; - if (prioritized) - { - if (!current.IsForbidden(pawn) && scanner.HasJobOnCell(pawn, current)) - { - float priority = scanner.GetPriority(pawn, current); - if (priority > num3 || (priority == num3 && num4 < num2)) - { - flag = true; - num3 = priority; - } - } - } - else if (num4 < num2 && !current.IsForbidden(pawn) && scanner.HasJobOnCell(pawn, current)) - { - flag = true; - } - if (flag) - { - targetInfo = new TargetInfo(current, pawn.Map, false); - workGiver_Scanner = scanner; - num2 = num4; - } - } - } - } - } - catch (Exception ex) - { - Log.Error(string.Concat(new object[] - { - pawn, - " threw exception in WorkGiver ", - workGiver.def.defName, - ": ", - ex.ToString() - })); - } - finally - { - } - if (targetInfo.IsValid) - { - pawn.mindState.lastGivenWorkType = workGiver.def.workType; - Job job3; - if (targetInfo.HasThing) - { - job3 = workGiver_Scanner.JobOnThing(pawn, targetInfo.Thing, false); - } - else - { - job3 = workGiver_Scanner.JobOnCell(pawn, targetInfo.Cell); - } - if (job3 != null) - { - return new ThinkResult(job3, this, new JobTag?(workList[j].def.tagToGive)); - } - Log.ErrorOnce(string.Concat(new object[] - { - workGiver_Scanner, - " provided target ", - targetInfo, - " but yielded no actual job for pawn ", - pawn, - ". The CanGiveJob and JobOnX methods may not be synchronized." - }), 6112651); - } - num = workGiver.def.priorityInType; - } - } - return ThinkResult.NoJob; - } - - private bool PawnCanUseWorkGiver(Pawn pawn, WorkGiver giver) - { - return !giver.ShouldSkip(pawn) && (giver.def.canBeDoneByNonColonists || pawn.IsPrisoner) && (pawn.story == null || !pawn.story.WorkTagIsDisabled(giver.def.workTags)) && giver.MissingRequiredCapacity(pawn) == null; - } - - private Job GiverTryGiveJobPrioritized(Pawn pawn, WorkGiver giver, IntVec3 cell) - { - if (!this.PawnCanUseWorkGiver(pawn, giver)) - { - return null; - } - try - { - Job job = giver.NonScanJob(pawn); - if (job != null) - { - Job result = job; - return result; - } - WorkGiver_Scanner scanner = giver as WorkGiver_Scanner; - if (scanner != null) - { - if (giver.def.scanThings) - { - Predicate predicate = (Thing t) => !t.IsForbidden(pawn) && scanner.HasJobOnThing(pawn, t, false); - List thingList = cell.GetThingList(pawn.Map); - for (int i = 0; i < thingList.Count; i++) - { - Thing thing = thingList[i]; - if (scanner.PotentialWorkThingRequest.Accepts(thing) && predicate(thing)) - { - pawn.mindState.lastGivenWorkType = giver.def.workType; - Job result = scanner.JobOnThing(pawn, thing, false); - return result; - } - } - } - if (giver.def.scanCells && !cell.IsForbidden(pawn) && scanner.HasJobOnCell(pawn, cell)) - { - pawn.mindState.lastGivenWorkType = giver.def.workType; - Job result = scanner.JobOnCell(pawn, cell); - return result; - } - } - } - catch (Exception ex) - { - Log.Error(string.Concat(new object[] - { - pawn, - " threw exception in GiverTryGiveJobTargeted on WorkGiver ", - giver.def.defName, - ": ", - ex.ToString() - })); - } - return null; - } - } -} diff --git a/Old sources/PrisonLabor v0.3a/Source/Laziness.cs b/Old sources/PrisonLabor v0.3a/Source/Laziness.cs deleted file mode 100644 index 1d1eae6a..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/Laziness.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -namespace PrisonLabor -{ - class Laziness - { - internal const double LAZY_LEVEL = 0.8; - internal const double NEED_INSPIRATION_LEVEL = 0.5; - internal const double LAZY_RATE = 0.03; - internal const double INSPIRE_RATE = 0.15; - public const int WARDEN_CAPACITY = (int)(INSPIRE_RATE/LAZY_RATE); - - private static Dictionary map = new Dictionary(); - private static PrisonerInteractionModeDef pimDef; - - private double level; - private bool needToBeInspired; - private bool isLazy; - - public static PrisonerInteractionModeDef PimDef - { - get - { - if (pimDef == null) - pimDef = DefDatabase.GetNamed("PrisonLabor_workOption"); - return pimDef; - } - } - - private Laziness() - { - level = 0; - needToBeInspired = false; - } - - public void change(double value) - { - level += value; - } - - public bool IsLazy - { - get - { - return isLazy; - } - } - - public bool NeedToBeInspired - { - get - { - return needToBeInspired; - } - } - - public static Laziness pawn(Pawn pawn) - { - if (map.ContainsKey(pawn)) - { - return map[pawn]; - } - else - { - Laziness laz = new Laziness(); - map.Add(pawn, laz); - return laz; - } - - } - - public static void tick(Pawn pawn) - { - Laziness laz = Laziness.pawn(pawn); - double oldValue = laz.level; - - List pawnsInRoom = new List(); - int prisonersCount = 0; - int wardensCount = 0; - foreach (IntVec3 cell in pawn.GetRoomGroup().Cells) - { - foreach (Thing thing in cell.GetThingList(pawn.Map)) - { - if (thing is Pawn) - pawnsInRoom.Add((Pawn)thing); - } - } - foreach (Pawn p in pawnsInRoom) - { - // colonist nearby - if (p.IsFreeColonist) - wardensCount++; - if (p.IsPrisoner && p.guest.interactionMode == PimDef) - prisonersCount++; - } - - laz.level = laz.level + LAZY_RATE < 1 ? laz.level + LAZY_RATE : 1; - double insipre = (wardensCount * INSPIRE_RATE) / prisonersCount; - laz.level = laz.level > insipre ? laz.level - insipre : 0; - - if (laz.level == 0) - laz.needToBeInspired = false; - if (laz.level >= NEED_INSPIRATION_LEVEL && !laz.needToBeInspired) - laz.needToBeInspired = true; - if (laz.level >= LAZY_LEVEL && !laz.isLazy && wardensCount == 0) - { - laz.isLazy = true; - Messages.Message("Your prioner got lazy!", pawn, MessageSound.Standard); - Tutorials.LazyPrisoner(); - } - else if (laz.isLazy && wardensCount > 0) - { - laz.isLazy = false; - } - - // For Denugging - //Log.Message("Laziness of " + pawn.Name + " changed from " + oldValue + " to " + laz.level); - } - } -} diff --git a/Old sources/PrisonLabor v0.3a/Source/Prefs.cs b/Old sources/PrisonLabor v0.3a/Source/Prefs.cs deleted file mode 100644 index ff07971a..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/Prefs.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Xml.Linq; -using Verse; - -namespace PrisonLabor -{ - public static class PrisonLaborPrefs - { - private static PrisonLaborPrefsData data; - private static string prefsFilePath = Path.Combine(GenFilePaths.ConfigFolderPath, "PrisonData_Prefs.xml"); - - public static int Version - { - get - { - return PrisonLaborPrefs.data.version; - } - set - { - PrisonLaborPrefs.data.version = value; - PrisonLaborPrefs.Apply(); - } - } - - public static void Init() - { - bool flag = !new FileInfo(prefsFilePath).Exists; - PrisonLaborPrefs.data = new PrisonLaborPrefsData(); - PrisonLaborPrefs.data = DirectXmlLoader.ItemFromXmlFile(prefsFilePath, true); - if (flag) - { - ; - } - } - - public static void Save() - { - try - { - XDocument xDocument = new XDocument(); - XElement content = DirectXmlSaver.XElementFromObject(PrisonLaborPrefs.data, typeof(PrisonLaborPrefsData)); - xDocument.Add(content); - xDocument.Save(prefsFilePath); - } - catch (Exception ex) - { - GenUI.ErrorDialog("ProblemSavingFile".Translate(new object[] - { - prefsFilePath, - ex.ToString() - })); - Log.Error("Exception saving prefs: " + ex); - } - } - - public static void Apply() - { - PrisonLaborPrefs.data.Apply(); - } - } -} \ No newline at end of file diff --git a/Old sources/PrisonLabor v0.3a/Source/PrefsData.cs b/Old sources/PrisonLabor v0.3a/Source/PrefsData.cs deleted file mode 100644 index a116a45c..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/PrefsData.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; - -namespace PrisonLabor -{ - public class PrisonLaborPrefsData - { - public int version = -1; - - public PrisonLaborPrefsData() - { - - } - - public void Apply() - { - } - } -} diff --git a/Old sources/PrisonLabor v0.3a/Source/PrisonLabor.csproj b/Old sources/PrisonLabor v0.3a/Source/PrisonLabor.csproj deleted file mode 100644 index d1a1f2f1..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/PrisonLabor.csproj +++ /dev/null @@ -1,76 +0,0 @@ - - - - - Debug - AnyCPU - {97750974-4CB6-4D31-84A1-A3AA77B1E2EE} - Library - Properties - PrisonLabor - PrisonLabor - v3.5 - 512 - - - - false - none - false - ..\Assemblies\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - ..\Assemblies\0Harmony.dll - True - - - ..\..\..\..\Games\SteamLibrary\SteamApps\common\RimWorld\RimWorldWin_Data\Managed\Assembly-CSharp.dll - False - - - - - - - - - ..\..\..\..\Games\SteamLibrary\SteamApps\common\RimWorld\RimWorldWin_Data\Managed\UnityEngine.dll - False - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Old sources/PrisonLabor v0.3a/Source/PrisonerInteractionModeOf.cs b/Old sources/PrisonLabor v0.3a/Source/PrisonerInteractionModeOf.cs deleted file mode 100644 index a9326e39..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/PrisonerInteractionModeOf.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -//Work in progress - -namespace RimWorldd -{ - [DefOf] - public static class PrisonerInteractionModeDefOf - { - public static PrisonerInteractionModeDef NoInteraction; - - public static PrisonerInteractionModeDef Chat; - - //public static PrisonerInteractionModeDef Work; - - public static PrisonerInteractionModeDef AttemptRecruit; - - public static PrisonerInteractionModeDef Release; - - public static PrisonerInteractionModeDef Execution; - } -} diff --git a/Old sources/PrisonLabor v0.3a/Source/PrisonerInteractionModeUtility.cs b/Old sources/PrisonLabor v0.3a/Source/PrisonerInteractionModeUtility.cs deleted file mode 100644 index bfbbca45..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/PrisonerInteractionModeUtility.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -//Work in progress - -namespace RimWorldd -{ - public static class PrisonerInteractionModeUtility - { - public static string GetLabel(this PrisonerInteractionModeDef mode) - { - if (mode == PrisonerInteractionModeDefOf.NoInteraction) - { - return "PrisonerNoInteraction".Translate(); - } - if (mode == PrisonerInteractionModeDefOf.Chat) - { - return "PrisonerFriendlyChat".Translate(); - } - /* - if (mode == PrisonerInteractionModeDefOf.Work) - { - return "Work"; - } - */ - if (mode == PrisonerInteractionModeDefOf.AttemptRecruit) - { - return "PrisonerAttemptRecruit".Translate(); - } - if (mode == PrisonerInteractionModeDefOf.Release) - { - return "PrisonerRelease".Translate(); - } - if (mode == PrisonerInteractionModeDefOf.Execution) - { - return "PrisonerExecution".Translate(); - } - return "Mode needs label"; - } - } -} diff --git a/Old sources/PrisonLabor v0.3a/Source/Properties/AssemblyInfo.cs b/Old sources/PrisonLabor v0.3a/Source/Properties/AssemblyInfo.cs deleted file mode 100644 index 7aeb72f4..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PrisonLabor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PrisonLabor")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("97750974-4cb6-4d31-84a1-a3aa77b1e2ee")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.3.0.0")] -[assembly: AssemblyFileVersion("0.3.0.0")] diff --git a/Old sources/PrisonLabor v0.3a/Source/ThinkNode_ConditionalIsForced.cs b/Old sources/PrisonLabor v0.3a/Source/ThinkNode_ConditionalIsForced.cs deleted file mode 100644 index a78c2a09..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/ThinkNode_ConditionalIsForced.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -namespace PrisonLabor -{ - class ThinkNode_ConditionalIsForced : ThinkNode_Conditional - { - protected override bool Satisfied(Pawn pawn) - { - //can work - if (pawn.IsPrisoner) - { - //show tutorial - Tutorials.PrisonLabor(); - if (pawn.guest.interactionMode == DefDatabase.GetNamed("PrisonLabor_workOption")) - { - //can't escape - IntVec3 c; - if (pawn.guest.PrisonerIsSecure && !RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn)) - { - //shouldn't rest (medical reasons) - if (!HealthAIUtility.ShouldSeekMedicalRest(pawn)) - { - // TODO can't or don't want to change - if (true) - { - // needs satisfied (sleep, food, etc.) - // TODO add more - if (pawn.needs.food.CurCategory == HungerCategory.Fed && - pawn.needs.rest.CurCategory == RestCategory.Rested) - { - Laziness.tick(pawn); - return true; - } - } - } - } - } - } - return false; - } - } -} diff --git a/Old sources/PrisonLabor v0.3a/Source/Tutorials.cs b/Old sources/PrisonLabor v0.3a/Source/Tutorials.cs deleted file mode 100644 index 54911857..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/Tutorials.cs +++ /dev/null @@ -1,34 +0,0 @@ -using RimWorld; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Verse; - -namespace PrisonLabor -{ - class Tutorials - { - private static ConceptDef prisonLaborDef = DefDatabase.GetNamed("PrisonLabor", true); - private static ConceptDef lazyPrisonerDef = DefDatabase.GetNamed("LazyPrisoner", true); - - public static void PrisonLabor() - { - if (!PlayerKnowledgeDatabase.IsComplete(prisonLaborDef)) - Verse.Find.Tutor.learningReadout.TryActivateConcept(prisonLaborDef); - //Move it to point after map genration - if(Initialization.oldPlayerNotification) - { - Find.WindowStack.Add(new Dialog_MessageBox("PrisonLabor machanics has changed.\n\n 1. Prisoner Interaction mode must be set to \"Work\" instead of \"No Interaction\".\n 2. Now prisoners will get lazy if not supervised. Warden job will include watching prisoners to prevent that (you can always draft your colonists).", "Ok", null, null, null, "PrisonLabor - New mechanics", false)); - Initialization.oldPlayerNotification = false; - } - } - - public static void LazyPrisoner() - { - if (!PlayerKnowledgeDatabase.IsComplete(lazyPrisonerDef)) - Verse.Find.Tutor.learningReadout.TryActivateConcept(lazyPrisonerDef); - } - - } -} diff --git a/Old sources/PrisonLabor v0.3a/Source/VersionChecker.cs b/Old sources/PrisonLabor v0.3a/Source/VersionChecker.cs deleted file mode 100644 index 8a05cb36..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/VersionChecker.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Harmony; -using System.Reflection; -using System.Reflection.Emit; - -namespace PrisonLabor -{ - [StaticConstructorOnStartup] - class VersionChecker - { - static VersionChecker() - { - var harmony = HarmonyInstance.Create("Harmony_PrisonLabor"); - harmony.PatchAll(Assembly.GetExecutingAssembly()); - } - } - - [HarmonyPatch(typeof(PrisonerInteractionModeUtility))] - [HarmonyPatch("GetLabel")] - [HarmonyPatch(new Type[] { typeof(PrisonerInteractionModeDef) })] - class Patch - { - static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable instr) - { - // create our WORK label - Label jumpTo = gen.DefineLabel(); - yield return new CodeInstruction(OpCodes.Ldarg_0); - yield return new CodeInstruction(OpCodes.Call, typeof(Patch).GetMethod("getLabelWork")); - //yield return new CodeInstruction(OpCodes.Dup); - yield return new CodeInstruction(OpCodes.Ldstr, "Work"); - yield return new CodeInstruction(OpCodes.Bne_Un, jumpTo); - yield return new CodeInstruction(OpCodes.Ldstr, "Work"); - yield return new CodeInstruction(OpCodes.Ret); - - bool first = true; - foreach (CodeInstruction ci in instr) - { - if (first) - { - first = false; - ci.labels.Add(jumpTo); - } - //debug - Log.Message("CODE: ToString():" + ci.ToString() + " || labels:" + ci.labels + " || opcode:" + ci.opcode.ToString()); - yield return ci; - } - } - - public static string getLabelWork(PrisonerInteractionModeDef def) - { - if(def == DefDatabase.GetNamed("PrisonLabor_workOption")) - return "Work"; - return ""; - } - } -} diff --git a/Old sources/PrisonLabor v0.3a/Source/WorkGiver_Supervise.cs b/Old sources/PrisonLabor v0.3a/Source/WorkGiver_Supervise.cs deleted file mode 100644 index 6c54d5d8..00000000 --- a/Old sources/PrisonLabor v0.3a/Source/WorkGiver_Supervise.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Verse.AI; - -namespace PrisonLabor -{ - class WorkGiver_Supervise : WorkGiver_Warden - { - public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) - { - if (!base.ShouldTakeCareOfPrisoner(pawn, t) || !Laziness.pawn((Pawn)t).NeedToBeInspired) - { - return null; - } - if (((Pawn)t).needs.food.CurCategory != HungerCategory.Fed && ((Pawn)t).needs.rest.CurCategory != RestCategory.Rested) - { - return null; - } - Pawn pawn2 = (Pawn)t; - if (pawn2.guest.interactionMode == DefDatabase.GetNamed("PrisonLabor_workOption") && (!pawn2.Downed || pawn2.InBed()) && pawn.CanReserve(t, 1, -1, null, false) && pawn2.Awake()) - { - return new Job(DefDatabase.GetNamed("PrisonerSupervise"), t); - } - return null; - } - } -} diff --git a/Old sources/PrisonLabor v0.3b/.gitignore b/Old sources/PrisonLabor v0.3b/.gitignore deleted file mode 100644 index 940794e6..00000000 --- a/Old sources/PrisonLabor v0.3b/.gitignore +++ /dev/null @@ -1,288 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ -**/Properties/launchSettings.json - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Typescript v1 declaration files -typings/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush -.cr/ - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs diff --git a/Old sources/PrisonLabor v0.3b/README.md b/Old sources/PrisonLabor v0.3b/README.md deleted file mode 100644 index 16b2dc0e..00000000 --- a/Old sources/PrisonLabor v0.3b/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# PrisonLabor -Prison Labor mod for "RimWorld" game - -## Version 0.3b - -## Description -This mod force prisoners to work if Prisoner Interaction is set to "Work". -Prisoner must be fed, and rested, or he(she) will refuse to work. Currently prisoners can only cook, mine, cut plants, craft, haul, and clean. -Attention! He can run away if he mine a way out. - -Prisoners need to be watched by wardens, or they will get lazy. - -This is early alpha version, and it can be buggy. - -## Compatibility -Works with mods that add Jobs of type cook/mine/craft/haul/clean like Quarry, or Haulers Can Haul To Blueprints -Works with saves. You can enable, re-enable, disable this mod to all saves. (However disabling mod can throw errors, but they just saying they can't find tutorials, no harm) -No collisions with other mods detected yet. Only mods that changes thinking of humanlike should be considered (Humanlike_PostDuty handle). - -## To-do list -* Make prisoner laziness appear on "Needs" tab -* Add translations -* Customize mod to satisfy every user. -* Add control time of work etc. -* Change way of getting food by prisoner (currently RimWorld mechanics forcing prisoner to get to bed and wait for warden unless he is very very hungry) - -## To make prisoners work you must meet these conditions -* Prisoner is safe, and don't need medical assistance. -* Prisoner don't need to recover from injury/sickness in bed. -* Prisoner can't escape. -* Prisoner can reach work (best way to do that is leaving open doors to work area). -* Prisoner is fed, and rested. -* Prisoner interaction is set to "Work" (no "Chat and Recruit", or "Friendly Chat"). - -## Translations -Please contact me if you want help me writing translations. It will take you a few minutes to translate few sentences, and you will help making the mod even better. Thank you in advance! -Also I would gladly hear about misspellings or grammar mistakes in English version. diff --git a/Old sources/PrisonLabor v0.3b/Source/ConceptDef_PrisonLaborInstruction.cs b/Old sources/PrisonLabor v0.3b/Source/ConceptDef_PrisonLaborInstruction.cs deleted file mode 100644 index acc52ab7..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/ConceptDef_PrisonLaborInstruction.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -namespace PrisonLabor -{ - class ConceptDef_PrisonLaborInstruction : ConceptDef - { - - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/InfoDialog.cs b/Old sources/PrisonLabor v0.3b/Source/InfoDialog.cs deleted file mode 100644 index 2b2a4716..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/InfoDialog.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using UnityEngine; - -namespace PrisonLabor -{ - class InfoDialog : Window - { - private string searchName = string.Empty; - - private string[] searchWords; - - private List cachedNames; - - public override Vector2 InitialSize - { - get - { - return new Vector2(400f, 650f); - } - } - - public InfoDialog() - { - this.doCloseButton = true; - this.absorbInputAroundWindow = true; - this.cachedNames = (from n in (from b in SolidBioDatabase.allBios - select b.name).Concat(PawnNameDatabaseSolid.AllNames()) - orderby n.Last descending - select n).ToList(); - } - - public override void DoWindowContents(Rect inRect) - { - Listing_Standard listing_Standard = new Listing_Standard(); - listing_Standard.Begin(inRect); - listing_Standard.Label("TypeFirstNickOrLastName".Translate(), -1f); - string text = listing_Standard.TextEntry(this.searchName, 1); - if (text.Length < 20) - { - this.searchName = text; - this.searchWords = this.searchName.Replace("'", string.Empty).Split(new char[] - { - ' ' - }); - } - listing_Standard.Gap(4f); - if (this.searchName.Length > 1) - { - foreach (NameTriple current in this.cachedNames.Where(new Func(this.FilterMatch))) - { - if (listing_Standard.ButtonText(current.ToString(), null)) - { - this.TryChooseName(current); - } - if (listing_Standard.CurHeight + 30f > inRect.height - (this.CloseButSize.y + 8f)) - { - break; - } - } - } - listing_Standard.End(); - } - - private bool FilterMatch(NameTriple n) - { - if (n.First == "Tynan" && n.Last == "Sylvester") - { - return false; - } - if (this.searchWords.Length == 0) - { - return false; - } - if (this.searchWords.Length == 1) - { - return n.Last.StartsWith(this.searchName, StringComparison.OrdinalIgnoreCase) || n.First.StartsWith(this.searchName, StringComparison.OrdinalIgnoreCase) || n.Nick.StartsWith(this.searchName, StringComparison.OrdinalIgnoreCase); - } - return this.searchWords.Length == 2 && n.First.EqualsIgnoreCase(this.searchWords[0]) && (n.Last.StartsWith(this.searchWords[1], StringComparison.OrdinalIgnoreCase) || n.Nick.StartsWith(this.searchWords[1], StringComparison.OrdinalIgnoreCase)); - } - - private void TryChooseName(NameTriple name) - { - if (this.AlreadyPreferred(name)) - { - Messages.Message("MessageAlreadyPreferredName".Translate(), MessageSound.RejectInput); - } - else - { - Prefs.PreferredNames.Add(name.ToString()); - this.Close(true); - } - } - - private bool AlreadyPreferred(NameTriple name) - { - return Prefs.PreferredNames.Contains(name.ToString()); - } - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/Initialization.cs b/Old sources/PrisonLabor v0.3b/Source/Initialization.cs deleted file mode 100644 index b997df52..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/Initialization.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Harmony; -using System.Reflection; -using System.Reflection.Emit; -using Verse.AI; - -namespace PrisonLabor -{ - [StaticConstructorOnStartup] - class Initialization - { - public static int version = 3; - public static bool oldPlayerNotification = false; - - static Initialization() - { - var harmony = HarmonyInstance.Create("Harmony_PrisonLabor"); - harmony.PatchAll(Assembly.GetExecutingAssembly()); - harmony.Patch(typeof(Pawn_CarryTracker).GetMethod("TryDropCarriedThing", new Type[] { typeof(IntVec3), typeof(ThingPlaceMode), typeof(Thing).MakeByRefType(), typeof(Action) }), - new HarmonyMethod(null), new HarmonyMethod(typeof(ForibiddenDropPatch).GetMethod("Postfix"))); - harmony.Patch(typeof(Pawn_CarryTracker).GetMethod("TryDropCarriedThing", new Type[] { typeof(IntVec3), typeof(int), typeof(ThingPlaceMode), typeof(Thing).MakeByRefType(), typeof(Action) }), - new HarmonyMethod(null), new HarmonyMethod(typeof(ForibiddenDropPatch).GetMethod("Postfix2"))); - - PrisonLaborPrefs.Init(); - checkVersion(); - } - - private static void checkVersion() - { - if(PrisonLaborPrefs.Version < 3) - { - // only way to check if mod was installed before - if (PlayerKnowledgeDatabase.IsComplete(DefDatabase.GetNamed("PrisonLabor"))) - { - Log.Message("Detected older version of PrisonLabor"); - oldPlayerNotification = true; - } - } - else - { - Log.Message("Detected PrisonLabor v" + PrisonLaborPrefs.Version); - } - PrisonLaborPrefs.Version = 3; - PrisonLaborPrefs.Save(); - } - } - - [HarmonyPatch(typeof(PrisonerInteractionModeUtility))] - [HarmonyPatch("GetLabel")] - [HarmonyPatch(new Type[] { typeof(PrisonerInteractionModeDef) })] - class PrisonInteractionPatch - { - static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable instr) - { - // create our WORK label - Label jumpTo = gen.DefineLabel(); - yield return new CodeInstruction(OpCodes.Ldarg_0); - yield return new CodeInstruction(OpCodes.Call, typeof(PrisonInteractionPatch).GetMethod("getLabelWork")); - //yield return new CodeInstruction(OpCodes.Dup); - yield return new CodeInstruction(OpCodes.Ldstr, "Work"); - yield return new CodeInstruction(OpCodes.Bne_Un, jumpTo); - yield return new CodeInstruction(OpCodes.Ldstr, "Work"); - yield return new CodeInstruction(OpCodes.Ret); - - bool first = true; - foreach (CodeInstruction ci in instr) - { - if (first) - { - first = false; - ci.labels.Add(jumpTo); - } - //debug - //Log.Message("CODE: ToString():" + ci.ToString() + " || labels:" + ci.labels + " || opcode:" + ci.opcode.ToString()); - yield return ci; - } - } - - public static string getLabelWork(PrisonerInteractionModeDef def) - { - if(def == DefDatabase.GetNamed("PrisonLabor_workOption")) - return "Work"; - return ""; - } - } - - class ForibiddenDropPatch - { - public static void Postfix(Pawn_CarryTracker __instance, IntVec3 dropLoc, ThingPlaceMode mode, Thing resultingThing, Action placedAction = null) - { - if (resultingThing.IsForbidden(Faction.OfPlayer) && __instance.pawn.IsPrisonerOfColony) - resultingThing.SetForbidden(false); - } - - public static void Postfix2(Pawn_CarryTracker __instance, int count, IntVec3 dropLoc, ThingPlaceMode mode, Thing resultingThing, Action placedAction = null) - { - Postfix(__instance, dropLoc, mode, resultingThing, placedAction); - } - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/JobDriver_Mine_Tweak.cs b/Old sources/PrisonLabor v0.3b/Source/JobDriver_Mine_Tweak.cs deleted file mode 100644 index 68001482..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/JobDriver_Mine_Tweak.cs +++ /dev/null @@ -1,103 +0,0 @@ -using RimWorld; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using Verse; -using Verse.AI; - -namespace PrisonLabor -{ - public class JobDriver_Mine_Tweak : JobDriver - { - public const int BaseTicksBetweenPickHits = 120; - - private const int BaseDamagePerPickHit = 80; - - private const float MinMiningSpeedForNPCs = 0.5f; - - private int ticksToPickHit = -1000; - - private Effecter effecter; - - private Thing MineTarget - { - get - { - return base.CurJob.GetTarget(TargetIndex.A).Thing; - } - } - - [DebuggerHidden] - protected override IEnumerable MakeNewToils() - { - this.FailOnDespawnedNullOrForbidden(TargetIndex.A); - this.FailOnCellMissingDesignation(TargetIndex.A, DesignationDefOf.Mine); - yield return Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null); - yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch); - Toil mine = new Toil(); - mine.tickAction = delegate - { - Pawn actor = mine.actor; - Thing mineTarget = this.MineTarget; - if (this.ticksToPickHit < -100) - { - this.ResetTicksToPickHit(); - } - if (actor.skills != null) - { - actor.skills.Learn(SkillDefOf.Mining, 0.11f, false); - } - this.ticksToPickHit--; - if (this.ticksToPickHit <= 0) - { - IntVec3 position = mineTarget.Position; - if (this.effecter == null) - { - this.effecter = EffecterDefOf.Mine.Spawn(); - } - this.effecter.Trigger(actor, mineTarget); - int num = 80; - Mineable mineable = mineTarget as Mineable; - if (mineable == null || mineTarget.HitPoints > num) - { - Pawn actor2 = mine.actor; - DamageInfo dinfo = new DamageInfo(DamageDefOf.Mining, num, -1f, actor2, null, null, DamageInfo.SourceCategory.ThingOrUnknown); - mineTarget.TakeDamage(dinfo); - } - else - { - mineable.DestroyMined(actor); - } - if (mineTarget.Destroyed) - { - actor.Map.mineStrikeManager.CheckStruckOre(position, mineTarget.def, actor); - actor.records.Increment(RecordDefOf.CellsMined); - this.ReadyForNextToil(); - return; - } - this.ResetTicksToPickHit(); - } - }; - mine.defaultCompleteMode = ToilCompleteMode.Never; - mine.WithProgressBar(TargetIndex.A, () => 1f - (float)this.MineTarget.HitPoints / (float)this.MineTarget.MaxHitPoints, false, -0.5f); - mine.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); - yield return mine; - } - - private void ResetTicksToPickHit() - { - float num = this.pawn.GetStatValue(StatDefOf.MiningSpeed, true); - if (num < 0.5f && this.pawn.Faction != Faction.OfPlayer) - { - num = 0.5f; - } - this.ticksToPickHit = (int)Math.Round((double)(120f / num)); - } - - public override void ExposeData() - { - base.ExposeData(); - Scribe_Values.Look(ref this.ticksToPickHit, "ticksToPickHit", 0, false); - } - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/JobDriver_Supervise.cs b/Old sources/PrisonLabor v0.3b/Source/JobDriver_Supervise.cs deleted file mode 100644 index e6fad431..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/JobDriver_Supervise.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Verse.AI; - -namespace PrisonLabor -{ - class JobDriver_Supervise : JobDriver - { - protected Pawn Prisoner - { - get - { - return (Pawn)base.CurJob.targetA.Thing; - } - } - - protected override IEnumerable MakeNewToils() - { - this.FailOnDespawnedOrNull(TargetIndex.A); - this.FailOnMentalState(TargetIndex.A); - this.FailOnNotAwake(TargetIndex.A); - this.FailOn(() => !Prisoner.IsPrisonerOfColony || !Prisoner.guest.PrisonerIsSecure); - - yield return Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null); - //yield return Toils_Interpersonal.GotoPrisoner(this.pawn, this.Prisoner, this.Prisoner.guest.interactionMode); - yield return MakeWatchToil(Prisoner); - for(int i = 0; i < 80; i++) - yield return Toils_General.Wait(10).FailOn(() => Prisoner.GetRoom() != pawn.GetRoom()); - yield return MakeWatchToil(Prisoner); - for (int i = 0; i < 80; i++) - yield return Toils_General.Wait(10).FailOn(() => Prisoner.GetRoom() != pawn.GetRoom()); - yield return Toils_Interpersonal.SetLastInteractTime(TargetIndex.A); - } - - protected Toil MakeWatchToil(Pawn prisoner) - { - Toil toil = new Toil(); - toil.initAction = delegate - { - Pawn actor = toil.actor; - IntVec3 ind; - if (Prisoner.GetRoom().Cells.Any(cell => cell.DistanceTo(Prisoner.InteractionCell) < 7 && cell.DistanceTo(Prisoner.InteractionCell) > 4)) - ind = prisoner.GetRoom().Cells.Where(cell => cell.DistanceTo(prisoner.InteractionCell) < 7 && cell.DistanceTo(prisoner.InteractionCell) > 4).RandomElement(); - else - ind = prisoner.GetRoom().Cells.RandomElement(); - actor.pather.StartPath(ind, PathEndMode.OnCell); - }; - toil.defaultCompleteMode = ToilCompleteMode.PatherArrival; - return toil; - } - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/JobGiver_Labor.cs b/Old sources/PrisonLabor v0.3b/Source/JobGiver_Labor.cs deleted file mode 100644 index 4ab08a8b..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/JobGiver_Labor.cs +++ /dev/null @@ -1,281 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Verse.AI; - -namespace PrisonLabor -{ - public class JobGiver_Labor : ThinkNode - { - public bool emergency; - - public override ThinkNode DeepCopy(bool resolve = true) - { - JobGiver_Labor jobGiver_Work = (JobGiver_Labor)base.DeepCopy(resolve); - jobGiver_Work.emergency = this.emergency; - return jobGiver_Work; - } - - public override float GetPriority(Pawn pawn) - { - if (pawn.workSettings == null || !pawn.workSettings.EverWork) - { - return 0f; - } - TimeAssignmentDef timeAssignmentDef = (pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything; - if (timeAssignmentDef == TimeAssignmentDefOf.Anything) - { - return 5.5f; - } - if (timeAssignmentDef == TimeAssignmentDefOf.Work) - { - return 9f; - } - if (timeAssignmentDef == TimeAssignmentDefOf.Sleep) - { - return 2f; - } - if (timeAssignmentDef == TimeAssignmentDefOf.Joy) - { - return 2f; - } - throw new NotImplementedException(); - } - - public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams) - { - //Check laziness - if( Laziness.pawn(pawn).IsLazy) - { - return ThinkResult.NoJob; - } - if (this.emergency && pawn.mindState.priorityWork.IsPrioritized) - { - List workGiversByPriority = pawn.mindState.priorityWork.WorkType.workGiversByPriority; - for (int i = 0; i < workGiversByPriority.Count; i++) - { - WorkGiver worker = workGiversByPriority[i].Worker; - Job job = this.GiverTryGiveJobPrioritized(pawn, worker, pawn.mindState.priorityWork.Cell); - if (job != null) - { - job.playerForced = true; - return new ThinkResult(job, this, new JobTag?(workGiversByPriority[i].tagToGive)); - } - } - pawn.mindState.priorityWork.Clear(); - } - //Work prisoners will do - List typeNameList = new List { "Cooking", "Mining", "PlantCutting", "Crafting", "Hauling", "Cleaning" }; - List typeList = new List(); - List workList = new List(); - foreach (String workTypeName in typeNameList) - typeList.Add(DefDatabase.GetNamed(workTypeName, true)); - foreach(WorkTypeDef workType in typeList.OrderBy(type => -pawn.skills.AverageOfRelevantSkillsFor(type))) - { - if (!pawn.story.WorkTypeIsDisabled(workType)) - { - for (int m = 0; m < workType.workGiversByPriority.Count; m++) - { - WorkGiver worker = workType.workGiversByPriority[m].Worker; - if (!worker.def.emergency) - { - workList.Add(worker); - } - } - } - } - - int num = -999; - TargetInfo targetInfo = TargetInfo.Invalid; - WorkGiver_Scanner workGiver_Scanner = null; - for (int j = 0; j < workList.Count; j++) - { - WorkGiver workGiver = workList[j]; - if (workGiver.def.priorityInType != num && targetInfo.IsValid) - { - break; - } - if (this.PawnCanUseWorkGiver(pawn, workGiver)) - { - try - { - Job job2 = workGiver.NonScanJob(pawn); - if (job2 != null) - { - return new ThinkResult(job2, this, new JobTag?(workList[j].def.tagToGive)); - } - WorkGiver_Scanner scanner = workGiver as WorkGiver_Scanner; - if (scanner != null) - { - if (workGiver.def.scanThings) - { - Predicate predicate = (Thing t) => !t.IsForbidden(pawn) && scanner.HasJobOnThing(pawn, t, false); - IEnumerable enumerable = scanner.PotentialWorkThingsGlobal(pawn); - Thing thing; - if (scanner.Prioritized) - { - IEnumerable enumerable2 = enumerable; - if (enumerable2 == null) - { - enumerable2 = pawn.Map.listerThings.ThingsMatching(scanner.PotentialWorkThingRequest); - } - Predicate validator = predicate; - thing = GenClosest.ClosestThing_Global_Reachable(pawn.Position, pawn.Map, enumerable2, scanner.PathEndMode, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator, (Thing x) => scanner.GetPriority(pawn, x)); - } - else - { - Predicate validator = predicate; - bool forceGlobalSearch = enumerable != null; - thing = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, scanner.PotentialWorkThingRequest, scanner.PathEndMode, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator, enumerable, 0, scanner.LocalRegionsToScanFirst, forceGlobalSearch, RegionType.Set_Passable, false); - } - if (thing != null) - { - targetInfo = thing; - workGiver_Scanner = scanner; - } - } - if (workGiver.def.scanCells) - { - IntVec3 position = pawn.Position; - float num2 = 99999f; - float num3 = -3.40282347E+38f; - bool prioritized = scanner.Prioritized; - foreach (IntVec3 current in scanner.PotentialWorkCellsGlobal(pawn)) - { - bool flag = false; - float num4 = (float)(current - position).LengthHorizontalSquared; - if (prioritized) - { - if (!current.IsForbidden(pawn) && scanner.HasJobOnCell(pawn, current)) - { - float priority = scanner.GetPriority(pawn, current); - if (priority > num3 || (priority == num3 && num4 < num2)) - { - flag = true; - num3 = priority; - } - } - } - else if (num4 < num2 && !current.IsForbidden(pawn) && scanner.HasJobOnCell(pawn, current)) - { - flag = true; - } - if (flag) - { - targetInfo = new TargetInfo(current, pawn.Map, false); - workGiver_Scanner = scanner; - num2 = num4; - } - } - } - } - } - catch (Exception ex) - { - Log.Error(string.Concat(new object[] - { - pawn, - " threw exception in WorkGiver ", - workGiver.def.defName, - ": ", - ex.ToString() - })); - } - finally - { - } - if (targetInfo.IsValid) - { - pawn.mindState.lastGivenWorkType = workGiver.def.workType; - Job job3; - if (targetInfo.HasThing) - { - job3 = workGiver_Scanner.JobOnThing(pawn, targetInfo.Thing, false); - } - else - { - job3 = workGiver_Scanner.JobOnCell(pawn, targetInfo.Cell); - } - if (job3 != null) - { - return new ThinkResult(job3, this, new JobTag?(workList[j].def.tagToGive)); - } - Log.ErrorOnce(string.Concat(new object[] - { - workGiver_Scanner, - " provided target ", - targetInfo, - " but yielded no actual job for pawn ", - pawn, - ". The CanGiveJob and JobOnX methods may not be synchronized." - }), 6112651); - } - num = workGiver.def.priorityInType; - } - } - return ThinkResult.NoJob; - } - - private bool PawnCanUseWorkGiver(Pawn pawn, WorkGiver giver) - { - return !giver.ShouldSkip(pawn) && (giver.def.canBeDoneByNonColonists || pawn.IsPrisoner) && (pawn.story == null || !pawn.story.WorkTagIsDisabled(giver.def.workTags)) && giver.MissingRequiredCapacity(pawn) == null; - } - - private Job GiverTryGiveJobPrioritized(Pawn pawn, WorkGiver giver, IntVec3 cell) - { - if (!this.PawnCanUseWorkGiver(pawn, giver)) - { - return null; - } - try - { - Job job = giver.NonScanJob(pawn); - if (job != null) - { - Job result = job; - return result; - } - WorkGiver_Scanner scanner = giver as WorkGiver_Scanner; - if (scanner != null) - { - if (giver.def.scanThings) - { - Predicate predicate = (Thing t) => !t.IsForbidden(pawn) && scanner.HasJobOnThing(pawn, t, false); - List thingList = cell.GetThingList(pawn.Map); - for (int i = 0; i < thingList.Count; i++) - { - Thing thing = thingList[i]; - if (scanner.PotentialWorkThingRequest.Accepts(thing) && predicate(thing)) - { - pawn.mindState.lastGivenWorkType = giver.def.workType; - Job result = scanner.JobOnThing(pawn, thing, false); - return result; - } - } - } - if (giver.def.scanCells && !cell.IsForbidden(pawn) && scanner.HasJobOnCell(pawn, cell)) - { - pawn.mindState.lastGivenWorkType = giver.def.workType; - Job result = scanner.JobOnCell(pawn, cell); - return result; - } - } - } - catch (Exception ex) - { - Log.Error(string.Concat(new object[] - { - pawn, - " threw exception in GiverTryGiveJobTargeted on WorkGiver ", - giver.def.defName, - ": ", - ex.ToString() - })); - } - return null; - } - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/Laziness.cs b/Old sources/PrisonLabor v0.3b/Source/Laziness.cs deleted file mode 100644 index 1d1eae6a..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/Laziness.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -namespace PrisonLabor -{ - class Laziness - { - internal const double LAZY_LEVEL = 0.8; - internal const double NEED_INSPIRATION_LEVEL = 0.5; - internal const double LAZY_RATE = 0.03; - internal const double INSPIRE_RATE = 0.15; - public const int WARDEN_CAPACITY = (int)(INSPIRE_RATE/LAZY_RATE); - - private static Dictionary map = new Dictionary(); - private static PrisonerInteractionModeDef pimDef; - - private double level; - private bool needToBeInspired; - private bool isLazy; - - public static PrisonerInteractionModeDef PimDef - { - get - { - if (pimDef == null) - pimDef = DefDatabase.GetNamed("PrisonLabor_workOption"); - return pimDef; - } - } - - private Laziness() - { - level = 0; - needToBeInspired = false; - } - - public void change(double value) - { - level += value; - } - - public bool IsLazy - { - get - { - return isLazy; - } - } - - public bool NeedToBeInspired - { - get - { - return needToBeInspired; - } - } - - public static Laziness pawn(Pawn pawn) - { - if (map.ContainsKey(pawn)) - { - return map[pawn]; - } - else - { - Laziness laz = new Laziness(); - map.Add(pawn, laz); - return laz; - } - - } - - public static void tick(Pawn pawn) - { - Laziness laz = Laziness.pawn(pawn); - double oldValue = laz.level; - - List pawnsInRoom = new List(); - int prisonersCount = 0; - int wardensCount = 0; - foreach (IntVec3 cell in pawn.GetRoomGroup().Cells) - { - foreach (Thing thing in cell.GetThingList(pawn.Map)) - { - if (thing is Pawn) - pawnsInRoom.Add((Pawn)thing); - } - } - foreach (Pawn p in pawnsInRoom) - { - // colonist nearby - if (p.IsFreeColonist) - wardensCount++; - if (p.IsPrisoner && p.guest.interactionMode == PimDef) - prisonersCount++; - } - - laz.level = laz.level + LAZY_RATE < 1 ? laz.level + LAZY_RATE : 1; - double insipre = (wardensCount * INSPIRE_RATE) / prisonersCount; - laz.level = laz.level > insipre ? laz.level - insipre : 0; - - if (laz.level == 0) - laz.needToBeInspired = false; - if (laz.level >= NEED_INSPIRATION_LEVEL && !laz.needToBeInspired) - laz.needToBeInspired = true; - if (laz.level >= LAZY_LEVEL && !laz.isLazy && wardensCount == 0) - { - laz.isLazy = true; - Messages.Message("Your prioner got lazy!", pawn, MessageSound.Standard); - Tutorials.LazyPrisoner(); - } - else if (laz.isLazy && wardensCount > 0) - { - laz.isLazy = false; - } - - // For Denugging - //Log.Message("Laziness of " + pawn.Name + " changed from " + oldValue + " to " + laz.level); - } - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/Prefs.cs b/Old sources/PrisonLabor v0.3b/Source/Prefs.cs deleted file mode 100644 index ff07971a..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/Prefs.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Xml.Linq; -using Verse; - -namespace PrisonLabor -{ - public static class PrisonLaborPrefs - { - private static PrisonLaborPrefsData data; - private static string prefsFilePath = Path.Combine(GenFilePaths.ConfigFolderPath, "PrisonData_Prefs.xml"); - - public static int Version - { - get - { - return PrisonLaborPrefs.data.version; - } - set - { - PrisonLaborPrefs.data.version = value; - PrisonLaborPrefs.Apply(); - } - } - - public static void Init() - { - bool flag = !new FileInfo(prefsFilePath).Exists; - PrisonLaborPrefs.data = new PrisonLaborPrefsData(); - PrisonLaborPrefs.data = DirectXmlLoader.ItemFromXmlFile(prefsFilePath, true); - if (flag) - { - ; - } - } - - public static void Save() - { - try - { - XDocument xDocument = new XDocument(); - XElement content = DirectXmlSaver.XElementFromObject(PrisonLaborPrefs.data, typeof(PrisonLaborPrefsData)); - xDocument.Add(content); - xDocument.Save(prefsFilePath); - } - catch (Exception ex) - { - GenUI.ErrorDialog("ProblemSavingFile".Translate(new object[] - { - prefsFilePath, - ex.ToString() - })); - Log.Error("Exception saving prefs: " + ex); - } - } - - public static void Apply() - { - PrisonLaborPrefs.data.Apply(); - } - } -} \ No newline at end of file diff --git a/Old sources/PrisonLabor v0.3b/Source/PrefsData.cs b/Old sources/PrisonLabor v0.3b/Source/PrefsData.cs deleted file mode 100644 index a116a45c..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/PrefsData.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; - -namespace PrisonLabor -{ - public class PrisonLaborPrefsData - { - public int version = -1; - - public PrisonLaborPrefsData() - { - - } - - public void Apply() - { - } - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/PrisonLabor.csproj b/Old sources/PrisonLabor v0.3b/Source/PrisonLabor.csproj deleted file mode 100644 index e1a04739..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/PrisonLabor.csproj +++ /dev/null @@ -1,79 +0,0 @@ - - - - - Debug - AnyCPU - {97750974-4CB6-4D31-84A1-A3AA77B1E2EE} - Library - Properties - PrisonLabor - PrisonLabor - v3.5 - 512 - - - - false - none - false - ..\Assemblies\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - ..\Assemblies\0Harmony.dll - True - - - ..\..\..\RimWorldWin_Data\Managed\Assembly-CSharp.dll - False - - - - - - - - - ..\..\..\RimWorldWin_Data\Managed\UnityEngine.dll - False - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Old sources/PrisonLabor v0.3b/Source/PrisonerInteractionModeOf.cs b/Old sources/PrisonLabor v0.3b/Source/PrisonerInteractionModeOf.cs deleted file mode 100644 index a9326e39..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/PrisonerInteractionModeOf.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -//Work in progress - -namespace RimWorldd -{ - [DefOf] - public static class PrisonerInteractionModeDefOf - { - public static PrisonerInteractionModeDef NoInteraction; - - public static PrisonerInteractionModeDef Chat; - - //public static PrisonerInteractionModeDef Work; - - public static PrisonerInteractionModeDef AttemptRecruit; - - public static PrisonerInteractionModeDef Release; - - public static PrisonerInteractionModeDef Execution; - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/PrisonerInteractionModeUtility.cs b/Old sources/PrisonLabor v0.3b/Source/PrisonerInteractionModeUtility.cs deleted file mode 100644 index bfbbca45..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/PrisonerInteractionModeUtility.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -//Work in progress - -namespace RimWorldd -{ - public static class PrisonerInteractionModeUtility - { - public static string GetLabel(this PrisonerInteractionModeDef mode) - { - if (mode == PrisonerInteractionModeDefOf.NoInteraction) - { - return "PrisonerNoInteraction".Translate(); - } - if (mode == PrisonerInteractionModeDefOf.Chat) - { - return "PrisonerFriendlyChat".Translate(); - } - /* - if (mode == PrisonerInteractionModeDefOf.Work) - { - return "Work"; - } - */ - if (mode == PrisonerInteractionModeDefOf.AttemptRecruit) - { - return "PrisonerAttemptRecruit".Translate(); - } - if (mode == PrisonerInteractionModeDefOf.Release) - { - return "PrisonerRelease".Translate(); - } - if (mode == PrisonerInteractionModeDefOf.Execution) - { - return "PrisonerExecution".Translate(); - } - return "Mode needs label"; - } - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/Properties/AssemblyInfo.cs b/Old sources/PrisonLabor v0.3b/Source/Properties/AssemblyInfo.cs deleted file mode 100644 index 7aeb72f4..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PrisonLabor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PrisonLabor")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("97750974-4cb6-4d31-84a1-a3aa77b1e2ee")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.3.0.0")] -[assembly: AssemblyFileVersion("0.3.0.0")] diff --git a/Old sources/PrisonLabor v0.3b/Source/ThinkNode_ConditionalIsForced.cs b/Old sources/PrisonLabor v0.3b/Source/ThinkNode_ConditionalIsForced.cs deleted file mode 100644 index a78c2a09..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/ThinkNode_ConditionalIsForced.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; - -namespace PrisonLabor -{ - class ThinkNode_ConditionalIsForced : ThinkNode_Conditional - { - protected override bool Satisfied(Pawn pawn) - { - //can work - if (pawn.IsPrisoner) - { - //show tutorial - Tutorials.PrisonLabor(); - if (pawn.guest.interactionMode == DefDatabase.GetNamed("PrisonLabor_workOption")) - { - //can't escape - IntVec3 c; - if (pawn.guest.PrisonerIsSecure && !RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn)) - { - //shouldn't rest (medical reasons) - if (!HealthAIUtility.ShouldSeekMedicalRest(pawn)) - { - // TODO can't or don't want to change - if (true) - { - // needs satisfied (sleep, food, etc.) - // TODO add more - if (pawn.needs.food.CurCategory == HungerCategory.Fed && - pawn.needs.rest.CurCategory == RestCategory.Rested) - { - Laziness.tick(pawn); - return true; - } - } - } - } - } - } - return false; - } - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/Tutorials.cs b/Old sources/PrisonLabor v0.3b/Source/Tutorials.cs deleted file mode 100644 index 54911857..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/Tutorials.cs +++ /dev/null @@ -1,34 +0,0 @@ -using RimWorld; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Verse; - -namespace PrisonLabor -{ - class Tutorials - { - private static ConceptDef prisonLaborDef = DefDatabase.GetNamed("PrisonLabor", true); - private static ConceptDef lazyPrisonerDef = DefDatabase.GetNamed("LazyPrisoner", true); - - public static void PrisonLabor() - { - if (!PlayerKnowledgeDatabase.IsComplete(prisonLaborDef)) - Verse.Find.Tutor.learningReadout.TryActivateConcept(prisonLaborDef); - //Move it to point after map genration - if(Initialization.oldPlayerNotification) - { - Find.WindowStack.Add(new Dialog_MessageBox("PrisonLabor machanics has changed.\n\n 1. Prisoner Interaction mode must be set to \"Work\" instead of \"No Interaction\".\n 2. Now prisoners will get lazy if not supervised. Warden job will include watching prisoners to prevent that (you can always draft your colonists).", "Ok", null, null, null, "PrisonLabor - New mechanics", false)); - Initialization.oldPlayerNotification = false; - } - } - - public static void LazyPrisoner() - { - if (!PlayerKnowledgeDatabase.IsComplete(lazyPrisonerDef)) - Verse.Find.Tutor.learningReadout.TryActivateConcept(lazyPrisonerDef); - } - - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/VersionChecker.cs b/Old sources/PrisonLabor v0.3b/Source/VersionChecker.cs deleted file mode 100644 index 8a05cb36..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/VersionChecker.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Harmony; -using System.Reflection; -using System.Reflection.Emit; - -namespace PrisonLabor -{ - [StaticConstructorOnStartup] - class VersionChecker - { - static VersionChecker() - { - var harmony = HarmonyInstance.Create("Harmony_PrisonLabor"); - harmony.PatchAll(Assembly.GetExecutingAssembly()); - } - } - - [HarmonyPatch(typeof(PrisonerInteractionModeUtility))] - [HarmonyPatch("GetLabel")] - [HarmonyPatch(new Type[] { typeof(PrisonerInteractionModeDef) })] - class Patch - { - static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable instr) - { - // create our WORK label - Label jumpTo = gen.DefineLabel(); - yield return new CodeInstruction(OpCodes.Ldarg_0); - yield return new CodeInstruction(OpCodes.Call, typeof(Patch).GetMethod("getLabelWork")); - //yield return new CodeInstruction(OpCodes.Dup); - yield return new CodeInstruction(OpCodes.Ldstr, "Work"); - yield return new CodeInstruction(OpCodes.Bne_Un, jumpTo); - yield return new CodeInstruction(OpCodes.Ldstr, "Work"); - yield return new CodeInstruction(OpCodes.Ret); - - bool first = true; - foreach (CodeInstruction ci in instr) - { - if (first) - { - first = false; - ci.labels.Add(jumpTo); - } - //debug - Log.Message("CODE: ToString():" + ci.ToString() + " || labels:" + ci.labels + " || opcode:" + ci.opcode.ToString()); - yield return ci; - } - } - - public static string getLabelWork(PrisonerInteractionModeDef def) - { - if(def == DefDatabase.GetNamed("PrisonLabor_workOption")) - return "Work"; - return ""; - } - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/WorkGiver_Miner_Tweak.cs b/Old sources/PrisonLabor v0.3b/Source/WorkGiver_Miner_Tweak.cs deleted file mode 100644 index 2fe30444..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/WorkGiver_Miner_Tweak.cs +++ /dev/null @@ -1,99 +0,0 @@ -using RimWorld; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using Verse; -using Verse.AI; - -namespace PrisonLabor -{ - public class WorkGiver_Miner_Tweak : WorkGiver_Scanner - { - public override PathEndMode PathEndMode - { - get - { - return PathEndMode.Touch; - } - } - - [DebuggerHidden] - public override IEnumerable PotentialWorkThingsGlobal(Pawn pawn) - { - foreach (Designation des in pawn.Map.designationManager.SpawnedDesignationsOfDef(DesignationDefOf.Mine)) - { - bool mayBeAccessible = false; - for (int i = 0; i < 8; i++) - { - IntVec3 c = des.target.Cell + GenAdj.AdjacentCells[i]; - if (c.InBounds(pawn.Map) && c.Walkable(pawn.Map)) - { - mayBeAccessible = true; - break; - } - } - if (mayBeAccessible) - { - Thing j = MineUtility.MineableInCell(des.target.Cell, pawn.Map); - if (j != null) - { - yield return j; - } - } - } - } - - public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) - { - if (!pawn.IsPrisoner) - { - return null; - } - if (!t.def.mineable) - { - return null; - } - if (pawn.Map.designationManager.DesignationAt(t.Position, DesignationDefOf.Mine) == null) - { - return null; - } - if (!pawn.CanReserve(t, 1, -1, null, false)) - { - return null; - } - bool flag = false; - for (int i = 0; i < 8; i++) - { - IntVec3 intVec = t.Position + GenAdj.AdjacentCells[i]; - if (intVec.InBounds(pawn.Map) && intVec.Standable(pawn.Map) && ReachabilityImmediate.CanReachImmediate(intVec, t, pawn.Map, PathEndMode.Touch, pawn)) - { - flag = true; - break; - } - } - if (!flag) - { - for (int j = 0; j < 8; j++) - { - IntVec3 intVec2 = t.Position + GenAdj.AdjacentCells[j]; - if (intVec2.InBounds(t.Map)) - { - if (ReachabilityImmediate.CanReachImmediate(intVec2, t, pawn.Map, PathEndMode.Touch, pawn)) - { - if (intVec2.Walkable(t.Map) && !intVec2.Standable(t.Map)) - { - Thing firstHaulable = intVec2.GetFirstHaulable(t.Map); - if (firstHaulable != null && firstHaulable.def.passability == Traversability.PassThroughOnly) - { - return HaulAIUtility.HaulAsideJobFor(pawn, firstHaulable); - } - } - } - } - } - return null; - } - return new Job(DefDatabase.GetNamed("PrisonLabor.Mine_Tweak"), t, 1500, true); - } - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/WorkGiver_Supervise.cs b/Old sources/PrisonLabor v0.3b/Source/WorkGiver_Supervise.cs deleted file mode 100644 index 6c54d5d8..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/WorkGiver_Supervise.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using Verse.AI; - -namespace PrisonLabor -{ - class WorkGiver_Supervise : WorkGiver_Warden - { - public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) - { - if (!base.ShouldTakeCareOfPrisoner(pawn, t) || !Laziness.pawn((Pawn)t).NeedToBeInspired) - { - return null; - } - if (((Pawn)t).needs.food.CurCategory != HungerCategory.Fed && ((Pawn)t).needs.rest.CurCategory != RestCategory.Rested) - { - return null; - } - Pawn pawn2 = (Pawn)t; - if (pawn2.guest.interactionMode == DefDatabase.GetNamed("PrisonLabor_workOption") && (!pawn2.Downed || pawn2.InBed()) && pawn.CanReserve(t, 1, -1, null, false) && pawn2.Awake()) - { - return new Job(DefDatabase.GetNamed("PrisonerSupervise"), t); - } - return null; - } - } -} diff --git a/Old sources/PrisonLabor v0.3b/Source/WorkGiver_Warden_DeliverFood_Tweak.cs b/Old sources/PrisonLabor v0.3b/Source/WorkGiver_Warden_DeliverFood_Tweak.cs deleted file mode 100644 index e77d1c7d..00000000 --- a/Old sources/PrisonLabor v0.3b/Source/WorkGiver_Warden_DeliverFood_Tweak.cs +++ /dev/null @@ -1,122 +0,0 @@ -using RimWorld; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Verse; -using Verse.AI; - -namespace PrisonLabor -{ - class WorkGiver_Warden_DeliverFood_Tweak : WorkGiver_Warden - { - public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) - { - if (!base.ShouldTakeCareOfPrisoner(pawn, t)) - { - Messages.Message("one", MessageSound.Negative); - return null; - } - Pawn pawn2 = (Pawn)t; - if (!pawn2.guest.CanBeBroughtFood) - { - Messages.Message("two", MessageSound.Negative); - return null; - } - //TODO test this condition - IntVec3 c; - //if (pawn2.Position.IsInPrisonCell(pawn2.Map) || RCellFinder.TryFindBestExitSpot((Pawn)t, out c, TraverseMode.ByPawn)) - if(false) - { - return null; - } - if (pawn2.needs.food.CurLevelPercentage >= pawn2.needs.food.PercentageThreshHungry + 0.02f) - { - Messages.Message("three", MessageSound.Negative); - return null; - } - if (WardenFeedUtility.ShouldBeFed(pawn2)) - { - Messages.Message("four", MessageSound.Negative); - return null; - } - Thing thing; - ThingDef def; - if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out thing, out def, false, true, false, false, false)) - { - Messages.Message("five", MessageSound.Negative); - return null; - } - if (thing.GetRoom(RegionType.Set_Passable) == pawn2.GetRoom(RegionType.Set_Passable)) - { - Messages.Message("six", MessageSound.Negative); - return null; - } - if (WorkGiver_Warden_DeliverFood_Tweak.FoodAvailableInRoomTo(pawn2)) - { - Messages.Message("seven", MessageSound.Negative); - return null; - } - return new Job(JobDefOf.DeliverFood, thing, pawn2) - { - count = FoodUtility.WillIngestStackCountOf(pawn2, def), - targetC = RCellFinder.SpotToChewStandingNear(pawn2, thing) - }; - } - - private static bool FoodAvailableInRoomTo(Pawn prisoner) - { - if (prisoner.carryTracker.CarriedThing != null && WorkGiver_Warden_DeliverFood_Tweak.NutritionAvailableForFrom(prisoner, prisoner.carryTracker.CarriedThing) > 0f) - { - return true; - } - float num = 0f; - float num2 = 0f; - Room room = prisoner.GetRoom(RegionType.Set_Passable); - if (room == null) - { - return false; - } - for (int i = 0; i < room.RegionCount; i++) - { - Region region = room.Regions[i]; - List list = region.ListerThings.ThingsInGroup(ThingRequestGroup.FoodSourceNotPlantOrTree); - for (int j = 0; j < list.Count; j++) - { - Thing thing = list[j]; - if (!thing.def.IsIngestible || thing.def.ingestible.preferability > FoodPreferability.DesperateOnly) - { - num2 += WorkGiver_Warden_DeliverFood_Tweak.NutritionAvailableForFrom(prisoner, thing); - } - } - List list2 = region.ListerThings.ThingsInGroup(ThingRequestGroup.Pawn); - for (int k = 0; k < list2.Count; k++) - { - Pawn pawn = list2[k] as Pawn; - if (pawn.IsPrisonerOfColony && pawn.needs.food.CurLevelPercentage < pawn.needs.food.PercentageThreshHungry + 0.02f && (pawn.carryTracker.CarriedThing == null || !pawn.RaceProps.WillAutomaticallyEat(pawn.carryTracker.CarriedThing))) - { - num += pawn.needs.food.NutritionWanted; - } - } - } - return num2 + 0.5f >= num; - } - - private static float NutritionAvailableForFrom(Pawn p, Thing foodSource) - { - if (foodSource.def.IsNutritionGivingIngestible && p.RaceProps.WillAutomaticallyEat(foodSource)) - { - return foodSource.def.ingestible.nutrition * (float)foodSource.stackCount; - } - if (p.RaceProps.ToolUser && p.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) - { - Building_NutrientPasteDispenser building_NutrientPasteDispenser = foodSource as Building_NutrientPasteDispenser; - if (building_NutrientPasteDispenser != null && building_NutrientPasteDispenser.CanDispenseNow) - { - return 99999f; - } - } - return 0f; - } - } -} diff --git a/Source/HarmonyPatches/HarmonyPatches.cs b/Source/HarmonyPatches/HarmonyPatches.cs new file mode 100644 index 00000000..9b1e72a3 --- /dev/null +++ b/Source/HarmonyPatches/HarmonyPatches.cs @@ -0,0 +1,171 @@ +using System; +using System.Reflection; +using Harmony; +using PrisonLabor.Harmony; +using Verse; +using System.Collections.Generic; +using System.IO; +using System.Reflection.Emit; + +namespace PrisonLabor.HarmonyPatches +{ + internal static class HarmonyPatches + { + public static void Init() + { + var harmony = HarmonyInstance.Create("Harmony_PrisonLabor"); + try + { + harmony.PatchAll(Assembly.GetExecutingAssembly()); + + // TODO move it to seperate files. Why I did this ??? I have no clue ... + harmony.Patch( + typeof(Pawn_CarryTracker).GetMethod("TryDropCarriedThing", + new[] + { + typeof(IntVec3), typeof(ThingPlaceMode), typeof(Thing).MakeByRefType(), + typeof(Action) + }), + new HarmonyMethod(null), new HarmonyMethod(typeof(ForibiddenDropPatch).GetMethod("Postfix"))); + harmony.Patch( + typeof(Pawn_CarryTracker).GetMethod("TryDropCarriedThing", + new[] + { + typeof(IntVec3), typeof(int), typeof(ThingPlaceMode), typeof(Thing).MakeByRefType(), + typeof(Action) + }), + new HarmonyMethod(null), new HarmonyMethod(typeof(ForibiddenDropPatch).GetMethod("Postfix2"))); + } + catch (Exception e) + { + Log.Error($"Prison Labor Exception, failed to proceed harmony patches: {e.Message}"); + } + } + + /// + /// CIL Debugging method. Creates debug file on desktop that list all CIL code instructions in the method. + /// + /// + /// + public static void CreateDebugFileOnDesktop(string fileName, IEnumerable instr) + { + // Set a variable to the Desktop path. + string myDesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + + // Write the string array to a new file. + using (StreamWriter outputFile = new StreamWriter(myDesktopPath + @"\" + fileName + ".txt")) + { + outputFile.WriteLine("=========="); + outputFile.WriteLine("Body of " + fileName + " method", fileName); + outputFile.WriteLine("=========="); + foreach (CodeInstruction instruction in instr) + { + var instructionString = instruction.opcode.ToString(); + instructionString += " | "; + instructionString += instruction.operand is Label ? $"Label {instruction.operand.GetHashCode()}" : instruction.operand; + instructionString += " | "; + if (instruction.labels.Count > 0) + foreach (var label in instruction.labels) + instructionString += $"Label {label.GetHashCode()}"; + else + instructionString += "no labels"; + outputFile.WriteLine(instructionString); + } + } + } + + /// + /// CIL Debugging method. Creates debug file on desktop that list all CIL code instructions in the method. Also returns original code. + /// + /// + /// + public static IEnumerable CreateDebugFileOnDesktopWithReturn(string fileName, IEnumerable instr) + { + // Set a variable to the Desktop path. + string myDesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + + // Write the string array to a new file. + using (StreamWriter outputFile = new StreamWriter(myDesktopPath + @"\" + fileName + ".txt")) + { + outputFile.WriteLine("=========="); + outputFile.WriteLine("Body of " + fileName + " method", fileName); + outputFile.WriteLine("=========="); + foreach (CodeInstruction instruction in instr) + { + var instructionString = instruction.opcode.ToString(); + instructionString += " | "; + instructionString += instruction.operand is Label ? $"Label {instruction.operand.GetHashCode()}" : instruction.operand; + instructionString += " | "; + if (instruction.labels.Count > 0) + foreach (var label in instruction.labels) + instructionString += $"Label {label.GetHashCode()}"; + else + instructionString += "no labels"; + outputFile.WriteLine(instructionString); + yield return instruction; + } + } + } + + /// + /// This method is used to add some CIL instructions after certain fragment in original code. + /// It should be used inside foreach loop, and return true if particular iteration is the desired one. + /// + /// + /// + /// + /// + /// + public static bool IsFragment(OpCode[] opCodes, String[] operands, CodeInstruction instr, ref int step) + { + if (opCodes.Length != operands.Length) + return false; + if (step < 0 || step >= opCodes.Length) + return false; + + var finalStep = opCodes.Length; + + if (instr.opcode == opCodes[step] && (instr.operand == null || instr.operand.ToString() == operands[step])) + step++; + else + step = 0; + + if (step == finalStep) + { + step++; + return true; + } + return false; + } + + /// + /// This method is used to find particular label that is assigned to last instruction's operand + /// + /// + /// + /// + /// + /// + public static object FindOperandAfter(OpCode[] opCodes, String[] operands, IEnumerable instr) + { + if (opCodes.Length != operands.Length) + return null; + + var finalStep = opCodes.Length; + + int step = 0; + foreach (var ci in instr) + { + if (ci.opcode == opCodes[step] && (ci.operand == null || ci.operand.ToString() == operands[step])) + step++; + else + step = 0; + + if (step == finalStep) + return ci.operand; + } + + return null; + } + } +} diff --git a/Source/HarmonyPatches/Initialization.cs b/Source/HarmonyPatches/Initialization.cs deleted file mode 100644 index dd4d9735..00000000 --- a/Source/HarmonyPatches/Initialization.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Reflection; -using Harmony; -using PrisonLabor.Harmony; -using Verse; - -namespace PrisonLabor.HarmonyPatches -{ - internal static class Initialization - { - public static void Run() - { - var harmony = HarmonyInstance.Create("Harmony_PrisonLabor"); - try - { - harmony.PatchAll(Assembly.GetExecutingAssembly()); - - // TODO move it to seperate files. Why I did this ??? I have no clue ... - harmony.Patch( - typeof(Pawn_CarryTracker).GetMethod("TryDropCarriedThing", - new[] - { - typeof(IntVec3), typeof(ThingPlaceMode), typeof(Thing).MakeByRefType(), - typeof(Action) - }), - new HarmonyMethod(null), new HarmonyMethod(typeof(ForibiddenDropPatch).GetMethod("Postfix"))); - harmony.Patch( - typeof(Pawn_CarryTracker).GetMethod("TryDropCarriedThing", - new[] - { - typeof(IntVec3), typeof(int), typeof(ThingPlaceMode), typeof(Thing).MakeByRefType(), - typeof(Action) - }), - new HarmonyMethod(null), new HarmonyMethod(typeof(ForibiddenDropPatch).GetMethod("Postfix2"))); - } - catch(Exception e) - { - Log.Error($"Prison Labor Exception, failed to proceed harmony patches: {e.Message}"); - } - } - } -} - -/* CIL Debugging method -=============== -// Set a variable to the Desktop path. -string myDesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); - -// Write the string array to a new file. -string fileName = "debug"; -using (StreamWriter outputFile = new StreamWriter(myDesktopPath + @"\" + fileName + ".txt")) -{ - outputFile.WriteLine("=========="); - outputFile.WriteLine("Body of " + fileName + " method", fileName); - outputFile.WriteLine("=========="); - foreach (CodeInstruction instruction in instr) - { - yield return instruction; - outputFile.WriteLine(String.Concat(instruction.opcode, " | ", instruction.operand, " | ", instruction.labels.Count > 0 ? instruction.labels[0].ToString() : "no labels")); - } -} -=============== -*/ diff --git a/Source/HarmonyPatches/Patch_BillCheckbox.cs b/Source/HarmonyPatches/Patch_BillCheckbox.cs index fe7220ca..c1abd214 100644 --- a/Source/HarmonyPatches/Patch_BillCheckbox.cs +++ b/Source/HarmonyPatches/Patch_BillCheckbox.cs @@ -5,6 +5,8 @@ using RimWorld; using UnityEngine; using Verse; +using System; +using System.IO; #pragma warning disable CS0252 @@ -12,52 +14,111 @@ namespace PrisonLabor.HarmonyPatches { [HarmonyPatch(typeof(Dialog_BillConfig))] [HarmonyPatch("DoWindowContents")] - [HarmonyPatch(new[] {typeof(Rect)})] + [HarmonyPatch(new[] { typeof(Rect) })] internal class Patch_BillCheckbox { private static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable instr) { - var step = 0; - CodeInstruction loadBillInstr = null; - var label = new Label(); - foreach (var instruction in instr) + // Find operands + OpCode[] opCodes0 = { - if (step == 0) - if (instruction.opcode == OpCodes.Ldfld) - { - loadBillInstr = instruction; - step++; - } - if (step == 1) - { - if (instruction.opcode == OpCodes.Ldstr && instruction.operand == "BillStoreMode_") - step++; - } - else if (step == 2) - { - if (instruction.opcode == OpCodes.Brfalse) - { - label = (Label) instruction.operand; - step++; - } - } - else if (step == 3) + OpCodes.Ldfld, + }; + String[] operands0 = + { + "RimWorld.Bill_Production bill", + }; + var billField = HarmonyPatches.FindOperandAfter(opCodes0, operands0, instr); + OpCode[] opCodes1 = + { + OpCodes.Ldloc_S, + OpCodes.Ldloc_S, + OpCodes.Ldnull, + OpCodes.Callvirt, + OpCodes.Brfalse + }; + String[] operands1 = + { + "Verse.Listing_Standard (4)", + "System.String (5)", + "", + "Boolean ButtonText(System.String, System.String)", + "System.Reflection.Emit.Label", + }; + var label = HarmonyPatches.FindOperandAfter(opCodes1, operands1, instr); + + // Begin rect - start of scrollable view + int step2 = 0; + int step4 = 0; + OpCode[] opCodes2 = + { + OpCodes.Ldloc_S, + OpCodes.Ldloc_2, + OpCodes.Callvirt, + }; + String[] operands2 = + { + "Verse.Listing_Standard (4)", + "", + "Void Begin(Rect)", + }; + // End rect - end of scrollable view + int step3 = 0; + OpCode[] opCodes3 = + { + OpCodes.Call, + OpCodes.Stfld, + OpCodes.Ldloc_S, + }; + String[] operands3 = + { + "Int32 RoundToInt(Single)", + "System.Int32 unpauseWhenYouHave", + "Verse.Listing_Standard (4)", + }; + + + // Transpiller + if (billField != null && label != null) + { + foreach (var ci in instr) { - if (instruction.labels.Count != 0 && instruction.labels.Contains(label)) + if (ci.labels.Contains((Label)label)) { - var injectedInstruction = new CodeInstruction(OpCodes.Ldloc_S, instruction.operand); - injectedInstruction.labels.Add(label); + var injectedInstruction = new CodeInstruction(OpCodes.Ldloc_S, ci.operand); + injectedInstruction.labels.Add((Label)label); yield return injectedInstruction; yield return new CodeInstruction(OpCodes.Ldarg_0); - yield return new CodeInstruction(loadBillInstr); + yield return new CodeInstruction(OpCodes.Ldfld, billField); yield return new CodeInstruction(OpCodes.Call, typeof(Patch_BillCheckbox).GetMethod("GroupExclusionButton")); - instruction.labels.Remove(label); + ci.labels.Remove((Label)label); + } + if(HarmonyPatches.IsFragment(opCodes3, operands3, ci, ref step3)) + { + var instruction = new CodeInstruction(OpCodes.Call, typeof(Patch_BillCheckbox).GetMethod("StopScrolling")); + instruction.labels.AddRange(ci.labels); + ci.labels.Clear(); + yield return instruction; + } + if (HarmonyPatches.IsFragment(opCodes2, operands2, ci, ref step4)) + { + yield return new CodeInstruction(OpCodes.Call, typeof(Patch_BillCheckbox).GetMethod("SetRect")); + } + yield return ci; + if(HarmonyPatches.IsFragment(opCodes2, operands2, ci, ref step2)) + { + yield return new CodeInstruction(OpCodes.Ldloc_2); + yield return new CodeInstruction(OpCodes.Call, typeof(Patch_BillCheckbox).GetMethod("StartScrolling")); } } - yield return instruction; } + else + { + throw new Exception($"Failed to get operands for harmony patch Patch_BillPrevention: billField: {billField != null}, label: {label != null}"); + } + } public static void GroupExclusionButton(Listing_Standard listing, Bill bill) @@ -79,5 +140,25 @@ public static void GroupExclusionButton(Listing_Standard listing, Bill bill) } listing.Gap(12f); } + + public static Rect SetRect(Rect rect) + { + rect.height += 32; + rect.width -= 16; + return rect; + } + + public static Vector2 position; + public static void StartScrolling(Rect rect) + { + Rect viewRect = new Rect(0, 0, rect.width - 16, rect.height + 32); + Rect outRect = new Rect(0, 0, rect.width, rect.height); + Widgets.BeginScrollView(outRect, ref position, viewRect, true); + } + + public static void StopScrolling() + { + Widgets.EndScrollView(); + } } } \ No newline at end of file diff --git a/Source/HarmonyPatches/Patch_BillPrevention.cs b/Source/HarmonyPatches/Patch_BillPrevention.cs index 034733a6..4a7ca072 100644 --- a/Source/HarmonyPatches/Patch_BillPrevention.cs +++ b/Source/HarmonyPatches/Patch_BillPrevention.cs @@ -4,38 +4,67 @@ using Harmony; using RimWorld; using Verse; +using System; +using System.IO; namespace PrisonLabor.HarmonyPatches { [HarmonyPatch(typeof(WorkGiver_DoBill))] [HarmonyPatch("StartOrResumeBillJob")] - [HarmonyPatch(new[] {typeof(Pawn), typeof(IBillGiver)})] + [HarmonyPatch(new[] { typeof(Pawn), typeof(IBillGiver) })] internal class Patch_BillPrevention { private static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable instr) { - var label = gen.DefineLabel(); - var step = 0; + OpCode[] opCodes = + { + OpCodes.Ldfld, + OpCodes.Ldfld, + OpCodes.Beq, + OpCodes.Br, + }; + String[] operands = + { + "RimWorld.WorkGiverDef def", + "Verse.WorkTypeDef workType", + "System.Reflection.Emit.Label", + "System.Reflection.Emit.Label", + }; + var label = (Label)HarmonyPatches.FindOperandAfter(opCodes, operands, instr); - foreach (var instruction in instr) + OpCode[] opCodes2 = { - if (step == 1) - { - instruction.labels.Add(label); - step++; - } - yield return instruction; - if (step == 0 && instruction.opcode == OpCodes.Stloc_1) + OpCodes.Ldc_I4_0, + OpCodes.Stloc_0, + OpCodes.Br, + OpCodes.Ldarg_2, + OpCodes.Callvirt, + OpCodes.Ldloc_0, + OpCodes.Callvirt, + OpCodes.Stloc_1, + }; + String[] operands2 = + { + "", + "", + "System.Reflection.Emit.Label", + "", + "RimWorld.BillStack get_BillStack()", + "", + "RimWorld.Bill get_Item(Int32)", + "", + }; + var step = 0; + foreach (var ci in instr) + { + yield return ci; + if (HarmonyPatches.IsFragment(opCodes2, operands2, ci, ref step)) { yield return new CodeInstruction(OpCodes.Ldarg_1); yield return new CodeInstruction(OpCodes.Ldloc_1); - yield return new CodeInstruction(OpCodes.Call, - typeof(Patch_BillPrevention).GetMethod("IsForCertainGroup")); - yield return new CodeInstruction(OpCodes.Brtrue, label); - yield return new CodeInstruction(OpCodes.Ldc_I4_0); - yield return new CodeInstruction(OpCodes.Ret); - step++; + yield return new CodeInstruction(OpCodes.Call, typeof(Patch_BillPrevention).GetMethod("IsForCertainGroup")); + yield return new CodeInstruction(OpCodes.Brfalse, label); } } } diff --git a/Source/IncidentWorker_Revolt.cs b/Source/IncidentWorker_Revolt.cs index 3fd8ef48..d323e27b 100644 --- a/Source/IncidentWorker_Revolt.cs +++ b/Source/IncidentWorker_Revolt.cs @@ -24,7 +24,10 @@ protected override bool CanFireNowSub(IIncidentTarget target) if (pawn.Faction.HostileTo(Faction.OfPlayer)) enemyFaction = true; - accumulatedMotivation += pawn.needs.TryGetNeed().CurLevel; + var need = pawn.needs.TryGetNeed(); + if (need == null) + continue; + accumulatedMotivation += need.CurLevel; prisonersCount++; } diff --git a/Source/Initialization.cs b/Source/Initialization.cs index 296f7b29..dd8d9107 100644 --- a/Source/Initialization.cs +++ b/Source/Initialization.cs @@ -7,7 +7,7 @@ internal class Initialization { static Initialization() { - HarmonyPatches.Initialization.Run(); + HarmonyPatches.HarmonyPatches.Init(); PrisonLaborPrefs.Init(); PrisonLaborMod.Init(); VersionUtility.CheckVersion(); diff --git a/Source/NewsDialog.cs b/Source/NewsDialog.cs index 997c86d6..80bed6d4 100644 --- a/Source/NewsDialog.cs +++ b/Source/NewsDialog.cs @@ -23,6 +23,7 @@ internal class NewsDialog : Window public static bool news_0_6 = false; public static bool news_0_7 = false; public static bool news_0_8_0 = false; + public static bool news_0_8_1 = false; // Fields private string[] titles; @@ -41,7 +42,22 @@ public void Init() { List titlesList = new List(); List itemsList = new List(); - + if (news_0_8_1 || showAll) + { + titlesList.Add("Prison Labor Beta v0.8.1"); + string[] itemsArray = + { + "[subtitle] Sorry for any inconvenience caused by 0.8.0 update. Some part of mod are very vulnerable to any mods installed", + "[subtitle] If you encouter any bugs please report it on github. I'm fixing most important ones every day. This is (recently) beta version and it has to consist some bugs. Thank you for understaning.", + "[subtitle] Also you can always download old version via github, but I think this was last big update", + "re-enabled button in Bills detail panel", + "added slider to Bills (temporary fix)", + "fixed Bill \"Prisoner only\" button (I think, let me know if you still experience errors)", + "fixed prisoners aren't working when Motivation is disabled (via Settings)", + "fixed null-reference error on some revolts incidents", + }; + itemsList.Add(itemsArray); + } if (news_0_8_0 || showAll) { titlesList.Add("Prison Labor Beta v0.8.0"); diff --git a/Source/PrefsData.cs b/Source/PrefsData.cs index 7108a8e7..641f84f9 100644 --- a/Source/PrefsData.cs +++ b/Source/PrefsData.cs @@ -38,7 +38,8 @@ public enum Version v0_7_dev3, v0_7_dev4, v0_7_dev5, - v0_8_0 + v0_8_0, + v0_8_1 } [Flags] diff --git a/Source/PrisonLabor.csproj b/Source/PrisonLabor.csproj index b5c73a94..b6353c0e 100644 --- a/Source/PrisonLabor.csproj +++ b/Source/PrisonLabor.csproj @@ -75,7 +75,7 @@ - + diff --git a/Source/ThinkNode_Labor.cs b/Source/ThinkNode_Labor.cs index 0b7203a1..1dfb6144 100644 --- a/Source/ThinkNode_Labor.cs +++ b/Source/ThinkNode_Labor.cs @@ -13,13 +13,21 @@ protected override bool Satisfied(Pawn pawn) Tutorials.Introduction(); Tutorials.Management(); + IntVec3 c; + var need = pawn.needs.TryGetNeed(); if (need == null) - return false; + { + if (!pawn.guest.PrisonerIsSecure || RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn)) + return false; + else if (PrisonLaborUtility.LaborEnabled(pawn)) + return true; + else + return false; + } // Prisoner will escape if get ready to run. // If he can run he will start ticking impatient, once complete he will get ready. - IntVec3 c; if (!pawn.guest.PrisonerIsSecure || RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn)) { diff --git a/Source/VersionUtility.cs b/Source/VersionUtility.cs index 5dcb30bd..1e9be300 100644 --- a/Source/VersionUtility.cs +++ b/Source/VersionUtility.cs @@ -8,8 +8,8 @@ namespace PrisonLabor { class VersionUtility { - public const Version versionNumber = Version.v0_8_0; - public const string versionString = "0.8.0"; + public const Version versionNumber = Version.v0_8_1; + public const string versionString = "0.8.1"; public static void CheckVersion() { @@ -45,6 +45,11 @@ public static void CheckVersion() NewsDialog.news_0_8_0 = true; NewsDialog.autoShow = true; } + if (PrisonLaborPrefs.LastVersion < Version.v0_8_1) + { + NewsDialog.news_0_8_1 = true; + NewsDialog.autoShow = true; + } Log.Message($"Enabled Prison Labor v{versionString}"); PrisonLaborPrefs.Version = versionNumber; diff --git a/changelog.txt b/changelog.txt index d21a5fd4..bdac9537 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,10 @@ Changelog: -0.8 +0.8.1 +- added slider to Bills (temporary fix) +- fixed Bill "Prisoner only" button (I think, let me know if you still experience errors) +- fixed prisoners aren't working when Motivation is disabled (via Settings) +- fixed null-reference error on some revolts incidents +0.8.0 - added revolts - reduced manipulation capability of prisoners (now they have 80% of normal manipulation, down from 100%) - added default prisoner interaction mode option to settings menu