-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
almost release candidate (missing some tutors)
- Loading branch information
Showing
18 changed files
with
203 additions
and
41 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<LanguageData> | ||
|
||
<Rescuing.labelShort>Redden</Rescuing.labelShort> | ||
<Rescuing.pawnLabel>Redden</Rescuing.pawnLabel> | ||
<Rescuing.gerundLabel>Reddend</Rescuing.gerundLabel> | ||
<Rescuing.description>Kolonisten redden</Rescuing.description> | ||
|
||
</LanguageData> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<LanguageData> | ||
|
||
<Rescuing.labelShort>Rettung</Rescuing.labelShort> | ||
<Rescuing.pawnLabel>Rettung</Rescuing.pawnLabel> | ||
<Rescuing.gerundLabel>Am Retten von</Rescuing.gerundLabel> | ||
<Rescuing.description>Rette Kolonisten</Rescuing.description> | ||
|
||
</LanguageData> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<LanguageData> | ||
|
||
<Rescuing.labelShort>Rescate</Rescuing.labelShort> | ||
<Rescuing.pawnLabel>Rescate</Rescuing.pawnLabel> | ||
<Rescuing.gerundLabel>Rescatando</Rescuing.gerundLabel> | ||
<Rescuing.description>Rescatar colonos</Rescuing.description> | ||
|
||
</LanguageData> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<LanguageData> | ||
|
||
<Rescuing.labelShort>Rädda</Rescuing.labelShort> | ||
<Rescuing.pawnLabel>Rädda</Rescuing.pawnLabel> | ||
<Rescuing.gerundLabel>Räddande</Rescuing.gerundLabel> | ||
<Rescuing.description>Rädda kolonister</Rescuing.description> | ||
|
||
</LanguageData> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using HarmonyLib; | ||
using RimWorld; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Verse; | ||
|
||
namespace AchtungMod | ||
{ | ||
public class DynamicWorkTypes | ||
{ | ||
static void Reload<T>() where T : Def | ||
{ | ||
DefDatabase<T>.ClearCachedData(); | ||
DefDatabase<T>.ResolveAllReferences(false, true); | ||
} | ||
|
||
static void UpdatePawns() | ||
{ | ||
Find.Maps.Do(map => map.mapPawns.AllPawnsSpawned.DoIf(p => p.workSettings != null, p => | ||
{ | ||
p.workSettings.priorities = null; | ||
p.workSettings.workGiversDirty = true; | ||
p.workSettings.EnableAndInitialize(); | ||
p.workSettings.CacheWorkGiversInOrder(); | ||
p.Notify_DisabledWorkTypesChanged(); | ||
})); | ||
} | ||
|
||
static void Update(PawnTableDef workTable) | ||
{ | ||
var moveWorkTypeLabelDown = false; | ||
for (var i = 0; i < workTable.columns.Count; i++) | ||
{ | ||
moveWorkTypeLabelDown = !moveWorkTypeLabelDown; | ||
workTable.columns[i].moveWorkTypeLabelDown = moveWorkTypeLabelDown; | ||
} | ||
|
||
var controller = AccessTools.TypeByName("WorkTab.Controller"); | ||
if (controller != null) | ||
{ | ||
var columns = new List<PawnColumnDef>(workTable.columns); | ||
Traverse.Create(controller).Field("allColumns").SetValue(columns); | ||
} | ||
} | ||
|
||
public static WorkTypeDef AddWorkTypeDef(WorkTypeDef def, WorkGiverDef workgiver) | ||
{ | ||
DefDatabase<WorkTypeDef>.Add(def); | ||
|
||
var saved = workgiver.workType; | ||
workgiver.workType = def; | ||
|
||
Reload<WorkTypeDef>(); | ||
Reload<WorkGiverDef>(); | ||
|
||
var workerClass = AccessTools.TypeByName("WorkTab.PawnColumnWorker_WorkType") ?? typeof(PawnColumnWorker_WorkPriority); | ||
var pawnColumnDefType = AccessTools.TypeByName("WorkTab.PawnColumnDef_WorkGiver") ?? typeof(PawnColumnDef); | ||
|
||
var columnDef = (PawnColumnDef)Activator.CreateInstance(pawnColumnDefType); | ||
Traverse.Create(columnDef).Field("workgiver").SetValue(workgiver); | ||
columnDef.defName = $"WorkPriority_{def.defName}"; | ||
columnDef.workType = def; | ||
columnDef.workerClass = workerClass; | ||
columnDef.sortable = true; | ||
columnDef.generated = true; | ||
columnDef.modContentPack = def.modContentPack; | ||
columnDef.PostLoad(); | ||
DefDatabase<PawnColumnDef>.Add(columnDef); | ||
|
||
var workTable = PawnTableDefOf.Work; | ||
var prio = columnDef.workType.naturalPriority; | ||
var idx = workTable.columns.FirstIndexOf(col => col.workType != null && col.workType.naturalPriority < prio); | ||
workTable.columns.Insert(idx, columnDef); | ||
Update(workTable); | ||
|
||
Reload<PawnColumnDef>(); | ||
Reload<PawnTableDef>(); | ||
UpdatePawns(); | ||
|
||
return saved; | ||
} | ||
|
||
public static void RemoveWorkTypeDef(WorkTypeDef def, WorkTypeDef savedDef, WorkGiverDef workGiver) | ||
{ | ||
workGiver.workType = savedDef; | ||
DefDatabase<WorkTypeDef>.Remove(def); | ||
var columnDef = DefDatabase<PawnColumnDef>.AllDefsListForReading.First(d => d.workType == def); | ||
DefDatabase<PawnColumnDef>.Remove(columnDef); | ||
|
||
PawnTableDef workTable = PawnTableDefOf.Work; | ||
workTable.columns.RemoveAll(col => col.workType == def); | ||
Update(workTable); | ||
|
||
Reload<WorkTypeDef>(); | ||
Reload<WorkGiverDef>(); | ||
Reload<PawnColumnDef>(); | ||
Reload<PawnTableDef>(); | ||
UpdatePawns(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters