Skip to content

Commit

Permalink
Tooling, preset reset
Browse files Browse the repository at this point in the history
  • Loading branch information
PeteTimesSix committed Jul 16, 2023
1 parent e99f9c9 commit a52a8dc
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 19 deletions.
4 changes: 2 additions & 2 deletions ResearchReinvented/About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ Consider inventing the humble mini-turret.
In vanilla Rimworld, the process is:
A colonist sits in front of a research table and stares at it for five weeks.


With Research Reinvented, the process can include any of the following:
Reverse engineer existing commandeered turrets.
See what you can learn from that ancient broken down security turret.
Analyse raw materials for their durability as turret armor.
Experiment with steel to figure out efficient barrel replacements.
Test out what modifications to the standard machine pistol or autopistol design might make for the best turret weapon.
Construct a prototype turret, even if it takes longer and the end product might need some fixing up right away.

Ask allies to provide some of their expertise, or demand that information from your prisoners.
Brainstorm solutions during social encounters between your colonists.

Taking advantage of such research opportunities can significantly accelerate your research progress. However, if none are available, the fallback Theory research is equivalent in speed to vanilla research (this speed can be lowered in the mod settings, if you'd prefer an incentive to seek opportunities out).
</description>
Expand Down
3 changes: 2 additions & 1 deletion ResearchReinvented/Source/Defs/ResearchOpportunityTypeDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public enum HandlingMode
Special_OnIngest_Observable = 1 << 4,
Special_Medicine = 1 << 5,
Special_Prototype = 1 << 6,
}
Special_Tooling = 1 << 7,
}

public class ResearchOpportunityTypeDef : Def
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using HarmonyLib;
using PeteTimesSix.ResearchReinvented.Defs;
using PeteTimesSix.ResearchReinvented.Managers;
using PeteTimesSix.ResearchReinvented.Rimworld.MiscData;
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using Verse.AI;

namespace PeteTimesSix.ResearchReinvented.HarmonyPatches.Prototypes
{
[HarmonyPatch(typeof(Toils_Recipe), nameof(Toils_Recipe.DoRecipeWork))]
public static class Toils_Recipe_DoRecipeWork_Patches
{
[HarmonyPostfix]
public static void Toils_Recipe_DoRecipeWork_Postfix(Toil __result)
{
__result.tickAction += () =>
{
//find tooling opportunity and do research
var toil = __result;
var actor = toil.actor;
var bench = toil.actor.CurJob.GetTarget(TargetIndex.A).Thing;
if (bench != null)
{
var opportunity = ResearchOpportunityManager.Instance.GetCurrentlyAvailableOpportunities()
.Where(o => o.def.handledBy.HasFlag(HandlingMode.Special_Tooling) && o.requirement.MetBy(bench))
.FirstOrDefault();
if(opportunity != null)
{
float num = actor.GetStatValue(StatDefOf.ResearchSpeed, true);
num *= FieldResearchHelper.GetFieldResearchSpeedFactor(actor, opportunity.project);
opportunity.ResearchTickPerformed(num, actor, null);
}
}
};
}
}
}
1 change: 1 addition & 0 deletions ResearchReinvented/Source/ResearchReinvented.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<Compile Include="HarmonyPatches\Medicine\TendUtility_Patches.cs" />
<Compile Include="HarmonyPatches\Prototypes\Bill_Medical_Notify_IterationCompleted_Patches.cs" />
<Compile Include="HarmonyPatches\Prototypes\Frame_FailConstruction_Patches.cs" />
<Compile Include="HarmonyPatches\Prototypes\Toils_Recipe_DoRecipeWork_Patches.cs" />
<Compile Include="HarmonyPatches\Prototypes\Toils_Recipe_MakeUnfinishedThingIfNeeded_Patches.cs" />
<Compile Include="HarmonyPatches\Social\FactionDialogMaker_FactionDialogFor_Patches.cs" />
<Compile Include="Managers\FactionLectureManager.cs" />
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ResearchReinvented/v1.4/Assemblies/ResearchReinvented.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<defName>RR_ScienceTalk</defName>
<label>talk about science</label>
<workerClass>PeteTimesSix.ResearchReinvented.Rimworld.InteractionWorkers.InteractionWorker_Brainstorm</workerClass>
<symbol>Motes/Speech/scienceIcon</symbol>
<symbol>Motes/Speech/science</symbol>
<initiatorXpGainSkill>Intellectual</initiatorXpGainSkill>
<initiatorXpGainAmount>10</initiatorXpGainAmount>
<logRulesInitiator>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>

<PeteTimesSix.ResearchReinvented.Defs.ResearchOpportunityTypeDef ParentName="AnalysisOpportunity">
<defName>AnalyseProductionFacility</defName>
<header_Direct>tooling tests</header_Direct>
<shortDesc_Direct>Examine wear patterns of tools at {0}.</shortDesc_Direct>
<category_Direct>Tooling</category_Direct>
</PeteTimesSix.ResearchReinvented.Defs.ResearchOpportunityTypeDef>

<PeteTimesSix.ResearchReinvented.Defs.ResearchOpportunityTypeDef ParentName="AnalysisOpportunity">
<defName>Analyse</defName>
<header_Direct>reverse engineer</header_Direct>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>

<PeteTimesSix.ResearchReinvented.Defs.ResearchOpportunityTypeDef ParentName="ResearchOpportunityBase">
<defName>AnalyseProductionFacility</defName>
<handledBy>Special_Tooling</handledBy>
<jobPickerClass>PeteTimesSix.ResearchReinvented.OpportunityJobPickers.JobPicker_NoJob</jobPickerClass>
<header_Direct>technique exploration</header_Direct>
<shortDesc_Direct>Practice with differing tools and methodologies while working at {0}.</shortDesc_Direct>
<category_Direct>Tooling</category_Direct>
<hintIcons Inherit="false">
<li>UI/hintIcons/wrench</li>
</hintIcons>
</PeteTimesSix.ResearchReinvented.Defs.ResearchOpportunityTypeDef>
</Defs>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<li>UI/hintIcons/magnifier</li>
</hintIcons>
</PeteTimesSix.ResearchReinvented.Defs.ResearchOpportunityTypeDef>

<PeteTimesSix.ResearchReinvented.Defs.ResearchOpportunityTypeDef Name="IngestibleOpportunity" ParentName="ResearchOpportunityBase" Abstract="True">
<handledBy>Special_OnIngest</handledBy>
<jobPickerClass>PeteTimesSix.ResearchReinvented.OpportunityJobPickers.JobPicker_NoJob</jobPickerClass>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<category>ReverseEngineering</category>

<importanceMultiplier>1.25</importanceMultiplier>
<importanceMultiplierCounted>1.0</importanceMultiplierCounted>
<importanceMultiplierCounted>0.5</importanceMultiplierCounted>
<targetIterations>5.0</targetIterations>
<researchSpeedMultiplier>2.0</researchSpeedMultiplier>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<category>ReverseEngineering</category>

<importanceMultiplier>1.25</importanceMultiplier>
<importanceMultiplierCounted>1.0</importanceMultiplierCounted>
<importanceMultiplierCounted>0.5</importanceMultiplierCounted>
<targetIterations>5.0</targetIterations>
<researchSpeedMultiplier>2.0</researchSpeedMultiplier>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<category>ReverseEngineering</category>

<importanceMultiplier>1.25</importanceMultiplier>
<importanceMultiplierCounted>1.0</importanceMultiplierCounted>
<importanceMultiplierCounted>0.5</importanceMultiplierCounted>
<targetIterations>5.0</targetIterations>
<researchSpeedMultiplier>2.5</researchSpeedMultiplier>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<category>ReverseEngineering</category>

<importanceMultiplier>1.25</importanceMultiplier>
<importanceMultiplierCounted>1.0</importanceMultiplierCounted>
<importanceMultiplierCounted>0.5</importanceMultiplierCounted>
<targetIterations>4.0</targetIterations>
<researchSpeedMultiplier>3.0</researchSpeedMultiplier>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<category>ReverseEngineering</category>

<importanceMultiplier>1.0</importanceMultiplier>
<importanceMultiplierCounted>1.0</importanceMultiplierCounted>
<importanceMultiplierCounted>0.5</importanceMultiplierCounted>
<infiniteOverflow>true</infiniteOverflow>
<targetIterations>4.0</targetIterations>
<researchSpeedMultiplier>2.0</researchSpeedMultiplier>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<category>ReverseEngineering</category>

<importanceMultiplier>1.25</importanceMultiplier>
<importanceMultiplierCounted>1.0</importanceMultiplierCounted>
<importanceMultiplierCounted>0.5</importanceMultiplierCounted>
<targetIterations>5.0</targetIterations>
<researchSpeedMultiplier>1.5</researchSpeedMultiplier>
</li>
Expand Down
16 changes: 16 additions & 0 deletions ResearchReinvented/v1.4/Defs/WorkGivers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@
<canBeDoneByMechs>false</canBeDoneByMechs>
</WorkGiverDef>

<WorkGiverDef>
<defName>RR_AnalyseTerrain</defName>
<label>analyse terrain</label>
<giverClass>PeteTimesSix.ResearchReinvented.Rimworld.WorkGivers.WorkGiver_AnalyseTerrain</giverClass>
<workType>Research</workType>
<verb>analyse</verb>
<gerund>analysing</gerund>
<priorityInType>150</priorityInType>
<requiredCapacities>
<li>Manipulation</li>
</requiredCapacities>
<scanThings>false</scanThings>
<scanCells>true</scanCells>
<canBeDoneByMechs>false</canBeDoneByMechs>
</WorkGiverDef>

<WorkGiverDef>
<defName>RR_LearnRemotely</defName>
<label>learn from allies</label>
Expand Down

0 comments on commit a52a8dc

Please sign in to comment.