-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
522 additions
and
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
735241897 |
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
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
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,87 +1,88 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Linq; | ||
|
||
using RimWorld; | ||
using Verse; | ||
|
||
namespace Mending | ||
{ | ||
public class QualityChances | ||
{ | ||
public float awful; | ||
public float shoddy; | ||
public float poor; | ||
public float normal; | ||
public float good; | ||
public float superior; | ||
public float excellent; | ||
public float masterwork; | ||
public float legendary; | ||
} | ||
public class QualityChances | ||
{ | ||
public float awful; | ||
public float shoddy; | ||
public float poor; | ||
public float normal; | ||
public float good; | ||
public float superior; | ||
public float excellent; | ||
public float masterwork; | ||
public float legendary; | ||
} | ||
|
||
public class TechLevelRange | ||
{ | ||
public TechLevel min = TechLevel.Undefined; | ||
public TechLevel max = TechLevel.Transcendent; | ||
} | ||
public class TechLevelRange | ||
{ | ||
public TechLevel min = TechLevel.Undefined; | ||
public TechLevel max = TechLevel.Transcendent; | ||
} | ||
|
||
public class ChanceDef : Verse.Def | ||
{ | ||
public TechLevelRange techLevel = new TechLevelRange(); | ||
public ThingFilter match = new ThingFilter (); | ||
public QualityChances chances = new QualityChances(); | ||
public float levelFactor = 1f; | ||
public class ChanceDef : Verse.Def | ||
{ | ||
public TechLevelRange techLevel = new TechLevelRange (); | ||
public ThingFilter match = new ThingFilter (); | ||
public QualityChances chances = new QualityChances (); | ||
public float levelFactor = 1f; | ||
|
||
public bool Allows(Thing thing) { | ||
TechLevel thingTech = thing.def.techLevel; | ||
public bool Allows (Thing thing) | ||
{ | ||
TechLevel thingTech = thing.def.techLevel; | ||
|
||
return thingTech >= techLevel.min | ||
&& thingTech <= techLevel.max | ||
&& match.Allows (thing); | ||
} | ||
return thingTech >= techLevel.min | ||
&& thingTech <= techLevel.max | ||
&& match.Allows (thing); | ||
} | ||
|
||
public float Chance(QualityCategory qc) { | ||
switch ( qc ) | ||
{ | ||
case QualityCategory.Awful: | ||
return chances.awful; | ||
case QualityCategory.Shoddy: | ||
return chances.shoddy; | ||
case QualityCategory.Poor: | ||
return chances.poor; | ||
case QualityCategory.Normal: | ||
return chances.normal; | ||
case QualityCategory.Good: | ||
return chances.good; | ||
case QualityCategory.Superior: | ||
return chances.superior; | ||
case QualityCategory.Excellent: | ||
return chances.excellent; | ||
case QualityCategory.Masterwork: | ||
return chances.masterwork; | ||
case QualityCategory.Legendary: | ||
return chances.legendary; | ||
default: | ||
return 0f; | ||
} | ||
} | ||
public float Chance (QualityCategory qc) | ||
{ | ||
switch (qc) { | ||
case QualityCategory.Awful: | ||
return chances.awful; | ||
case QualityCategory.Shoddy: | ||
return chances.shoddy; | ||
case QualityCategory.Poor: | ||
return chances.poor; | ||
case QualityCategory.Normal: | ||
return chances.normal; | ||
case QualityCategory.Good: | ||
return chances.good; | ||
case QualityCategory.Superior: | ||
return chances.superior; | ||
case QualityCategory.Excellent: | ||
return chances.excellent; | ||
case QualityCategory.Masterwork: | ||
return chances.masterwork; | ||
case QualityCategory.Legendary: | ||
return chances.legendary; | ||
default: | ||
return 0f; | ||
} | ||
} | ||
|
||
public override void ResolveReferences () | ||
{ | ||
base.ResolveReferences (); | ||
public override void ResolveReferences () | ||
{ | ||
base.ResolveReferences (); | ||
|
||
this.match.ResolveReferences (); | ||
} | ||
match.ResolveReferences (); | ||
} | ||
|
||
public static ChanceDef GetFor( Thing thing ) { | ||
var chanceDef = ( | ||
from chance in DefDatabase< ChanceDef >.AllDefs.Reverse() | ||
where chance.Allows(thing) | ||
select chance | ||
).FirstOrDefault(); | ||
public static ChanceDef GetFor (Thing thing) | ||
{ | ||
var chanceDef = ( | ||
from chance in DefDatabase<ChanceDef>.AllDefs.Reverse () | ||
where chance.Allows (thing) | ||
select chance | ||
).FirstOrDefault (); | ||
|
||
return chanceDef; | ||
} | ||
} | ||
return chanceDef; | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.