Skip to content

Commit

Permalink
small bugfix for linq bug
Browse files Browse the repository at this point in the history
  • Loading branch information
erdelf committed Feb 13, 2018
1 parent 24aeba8 commit 2542beb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Binary file modified Assemblies/AlienRace.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Source/AlienRace/AlienRace/BackstoryDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class BackstoryDef : Def
public List<string> forcedHediffs = new List<string>();
public IntRange bioAgeRange;
public IntRange chronoAgeRange;
public List<string> forcedItems;
public List<string> forcedItems = new List<string>();

public bool CommonalityApproved(Gender g) => Rand.Range(0, 100) < (g == Gender.Female ? this.femaleCommonality : this.maleCommonality);

Expand Down
4 changes: 2 additions & 2 deletions Source/AlienRace/AlienRace/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ static HarmonyPatches()
harmony.Patch(AccessTools.Method(typeof(ApparelProperties), nameof(ApparelProperties.GetInterferingBodyPartGroups)), null, null, new HarmonyMethod(patchType, nameof(GetInterferingBodyPartGroupsTranspiler)));
harmony.Patch(AccessTools.Method(typeof(PawnGenerator), "GenerateGearFor"), null, new HarmonyMethod(patchType, nameof(GenerateGearForPostfix)));

Log.Message("Alien race successfully completed " + harmony.GetPatchedMethods().Count() + " patches with harmony.");
//Log.Message("Alien race successfully completed " + harmony.GetPatchedMethods().Count() + " patches with harmony.");
DefDatabase<HairDef>.GetNamed("Shaved").hairTags.Add("alienNoHair"); // needed because..... the original idea doesn't work and I spend enough time finding a good solution
}

public static void GenerateGearForPostfix(Pawn pawn) =>
pawn.story?.AllBackstories?.Select(bs => DefDatabase<BackstoryDef>.GetNamedSilentFail(bs.identifier)).OfType<BackstoryDef>().SelectMany(bd => bd.forcedItems).Concat(bioReference?.forcedItems ?? new List<string>(0)).Select(s =>
DefDatabase<ThingDef>.GetNamedSilentFail(s)).OfType<ThingDef>().Select(td => ThingMaker.MakeThing(td, GenStuff.RandomStuffFor(td))).OfType<Thing>().ToList().ForEach(th => pawn.inventory.TryAddItemNotForSale(th));
DefDatabase<ThingDef>.GetNamedSilentFail(s)).OfType<ThingDef>().Select(td => ThingMaker.MakeThing(td, GenStuff.RandomStuffFor(td))).OfType<Thing>().ToList().ForEach(th => pawn.inventory?.TryAddItemNotForSale(th));

//Zorba.....
public static IEnumerable<CodeInstruction> GetInterferingBodyPartGroupsTranspiler(IEnumerable<CodeInstruction> instructions)
Expand Down
2 changes: 1 addition & 1 deletion Source/AlienRace/AlienRace/PawnBioDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class PawnBioDef : Def
public List<ThingDef> validRaces;
public bool factionLeader;
public List<string> forcedHediffs = new List<string>();
public List<string> forcedItems;
public List<string> forcedItems = new List<string>();

public override void ResolveReferences()
{
Expand Down

0 comments on commit 2542beb

Please sign in to comment.