Skip to content

Commit

Permalink
v2.7.1 fixes zombie spawning and a bug with saving colonist settings
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Jan 13, 2022
1 parent 2b8faf6 commit 0993389
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 23 deletions.
Binary file modified 1.3/Assemblies/ZombieLand.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion About/Manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>net.pardeike.rimworld.mod.zombieland</identifier>
<version>2.7.0.0</version>
<version>2.7.1.0</version>
<targetVersions>
<li>1.0.0</li>
<li>1.1.0</li>
Expand Down
27 changes: 9 additions & 18 deletions Source/ColonistSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,26 @@ public void ExposeData()

class ColonistSettings : WorldComponent
{
public static Dictionary<Pawn, ColonistConfig> colonists = new Dictionary<Pawn, ColonistConfig>();
public static Dictionary<Pawn, ColonistConfig> colonists;
private List<Pawn> colonistsKeysWorkingList;
private List<ColonistConfig> colonistsValuesWorkingList;

public static ColonistSettings Values => Find.World.GetComponent<ColonistSettings>();

public ColonistSettings(World world) : base(world)
{
colonists = new Dictionary<Pawn, ColonistConfig>();
}

public ColonistConfig ConfigFor(Pawn pawn)
{
if (pawn.IsColonist == false)
if (pawn?.Map == null || pawn.IsColonist == false || pawn.Spawned == false)
return null;
if (colonists.TryGetValue(pawn, out var config))
return config;
config = new ColonistConfig();
colonists[pawn] = config;
if (colonists.TryGetValue(pawn, out var config) == false)
{
config = new ColonistConfig();
colonists[pawn] = config;
}
return config;
}

Expand All @@ -64,19 +66,8 @@ public void RemoveColonist(Pawn pawn)
public override void ExposeData()
{
base.ExposeData();

if (Scribe.mode == LoadSaveMode.Saving)
_ = colonists.RemoveAll(pair => pair.Key == null || pair.Key.IsColonist == false || pair.Key.Spawned == false || pair.Value == null);

colonists ??= new Dictionary<Pawn, ColonistConfig>();
Scribe_Collections.Look(ref colonists, "colonists", LookMode.Reference, LookMode.Deep, ref colonistsKeysWorkingList, ref colonistsValuesWorkingList);

if (Scribe.mode == LoadSaveMode.PostLoadInit)
{
if (colonists == null)
colonists = new Dictionary<Pawn, ColonistConfig>();
else
_ = colonists.RemoveAll(pair => pair.Key == null || pair.Key.IsColonist == false || pair.Value == null);
}
}
}
}
8 changes: 7 additions & 1 deletion Source/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,16 @@ public static IntVec3 RandomSpawnCell(Map map, bool nearEdge, Predicate<IntVec3>
var allRegions = PlayerReachableRegions(map);
if (nearEdge)
allRegions = allRegions.Where(region => region.touchesMapEdge).ToList();
return allRegions
var cell = allRegions
.SelectMany(region => region.Cells)
.InRandomOrder()
.FirstOrFallback(cell => predicate(cell), IntVec3.Invalid);
if (cell.IsValid == false)
{
if (RCellFinder.TryFindRandomPawnEntryCell(out cell, map, 0.1f, true, predicate) == false)
cell = IntVec3.Invalid;
}
return cell;
}

public static void QueueConvertToZombie(ThingWithComps thing, Map mapForTickmanager)
Expand Down
4 changes: 1 addition & 3 deletions Source/ZombieLand.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<OutputPath>..\1.3\Assemblies\</OutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Version>2.7.0.0</Version>
<Version>2.7.1.0</Version>
<Copyright>Copyright © 2017</Copyright>
</PropertyGroup>

Expand Down Expand Up @@ -90,8 +90,6 @@
<PackageProjectUrl>https://github.com/pardeike/Zombieland</PackageProjectUrl>
<RepositoryUrl>https://github.com/pardeike/Zombieland</RepositoryUrl>
<Product>ZombieLand</Product>
<AssemblyVersion>2.7.0.0</AssemblyVersion>
<FileVersion>2.7.0.0</FileVersion>
</PropertyGroup>

</Project>

0 comments on commit 0993389

Please sign in to comment.