mirror of
https://github.com/Xevion/RimWorld_ResearchWhatever.git
synced 2025-12-06 03:16:19 -06:00
1.0
This commit is contained in:
BIN
1.3/Assemblies/ResearchWhatever.dll
Normal file
BIN
1.3/Assemblies/ResearchWhatever.dll
Normal file
Binary file not shown.
19
About/About.xml
Normal file
19
About/About.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ModMetaData>
|
||||
<name>Research Whatever</name>
|
||||
<author>avilmask</author>
|
||||
<supportedVersions>
|
||||
<li>1.2</li>
|
||||
<li>1.3</li>
|
||||
</supportedVersions>
|
||||
<url>none</url>
|
||||
<packageId>avilmask.ResearchWhatever</packageId>
|
||||
<modDependencies>
|
||||
<li>
|
||||
<packageId>brrainz.harmony</packageId>
|
||||
<displayName>Harmony</displayName>
|
||||
<steamWorkshopUrl>steam://url/CommunityFilePage/2009463077</steamWorkshopUrl>
|
||||
</li>
|
||||
</modDependencies>
|
||||
<description>When research subject is not selected, pawns just choose the cheapest one on their own. This option is accessible from research bench.</description>
|
||||
</ModMetaData>
|
||||
BIN
About/preview.png
Normal file
BIN
About/preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 72 KiB |
8
Languages/English/Keyed/strings.xml
Normal file
8
Languages/English/Keyed/strings.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<LanguageData>
|
||||
<CommandResearchWhateverToggleLabel>Research whatever</CommandResearchWhateverToggleLabel>
|
||||
<CommandResearchWhateverToggleDescActive>Active - colonists will choose something to research on their own.</CommandResearchWhateverToggleDescActive>
|
||||
<CommandResearchWhateverToggleDescInactive>Inactive - colonists will not choose something to research on their own.</CommandResearchWhateverToggleDescInactive>
|
||||
<ResearchWhateverNothingLeftToResearch>{0} has nothing left to research</ResearchWhateverNothingLeftToResearch>
|
||||
<ResearchWhateverNewResearch>{0} have started a new research: {1}</ResearchWhateverNewResearch>
|
||||
</LanguageData>
|
||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# RimWorld_AnimalControls
|
||||
|
||||
Research Whatever - is a mod for videogame RimWorld.
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
using HarmonyLib;
|
||||
using System.Reflection;
|
||||
using RimWorld;
|
||||
|
||||
|
||||
namespace ResearchWhatever
|
||||
{
|
||||
public static class StaticConstructorOnStartupUtility_Patch
|
||||
{
|
||||
//[HarmonyPatch(typeof(StaticConstructorOnStartupUtility), "CallAll")]
|
||||
[HarmonyPatch]
|
||||
static class StaticConstructorOnStartupUtility_CallAll_NonUnoPinataPatch
|
||||
{
|
||||
internal static MethodBase TargetMethod()
|
||||
{
|
||||
MethodBase LCallAll = AccessTools.Method("BetterLoading.Stage.InitialLoad.StageRunStaticCctors:PreCallAll");
|
||||
if (LCallAll == null)
|
||||
{
|
||||
LCallAll = AccessTools.Method("Verse.StaticConstructorOnStartupUtility:CallAll");
|
||||
if (LCallAll == null)
|
||||
throw new Exception("Couldn't find StaticConstructorOnStartupUtility.CallAll()");
|
||||
}
|
||||
else
|
||||
Log.Message("[ResearchWhatever] BetterLoading detected, workaround initiated");
|
||||
return LCallAll;
|
||||
}
|
||||
//
|
||||
static void Postfix()
|
||||
{
|
||||
List<ThingDef> list = new List<ThingDef>(
|
||||
from x in DefDatabase<ThingDef>.AllDefsListForReading
|
||||
where x.thingClass == typeof(Building_ResearchBench) || x.thingClass.IsSubclassOf(typeof(Building_ResearchBench))
|
||||
select x);
|
||||
|
||||
foreach (var thing in list)
|
||||
{
|
||||
thing?.comps.Add(new CompProperties(typeof(ResearchWhateverComp)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using Verse.Sound;
|
||||
|
||||
namespace ResearchWhatever.Patches
|
||||
{
|
||||
[HarmonyPatch(typeof(WorkGiver_Researcher), "ShouldSkip")]
|
||||
static class WorkGiver_Researcher_ShouldSkip_ResearchWhateverPatch
|
||||
{
|
||||
static bool Prefix(ref bool __result)
|
||||
{
|
||||
__result = false;
|
||||
//Log.Message($"ShouldSkip={__result}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(WorkGiver_Researcher), "PotentialWorkThingRequest", MethodType.Getter)]
|
||||
static class WorkGiver_PotentialWorkThingRequest_ResearchWhateverPatch
|
||||
{
|
||||
static bool Prefix(ref ThingRequest __result)
|
||||
{
|
||||
__result = ThingRequest.ForGroup(ThingRequestGroup.ResearchBench);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(WorkGiver_Researcher), "HasJobOnThing")]
|
||||
static class WorkGiver_Researcher_HasJobOnThing_ResearchWhateverPatch
|
||||
{
|
||||
private static bool hasFacilities(this Building_ResearchBench bench, List<ThingDef> requiredFacilities)
|
||||
{
|
||||
if (requiredFacilities.NullOrEmpty()) return true;
|
||||
CompAffectedByFacilities comp = bench.TryGetComp<CompAffectedByFacilities>();
|
||||
if (comp == null) return false;
|
||||
|
||||
foreach (var rf in requiredFacilities)
|
||||
if (comp.LinkedFacilitiesListForReading.FirstOrDefault(x => x.def == rf && comp.IsFacilityActive(x)) == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Prefix(Pawn pawn, Thing t, bool forced)
|
||||
{
|
||||
|
||||
ResearchProjectDef currentProj = Find.ResearchManager.currentProj;
|
||||
if (currentProj != null) return;
|
||||
Building_ResearchBench bench = t as Building_ResearchBench;
|
||||
if (bench == null) return;
|
||||
|
||||
ResearchWhateverComp comp = bench.TryGetComp<ResearchWhateverComp>();
|
||||
|
||||
if (comp == null || !comp.Active) return;
|
||||
|
||||
List<ResearchProjectDef> projects = new List<ResearchProjectDef>(
|
||||
from x in DefDatabase<ResearchProjectDef>.AllDefsListForReading
|
||||
where Find.Storyteller.difficulty.AllowedBy(x.hideWhen)
|
||||
&& !x.IsFinished
|
||||
&& x.TechprintRequirementMet
|
||||
&& x.PrerequisitesCompleted
|
||||
&& (x.requiredResearchBuilding == null || x.requiredResearchBuilding == bench.def && bench.hasFacilities(x.requiredResearchFacilities))
|
||||
select x);
|
||||
|
||||
if (projects.NullOrEmpty())
|
||||
{
|
||||
comp.Active = false;
|
||||
Messages.Message("ResearchWhateverNothingLeftToResearch".Translate(bench.Label).CapitalizeFirst(), new TargetInfo(bench.Position, bench.Map, false), MessageTypeDefOf.NeutralEvent);
|
||||
return;
|
||||
}
|
||||
projects.SortBy(x => x.CostApparent);
|
||||
|
||||
ResearchProjectDef def = projects.First();
|
||||
projects.TryRandomElementByWeight(x => x.CostApparent == def.CostApparent ? 1f : 0f, out def);
|
||||
SoundDefOf.ResearchStart.PlayOneShotOnCamera(null);
|
||||
Find.ResearchManager.currentProj = def;
|
||||
TutorSystem.Notify_Event("StartResearchProject");
|
||||
Messages.Message( "ResearchWhateverNewResearch".Translate(pawn.Name.ToStringFull, def.label).CapitalizeFirst(), new TargetInfo(bench.Position, bench.Map, false), MessageTypeDefOf.SilentInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Source/ResearchWhatever13/ResearchWhatever.cs
Normal file
16
Source/ResearchWhatever13/ResearchWhatever.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using HarmonyLib;
|
||||
using System.Reflection;
|
||||
using Verse;
|
||||
|
||||
namespace ResearchWhatever
|
||||
{
|
||||
[StaticConstructorOnStartup]
|
||||
public class ResearchWhatever : Mod
|
||||
{
|
||||
public ResearchWhatever(ModContentPack content) : base(content)
|
||||
{
|
||||
var harmony = new Harmony("net.avilmask.rimworld.mod.ResearchWhatever");
|
||||
harmony.PatchAll(Assembly.GetExecutingAssembly());
|
||||
}
|
||||
}
|
||||
}
|
||||
74
Source/ResearchWhatever13/ResearchWhatever.csproj
Normal file
74
Source/ResearchWhatever13/ResearchWhatever.csproj
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{B08C8BAF-9849-4317-B2BE-639354820A7D}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ResearchWhatever</RootNamespace>
|
||||
<AssemblyName>ResearchWhatever</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\1.3\Assemblies\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="0Harmony, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Lib.Harmony.2.1.0\lib\net472\0Harmony.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\..\..\..\..\..\..\Games\steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>..\..\..\..\..\..\..\Games\steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>..\..\..\..\..\..\..\Games\steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.IMGUIModule">
|
||||
<HintPath>..\..\..\..\..\..\..\Games\steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Patches\StaticConstructorOnStartupUtilityPatch.cs" />
|
||||
<Compile Include="Patches\WorkGiver_ResearcherPatch.cs" />
|
||||
<Compile Include="ResearchWhatever.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ResearchWhateverComp.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
25
Source/ResearchWhatever13/ResearchWhatever.sln
Normal file
25
Source/ResearchWhatever13/ResearchWhatever.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.1062
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResearchWhatever", "ResearchWhatever.csproj", "{B08C8BAF-9849-4317-B2BE-639354820A7D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B08C8BAF-9849-4317-B2BE-639354820A7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B08C8BAF-9849-4317-B2BE-639354820A7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B08C8BAF-9849-4317-B2BE-639354820A7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B08C8BAF-9849-4317-B2BE-639354820A7D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {0D207634-209F-4992-A31F-77B17C0ED417}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
56
Source/ResearchWhatever13/ResearchWhateverComp.cs
Normal file
56
Source/ResearchWhatever13/ResearchWhateverComp.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
|
||||
namespace ResearchWhatever
|
||||
{
|
||||
public class ResearchWhateverComp : ThingComp
|
||||
{
|
||||
public bool Active
|
||||
{
|
||||
get
|
||||
{
|
||||
return active;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.active = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void PostExposeData()
|
||||
{
|
||||
Scribe_Values.Look(ref active, "active", true, false);
|
||||
}
|
||||
|
||||
public override IEnumerable<Gizmo> CompGetGizmosExtra()
|
||||
{
|
||||
Command_Toggle command_Toggle = new Command_Toggle();
|
||||
command_Toggle.hotKey = KeyBindingDefOf.Command_TogglePower;
|
||||
command_Toggle.defaultLabel = "CommandResearchWhateverToggleLabel".Translate();
|
||||
command_Toggle.icon = TexCommand.OpenLinkedQuestTex;
|
||||
command_Toggle.isActive = (() => this.Active);
|
||||
command_Toggle.toggleAction = delegate ()
|
||||
{
|
||||
this.Active = !this.Active;
|
||||
};
|
||||
if (this.Active)
|
||||
{
|
||||
command_Toggle.defaultDesc = "CommandResearchWhateverToggleDescActive".Translate();
|
||||
}
|
||||
else
|
||||
{
|
||||
command_Toggle.defaultDesc = "CommandResearchWhateverToggleDescInactive".Translate();
|
||||
}
|
||||
yield return command_Toggle;
|
||||
yield break;
|
||||
}
|
||||
|
||||
private bool active = true;
|
||||
}
|
||||
|
||||
}
|
||||
2
change.log
Normal file
2
change.log
Normal file
@@ -0,0 +1,2 @@
|
||||
1.0.0
|
||||
- :T
|
||||
Reference in New Issue
Block a user