Skip to content

Commit

Permalink
A17 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
notfood committed May 25, 2017
1 parent 8e72aeb commit ae9a643
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 123 deletions.
4 changes: 2 additions & 2 deletions 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.16.0</targetVersion>
<description>Repair the durability of items.</description>
<targetVersion>0.17.0</targetVersion>
<description>Repair the durability of items or just recycle them.</description>
</ModMetaData>
Binary file modified Assemblies/Mending.dll
Binary file not shown.
13 changes: 10 additions & 3 deletions Defs/RecipeDefs/Recipes_Misc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<RecipeDefs>

<RecipeDef>
<workerClass>Mending.Worker</workerClass>
<defName>MendSimpleApparel</defName>
<label>mend simple apparel</label>
<description>Mend simple apparel.</description>
Expand Down Expand Up @@ -30,7 +31,6 @@
<exceptedThingDefs>
<li>Apparel_VestPlate</li>
<li>Apparel_PowerArmor</li>
<li>Apparel_PersonalShield</li>
</exceptedThingDefs>
</fixedIngredientFilter>
<skillRequirements>
Expand All @@ -42,6 +42,7 @@
</RecipeDef>

<RecipeDef>
<workerClass>Mending.Worker</workerClass>
<defName>MendComplexApparel</defName>
<label>mend complex apparel</label>
<description>Mend armor.</description>
Expand All @@ -59,7 +60,6 @@
<thingDefs>
<li>Apparel_VestPlate</li>
<li>Apparel_PowerArmor</li>
<li>Apparel_PersonalShield</li>
</thingDefs>
</filter>
<count>1</count>
Expand All @@ -72,7 +72,6 @@
<thingDefs>
<li>Apparel_VestPlate</li>
<li>Apparel_PowerArmor</li>
<li>Apparel_PersonalShield</li>
</thingDefs>
</fixedIngredientFilter>
<skillRequirements>
Expand All @@ -84,6 +83,7 @@
</RecipeDef>

<RecipeDef>
<workerClass>Mending.Worker</workerClass>
<defName>MendSimpleWeapon</defName>
<label>repair simple weapon</label>
<description>Repair weapon.</description>
Expand Down Expand Up @@ -116,6 +116,7 @@
</RecipeDef>

<RecipeDef>
<workerClass>Mending.Worker</workerClass>
<defName>MendComplexWeapon</defName>
<label>repair complex weapon</label>
<description>Repair weapon.</description>
Expand Down Expand Up @@ -176,6 +177,7 @@
-->

<RecipeDef>
<workerClass>Mending.Worker</workerClass>
<defName>RecycleApparel</defName>
<label>recycle apparel</label>
<description>Recycle apparel into their basic components.</description>
Expand Down Expand Up @@ -205,6 +207,11 @@
<minLevel>2</minLevel>
</li>
</skillRequirements>
<requiredGiverWorkType>Crafting</requiredGiverWorkType>
<recipeUsers>
<li>ElectricTailoringBench</li>
<li>HandTailoringBench</li>
</recipeUsers>
</RecipeDef>

</RecipeDefs>
76 changes: 1 addition & 75 deletions Defs/ThingDefs/Buildings_Production.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<li Class="CompProperties_Power">
<compClass>CompPowerTrader</compClass>
<startElectricalFires>true</startElectricalFires>
<basePowerConsumption>400</basePowerConsumption>
<basePowerConsumption>200</basePowerConsumption>
</li>
<li Class="CompProperties_Refuelable">
<fuelConsumptionRate>5.0</fuelConsumptionRate>
Expand Down Expand Up @@ -104,79 +104,5 @@
<li>Mending</li>
</researchPrerequisites>
</ThingDef>

<ThingDef ParentName="BenchBase">
<DefName>TableRecycle</DefName>
<label>recycle workbench</label>
<ThingClass>Building_WorkTable</ThingClass>
<Description>A workbench equipped with all the tools required to recycle items and recover their components. Power is optional, it doubles the efficiency.</Description>
<graphicData>
<texPath>Things/Buildings/TableRecycle</texPath>
<graphicClass>Graphic_Single</graphicClass>
<drawSize>(3,1)</drawSize>
<damageData>
<cornerTL>Damage/Corner</cornerTL>
<cornerTR>Damage/Corner</cornerTR>
<cornerBL>Damage/Corner</cornerBL>
<cornerBR>Damage/Corner</cornerBR>
</damageData>
</graphicData>
<CostList>
<Steel>50</Steel>
<Component>3</Component>
</CostList>
<stuffCategories>
<li>Metallic</li>
<li>Woody</li>
</stuffCategories>
<costStuffCount>75</costStuffCount>
<AltitudeLayer>Building</AltitudeLayer>
<fillPercent>0.5</fillPercent>
<useHitPoints>True</useHitPoints>
<statBases>
<WorkToMake>2500</WorkToMake>
<MaxHitPoints>180</MaxHitPoints>
<Flammability>1.0</Flammability>
<Cleanliness>-5</Cleanliness>
</statBases>
<Size>(3,1)</Size>
<DesignationCategory>Production</DesignationCategory>
<Passability>PassThroughOnly</Passability>
<pathCost>70</pathCost>
<hasInteractionCell>True</hasInteractionCell>
<interactionCellOffset>(0,0,-1)</interactionCellOffset>
<surfaceType>Item</surfaceType>
<recipes>
<li>RecycleApparel</li>
</recipes>
<inspectorTabs>
<li>ITab_Bills</li>
</inspectorTabs>
<building>
<spawnedConceptLearnOpportunity>BillsTab</spawnedConceptLearnOpportunity>
<unpoweredWorkTableWorkSpeedFactor>0.5</unpoweredWorkTableWorkSpeedFactor>
</building>
<comps>
<li Class="CompProperties_Power">
<compClass>CompPowerTrader</compClass>
<startElectricalFires>true</startElectricalFires>
<basePowerConsumption>100</basePowerConsumption>
</li>
<li Class="CompProperties_Flickable"/>
<li Class="CompProperties_AffectedByFacilities">
<linkableFacilities>
<li>ToolCabinet</li>
</linkableFacilities>
</li>
<li Class="CompProperties_Breakdownable"/>
</comps>
<designationHotKey>Misc3</designationHotKey>
<placeWorkers>
<li>PlaceWorker_ShowFacilitiesConnections</li>
</placeWorkers>
<researchPrerequisites>
<li>ComplexClothing</li>
</researchPrerequisites>
</ThingDef>

</Defs>
3 changes: 2 additions & 1 deletion Defs/WorkGiverDefs/mending_WorkGivers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
<workType>Crafting</workType>
<priorityInType>90</priorityInType>
<fixedBillGiverDefs>
<li>TableRecycle</li>
<li>ElectricTailoringBench</li>
<li>HandTailoringBench</li>
</fixedBillGiverDefs>
<verb>recycle</verb>
<gerund>recycling</gerund>
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# RimWorld-Mending

[![Version](https://img.shields.io/badge/Rimworld-A16-green.svg)]
(http://rimworldgame.com/)
[![License: CC BY-NC-SA 4.0](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-blue.svg)]
(http://creativecommons.org/licenses/by-nc-sa/4.0/)
[![Version](https://img.shields.io/badge/Rimworld-A17-green.svg)](http://rimworldgame.com/)
[![License: CC BY-NC-SA 4.0](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-blue.svg)](http://creativecommons.org/licenses/by-nc-sa/4.0/)

Repair the durability of your items.

Expand Down
4 changes: 2 additions & 2 deletions Source/JobDriverUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public static List<Thing> Reclaim(Thing thing, float efficiency) {
{
if (!thingCost.thingDef.intricate)
{
var mainSmeltProductCount = (float)thingCost.count * efficiency;
int mainSmeltProductCount = (int)UnityEngine.Mathf.Floor(thingCost.count * efficiency);
if (mainSmeltProductCount > 0)
{
var resultantSmeltedThing = ThingMaker.MakeThing(thingCost.thingDef, null);
resultantSmeltedThing.stackCount = (int)mainSmeltProductCount;
resultantSmeltedThing.stackCount = mainSmeltProductCount;
list.Add (resultantSmeltedThing);
}
}
Expand Down
7 changes: 3 additions & 4 deletions Source/JobDriver_DoBill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,16 @@ private Toil Store() {
Job curJob = actor.jobs.curJob;
Thing objectThing = curJob.GetTarget(objectTI).Thing;

if (curJob.bill.GetStoreMode () != BillStoreMode.DropOnFloor) {
if (curJob.bill.GetStoreMode () != BillStoreModeDefOf.DropOnFloor) {
IntVec3 vec;
if (StoreUtility.TryFindBestBetterStoreCellFor (objectThing, actor, actor.Map, StoragePriority.Unstored, actor.Faction, out vec, true)) {
actor.carryTracker.TryStartCarry (objectThing);
actor.carryTracker.TryStartCarry (objectThing, 1);
curJob.SetTarget(haulTI, vec);
curJob.count = 99999;
return;
}
}

actor.carryTracker.TryStartCarry (objectThing);
actor.carryTracker.TryStartCarry (objectThing, 1);
actor.carryTracker.TryDropCarriedThing(actor.Position, ThingPlaceMode.Near, out objectThing);

actor.jobs.EndCurrentJob (JobCondition.Succeeded);
Expand Down
20 changes: 10 additions & 10 deletions Source/JobDriver_Mend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected override Toil DoBill()

Toil toil = new Toil ();
toil.initAction = delegate {
curJob.bill.Notify_DoBillStarted ();
curJob.bill.Notify_DoBillStarted (actor);

this.failChance = ChanceDef.GetFor(objectThing);

Expand All @@ -42,6 +42,7 @@ protected override Toil DoBill()

workCycleProgress -= StatExtension.GetStatValue (actor, StatDefOf.WorkToMake, true);

tableThing.UsedThisTick ();
if (!tableThing.UsableNow) {
actor.jobs.EndCurrentJob (JobCondition.Incompletable);
}
Expand All @@ -52,20 +53,19 @@ protected override Toil DoBill()
objectThing.HitPoints += (int) Math.Min(remainingHitPoints, fixedHitPointsPerCycle);
}

SkillRecord skill = actor.skills.GetSkill (SkillDefOf.Crafting);
float skillPerc = 0.5f;

if (skill == null) {
Log.Error("Mending :: This should never happen! skill == null");
SkillDef skillDef = curJob.RecipeDef.workSkill;
if (skillDef != null) {
SkillRecord skill = actor.skills.GetSkill (skillDef);

actor.jobs.EndCurrentJob (JobCondition.Incompletable);
if (skill != null) {
skillPerc = (float)skill.Level / 20f;

return;
skill.Learn (0.11f * curJob.RecipeDef.workSkillLearnFactor);
}
}

float skillPerc = (float) skill.Level / 20f;

skill.Learn (0.33f);

CompQuality qualityComponent = objectThing.TryGetComp<CompQuality>();
if (qualityComponent != null && qualityComponent.Quality > QualityCategory.Awful) {
QualityCategory qc = qualityComponent.Quality;
Expand Down
23 changes: 12 additions & 11 deletions Source/JobDriver_Recycle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class JobDriver_Recycle : JobDriver_DoBill
protected override Toil DoBill()
{
Pawn actor = GetActor();
SkillRecord skill = actor.skills.GetSkill (SkillDefOf.Crafting);
Job curJob = actor.jobs.curJob;
Thing objectThing = curJob.GetTarget(objectTI).Thing;
CompQuality qualityComponent = objectThing.TryGetComp<CompQuality>();
Expand All @@ -30,7 +29,7 @@ protected override Toil DoBill()

Toil toil = new Toil ();
toil.initAction = delegate {
curJob.bill.Notify_DoBillStarted ();
curJob.bill.Notify_DoBillStarted (actor);

this.processedHitPoints = 0;
this.failChance = ChanceDef.GetFor(objectThing);
Expand All @@ -43,7 +42,8 @@ protected override Toil DoBill()
}

workCycleProgress -= StatExtension.GetStatValue (actor, StatDefOf.WorkToMake, true);
tableThing.Tick();

tableThing.UsedThisTick ();
if (!tableThing.UsableNow) {
actor.jobs.EndCurrentJob (JobCondition.Incompletable);
}
Expand All @@ -57,17 +57,18 @@ protected override Toil DoBill()
processedHitPoints += fixedHitPointsPerCycle/2;
}

if (skill == null) {
Log.Error("Mending :: This should never happen! skill == null");

actor.jobs.EndCurrentJob (JobCondition.Incompletable);
float skillPerc = 0.5f;

return;
}
SkillDef skillDef = curJob.RecipeDef.workSkill;
if (skillDef != null) {
SkillRecord skill = actor.skills.GetSkill (skillDef);

float skillPerc = (float) skill.Level / 20f;
if (skill != null) {
skillPerc = (float)skill.Level / 20f;

skill.Learn (0.33f);
skill.Learn (0.11f * curJob.RecipeDef.workSkillLearnFactor);
}
}

if (qualityComponent != null && qualityComponent.Quality > QualityCategory.Awful) {
QualityCategory qc = qualityComponent.Quality;
Expand Down
3 changes: 2 additions & 1 deletion Source/Mending.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@
<Compile Include="JobDriverUtils.cs" />
<Compile Include="WorkGiver_Recycle.cs" />
<Compile Include="LocalJobDefOf.cs" />
<Compile Include="WorkGiver_Scanner.cs" />
<Compile Include="WorkGiver_Mend.cs" />
<Compile Include="JobDriver_DoBill.cs" />
<Compile Include="WorkGiver_DoBill.cs" />
<Compile Include="Worker.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
Expand Down
Loading

0 comments on commit ae9a643

Please sign in to comment.