public static bool NewCalcBlendShape(FBSBase __instance) { var enabled = LipsyncConfig.Instance.enabled; if (!enabled) { return(true); } var nowFace = AccessTools.Field(typeof(FBSCtrlMouth), "dictNowFace").GetValue(__instance) as Dictionary <int, float>; var openness = (float)AccessTools.Field(typeof(FBSCtrlMouth), "FixedRate").GetValue(__instance); if (nowFace is null) { return(true); } if (LipsyncConfig.Instance.frameStore.TryGetValue(__instance.GetHashCode(), out var targetFrame)) { MapFrame(targetFrame, ref nowFace, ref openness); AccessTools.Field(typeof(FBSCtrlMouth), "FixedRate").SetValue(__instance, openness); AccessTools.Field(typeof(FBSCtrlMouth), "dictNowFace").SetValue(__instance, nowFace); return(true); } else { return(true); } }
public static bool NewCalcBlendShape(FBSBase __instance) { var enabled = LipsyncConfig.Instance.enabled; if (!enabled) { return(true); } var nowFace = AccessTools.Field(typeof(FBSCtrlMouth), "dictNowFace").GetValue(__instance) as Dictionary <int, float>; if (nowFace is null) { return(true); } LipsyncConfig cfg = LipsyncConfig.Instance; if (cfg.frameStore.TryGetValue(__instance.GetHashCode(), out var targetFrame)) { var openness = (float)AccessTools.Field(typeof(FBSCtrlMouth), "openRate").GetValue(__instance); if (!cfg.baseFaceStore.TryGetValue(__instance.GetHashCode(), out var baseFace)) { baseFace = new Dictionary <int, float>(); cfg.baseFaceStore[__instance.GetHashCode()] = baseFace; } if (!cfg.lastFaceStore.TryGetValue(__instance.GetHashCode(), out var lastFace)) { lastFace = new Dictionary <int, float>(); cfg.lastFaceStore[__instance.GetHashCode()] = lastFace; } MapFrame(targetFrame, ref baseFace, ref lastFace, ref nowFace, ref openness); AccessTools.Field(typeof(FBSCtrlMouth), "openRate").SetValue(__instance, openness); AccessTools.Field(typeof(FBSCtrlMouth), "dictNowFace").SetValue(__instance, nowFace); return(true); } else { return(true); } }