Skip to content

Commit

Permalink
v1.2.4
Browse files Browse the repository at this point in the history
- Added null check on food categories for potentially uncategorized modded foods
  • Loading branch information
Jaxe-Dev committed Nov 12, 2018
1 parent ec35e44 commit f35273b
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<name>Pawn Rules</name>
<author>Jaxe</author>
<targetVersion>1.0.0</targetVersion>
<description>Mod Version: 1.2.3\n\n\nPawn Rules is a mod that allows custom rules to be assigned individually to your colonists, animals, guests and prisoners.\n\nCurrently the following rules can be applied:\n\n- Disallow certain foods\n- Disallow bonding with certain animals\n- Disallow new romances\n- Disallow constructing items that have a quality level\n\nAny of these rules can be disabled and hidden from the rules window. Rules presets and defaults can be imported and exported between games.</description>
<description>Mod Version: 1.2.4\n\n\nPawn Rules is a mod that allows custom rules to be assigned individually to your colonists, animals, guests and prisoners.\n\nCurrently the following rules can be applied:\n\n- Disallow certain foods\n- Disallow bonding with certain animals\n- Disallow new romances\n- Disallow constructing items that have a quality level\n\nAny of these rules can be disabled and hidden from the rules window. Rules presets and defaults can be imported and exported between games.</description>
</ModMetaData>
2 changes: 1 addition & 1 deletion About/Manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<Manifest>
<identifier>PawnRules</identifier>
<version>1.2.3</version>
<version>1.2.4</version>
<manifestUri>https://raw.githubusercontent.com/Jaxe-Dev/PawnRules/master/About/Manifest.xml</manifestUri>
<downloadUri>https://github.com/Jaxe-Dev/PawnRules/releases/latest</downloadUri>
</Manifest>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Pawn Rules
![Mod Version](https://img.shields.io/badge/Mod_Version-1.2.3-blue.svg)
![Mod Version](https://img.shields.io/badge/Mod_Version-1.2.4-blue.svg)
![RimWorld Version](https://img.shields.io/badge/Built_for_RimWorld-1.0-blue.svg)
![Harmony Version](https://img.shields.io/badge/Powered_by_Harmony-1.2.0.1-blue.svg)\
![Steam Subscribers](https://img.shields.io/badge/dynamic/xml.svg?label=Steam+Subscribers&query=//table/tr[2]/td[1]&colorB=blue&url=https://steamcommunity.com/sharedfiles/filedetails/%3Fid=1499843448&suffix=+total)
Expand Down
4 changes: 3 additions & 1 deletion Source/Data/Registry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,16 @@ public static void DeletePreset<T>(T preset) where T : Presetable
{
if ((preset == null) || preset.IsVoid) { throw new Mod.Exception("Tried to delete void preset"); }

if (!_instance._presets.ContainsKey(preset.GetType()) || !_instance._presets[preset.GetType()].ContainsKey(preset.Type)) { return; }

_instance._presets[preset.GetType()][preset.Type].Remove(preset.Name);

if (typeof(T) == typeof(Rules))
{
foreach (var rule in _instance._rules.Where(rule => rule.Value == preset).ToArray()) { _instance._rules[rule.Key] = GetVoidPreset<Rules>(rule.Value.Type).CloneRulesFor(rule.Key); }
foreach (var rule in _instance._defaults.Where(rule => rule.Value == preset).ToArray()) { _instance._defaults[rule.Key] = GetVoidPreset<Rules>(rule.Value.Type); }
}
else if ((typeof(T) == typeof(Restriction)) && !_instance._presets.ContainsKey(typeof(Rules)))
else if ((typeof(T) == typeof(Restriction)) && _instance._presets.ContainsKey(typeof(Rules)))
{
foreach (var rulesType in _instance._presets[typeof(Rules)].Values.ToArray())
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Data/RestrictionTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static RestrictionTemplate GetFoodsCategorized(Restriction restriction)
return new RestrictionTemplate(list.Values.ToArray());
}

private static string GetFoodCategory(ThingDef self) => self.category == ThingCategory.Item ? self.FirstThingCategory.LabelCap : self.category.ToString();
private static string GetFoodCategory(ThingDef self) => (self.category == ThingCategory.Item) && (self.FirstThingCategory != null) ? self.FirstThingCategory.LabelCap : self.category.ToString();

private static RestrictionTemplate GetAnimalsCategorized(Restriction restriction)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class Mod : Verse.Mod
{
public const string Id = "PawnRules";
public const string Name = "Pawn Rules";
public const string Version = "1.2.3";
public const string Version = "1.2.4";

public static readonly DirectoryInfo ConfigDirectory = new DirectoryInfo(Path.Combine(GenFilePaths.ConfigFolderPath, Id));

Expand Down

0 comments on commit f35273b

Please sign in to comment.