From 2b8115e073cd7b11128d31563661207f1e52e979 Mon Sep 17 00:00:00 2001 From: Sauceke Date: Sun, 29 Dec 2024 21:22:33 +0300 Subject: [PATCH] [HC] Find characters the proper way --- .../DigitalCraftGame.cs | 25 +++++++++++-------- src/LoveMachine.HC/HoneyComeGame.cs | 20 +++++++-------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/LoveMachine.HC.DigitalCraft/DigitalCraftGame.cs b/src/LoveMachine.HC.DigitalCraft/DigitalCraftGame.cs index 47aa9ab..5a45754 100644 --- a/src/LoveMachine.HC.DigitalCraft/DigitalCraftGame.cs +++ b/src/LoveMachine.HC.DigitalCraft/DigitalCraftGame.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Reflection; using HarmonyLib; +using Il2CppInterop.Runtime; using LoveMachine.Core.Common; using LoveMachine.Core.Game; using UnityEngine; @@ -37,7 +38,7 @@ public class DigitalCraftGame : GameAdapter protected override float PenisSize => 0.07f; protected override int AnimationLayer => 0; protected override int HeroineCount => females.Length; - protected override int MaxHeroineCount => 2; + protected override int MaxHeroineCount => 4; protected override bool IsHardSex => false; protected override Animator GetFemaleAnimator(int girlIndex) => @@ -51,17 +52,19 @@ protected override Animator GetFemaleAnimator(int girlIndex) => protected override IEnumerator UntilReady(object instance) { - yield return new WaitForSeconds(10f); - females = new[] { "chaF_00", "chaF_01" } - .Select(GameObject.Find) - .Where(go => go != null && go.active) - .Select(chara => (chara.transform.Find("BodyTop/p_cf_jm_body_bone_00") - ?? chara.transform.Find("BodyTop/p_cf_jm_body_bone_00(Clone)")).gameObject) + yield return new WaitForSeconds(5f); + var humanType = Il2CppType.From(Type.GetType("Character.HumanComponent,Assembly-CSharp")); + var humans = FindObjectsOfType(humanType, false) + .Select(human => human.Cast().transform) .ToArray(); - penises = new[] { "chaM_00", "chaM_01" } - .Select(GameObject.Find) - .Where(go => go != null && go.active) - .Select(chara => FindDeepChildrenByPath(chara, "k_f_tamaC_00").First()) + females = humans + .Where(tf => tf.name.StartsWith("chaF_")) + .Select(chara => (chara.Find("BodyTop/p_cf_jm_body_bone_00") + ?? chara.Find("BodyTop/p_cf_jm_body_bone_00(Clone)")).gameObject) + .ToArray(); + penises = humans + .Where(tf => tf.name.StartsWith("chaM_")) + .Select(chara => FindDeepChildrenByPath(chara.gameObject, "k_f_tamaC_00").First()) .ToArray(); } } \ No newline at end of file diff --git a/src/LoveMachine.HC/HoneyComeGame.cs b/src/LoveMachine.HC/HoneyComeGame.cs index d770803..b61fc70 100644 --- a/src/LoveMachine.HC/HoneyComeGame.cs +++ b/src/LoveMachine.HC/HoneyComeGame.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Reflection; using HarmonyLib; +using Il2CppInterop.Runtime.InteropTypes.Arrays; using LoveMachine.Core.Common; using LoveMachine.Core.Game; using UnityEngine; @@ -62,21 +63,20 @@ protected override string GetPose(int girlIndex) => protected override bool IsOrgasming(int girlIndex) => nowOrgasm.Value; - protected override IEnumerator UntilReady(object hscene) + protected override IEnumerator UntilReady(object instance) { yield return new WaitForSeconds(10f); - ctrlFlag = Traverse.Create(hscene).Property("CtrlFlag"); + var hscene = Traverse.Create(instance); + ctrlFlag = hscene.Property("CtrlFlag"); loopType = ctrlFlag.Property("LoopType"); nowOrgasm = ctrlFlag.Property("NowOrgasm"); - females = new[] { "chaF_00", "chaF_01" } - .Select(GameObject.Find) - .Where(go => go != null && go.active) - .Select(chara => chara.transform.Find("BodyTop/p_cf_jm_body_bone_00").gameObject) + females = hscene.Property>("_chaFemalesTrans").Value + .Where(tf => tf != null && tf.gameObject.active) + .Select(chara => chara.Find("BodyTop/p_cf_jm_body_bone_00").gameObject) .ToArray(); - penises = new[] { "chaM_00", "chaM_01" } - .Select(GameObject.Find) - .Where(go => go != null && go.active) - .Select(chara => FindDeepChildrenByPath(chara, "k_f_tamaC_00").First()) + penises = hscene.Property>("_chaMalesTrans").Value + .Where(tf => tf != null && tf.gameObject.active) + .Select(chara => FindDeepChildrenByPath(chara.gameObject, "k_f_tamaC_00").First()) .ToArray(); } } \ No newline at end of file