Skip to content

Commit

Permalink
rewrote detour
Browse files Browse the repository at this point in the history
  • Loading branch information
Skullywag committed Aug 11, 2016
1 parent 6328336 commit 712f444
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 28 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 @@
<ModMetaData>
<name>ReclaimFabric</name>
<author>Skullywag</author>
<targetVersion>0.14.1234</targetVersion>
<targetVersion>0.14.1249</targetVersion>
<description>Allows tailors to reclaim fabric from clothing.</description>
</ModMetaData>
Binary file modified Assemblies/ReclaimFabric.dll
Binary file not shown.
3 changes: 3 additions & 0 deletions Defs/RecipeDefs/RecycleApparel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<categories>
<li>Apparel</li>
</categories>
<disallowedSpecialFilters>
<li>AllowNoIngredients</li>
</disallowedSpecialFilters>
</fixedIngredientFilter>
<workSkill>Crafting</workSkill>
<efficiencyStat>TailoringSpeed</efficiencyStat>
Expand Down
17 changes: 17 additions & 0 deletions Defs/SpecialThingFilterDefs/SpecialThingFilters.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<SpecialThingFilters>

<SpecialThingFilterDef>
<defName>AllowNoIngredients</defName>
<label>allow things with ingredients</label>
<description>Allow things with ingredients in their recipes.</description>
<parentCategory>Root</parentCategory>
<allowedByDefault>true</allowedByDefault>
<saveKey>AllowNoIngredients</saveKey>
<configurable>false</configurable>
<workerClass>ReclaimFabric.SpecialThingFilterWorker_NoIngredients</workerClass>
</SpecialThingFilterDef>

</SpecialThingFilters>


Binary file modified Source/.vs/ReclaimFabric/v14/.suo
Binary file not shown.
1 change: 1 addition & 0 deletions Source/ReclaimFabric/ReclaimFabric.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<Compile Include="SpecialThingFilterWorker_ReclaimAdvancedArmor.cs" />
<Compile Include="SpecialThingFilterWorker_ReclaimArmor.cs" />
<Compile Include="SpecialThingFilterWorker_ReclaimEnergyShields.cs" />
<Compile Include="SpecialThingFilterWorker_NoIngredients.cs" />
<Compile Include="_Thing.cs" />
</ItemGroup>
<ItemGroup />
Expand Down
19 changes: 19 additions & 0 deletions Source/ReclaimFabric/SpecialThingFilterWorker_NoIngredients.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using Verse;
using RimWorld;

namespace ReclaimFabric
{
public class SpecialThingFilterWorker_NoIngredients : SpecialThingFilterWorker
{
public override bool Matches(Thing t)
{
return this.AlwaysMatches(t.def);
}

public override bool AlwaysMatches(ThingDef def)
{
return def.costList == null && def.stuffCategories == null;
}
}
}
51 changes: 24 additions & 27 deletions Source/ReclaimFabric/_Thing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,29 @@ public static class _Thing
internal static IEnumerable<Thing> _SmeltProducts(this Thing _this, float efficiency)
{
var costListAdj = _this.CostListAdjusted();
if (!costListAdj.NullOrEmpty())
if (_this.def.IsClothes() || _this.def.IsAdvancedArmor() || _this.def.IsArmor())
{
Pawn crafter = _this.Position.GetEdifice().InteractionCell.GetFirstPawn();
float skillPerc = ((float)crafter.skills.GetSkill(SkillDefOf.Crafting).level / 20);
float num = Mathf.Lerp(0.5f, 1.5f, skillPerc);
float healthPerc = ((float)_this.HitPoints / (float)_this.MaxHitPoints);
float num1 = Mathf.Lerp(0f, 0.4f, healthPerc);
foreach (var thingCost in costListAdj)
{
if (!thingCost.thingDef.intricate)
{
var PercentMaxLimit = (float)thingCost.count * num1;
var mainSmeltProductCount = (PercentMaxLimit * num);
if (mainSmeltProductCount > 0)
{
var resultantSmeltedThing = ThingMaker.MakeThing(thingCost.thingDef, null);
resultantSmeltedThing.stackCount = (int)mainSmeltProductCount;
yield return resultantSmeltedThing;
}
}
}
}
else if (!costListAdj.NullOrEmpty())
{
foreach (var thingCost in costListAdj)
{
Expand All @@ -32,7 +54,7 @@ internal static IEnumerable<Thing> _SmeltProducts(this Thing _this, float effici
}
}
}
if (!_this.def.smeltProducts.NullOrEmpty())
else if (!_this.def.smeltProducts.NullOrEmpty())
{
foreach (var smeltProduct in _this.def.smeltProducts)
{
Expand All @@ -41,31 +63,6 @@ internal static IEnumerable<Thing> _SmeltProducts(this Thing _this, float effici
yield return resultantSmeltedThing;
}
}

if (_this.def.IsClothes())
{
Pawn crafter = _this.Position.GetEdifice().InteractionCell.GetFirstPawn();
float skillPerc = ((float)crafter.skills.GetSkill(SkillDefOf.Crafting).level / 20);
float num = Mathf.Lerp(0.5f, 1.5f, skillPerc);
float healthPerc = ((float)_this.HitPoints / (float)_this.MaxHitPoints);
float num1 = Mathf.Lerp(0f, 0.4f, healthPerc);
var mainSmeltProductCount = (_this.def.costStuffCount * num1 / _this.Stuff.VolumePerUnit) * num;
var adjustedCount = GenMath.RoundRandom(mainSmeltProductCount);
//float healthPerc = ((float)_this.HitPoints / (float)_this.MaxHitPoints);
//float num1 = Mathf.Lerp(0f, 0.4f, healthPerc);
//var mainSmeltProductCount = (_this.def.costStuffCount * num1 / _this.Stuff.VolumePerUnit) * efficiency;
//var adjustedCount = GenMath.RoundRandom(mainSmeltProductCount);
if (adjustedCount > 0)
{
do
{
var thing = ThingMaker.MakeThing(_this.Stuff);
thing.stackCount = Mathf.Min(thing.def.stackLimit, adjustedCount);
adjustedCount -= thing.stackCount;
yield return thing;
} while (adjustedCount > 0);
}
}
}
}
}
Binary file modified Source/ReclaimFabric/bin/Debug/Community Core Library.dll
Binary file not shown.
Binary file modified Source/ReclaimFabric/bin/Debug/ReclaimFabric.dll
Binary file not shown.
Binary file modified Source/ReclaimFabric/bin/Debug/ReclaimFabric.pdb
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ C:\Users\mjsku\Desktop\RimWorldAlpha14Win\RimWorld1234Win\Mods\ReclaimFabric\Sou
C:\Users\mjsku\Desktop\RimWorldAlpha14Win\RimWorld1234Win\Mods\ReclaimFabric\Source\ReclaimFabric\obj\Debug\ReclaimFabric.csprojResolveAssemblyReference.cache
C:\Users\mjsku\Desktop\RimWorldAlpha14Win\RimWorld1234Win\Mods\ReclaimFabric\Source\ReclaimFabric\obj\Debug\ReclaimFabric.dll
C:\Users\mjsku\Desktop\RimWorldAlpha14Win\RimWorld1234Win\Mods\ReclaimFabric\Source\ReclaimFabric\obj\Debug\ReclaimFabric.pdb
C:\Users\mjsku\Desktop\RimWorldAlpha14eWin\RimWorld1249Win\Mods\ReclaimFabric\Source\ReclaimFabric\bin\Debug\ReclaimFabric.dll
C:\Users\mjsku\Desktop\RimWorldAlpha14eWin\RimWorld1249Win\Mods\ReclaimFabric\Source\ReclaimFabric\bin\Debug\ReclaimFabric.pdb
C:\Users\mjsku\Desktop\RimWorldAlpha14eWin\RimWorld1249Win\Mods\ReclaimFabric\Source\ReclaimFabric\bin\Debug\Community Core Library.dll
C:\Users\mjsku\Desktop\RimWorldAlpha14eWin\RimWorld1249Win\Mods\ReclaimFabric\Source\ReclaimFabric\bin\Debug\Assembly-CSharp-firstpass.dll
C:\Users\mjsku\Desktop\RimWorldAlpha14eWin\RimWorld1249Win\Mods\ReclaimFabric\Source\ReclaimFabric\bin\Debug\NAudio.dll
C:\Users\mjsku\Desktop\RimWorldAlpha14eWin\RimWorld1249Win\Mods\ReclaimFabric\Source\ReclaimFabric\bin\Debug\NVorbis.dll
C:\Users\mjsku\Desktop\RimWorldAlpha14eWin\RimWorld1249Win\Mods\ReclaimFabric\Source\ReclaimFabric\obj\Debug\ReclaimFabric.csprojResolveAssemblyReference.cache
C:\Users\mjsku\Desktop\RimWorldAlpha14eWin\RimWorld1249Win\Mods\ReclaimFabric\Source\ReclaimFabric\obj\Debug\ReclaimFabric.dll
C:\Users\mjsku\Desktop\RimWorldAlpha14eWin\RimWorld1249Win\Mods\ReclaimFabric\Source\ReclaimFabric\obj\Debug\ReclaimFabric.pdb
Binary file not shown.
Binary file modified Source/ReclaimFabric/obj/Debug/ReclaimFabric.dll
Binary file not shown.
Binary file modified Source/ReclaimFabric/obj/Debug/ReclaimFabric.pdb
Binary file not shown.

0 comments on commit 712f444

Please sign in to comment.