Skip to content

Commit

Permalink
Rename comps to match base game
Browse files Browse the repository at this point in the history
  • Loading branch information
eth0net committed Jan 30, 2023
1 parent c71dc1c commit 502efc2
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 33 deletions.
Binary file modified Assemblies/SubcoreInfo.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<value>
<comps>
<li>
<compClass>SubcoreInfo.Comps.SubcoreScannerEjectedComp</compClass>
<compClass>SubcoreInfo.Comps.CompEjected</compClass>
</li>
</comps>
</value>
Expand All @@ -18,7 +18,7 @@
<xpath>/Defs/ThingDef[defName="SubcoreSoftscanner" or defName="SubcoreRipscanner"]/comps</xpath>
<value>
<li>
<compClass>SubcoreInfo.Comps.SubcoreScannerEjectedComp</compClass>
<compClass>SubcoreInfo.Comps.CompEjected</compClass>
</li>
</value>
</match>
Expand Down
4 changes: 2 additions & 2 deletions Patches/MechInfoComp.xml → Patches/CompMechInfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<value>
<comps>
<li>
<compClass>SubcoreInfo.Comps.MechInfoComp</compClass>
<compClass>SubcoreInfo.Comps.CompMechInfo</compClass>
</li>
</comps>
</value>
Expand All @@ -18,7 +18,7 @@
<xpath>/Defs/ThingDef[@Name="BaseMechanoid"]/comps</xpath>
<value>
<li>
<compClass>SubcoreInfo.Comps.MechInfoComp</compClass>
<compClass>SubcoreInfo.Comps.CompMechInfo</compClass>
</li>
</value>
</match>
Expand Down
4 changes: 2 additions & 2 deletions Patches/SubcoreInfoComp.xml → Patches/CompSubcoreInfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<value>
<comps>
<li>
<compClass>SubcoreInfo.Comps.SubcoreInfoComp</compClass>
<compClass>SubcoreInfo.Comps.CompSubcoreInfo</compClass>
</li>
</comps>
</value>
Expand All @@ -18,7 +18,7 @@
<xpath>/Defs/ThingDef[defName="SubcoreRegular" or defName="SubcoreHigh"]/comps</xpath>
<value>
<li>
<compClass>SubcoreInfo.Comps.SubcoreInfoComp</compClass>
<compClass>SubcoreInfo.Comps.CompSubcoreInfo</compClass>
</li>
</value>
</match>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace SubcoreInfo.Comps
{
/// <summary>
/// SubcoreScannerEjectedComp is added to subcore scanners
/// CompEjected is added to subcore scanners
/// allowing us to track when a subcore is ejected.
/// </summary>
public class SubcoreScannerEjectedComp : ThingComp
public class CompEjected : ThingComp
{
/// <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,9 +3,9 @@
namespace SubcoreInfo.Comps
{
/// <summary>
/// MechInfoComp is added to mechanoids and is used to track the pawn scanned into the subcore.
/// CompMechInfo is added to mechanoids and is used to track the pawn scanned into the subcore.
/// </summary>
public class MechInfoComp : BaseInfoComp {
public class CompMechInfo : CompPatternInfo {
/// <summary>
/// Disassembling tracks when a mech is being disassembled.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace SubcoreInfo.Comps
{
/// <summary>
/// BaseInfoComp implements the common inspect method for pattern components.
/// CompPatternInfo implements the common inspect method for pattern components.
/// </summary>
public class BaseInfoComp : ThingComp
public class CompPatternInfo : ThingComp
{
/// <summary>
/// PatternName tracks the name of the pawn scanned.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
namespace SubcoreInfo.Comps
{
/// <summary>
/// SubcoreInfoComp is added to subcores and is used to track the pawn scanned into the subcore.
/// CompSubcoreInfo is added to subcores and is used to track the pawn scanned into the subcore.
/// </summary>
public class SubcoreInfoComp : BaseInfoComp
public class CompSubcoreInfo : CompPatternInfo
{
/// <summary>
/// AllowStackWith ensures that subcores can only be stacked with others of the same pattern.
Expand All @@ -17,7 +17,7 @@ public override bool AllowStackWith(Thing other)
{
if (base.AllowStackWith(other) == false) { return false; };

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

return PatternName == otherComp.PatternName;
Expand Down
6 changes: 3 additions & 3 deletions Source/SubcoreInfo/Harmony/Harmony_Building_MechGestator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ internal static class Harmony_Building_MechGestator_Notify_AllGestationCyclesCom
/// <param name="__state"></param>
internal static void Prefix(Building_MechGestator __instance, ref Name __state)
{
static bool hasNamedSubcoreComp(Thing thing) => (thing?.TryGetComp<SubcoreInfoComp>() ?? null) != null;
static bool hasNamedSubcoreComp(Thing thing) => (thing?.TryGetComp<CompSubcoreInfo>() ?? null) != null;
Thing subcore = __instance.innerContainer.FirstOrDefault(hasNamedSubcoreComp);
if (subcore == null) { return; }

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

__state = subcoreComp.PatternName;
Expand All @@ -38,7 +38,7 @@ internal static void Prefix(Building_MechGestator __instance, ref Name __state)
/// <param name="__state"></param>
internal static void Postfix(Building_MechGestator __instance, Name __state)
{
MechInfoComp mechComp = __instance.GestatingMech.GetComp<MechInfoComp>();
CompMechInfo mechComp = __instance.GestatingMech.GetComp<CompMechInfo>();
if (mechComp == null) { return; }

mechComp.PatternName = __state;
Expand Down
10 changes: 5 additions & 5 deletions Source/SubcoreInfo/Harmony/Harmony_Building_SubcoreScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal static class Harmony_Building_SubcoreScanner_EjectContents
/// <param name="__instance"></param>
internal static void Postfix(Building_SubcoreScanner __instance)
{
__instance.GetComp<SubcoreScannerEjectedComp>().Ejected = true;
__instance.GetComp<CompEjected>().Ejected = true;
}
}

Expand All @@ -44,7 +44,7 @@ internal static void Prefix(Building_SubcoreScanner __instance, ref Name __state
/// <param name="__state"></param>
internal static void Postfix(Building_SubcoreScanner __instance, Name __state)
{
SubcoreInfoComp comp = TryGetSubcoreComp(__instance);
CompSubcoreInfo comp = TryGetSubcoreComp(__instance);
if (comp == null) return;

comp.PatternName = __state;
Expand All @@ -55,7 +55,7 @@ internal static void Postfix(Building_SubcoreScanner __instance, Name __state)
/// </summary>
/// <param name="scanner"></param>
/// <returns></returns>
static SubcoreInfoComp TryGetSubcoreComp(Building_SubcoreScanner scanner)
static CompSubcoreInfo TryGetSubcoreComp(Building_SubcoreScanner scanner)
{
ThingDef subcoreDef = scanner.def.defName switch
{
Expand All @@ -68,13 +68,13 @@ static SubcoreInfoComp TryGetSubcoreComp(Building_SubcoreScanner scanner)

static bool validator(Thing subcore)
{
SubcoreInfoComp comp = subcore.TryGetComp<SubcoreInfoComp>();
CompSubcoreInfo comp = subcore.TryGetComp<CompSubcoreInfo>();
return comp != null && 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<SubcoreInfoComp>() ?? null;
return subcore?.TryGetComp<CompSubcoreInfo>() ?? null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal static void Prefix(JobDriver_DisassembleMech __instance)
Pawn mech = (Pawn)__instance.job.GetTarget(TargetIndex.A).Thing;
if (mech == null) { return; }

MechInfoComp mechComp = mech.GetComp<MechInfoComp>();
CompMechInfo mechComp = mech.GetComp<CompMechInfo>();
if (mechComp == null) { return; }

mechComp.Disassembling = true;
Expand Down
10 changes: 5 additions & 5 deletions Source/SubcoreInfo/Harmony/Harmony_Pawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ internal static void Prefix(Pawn __instance)
{
if (__instance == null || !__instance.IsColonyMech) { return; }

MechInfoComp mechComp = __instance.GetComp<MechInfoComp>();
CompMechInfo mechComp = __instance.GetComp<CompMechInfo>();
if (mechComp == null || !mechComp.Disassembling) { return; }

SubcoreInfoComp subcoreComp = TryGetSubcoreComp(__instance);
CompSubcoreInfo subcoreComp = TryGetSubcoreComp(__instance);
if (subcoreComp == null) { return; }

subcoreComp.PatternName = mechComp.PatternName;
Expand All @@ -37,21 +37,21 @@ internal static void Prefix(Pawn __instance)
/// </summary>
/// <param name="scanner"></param>
/// <returns></returns>
static SubcoreInfoComp TryGetSubcoreComp(Pawn mech)
static CompSubcoreInfo TryGetSubcoreComp(Pawn mech)
{
ThingDefCountClass subcoreClass = MechanitorUtility.IngredientsFromDisassembly(mech.def).FirstOrDefault((ThingDefCountClass thing) => thing.thingDef.defName == "SubcoreRegular" || thing.thingDef.defName == "SubcoreHigh");
if (subcoreClass == null) { return null; }

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

Thing subcore = GenClosest.ClosestThingReachable(mech.Position, mech.Map, ThingRequest.ForDef(subcoreClass.thingDef), PathEndMode.ClosestTouch, TraverseParms.For(TraverseMode.ByPawn), 9999, validator);

return subcore?.TryGetComp<SubcoreInfoComp>() ?? null;
return subcore?.TryGetComp<CompSubcoreInfo>() ?? null;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Source/SubcoreInfo/SubcoreInfo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
</ItemGroup>
<ItemGroup>
<Compile Include="SubcoreInfo.cs" />
<Compile Include="Comps\BaseInfoComp.cs" />
<Compile Include="Comps\MechInfoComp.cs" />
<Compile Include="Comps\SubcoreInfoComp.cs" />
<Compile Include="Comps\SubcoreScannerEjectedComp.cs" />
<Compile Include="Comps\CompPatternInfo.cs" />
<Compile Include="Comps\CompMechInfo.cs" />
<Compile Include="Comps\CompSubcoreInfo.cs" />
<Compile Include="Comps\CompEjected.cs" />
<Compile Include="Harmony\Harmony_Building_MechGestator.cs" />
<Compile Include="Harmony\Harmony_Building_SubcoreScanner.cs" />
<Compile Include="Harmony\Harmony_JobDriver_DisassembleMech.cs" />
Expand Down

0 comments on commit 502efc2

Please sign in to comment.