-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed null reference exception when the game passed a null blueprint/frame.
- Loading branch information
1 parent
6bc0561
commit 8be0fae
Showing
5 changed files
with
32 additions
and
43 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,34 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Verse; | ||
using Verse; | ||
|
||
namespace HMTB | ||
{ | ||
[StaticConstructorOnStartup] | ||
public static class Utilities | ||
{ | ||
public static IEnumerable<Thing> WorkThingsOpportunistic(Pawn pawn, ThingRequest request) | ||
public static bool AllowedHaulDistance(Pawn pawn, Thing t) | ||
{ | ||
IEnumerable<Thing> allMatchingThings = pawn.Map.listerThings.ThingsMatching(request); | ||
OpportunityDistance distance = Controller.OpportunisticMode.Value; | ||
|
||
if (Controller.OpportunisticMode.Value == OpportunityDistance.HMTB_Unrestricted) | ||
if (distance == OpportunityDistance.HMTB_Unrestricted) | ||
{ | ||
return allMatchingThings; | ||
return true; | ||
} | ||
|
||
else | ||
{ | ||
float maxSearchDistance; | ||
|
||
switch (Controller.OpportunisticMode.Value) | ||
{ | ||
case OpportunityDistance.HMTB_Close: | ||
maxSearchDistance = 15f; | ||
break; | ||
case OpportunityDistance.HMTB_Medium: | ||
maxSearchDistance = 45f; | ||
break; | ||
default: | ||
maxSearchDistance = 100f; //(Long) | ||
break; | ||
} | ||
float maxSearchDistance; | ||
|
||
return allMatchingThings.Where(t => t.Position.DistanceTo(pawn.Position) < maxSearchDistance); | ||
switch (distance) | ||
{ | ||
case OpportunityDistance.HMTB_Close: | ||
maxSearchDistance = 15f; //Close | ||
break; | ||
case OpportunityDistance.HMTB_Medium: | ||
maxSearchDistance = 45f; //Medium | ||
break; | ||
default: | ||
maxSearchDistance = 100f; //Long | ||
break; | ||
} | ||
|
||
return t.Position.DistanceTo(pawn.Position) <= maxSearchDistance; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters