Skip to content

Commit

Permalink
Rename to SubcoreInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
eth0net committed Jan 17, 2023
1 parent f8a7619 commit 6fb850c
Show file tree
Hide file tree
Showing 27 changed files with 87 additions and 84 deletions.
4 changes: 2 additions & 2 deletions About/About.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<ModMetaData>
<name>Named Subcores</name>
<packageId>eth0net.NamedSubcores</packageId>
<name>SubcoreInfo</name>
<packageId>eth0net.SubcoreInfo</packageId>
<author>synthe0n</author>
<description>Track which unfortunate pawn your subcores came from!</description>
<supportedVersions>
Expand Down
Binary file modified About/Preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Assemblies/NamedSubcores.dll
Binary file not shown.
Binary file added Assemblies/SubcoreInfo.dll
Binary file not shown.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<value>
<comps>
<li>
<compClass>NamedSubcores.MechGestatorComp</compClass>
<compClass>SubcoreInfo.MechGestatorPatternComp</compClass>
</li>
</comps>
</value>
Expand All @@ -18,7 +18,7 @@
<xpath>/Defs/ThingDef[@Name="MechGestatorBase"]/comps</xpath>
<value>
<li>
<compClass>NamedSubcores.MechGestatorComp</compClass>
<compClass>SubcoreInfo.MechGestatorPatternComp</compClass>
</li>
</value>
</match>
Expand Down
4 changes: 2 additions & 2 deletions Patches/MechPatternComp.xml → Patches/MechInfoComp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<value>
<comps>
<li>
<compClass>NamedSubcores.MechPatternComp</compClass>
<compClass>SubcoreInfo.MechInfoComp</compClass>
</li>
</comps>
</value>
Expand All @@ -18,7 +18,7 @@
<xpath>/Defs/ThingDef[@Name="BaseMechanoid"]/comps</xpath>
<value>
<li>
<compClass>NamedSubcores.MechPatternComp</compClass>
<compClass>SubcoreInfo.MechInfoComp</compClass>
</li>
</value>
</match>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<value>
<comps>
<li>
<compClass>NamedSubcores.SubcorePatternComp</compClass>
<compClass>SubcoreInfo.SubcoreInfoComp</compClass>
</li>
</comps>
</value>
Expand All @@ -18,7 +18,7 @@
<xpath>/Defs/ThingDef[defName="SubcoreRegular" or defName="SubcoreHigh"]/comps</xpath>
<value>
<li>
<compClass>NamedSubcores.SubcorePatternComp</compClass>
<compClass>SubcoreInfo.SubcoreInfoComp</compClass>
</li>
</value>
</match>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<value>
<comps>
<li>
<compClass>NamedSubcores.SubcoreScannerComp</compClass>
<compClass>SubcoreInfo.SubcoreScannerPatternComp</compClass>
</li>
</comps>
</value>
Expand All @@ -18,7 +18,7 @@
<xpath>/Defs/ThingDef[defName="SubcoreSoftscanner" or defName="SubcoreRipscanner"]/comps</xpath>
<value>
<li>
<compClass>NamedSubcores.SubcoreScannerComp</compClass>
<compClass>SubcoreInfo.SubcoreScannerPatternComp</compClass>
</li>
</value>
</match>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ![NamedSubcores](./About/Preview.png)
# ![SubcoreInfo](./About/Preview.png)

Track which unfortunate pawn your subcores came from!

Expand Down
7 changes: 0 additions & 7 deletions Source/NamedSubcores/Comps/MechGestatorComp.cs

This file was deleted.

7 changes: 0 additions & 7 deletions Source/NamedSubcores/Comps/MechPatternComp.cs

This file was deleted.

21 changes: 0 additions & 21 deletions Source/NamedSubcores/NamedSubcores.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Source/NamedSubcores.sln → Source/SubcoreInfo.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NamedSubcores", "NamedSubcores\NamedSubcores.csproj", "{5850B4A6-F2A1-4822-8C82-EF54E17AF49F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubcoreInfo", "SubcoreInfo\SubcoreInfo.csproj", "{5850B4A6-F2A1-4822-8C82-EF54E17AF49F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Verse;

namespace NamedSubcores
namespace SubcoreInfo
{
/// <summary>
/// InspectPatternComp implements the common inspect method for pattern components.
/// BaseInfoComp implements the common inspect method for pattern components.
/// </summary>
public class InspectPatternComp : BasePatternComp
public class BaseInfoComp : BasePatternComp
{
/// <summary>
/// <summary>
/// CompInspectStringExtra adds to the item inspection pane.
/// </summary>
/// <returns></returns>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Verse;

namespace NamedSubcores
namespace SubcoreInfo
{
/// <summary>
/// BasePatternComp implements the common features for the pattern components.
Expand Down
8 changes: 8 additions & 0 deletions Source/SubcoreInfo/Comps/MechGestatorPatternComp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace SubcoreInfo
{
/// <summary>
/// MechGestatorPatternComp is added to mech gestators and
/// allows us to track the subcore pattern during gestation.
/// </summary>
public class MechGestatorPatternComp : BasePatternComp { }
}
7 changes: 7 additions & 0 deletions Source/SubcoreInfo/Comps/MechInfoComp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SubcoreInfo
{
/// <summary>
/// MechInfoComp is added to mechanoids and is used to track the pawn scanned into the subcore.
/// </summary>
public class MechInfoComp : BaseInfoComp { }
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Verse;

namespace NamedSubcores
namespace SubcoreInfo
{
/// <summary>
/// MechPatternComp is added to subcores and is used to track the pawn scanned into the subcore.
/// SubcoreInfoComp is added to subcores and is used to track the pawn scanned into the subcore.
/// </summary>
public class SubcorePatternComp : InspectPatternComp {
public class SubcoreInfoComp : BaseInfoComp
{
/// <summary>
/// AllowStackWith ensures that subcores can only be stacked with others of the same pattern.
/// </summary>
Expand All @@ -15,7 +16,7 @@ public override bool AllowStackWith(Thing other)
{
if (base.AllowStackWith(other) == false) { return false; };

SubcorePatternComp otherComp = other?.TryGetComp<SubcorePatternComp>();
SubcoreInfoComp otherComp = other?.TryGetComp<SubcoreInfoComp>();
if (otherComp == null) { return false; }

return PatternName == otherComp.PatternName;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Verse;

namespace NamedSubcores
namespace SubcoreInfo
{
/// <summary>
/// SubcoreScannerComp is added to subcore scanners and allows us to track when a subcore is ejected.
/// SubcoreScannerPatternComp is added to subcore scanners
/// allowing us to track when a subcore is ejected.
/// </summary>
public class SubcoreScannerComp : BasePatternComp
public class SubcoreScannerPatternComp : BasePatternComp
{
/// <summary>
/// Ejected tracks whether a subcore has just been ejected.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using Verse;

namespace NamedSubcores
namespace SubcoreInfo
{
internal class Harmony_Building_MechGestator
{
Expand All @@ -19,14 +19,14 @@ internal static class Harmony_Building_MechGestator_Notify_AllGestationCyclesCom
/// <param name="__instance"></param>
internal static void Prefix(Building_MechGestator __instance)
{
static bool hasNamedSubcoreComp(Thing thing) => (thing?.TryGetComp<SubcorePatternComp>() ?? null) != null;
static bool hasNamedSubcoreComp(Thing thing) => (thing?.TryGetComp<SubcoreInfoComp>() ?? null) != null;
Thing subcore = __instance.innerContainer.FirstOrDefault(hasNamedSubcoreComp);
if (subcore == null) { return; }

SubcorePatternComp subcoreComp = subcore.TryGetComp<SubcorePatternComp>();
SubcoreInfoComp subcoreComp = subcore.TryGetComp<SubcoreInfoComp>();
if (subcoreComp == null) { return; }

MechGestatorComp gestatorComp = __instance.GetComp<MechGestatorComp>();
MechGestatorPatternComp gestatorComp = __instance.GetComp<MechGestatorPatternComp>();
if (gestatorComp == null) { return; }

gestatorComp.PatternName = subcoreComp.PatternName;
Expand All @@ -38,10 +38,10 @@ internal static void Prefix(Building_MechGestator __instance)
/// <param name="__instance"></param>
internal static void Postfix(Building_MechGestator __instance)
{
MechGestatorComp gestatorComp = __instance.GetComp<MechGestatorComp>();
MechGestatorPatternComp gestatorComp = __instance.GetComp<MechGestatorPatternComp>();
if (gestatorComp == null) { return; }

MechPatternComp mechComp = __instance.GestatingMech.GetComp<MechPatternComp>();
MechInfoComp mechComp = __instance.GestatingMech.GetComp<MechInfoComp>();
if (mechComp == null) { return; }

mechComp.PatternName = gestatorComp.PatternName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using RimWorld;
using Verse;

namespace NamedSubcores
namespace SubcoreInfo
{
/// <summary>
/// Harmony_Building_SubcoreScanner_EjectContents patches subcore scanners to use our component during ejects.
Expand All @@ -16,7 +16,7 @@ internal static class Harmony_Building_SubcoreScanner_EjectContents
/// <param name="__instance"></param>
internal static void Postfix(Building_SubcoreScanner __instance)
{
__instance.GetComp<SubcoreScannerComp>().Ejected = true;
__instance.GetComp<SubcoreScannerPatternComp>().Ejected = true;
}
}

Expand All @@ -32,7 +32,7 @@ internal static class Harmony_Building_SubcoreScanner_Tick
/// <param name="__instance"></param>
internal static void Prefix(Building_SubcoreScanner __instance)
{
SubcoreScannerComp scannerComp = __instance.GetComp<SubcoreScannerComp>();
SubcoreScannerPatternComp scannerComp = __instance.GetComp<SubcoreScannerPatternComp>();
scannerComp.PatternName = __instance?.Occupant?.Name ?? null;
}

Expand All @@ -42,10 +42,10 @@ internal static void Prefix(Building_SubcoreScanner __instance)
/// <param name="__instance"></param>
internal static void Postfix(Building_SubcoreScanner __instance)
{
SubcoreScannerComp scannerComp = __instance.GetComp<SubcoreScannerComp>();
SubcoreScannerPatternComp scannerComp = __instance.GetComp<SubcoreScannerPatternComp>();
if (!scannerComp.Ejected) { return; }

SubcorePatternComp subcoreComp = TryGetSubcoreComp(__instance);
SubcoreInfoComp subcoreComp = TryGetSubcoreComp(__instance);
if (subcoreComp != null)
{
subcoreComp.PatternName = scannerComp.PatternName;
Expand All @@ -55,11 +55,11 @@ internal static void Postfix(Building_SubcoreScanner __instance)
}

/// <summary>
/// Try to find the subcore ejected from the scanner and return the component for it.
/// Try to find kekethe subcore ejected from the scanner and return the component for it.
/// </summary>
/// <param name="scanner"></param>
/// <returns></returns>
static SubcorePatternComp TryGetSubcoreComp(Building_SubcoreScanner scanner)
static SubcoreInfoComp TryGetSubcoreComp(Building_SubcoreScanner scanner)
{
ThingDef subcoreDef = scanner.def.defName switch
{
Expand All @@ -72,14 +72,14 @@ static SubcorePatternComp TryGetSubcoreComp(Building_SubcoreScanner scanner)

static bool validator(Thing subcore)
{
SubcorePatternComp comp = subcore.TryGetComp<SubcorePatternComp>();
SubcoreInfoComp comp = subcore.TryGetComp<SubcoreInfoComp>();
if (comp == null) { return false; }
return comp.PatternName == null;
}

Thing subcore = GenClosest.ClosestThingReachable(scanner.InteractionCell, scanner.Map, ThingRequest.ForDef(subcoreDef), Verse.AI.PathEndMode.ClosestTouch, TraverseParms.For(TraverseMode.ByPawn), 9999, validator);

return subcore?.TryGetComp<SubcorePatternComp>() ?? null;
return subcore?.TryGetComp<SubcoreInfoComp>() ?? null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
// 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("NamedSubcores")]
[assembly: AssemblyTitle("SubcoreInfo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NamedSubcores")]
[assembly: AssemblyProduct("SubcoreInfo")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
Expand Down
21 changes: 21 additions & 0 deletions Source/SubcoreInfo/SubcoreInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using HarmonyLib;
using Verse;

namespace SubcoreInfo
{
/// <summary>
/// SubcoreInfo static class to load up the mod and initialise everything.
/// </summary>
[StaticConstructorOnStartup]
public static class SubcoreInfo
{
/// <summary>
/// SubcoreInfo constructor to patch things using harmony.
/// </summary>
static SubcoreInfo()
{
var harmony = new Harmony("eth0net.SubcoreInfo.harmony");
harmony.PatchAll();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<ProjectGuid>{5850B4A6-F2A1-4822-8C82-EF54E17AF49F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NamedSubcores</RootNamespace>
<AssemblyName>NamedSubcores</AssemblyName>
<RootNamespace>SubcoreInfo</RootNamespace>
<AssemblyName>SubcoreInfo</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<LangVersion>preview</LangVersion>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -55,13 +55,13 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="NamedSubcores.cs" />
<Compile Include="SubcoreInfo.cs" />
<Compile Include="Comps\BasePatternComp.cs" />
<Compile Include="Comps\InspectPatternComp.cs" />
<Compile Include="Comps\MechGestatorComp.cs" />
<Compile Include="Comps\MechPatternComp.cs" />
<Compile Include="Comps\SubcorePatternComp.cs" />
<Compile Include="Comps\SubcoreScannerComp.cs" />
<Compile Include="Comps\BaseInfoComp.cs" />
<Compile Include="Comps\MechGestatorPatternComp.cs" />
<Compile Include="Comps\MechInfoComp.cs" />
<Compile Include="Comps\SubcoreInfoComp.cs" />
<Compile Include="Comps\SubcoreScannerPatternComp.cs" />
<Compile Include="Harmony\Harmony_Building_MechGestator.cs" />
<Compile Include="Harmony\Harmony_Building_SubcoreScanner.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 6fb850c

Please sign in to comment.