Skip to content

Commit

Permalink
Fixed errors with Dragon's Descent (#433)
Browse files Browse the repository at this point in the history
Looks like some stuff got removed from the mod - so the fix is removing code that patched parts of the mod that no longer exist.

I think hostility response may have not been in previously, just kept for legacy reasons? And ritual dev mode gizmos were (for whatever reason) removed.
  • Loading branch information
SokyranTheDragon authored Mar 14, 2024
1 parent 1a2d9b9 commit 9d4ab51
Showing 1 changed file with 1 addition and 50 deletions.
51 changes: 1 addition & 50 deletions Source/Mods/DragonsDescent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Linq;
using System.Reflection;
using HarmonyLib;
Expand All @@ -14,16 +13,6 @@ namespace Multiplayer.Compat
[MpCompatFor("onyxae.dragonsdescent")]
public class DragonsDescent
{
//// Gizmos ////
// CompHostileResponse
// Inner class inside of CompHostileResponse
private static AccessTools.FieldRef<object, ThingComp> compHostileResponseParentField;
private static AccessTools.FieldRef<object, IList> compHostileResponseOptionsField;
private static AccessTools.FieldRef<object, int> compHostileResponseIndexField;

// CompProperties_HostileResponse
private static AccessTools.FieldRef<object, IList> compHostileResponsePropsOptionsField;

//// Altar and Rituals ////
// Command_RitualEffect
private static ConstructorInfo ritualEffectCommandCtor;
Expand Down Expand Up @@ -58,23 +47,7 @@ public DragonsDescent(ModContentPack mod)
MpCompat.RegisterLambdaDelegate("DD.CompProperties_EggIncubator", "CreateGizmo", 0);
}

// AbilityCom_AbilityControl seems unused, skipping this gizmo

// Hostility response type changing
{
var type = AccessTools.TypeByName("DD.CompHostileResponse");
var method = MpMethodUtil.GetLambda(type, "Gizmo", MethodType.Getter, null, 1);
var inner = method.DeclaringType;

compHostileResponseParentField = AccessTools.FieldRefAccess<ThingComp>(inner, "<>4__this");
compHostileResponseOptionsField = AccessTools.FieldRefAccess<IList>(inner, "options");
compHostileResponseIndexField = AccessTools.FieldRefAccess<int>(inner, "index");

compHostileResponsePropsOptionsField = AccessTools.FieldRefAccess<IList>("DD.CompProperties_HostileResponse:options");

MP.RegisterSyncMethod(method);
MP.RegisterSyncWorker<object>(SyncHostileResponseOptionInnerClass, inner, shouldConstruct: true);
}
// AbilityComp_AbilityControl seems unused, skipping this gizmo

// Altar and Rituals
{
Expand All @@ -91,9 +64,6 @@ public DragonsDescent(ModContentPack mod)
// RitualTracker
var ritualTrackerType = AccessTools.TypeByName("DD.RitualTracker");
ritualTrackerMapField = AccessTools.FieldRefAccess<Map>(ritualTrackerType, "map");

// CompRitualAltar
MpCompat.RegisterLambdaDelegate("DD.CompRitualAltar", "CompGetGizmosExtra", 0, 1, 2, 3, 4, 5).SetDebugOnly();
MP.RegisterSyncWorker<object>(SyncRitualTracker, ritualTrackerType);
}

Expand All @@ -120,25 +90,6 @@ private static void LatePatch()
MP.RegisterSyncWorker<Command>(SyncRitualEffectCommand, ritualEffectCommand);
}

private static void SyncHostileResponseOptionInnerClass(SyncWorker sync, ref object obj)
{
if (sync.isWriting)
{
sync.Write(compHostileResponseParentField(obj));
sync.Write(compHostileResponseIndexField(obj));
}
else
{
var comp = sync.Read<ThingComp>();
var index = sync.Read<int>();
var options = compHostileResponsePropsOptionsField(comp.props);

compHostileResponseParentField(obj) = comp;
compHostileResponseOptionsField(obj) = options;
compHostileResponseIndexField(obj) = index;
}
}

private static void SyncRitualTracker(SyncWorker sync, ref object tracker)
{
if (sync.isWriting)
Expand Down

0 comments on commit 9d4ab51

Please sign in to comment.