Skip to content

Commit

Permalink
B18 update
Browse files Browse the repository at this point in the history
  • Loading branch information
notfood committed Nov 18, 2017
1 parent 93dbe50 commit db8e176
Show file tree
Hide file tree
Showing 19 changed files with 522 additions and 547 deletions.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<name>Mending</name>
<author>notfood</author>
<url>https://ludeon.com/forums/index.php?topic=22894.0</url>
<targetVersion>0.17.0</targetVersion>
<targetVersion>0.18.0</targetVersion>
<description>Repair the durability of items or just recycle them.</description>
</ModMetaData>
1 change: 1 addition & 0 deletions About/PublishedFileId.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
735241897
Binary file modified Assemblies/Mending.dll
Binary file not shown.
29 changes: 7 additions & 22 deletions Defs/RecipeDefs/Recipes_Misc.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<RecipeDefs>
<Defs>

<RecipeDef>
<workerClass>Mending.Worker</workerClass>
Expand Down Expand Up @@ -34,10 +34,7 @@
</exceptedThingDefs>
</fixedIngredientFilter>
<skillRequirements>
<li>
<skill>Crafting</skill>
<minLevel>4</minLevel>
</li>
<Crafting>4</Crafting>
</skillRequirements>
</RecipeDef>

Expand Down Expand Up @@ -75,10 +72,7 @@
</thingDefs>
</fixedIngredientFilter>
<skillRequirements>
<li>
<skill>Crafting</skill>
<minLevel>8</minLevel>
</li>
<Crafting>8</Crafting>
</skillRequirements>
</RecipeDef>

Expand Down Expand Up @@ -108,10 +102,7 @@
</categories>
</fixedIngredientFilter>
<skillRequirements>
<li>
<skill>Crafting</skill>
<minLevel>4</minLevel>
</li>
<Crafting>4</Crafting>
</skillRequirements>
</RecipeDef>

Expand Down Expand Up @@ -141,10 +132,7 @@
</categories>
</fixedIngredientFilter>
<skillRequirements>
<li>
<skill>Crafting</skill>
<minLevel>8</minLevel>
</li>
<Crafting>8</Crafting>
</skillRequirements>
</RecipeDef>

Expand Down Expand Up @@ -202,10 +190,7 @@
</categories>
</fixedIngredientFilter>
<skillRequirements>
<li>
<skill>Crafting</skill>
<minLevel>2</minLevel>
</li>
<Crafting>2</Crafting>
</skillRequirements>
<requiredGiverWorkType>Crafting</requiredGiverWorkType>
<recipeUsers>
Expand All @@ -214,4 +199,4 @@
</recipeUsers>
</RecipeDef>

</RecipeDefs>
</Defs>
10 changes: 4 additions & 6 deletions Defs/RecipeDefs/Recipes_Production.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<RecipeDefs>
<?xml version="1.0"?>
<Defs>

<RecipeDef>
<defName>MakeMendingKit</defName>
Expand Down Expand Up @@ -37,10 +38,7 @@
<MendingKit>5</MendingKit>
</products>
<skillRequirements>
<li>
<skill>Crafting</skill>
<minLevel>4</minLevel>
</li>
<Crafting>4</Crafting>
</skillRequirements>
<workSkill>Crafting</workSkill>
<recipeUsers>
Expand All @@ -49,4 +47,4 @@
<researchPrerequisite>Mending</researchPrerequisite>
</RecipeDef>

</RecipeDefs>
</Defs>
4 changes: 2 additions & 2 deletions Defs/ResearchProjectDefs/ResearchProjects.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<ResearchProjectDefs>
<Defs>

<ResearchProjectDef>
<defName>Mending</defName>
Expand All @@ -12,4 +12,4 @@
</prerequisites>
</ResearchProjectDef>

</ResearchProjectDefs>
</Defs>
18 changes: 9 additions & 9 deletions Defs/ThingDefs/Buildings_Production.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
</ThingDef>

<ThingDef ParentName="BenchBase">
<DefName>TableMending</DefName>
<defName>TableMending</defName>
<label>mending workbench</label>
<ThingClass>Building_WorkTable</ThingClass>
<Description>A workbench equipped with all the tools required to mend and repair damaged items. Requires power and consumes mending kits. Mending kits can be made in the electric tailoring workbench</Description>
<thingClass>Building_WorkTable</thingClass>
<description>A workbench equipped with all the tools required to mend and repair damaged items. Requires power and consumes mending kits. Mending kits can be made in the electric tailoring workbench</description>
<graphicData>
<texPath>Things/Buildings/TableMending</texPath>
<graphicClass>Graphic_Single</graphicClass>
Expand All @@ -34,16 +34,16 @@
<cornerBR>Damage/Corner</cornerBR>
</damageData>
</graphicData>
<CostList>
<costList>
<Steel>50</Steel>
<Component>3</Component>
</CostList>
</costList>
<stuffCategories>
<li>Metallic</li>
<li>Woody</li>
</stuffCategories>
<costStuffCount>75</costStuffCount>
<AltitudeLayer>Building</AltitudeLayer>
<altitudeLayer>Building</altitudeLayer>
<fillPercent>0.5</fillPercent>
<useHitPoints>True</useHitPoints>
<statBases>
Expand All @@ -52,9 +52,9 @@
<Flammability>1.0</Flammability>
<Cleanliness>-5</Cleanliness>
</statBases>
<Size>(3,1)</Size>
<DesignationCategory>Production</DesignationCategory>
<Passability>PassThroughOnly</Passability>
<size>(3,1)</size>
<designationCategory>Production</designationCategory>
<passability>PassThroughOnly</passability>
<pathCost>70</pathCost>
<hasInteractionCell>True</hasInteractionCell>
<interactionCellOffset>(0,0,-1)</interactionCellOffset>
Expand Down
4 changes: 2 additions & 2 deletions Defs/WorkGiverDefs/mending_WorkGivers.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<WorkGivers>
<Defs>

<WorkGiverDef>
<defName>DoBillsMending</defName>
Expand Down Expand Up @@ -36,7 +36,7 @@
<prioritizeSustains>true</prioritizeSustains>
</WorkGiverDef>

</WorkGivers>
</Defs>



Expand Down
141 changes: 71 additions & 70 deletions Source/ChanceDef.cs
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;
}
}
}

Loading

0 comments on commit db8e176

Please sign in to comment.