-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from RimWorldCCLTeam/development
Alpha 14 Update
- Loading branch information
Showing
207 changed files
with
4,452 additions
and
4,547 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,99 @@ | ||
using RimWorld; | ||
using Verse; | ||
using Verse.AI; | ||
|
||
namespace CommunityCoreLibrary | ||
{ | ||
|
||
public class Building_AdvancedPasteDispenser : Building_NutrientPasteDispenser | ||
{ | ||
|
||
private static CompHopperUser compHopperUser; | ||
|
||
public override void SpawnSetup() | ||
{ | ||
base.SpawnSetup(); | ||
compHopperUser = this.TryGetComp<CompHopperUser>(); | ||
} | ||
|
||
|
||
public override Building AdjacentReachableHopper( Pawn reacher ) | ||
{ | ||
// Check for generic hoppers | ||
if( compHopperUser != null ) | ||
{ | ||
var hoppers = compHopperUser.FindHoppers(); | ||
if( !hoppers.NullOrEmpty() ) | ||
{ | ||
foreach( var hopper in hoppers ) | ||
{ | ||
if( | ||
reacher.CanReach( | ||
( TargetInfo )( ( Thing )hopper.parent ), | ||
PathEndMode.Touch, | ||
reacher.NormalMaxDanger(), | ||
false ) | ||
) | ||
{ | ||
return (Building) hopper.parent; | ||
} | ||
} | ||
} | ||
} | ||
// Check for vanilla hoppers | ||
return base.AdjacentReachableHopper( reacher ); | ||
} | ||
|
||
protected override Thing FindFeedInAnyHopper() | ||
{ | ||
// Check for generic hoppers | ||
if( compHopperUser != null ) | ||
{ | ||
var hoppers = compHopperUser.FindHoppers(); | ||
if( !hoppers.NullOrEmpty() ) | ||
{ | ||
foreach( var hopper in hoppers ) | ||
{ | ||
var resources = hopper.GetAllResources( compHopperUser.Resources ); | ||
if( !resources.NullOrEmpty() ) | ||
{ | ||
foreach( var resource in resources ) | ||
{ | ||
// This check shouldn't be needed, but we'll do it as a fail-safe | ||
if( Building_NutrientPasteDispenser.IsAcceptableFeedstock( resource.def ) ) | ||
{ | ||
return resource; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
// Check for vanilla hoppers | ||
return base.FindFeedInAnyHopper(); | ||
} | ||
|
||
public override bool HasEnoughFeedstockInHoppers() | ||
{ | ||
int costPerDispense = this.def.building.foodCostPerDispense; | ||
/* Research Project cut from A13 | ||
if( ResearchProjectDef.Named( "NutrientResynthesis" ).IsFinished ) | ||
{ | ||
costPerDispense--; | ||
} | ||
*/ | ||
// Check for generic hoppers | ||
if( compHopperUser != null ) | ||
{ | ||
if( compHopperUser.EnoughResourcesInHoppers( costPerDispense ) ) | ||
{ | ||
return true; | ||
} | ||
} | ||
// Check for vanilla hoppers | ||
return base.HasEnoughFeedstockInHoppers(); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.