mirror of
https://github.com/Xevion/RimWorld_ResearchWhatever.git
synced 2025-12-09 06:08:23 -06:00
1.0.5
This commit is contained in:
BIN
1.4/Assemblies/ResearchWhatever.dll
Normal file
BIN
1.4/Assemblies/ResearchWhatever.dll
Normal file
Binary file not shown.
33
1.4/Patches/firefoxpdm.ResearchableStatUpgrades.xml
Normal file
33
1.4/Patches/firefoxpdm.ResearchableStatUpgrades.xml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Patch>
|
||||||
|
<Operation Class="PatchOperationSequence">
|
||||||
|
<success>Always</success>
|
||||||
|
<operations>
|
||||||
|
<li Class="PatchOperationTest"><xpath>Defs/ResearchProjectDef[defName="StackingRepeatable"]/modExtensions</xpath></li>
|
||||||
|
<li Class="PatchOperationAdd">
|
||||||
|
<xpath>Defs/ResearchProjectDef[defName="StackingRepeatable"]/modExtensions</xpath>
|
||||||
|
<value>
|
||||||
|
<li Class="ResearchWhatever.ResearchWhateverExtansion">
|
||||||
|
<!-- <ignore>true</ignore> -->
|
||||||
|
<lowPriority>true</lowPriority>
|
||||||
|
</li>
|
||||||
|
</value>
|
||||||
|
</li>
|
||||||
|
</operations>
|
||||||
|
</Operation>
|
||||||
|
|
||||||
|
<Operation Class="PatchOperationSequence">
|
||||||
|
<success>Always</success>
|
||||||
|
<operations>
|
||||||
|
<li Class="PatchOperationTest"><xpath>Defs/ResearchProjectDef[defName="ProductivityRepeatable"]/modExtensions</xpath></li>
|
||||||
|
<li Class="PatchOperationAdd">
|
||||||
|
<xpath>Defs/ResearchProjectDef[defName="ProductivityRepeatable"]/modExtensions</xpath>
|
||||||
|
<value>
|
||||||
|
<li Class="ResearchWhatever.ResearchWhateverExtansion">
|
||||||
|
<lowPriority>true</lowPriority>
|
||||||
|
</li>
|
||||||
|
</value>
|
||||||
|
</li>
|
||||||
|
</operations>
|
||||||
|
</Operation>
|
||||||
|
</Patch>
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
<author>avilmask</author>
|
<author>avilmask</author>
|
||||||
<supportedVersions>
|
<supportedVersions>
|
||||||
<li>1.3</li>
|
<li>1.3</li>
|
||||||
|
<li>1.4</li>
|
||||||
</supportedVersions>
|
</supportedVersions>
|
||||||
<url>none</url>
|
<url>none</url>
|
||||||
<packageId>avilmask.ResearchWhatever</packageId>
|
<packageId>avilmask.ResearchWhatever</packageId>
|
||||||
|
|||||||
36
Source/ResearchWhatever13/Properties/AssemblyInfo.cs
Normal file
36
Source/ResearchWhatever13/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("ResearchWhatever")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("ResearchWhatever")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("b08c8baf-9849-4317-b2be-639354820a7d")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
4
Source/ResearchWhatever13/packages.config
Normal file
4
Source/ResearchWhatever13/packages.config
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Lib.Harmony" version="2.1.0" targetFramework="net472" />
|
||||||
|
</packages>
|
||||||
37
Source/ResearchWhatever14/Patches/ResearchManagerPatch.cs
Normal file
37
Source/ResearchWhatever14/Patches/ResearchManagerPatch.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using HarmonyLib;
|
||||||
|
using RimWorld;
|
||||||
|
using Verse;
|
||||||
|
using Verse.Sound;
|
||||||
|
|
||||||
|
namespace ResearchWhatever.Patches
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(ResearchManager), "FinishProject")]
|
||||||
|
public static class ResearchManager_FinishProject_ResearchWhateverPatch
|
||||||
|
{
|
||||||
|
public static void Prefix(ResearchManager __instance, ref bool doCompletionDialog)
|
||||||
|
{
|
||||||
|
if (doCompletionDialog)
|
||||||
|
{
|
||||||
|
var comp = Current.Game.GetComponent<ResearchWhateverGameComp>();
|
||||||
|
if (comp.NotifyMode == ResearchWhateverNotifyMode.rwnDefault)
|
||||||
|
return;
|
||||||
|
|
||||||
|
doCompletionDialog = false;
|
||||||
|
|
||||||
|
switch (comp.NotifyMode)
|
||||||
|
{
|
||||||
|
case ResearchWhateverNotifyMode.rwnLetter:
|
||||||
|
Find.LetterStack.ReceiveLetter("ResearchFinished".Translate(__instance.currentProj.LabelCap), __instance.currentProj.description, LetterDefOf.PositiveEvent, null, null, null, null, null);
|
||||||
|
break;
|
||||||
|
case ResearchWhateverNotifyMode.rwnNotice:
|
||||||
|
Messages.Message("ResearchFinished".Translate(__instance.currentProj.LabelCap).CapitalizeFirst(), MessageTypeDefOf.SilentInput);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
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]
|
||||||
|
public static class StaticConstructorOnStartupUtility_CallAll_ResearchWhateverPatch
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
public static void Postfix()
|
||||||
|
{
|
||||||
|
List<ThingDef> list = new List<ThingDef>(
|
||||||
|
from x in DefDatabase<ThingDef>.AllDefsListForReading
|
||||||
|
where x.thingClass == typeof(Building_ResearchBench) || x.thingClass != null && x.thingClass.IsSubclassOf(typeof(Building_ResearchBench))
|
||||||
|
select x);
|
||||||
|
|
||||||
|
if (list.NullOrEmpty())
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
foreach (var thing in list)
|
||||||
|
{
|
||||||
|
thing?.comps?.Add(new CompProperties(typeof(ResearchWhateverComp)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using HarmonyLib;
|
||||||
|
using RimWorld;
|
||||||
|
using Verse;
|
||||||
|
using Verse.Sound;
|
||||||
|
|
||||||
|
namespace ResearchWhatever.Patches
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(WorkGiver_Researcher), "ShouldSkip")]
|
||||||
|
public static class WorkGiver_Researcher_ShouldSkip_ResearchWhateverPatch
|
||||||
|
{
|
||||||
|
public static bool Prefix(ref bool __result)
|
||||||
|
{
|
||||||
|
__result = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(WorkGiver_Researcher), "PotentialWorkThingRequest", MethodType.Getter)]
|
||||||
|
public static class WorkGiver_PotentialWorkThingRequest_ResearchWhateverPatch
|
||||||
|
{
|
||||||
|
public static bool Prefix(ref ThingRequest __result)
|
||||||
|
{
|
||||||
|
__result = ThingRequest.ForGroup(ThingRequestGroup.ResearchBench);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(WorkGiver_Researcher), "HasJobOnThing")]
|
||||||
|
public 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public 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))
|
||||||
|
&& x.GetModExtension<ResearchWhateverExtansion>()?.ignore != true
|
||||||
|
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.GetModExtension<ResearchWhateverExtansion>()?.lowPriority == true ? 100000000f + x.CostApparent : 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Source/ResearchWhatever14/Properties/AssemblyInfo.cs
Normal file
36
Source/ResearchWhatever14/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("ResearchWhatever")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("ResearchWhatever")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("b08c8baf-9849-4317-b2be-639354820a7d")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
17
Source/ResearchWhatever14/ResearchWhatever.cs
Normal file
17
Source/ResearchWhatever14/ResearchWhatever.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using System.Reflection;
|
||||||
|
using Verse;
|
||||||
|
using RimWorld;
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
77
Source/ResearchWhatever14/ResearchWhatever.csproj
Normal file
77
Source/ResearchWhatever14/ResearchWhatever.csproj
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<?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.4\Assemblies\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="0Harmony, Version=2.2.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\Lib.Harmony.2.2.2\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\ResearchManagerPatch.cs" />
|
||||||
|
<Compile Include="Patches\StaticConstructorOnStartupUtilityPatch.cs" />
|
||||||
|
<Compile Include="Patches\WorkGiver_ResearcherPatch.cs" />
|
||||||
|
<Compile Include="ResearchWhatever.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="ResearchWhateverComp.cs" />
|
||||||
|
<Compile Include="ResearchWhateverExtansion.cs" />
|
||||||
|
<Compile Include="ResearchWhateverGameComp.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
76
Source/ResearchWhatever14/ResearchWhateverComp.cs
Normal file
76
Source/ResearchWhatever14/ResearchWhateverComp.cs
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Verse;
|
||||||
|
using RimWorld;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace ResearchWhatever
|
||||||
|
{
|
||||||
|
public class ResearchWhateverComp : ThingComp
|
||||||
|
{
|
||||||
|
public bool Active
|
||||||
|
{
|
||||||
|
get { return parent?.Faction == Faction.OfPlayer && active; }
|
||||||
|
set { if (value == active) return; active = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void PostExposeData()
|
||||||
|
{
|
||||||
|
Scribe_Values.Look(ref active, "active", true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<Gizmo> CompGetGizmosExtra()
|
||||||
|
{
|
||||||
|
if (parent?.Faction != Faction.OfPlayer)
|
||||||
|
yield break;
|
||||||
|
//
|
||||||
|
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 = (() => active);
|
||||||
|
command_Toggle.toggleAction = delegate ()
|
||||||
|
{
|
||||||
|
if (Event.current.button == 0)
|
||||||
|
Active = !Active;
|
||||||
|
else if (Event.current.button == 1)
|
||||||
|
{
|
||||||
|
var comp = Current.Game.GetComponent<ResearchWhateverGameComp>();
|
||||||
|
//var lable = Mute ? "CommandResearchWhateverToggleMute".Translate().CapitalizeFirst() : "CommandResearchWhateverToggleUnmute".Translate().CapitalizeFirst();
|
||||||
|
List<FloatMenuOption> list = new List<FloatMenuOption>();
|
||||||
|
list.Add(new FloatMenuOption("CommandResearchWhateverToggleDefault".Translate().CapitalizeFirst(), delegate ()
|
||||||
|
{
|
||||||
|
comp.NotifyMode = ResearchWhateverNotifyMode.rwnDefault;
|
||||||
|
}));
|
||||||
|
list.Add(new FloatMenuOption("CommandResearchWhateverToggleLetter".Translate().CapitalizeFirst(), delegate ()
|
||||||
|
{
|
||||||
|
comp.NotifyMode = ResearchWhateverNotifyMode.rwnLetter;
|
||||||
|
}));
|
||||||
|
list.Add(new FloatMenuOption("CommandResearchWhateverToggleNotice".Translate().CapitalizeFirst(), delegate ()
|
||||||
|
{
|
||||||
|
comp.NotifyMode = ResearchWhateverNotifyMode.rwnNotice;
|
||||||
|
}));
|
||||||
|
list.Add(new FloatMenuOption("CommandResearchWhateverToggleMute".Translate().CapitalizeFirst(), delegate ()
|
||||||
|
{
|
||||||
|
comp.NotifyMode = ResearchWhateverNotifyMode.rwnMute;
|
||||||
|
}));
|
||||||
|
FloatMenu floatMenu = new FloatMenu(list);
|
||||||
|
floatMenu.vanishIfMouseDistant = true;
|
||||||
|
Find.WindowStack.Add(floatMenu);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (Active)
|
||||||
|
{
|
||||||
|
command_Toggle.defaultDesc = "CommandResearchWhateverToggleDescActive".Translate();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
command_Toggle.defaultDesc = "CommandResearchWhateverToggleDescInactive".Translate();
|
||||||
|
}
|
||||||
|
yield return command_Toggle;
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
10
Source/ResearchWhatever14/ResearchWhateverExtansion.cs
Normal file
10
Source/ResearchWhatever14/ResearchWhateverExtansion.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using Verse;
|
||||||
|
|
||||||
|
namespace ResearchWhatever
|
||||||
|
{
|
||||||
|
public class ResearchWhateverExtansion : DefModExtension
|
||||||
|
{
|
||||||
|
public bool ignore = false;
|
||||||
|
public bool lowPriority = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
24
Source/ResearchWhatever14/ResearchWhateverGameComp.cs
Normal file
24
Source/ResearchWhatever14/ResearchWhateverGameComp.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Verse;
|
||||||
|
using RimWorld;
|
||||||
|
|
||||||
|
namespace ResearchWhatever
|
||||||
|
{
|
||||||
|
public enum ResearchWhateverNotifyMode { rwnDefault, rwnLetter, rwnNotice, rwnMute }
|
||||||
|
public class ResearchWhateverGameComp : GameComponent
|
||||||
|
{
|
||||||
|
public ResearchWhateverGameComp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public ResearchWhateverGameComp(Game game)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public override void ExposeData()
|
||||||
|
{
|
||||||
|
Scribe_Values.Look(ref notifyMode, "NotifyMode");
|
||||||
|
}
|
||||||
|
private ResearchWhateverNotifyMode notifyMode = ResearchWhateverNotifyMode.rwnDefault;
|
||||||
|
public ResearchWhateverNotifyMode NotifyMode { get { return notifyMode; } set { notifyMode = value; } }
|
||||||
|
}
|
||||||
|
}
|
||||||
4
Source/ResearchWhatever14/packages.config
Normal file
4
Source/ResearchWhatever14/packages.config
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Lib.Harmony" version="2.2.2" targetFramework="net472" />
|
||||||
|
</packages>
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
1.0.4
|
1.0.5
|
||||||
|
- 1.4 aye;
|
||||||
|
|
||||||
|
1.0.4
|
||||||
- now you can r-click on the toggle to mute completion notifications;
|
- now you can r-click on the toggle to mute completion notifications;
|
||||||
|
|
||||||
1.0.3
|
1.0.3
|
||||||
|
|||||||
Reference in New Issue
Block a user