Skip to content

Commit

Permalink
v1.3.1
Browse files Browse the repository at this point in the history
- Re-fixed "Could not find player faction bug"
  • Loading branch information
Jaxe-Wilde committed Nov 5, 2019
1 parent d896b65 commit 9a01e23
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<supportedVersions>
<li>1.0</li>
</supportedVersions>
<description>Mod Version: 1.3.0\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.3.1\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
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>PawnRules</identifier>
<version>1.3.0</version>
<version>1.3.1</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.3.0-blue.svg)
![Mod Version](https://img.shields.io/badge/Mod_Version-1.3.1-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
16 changes: 6 additions & 10 deletions Source/Data/Registry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public static void DeletePreset<T>(T preset) where T : Presetable
public static Rules GetDefaultRules(PawnType type) => _instance._defaults[type];
public static void SetDefaultRules(Rules rules) => _instance._defaults[rules.Type] = rules;

public static T GetAddonDefaultValue<T>(OptionTarget target, AddonOption addon, T invalidValue = default(T))
public static T GetAddonDefaultValue<T>(OptionTarget target, AddonOption addon, T invalidValue = default)
{
var rules = GetDefaultRules(PawnType.FromTarget(target));
if ((rules == null) || !addon.AllowedInPreset) { return invalidValue; }
Expand Down Expand Up @@ -211,7 +211,7 @@ public static void DeleteRules(Pawn pawn)

public static void FactionUpdate(Thing thing, Faction newFaction, bool? guest = null)
{
if (!(thing is Pawn pawn) || pawn.Dead) { return; }
if (!IsActive || !(thing is Pawn pawn) || pawn.Dead) { return; }

var oldFaction = guest == null ? pawn.Faction : pawn.HostFaction;
PawnType type;
Expand Down Expand Up @@ -282,17 +282,13 @@ public override void PostAdd()
InitDefaults();
}

public override void SpawnSetup()
{ }
public override void SpawnSetup() { }

public override void PostRemove()
{ }
public override void PostRemove() { }

public override void Print(LayerSubMesh subMesh)
{ }
public override void Print(LayerSubMesh subMesh) { }

public override void Draw()
{ }
public override void Draw() { }

public override void ExposeData()
{
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.3.0";
public const string Version = "1.3.1";

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

Expand Down
4 changes: 3 additions & 1 deletion Source/Patch/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ internal static class Extensions
public static float ToFloat(this string self, float defaultValue = 0f) => float.TryParse(self, out var result) ? result : defaultValue;

public static bool CanHaveRules(this Pawn self) => (self != null) && !self.Dead && (self.GetTargetType() != null);

public static PawnType GetTargetType(this Pawn self)
{
if (self == null) { return null; }
if (!Registry.IsActive || (self == null)) { return null; }
if ((self.Faction == Faction.OfPlayer) && self.IsColonist) { return PawnType.Colonist; }
if ((self.Faction == Faction.OfPlayer) && self.RaceProps.Animal) { return PawnType.Animal; }
if (self.HostFaction == Faction.OfPlayer) { return self.IsPrisonerOfColony ? PawnType.Prisoner : PawnType.Guest; }
Expand Down Expand Up @@ -72,6 +73,7 @@ public static Rect[] GetHGrid(this Rect self, float padding, params float[] widt

return rects.ToArray();
}

public static Rect[] GetVGrid(this Rect self, float padding, params float[] heights)
{
var unfixedCount = 0;
Expand Down

0 comments on commit 9a01e23

Please sign in to comment.