Skip to content

Conversation

@Chillayy
Copy link

@Chillayy Chillayy commented Jan 10, 2026

Changes

  • Updated VEF ability type lookups to support VEF 1.6 namespace changes (VEF.Abilities instead of VFECore.Abilities)
  • Added fallback to VFECore namespace for backward compatibility with older VEF versions
  • Improved Run and Gun compatibility with conditional patches for different mod versions
  • Added WorldComponent_ToggleData.SetRunAndGun sync method to fix toggle button desyncs

These changes should solve issues with mods like Dragon's Descent, VPE, and others that rely on VEF.

Testing

Tested with all DLC, VEF 1.6, Dragon's Descent, and Run and Gun - confirmed no desyncs when using dragon abilities or toggling run and gun.

@Chillayy Chillayy marked this pull request as draft January 10, 2026 09:48
@Chillayy Chillayy marked this pull request as ready for review January 10, 2026 09:50
@SokyranTheDragon
Copy link
Member

  • Updated VEF ability type lookups to support VEF 1.6 namespace changes (VEF.Abilities instead of VFECore.Abilities)
  • Added fallback to VFECore namespace for backward compatibility with older VEF versions

It's pointless to keep the old namespace around. There's not a single 1.6 VEF version that uses VFECore namespace for anything, and this code will never be used for compiling a 1.5 or earlier version.

In fact, it would probably be wise to update all the other namespaces away from VFECore to the new VEF one, as I assume there will be a lot of startup errors as well as desyncs in-game unless those are changed.

Also, you've added a bunch of check for null types which will cause warnings and return early if null. The code was designed to handle any exceptions and log errors when it happens, so it's not really needed to handle null types/methods there like that.

MpCompat.harmony.Patch(AccessTools.DeclaredMethod(type, "Cast"),
    prefix: new HarmonyMethod(typeof(VanillaExpandedFramework), nameof(PreAbilityCast)),
    postfix: new HarmonyMethod(typeof(VanillaExpandedFramework), nameof(PostAbilityCast)));
private static void PreAbilityCast(object __instance, out PatchingUtilities.TimeSnapshot? __state)
{
    if (!MP.IsInMultiplayer)
    {
        __state = null;
        return;
    }

    var pawn = abilityPawnField(__instance);
    __state = pawn?.Map != null ? PatchingUtilities.TimeSnapshot.GetAndSetFromMap(pawn.Map) : null;
}

private static void PostAbilityCast(PatchingUtilities.TimeSnapshot? __state)
{
    __state?.Set();
}

What's the point of this patch? It's temporarily changing the current tick while casting the ability to match the map the pawn is on... Except that this method should already be called in a place where this is the case. (Or it won't do anything if casting from the world map.)

@SokyranTheDragon
Copy link
Member

  • Improved Run and Gun compatibility with conditional patches for different mod versions
  • Added WorldComponent_ToggleData.SetRunAndGun sync method to fix toggle button desyncs
/// <see href="https://github.com/MemeGoddess/RunAndGun-continued"/>

Dead link.

var type = AccessTools.TypeByName("RunAndGun.Harmony.Pawn_DraftController_GetGizmos_Patch");
if (type != null)
{
    MP.RegisterSyncDelegateLambda(type, "Postfix", 1); // one fucking number, i cant believe this shit.
}

From a quick look at the mod's code, I believe that it should be 2 and not 1. Currently this will sync the delegate for isActive action, which is called each frame while active. You want to sync the delegate for toggleAction action, which is called when clicking the gizmo.

Second, is the null check even required here for anything? I don't think this check would fail in any release of Run and Gun, the original we patched or this particular one.

Third, I don't think the comment contributes anything, is not informative, etc. and should be removed.

type = AccessTools.TypeByName("RunAndGun.Utilities.WorldComponent_ToggleData");
if (type != null)
{
    MP.RegisterSyncMethod(type, "SetRunAndGun");
}

I'm sorry, but what? What is this supposed to be even doing? Run and Gun doesn't have any world components, nor any methods called SetRunAndGun. This will fail because the type is always null and will do nothing. What even is this? Where did you even find this code from?

var mentalStateMethod = AccessTools.Method("RunAndGun.Harmony.MentalStateHandler_TryStartMentalState:shouldRunAndGun");
if (mentalStateMethod != null)
{
    PatchingUtilities.PatchSystemRand("RunAndGun.Harmony.MentalStateHandler_TryStartMentalState:shouldRunAndGun", false);
}

First, pointless null check again? The method won't be null, and PatchingUtilities.PatchSystemRand already handles null methods.

Second, this will now cause warnings/errors as that method has no system RNG. It instead uses Unity RNG, and a respective method from PatchingUtilities should be used instead.

In fact, the whole conditional part seems... pointless? I checked code for a few versions of Run and Gun, and the conditional patches don't seem to do anything besides skipping code that doesn't exist for any of the mod versions.

@SokyranTheDragon
Copy link
Member

Also: please make a separate PR for changes to VEF and Run and Gun.

It would be fine if the 2 patches were related to each other (using shared code, for example), but since those 2 aren't related at all - it's best to keep them separate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants