Skip to content

Commit

Permalink
v1.0.4
Browse files Browse the repository at this point in the history
- Fixed the null material error on World view
  • Loading branch information
Jaxe-Wilde committed Aug 31, 2018
1 parent f1ce96d commit 5a20bf4
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 19 deletions.
4 changes: 2 additions & 2 deletions About/ModSync.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>

<ModSyncNinjaData>
<ID>59f538ed-f86d-4506-a4a5-7e9faaa37509</ID>
<ID>59f538ed-f86d-4506-a4a5-7e9faaa37508</ID>
<ModName>Pawn Rules</ModName>
<Version>v1.0.3</Version>
<Version>v1.0.4</Version>
<SaveBreaking>False</SaveBreaking>
<Host name="Github">
<Owner>Jaxe-Dev</Owner>
Expand Down
4 changes: 4 additions & 0 deletions Defs/WorldObjectDefs/PawnRules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<defName>PawnRules_Registry</defName>
<label>Pawn Rules Registry</label>
<worldObjectClass>PawnRules.Data.Registry</worldObjectClass>
<useDynamicDrawer>true</useDynamicDrawer>
<selectable>false</selectable>
<neverMultiSelect>true</neverMultiSelect>
<canHaveFaction>false</canHaveFaction>
</WorldObjectDef>

</Defs>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Pawn Rules
![](https://img.shields.io/badge/Version-1.0.3-brightgreen.svg)
![](https://img.shields.io/badge/Version-1.0.4-brightgreen.svg)

Built for **RimWorld 1.0.x / 0.19.x**\
Powered by **Harmony**\
Expand Down
1 change: 0 additions & 1 deletion Source/Data/Binding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public void ExposeData()
if ((Scribe.mode != LoadSaveMode.Saving) || (Target == null)) { Scribe_References.Look(ref Pawn, "pawn"); }
if ((Scribe.mode != LoadSaveMode.Saving) || (Target != null)) { Target = PawnType.FromId(ScribePlus.LookValue(Target?.Id, "target")); }


if (Scribe.mode != LoadSaveMode.Saving)
{
Scribe_References.Look(ref _preset, "preset");
Expand Down
29 changes: 20 additions & 9 deletions Source/Data/Registry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static void DeletePreset<T>(T preset) where T : Presetable
{
var rule = (Rules) presetable;
var type = (RestrictionType) preset.Type;
if(rule.GetRestriction(type) == preset) { rule.SetRestriction(type, GetVoidPreset<Restriction>(type));}
if (rule.GetRestriction(type) == preset) { rule.SetRestriction(type, GetVoidPreset<Restriction>(type)); }
}
}
}
Expand Down Expand Up @@ -220,14 +220,6 @@ public static void DeactivateMod()
Find.WindowStack.Add(new Dialog_Alert(message, Dialog_Alert.Buttons.Ok, GenCommandLine.Restart));
}

public override void PostAdd()
{
base.PostAdd();
Instance = this;
InitVoids();
InitDefaults();
}

private void InitVoids()
{
_voidPresets[typeof(Rules)] = new Dictionary<IPresetableType, Presetable>();
Expand All @@ -242,6 +234,25 @@ private void InitDefaults()
foreach (var type in PawnType.List.Where(type => !_defaults.ContainsKey(type))) { _defaults.Add(type, (Rules) _voidPresets[typeof(Rules)][type]); }
}

public override void PostAdd()
{
base.PostAdd();
Instance = this;
InitVoids();
InitDefaults();
}
public override void SpawnSetup()
{ }

public override void PostRemove()
{ }

public override void Print(LayerSubMesh subMesh)
{ }

public override void Draw()
{ }

public override void ExposeData()
{
if (_isDeactivating) { return; }
Expand Down
3 changes: 2 additions & 1 deletion Source/Interface/Listing_StandardPlus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ internal class Listing_StandardPlus : Listing_Standard

private bool _scrollable;

public override void Begin(Rect rect) { Begin(rect, false); }
public override void Begin(Rect rect) => Begin(rect, false);

public void Begin(Rect rect, bool scrollable)
{
_scrollable = scrollable;
Expand Down
2 changes: 1 addition & 1 deletion Source/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal class Mod : Verse.Mod
public const string Id = "PawnRules";
public const string Name = "Pawn Rules";
public const string Author = "Jaxe";
public const string Version = "1.0.3";
public const string Version = "1.0.4";

public static ModContentPack ContentPack { get; private set; }

Expand Down
4 changes: 2 additions & 2 deletions Source/Patch/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ public static Rect[] GetVGrid(this Rect self, float spacing, params float[] heig
}
else
{
newHeight = unfixedWidth;
newHeight = unfixedWidth;
rects[index] = new Rect(self.x, currentY, self.width, newHeight);
}
currentY += newHeight + spacing;
}

return rects;
}
/*
/*
public static Rect[] GetVGrid(this Rect self, float spacing, params float[] heights)
{
var unfixedCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion Source/Patch/PrivateAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal static class PrivateAccess
private static readonly FieldInfo Field_Verse_LoadedModManager_RunningMods = AccessTools.Field(typeof(LoadedModManager), "runningMods");

public static Pawn RimWorld_FoodUtility_BestPawnToHuntForPredator(Pawn predator, bool forceScanWholeMap) => (Pawn) Method_RimWorld_FoodUtility_BestPawnToHuntForPredator.Invoke(null, new object[] { predator, forceScanWholeMap });
public static int RimWorld_FoodUtility_GetMaxRegionsToScan(Pawn getter, bool forceScanWholeMap) => (int)Method_RimWorld_FoodUtility_GetMaxRegionsToScan.Invoke(null, new object[] { getter, forceScanWholeMap });
public static int RimWorld_FoodUtility_GetMaxRegionsToScan(Pawn getter, bool forceScanWholeMap) => (int) Method_RimWorld_FoodUtility_GetMaxRegionsToScan.Invoke(null, new object[] { getter, forceScanWholeMap });
public static bool RimWorld_FoodUtility_IsFoodSourceOnMapSociallyProper(Thing thing, Pawn getter, Pawn eater, bool allowSociallyImproper) => (bool) Method_RimWorld_FoodUtility_IsFoodSourceOnMapSociallyProper.Invoke(null, new object[] { thing, getter, eater, allowSociallyImproper });
public static Thing RimWorld_FoodUtility_SpawnedFoodSearchInnerScan(Pawn eater, IntVec3 root, List<Thing> searchSet, PathEndMode peMode, TraverseParms traverseParams, float maxDistance = 9999f, Predicate<Thing> validator = null) => (Thing) Method_RimWorld_FoodUtility_SpawnedFoodSearchInnerScan.Invoke(null, new object[] { eater, root, searchSet, peMode, traverseParams, maxDistance, validator });
public static HashSet<Thing> RimWorld_FoodUtility_Filtered() => (HashSet<Thing>) Field_RimWorld_FoodUtility_Filtered.GetValue(null);
Expand Down
2 changes: 1 addition & 1 deletion Source/Patch/RimWorld_FoodUtility_BestFoodSourceOnMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private static bool Prefix(ref Thing __result, Pawn getter, Pawn eater, bool des
if (!Registry.IsActive) { return true; }

var rules = Registry.GetRules(eater);
if (eater.InMentalState || (rules == null) || (rules.GetRestriction(RestrictionType.Food).IsVoid)) { return true; }
if (eater.InMentalState || (rules == null) || rules.GetRestriction(RestrictionType.Food).IsVoid) { return true; }

Profiler.BeginSample("BestFoodInWorldFor getter=" + getter.LabelCap + " eater=" + eater.LabelCap);
var getterCanManipulate = getter.RaceProps.ToolUser && getter.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation);
Expand Down

0 comments on commit 5a20bf4

Please sign in to comment.