Here are the examples of the csharp api HarmonyLib.Traverse.Field(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
67 Examples
19
Source : Traverse.cs
with MIT License
from BepInEx
with MIT License
from BepInEx
public Traverse<T> Field<T>(string name)
{
return new Traverse<T>(Field(name));
}
19
Source : Traverse.cs
with MIT License
from BepInEx
with MIT License
from BepInEx
public static void IterateFields(object source, Action<Traverse> action)
{
var sourceTrv = Create(source);
AccessTools.GetFieldNames(source).ForEach(f => action(sourceTrv.Field(f)));
}
19
Source : Traverse.cs
with MIT License
from BepInEx
with MIT License
from BepInEx
public static void IterateFields(object source, object target, Action<Traverse, Traverse> action)
{
var sourceTrv = Create(source);
var targetTrv = Create(target);
AccessTools.GetFieldNames(source).ForEach(f => action(sourceTrv.Field(f), targetTrv.Field(f)));
}
19
Source : Traverse.cs
with MIT License
from BepInEx
with MIT License
from BepInEx
public static void IterateFields(object source, object target, Action<string, Traverse, Traverse> action)
{
var sourceTrv = Create(source);
var targetTrv = Create(target);
AccessTools.GetFieldNames(source).ForEach(f => action(f, sourceTrv.Field(f), targetTrv.Field(f)));
}
19
Source : VirtualizeMakerLists.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
private static Sprite GetThumbSpriteHook(CustomSelectInfo item, MonoBehaviour csk)
{
var list = Traverse.Create(csk).Field<CustomSelectListCtrl>("listCtrl").Value;
_listCache.TryGetValue(list, out var listData);
return listData?.GetThumbSprite(item);
}
19
Source : Core.MakerOptimizations.Hooks.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
[HarmonyPostfix, HarmonyPatch(typeof(CustomControl), "Start")]
public static void MakerUiHideLagFix(CustomControl __instance)
{
var customControl = Traverse.Create(__instance);
var oldHide = __instance._hideFrontUI;
oldHide.Dispose();
var newHide = new BoolReactiveProperty(false);
__instance._hideFrontUI = newHide;
var cvsSpace = customControl.Field("cvsSpace").GetValue<Canvas>();
var objFrontUiGroup = customControl.Field("objFrontUIGroup").GetValue<GameObject>();
var frontCanvasGroup = objFrontUiGroup.GetComponent<CanvasGroup>();
//Modified code from CustomControl.Start -> _hideFrontUI.Subscribe anonymous method
newHide.Subscribe(hideFront =>
{
if (__instance.saveMode) return;
//Instead of enabling/disabling the CanvasGroup Gameobject, just hide it and make it non-interactive
//This way we get the same effect but for no cost for load/unload
frontCanvasGroup.alpha = hideFront ? 0f : 1f;
frontCanvasGroup.interactable = !hideFront;
frontCanvasGroup.blocksRaycasts = !hideFront;
if (cvsSpace) cvsSpace.enabled = !hideFront;
__instance.ChangeMainCameraRect(!hideFront ? CustomControl.MainCameraMode.Custom : CustomControl.MainCameraMode.View);
});
}
19
Source : VirtualizeMakerLists.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
private static void ChangeItem(CustomSelectListCtrl __instance, CustomSelectInfo itemInfo, VirtualListData listData)
{
// Calling original whenever possible is probably better for interop since any hooks will run
if (itemInfo.sic != null)
{
__instance.ChangeItem(itemInfo.sic.gameObject);
return;
}
__instance.onChangeItemFunc?.Invoke(itemInfo.index);
var tv = new Traverse(__instance);
tv.Field<string>("selectDrawName").Value = itemInfo.name;
#if KK
var tmp = tv.Field<TMPro.TextMeshProUGUI>("textDrawName").Value;
if (tmp) tmp.text = itemInfo.name;
#endif
if (VirtualListData.IsItemNew(itemInfo))
{
VirtualListData.MarkItemAsNotNew(itemInfo);
MarkListDirty(__instance);
}
listData.SelectedItem = itemInfo;
}
19
Source : CharacterListOptimizations.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
[HarmonyPostfix, HarmonyPatch(typeof(ClreplacedRoomCharaFile), "Start")]
internal static void ClreplacedRoomCharaFileStartPostfix(object __instance)
{
var traverse = Traverse.Create(__instance);
var info = traverse.Field("info").GetValue<ReactiveProperty<ChaFileControl>>();
var lstFileInfo = traverse.Field("listCtrl").Field("lstFileInfo").GetValue<List<CustomFileInfo>>();
var enterButton = traverse.Field("enterButton").GetValue<Button>();
enterButton.onClick.RemoveAllListeners();
enterButton.onClick.AddListener(() =>
{
var onEnter = traverse.Field("onEnter").GetValue<Action<ChaFileControl>>();
string fullPath = lstFileInfo.First(x => x.FileName == info.Value.charaFileName.Remove(info.Value.charaFileName.Length - 4)).FullPath;
ChaFileControl chaFileControl = new ChaFileControl();
chaFileControl.LoadCharaFile(fullPath, info.Value.parameter.sex, false, true);
onEnter(chaFileControl);
Utils.Sound.Play(SystemSE.sel);
});
}
19
Source : MakerDropdown.cs
with GNU Lesser General Public License v3.0
from IllusionMods
with GNU Lesser General Public License v3.0
from IllusionMods
protected override GameObject OnCreateControl(Transform subCategoryList)
{
var dd = MakerAPI.GetMakerBase().CreateDropDownUI(subCategoryList.gameObject, SettingName, Options.Select(x => new Dropdown.OptionData(x)).ToList(), SetValue);
BufferedValueChanged.Subscribe(dd.SetValue);
var text = Traverse.Create(dd).Field<Text>("replacedle").Value;
text.color = TextColor;
foreach (var txt in dd.GetComponentsInChildren<Text>(true))
SetTextAutosize(txt);
return dd.gameObject;
}
19
Source : AccessoriesApi.PH.cs
with GNU Lesser General Public License v3.0
from IllusionMods
with GNU Lesser General Public License v3.0
from IllusionMods
private static ToggleButton[] GetMakerToggles()
{//nowTab
if (!MakerAPI.InsideMaker || _accCustomEdit == null) return null;
return _accCustomEdit.Field<ToggleButton[]>("toggles").Value;
}
19
Source : AccessoriesApi.AI.cs
with GNU Lesser General Public License v3.0
from IllusionMods
with GNU Lesser General Public License v3.0
from IllusionMods
public static GameObject[] GetAccessoryObjects(this ChaControl character)
{
if (character == null) throw new ArgumentNullException(nameof(character));
if (!MoreAccessoriesInstalled) return character.objAccessory;
var dict = Traverse.Create(_moreAccessoriesInstance).Field("_charAdditionalData").GetValue();
var m = dict.GetType().GetMethod("TryGetValue", AccessTools.allDeclared) ?? throw new ArgumentException("TryGetValue not found");
var parameters = new object[] { character.chaFile, null };
m.Invoke(dict, parameters);
//List<MoreAccessories.AdditionalData.AccessoryObject> objects
var objs = Traverse.Create(parameters[1]).Field<ICollection>("objects").Value;
var objs2 = objs.Cast<object>().Select(x => Traverse.Create(x).Field<GameObject>("obj").Value);
return character.objAccessory.Concat(objs2).ToArray();
}
19
Source : Extensions.cs
with GNU Lesser General Public License v3.0
from IllusionMods
with GNU Lesser General Public License v3.0
from IllusionMods
public static bool SetFieldValue(this object self, string name, object value)
{
return Traverse.Create(self).Field(name).SetValue(value).FieldExists();
}
19
Source : Extensions.cs
with GNU Lesser General Public License v3.0
from IllusionMods
with GNU Lesser General Public License v3.0
from IllusionMods
public static bool GetFieldValue(this object self, string name, out object value)
{
var field = Traverse.Create(self).Field(name);
if (field.FieldExists())
{
value = field.GetValue();
return true;
}
else
{
UnityEngine.Debug.LogWarning($"Field {name} doesn't exist on {self?.GetType().FullName}");
value = null;
return false;
}
}
19
Source : EyeShaking.Hooks.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
internal static void MapSameObjectDisableVR(object __instance)
{
HFlag flags = (HFlag)Traverse.Create(__instance).Field("flags").GetValue();
SaveData.Heroine heroine = flags.lstHeroine[0];
GetController(heroine.chaCtrl).HSceneStart(heroine.isVirgin && heroine.isreplacedVirgin);
}
19
Source : KK.FreeHStudioSceneLoader.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
[HarmonyPostfix, HarmonyPatch(typeof(Manager.Config), nameof(Manager.Config.Start))]
private static void Config_Start()
{
if (IsStudio) return;
GameObject go = new GameObject("Studio");
DontDestroyOnLoad(go);
go.AddComponent<Studio.Studio>();
go.AddComponent<MapCtrl>();
go.AddComponent<Map>();
go.AddComponent<Info>();
go.AddComponent<GuideObjectManager>();
Singleton<Info>.Instance.StartCoroutine(Singleton<Info>.Instance.LoadExcelDataCoroutine());
Traverse.Create(Singleton<Studio.Studio>.Instance).Field("m_CameraCtrl").SetValue(go.AddComponent<Studio.CameraControl>());
Traverse.Create(Singleton<Studio.Studio>.Instance).Field("m_CameraLightCtrl").SetValue(go.AddComponent<CameraLightCtrl>());
Traverse.Create(Singleton<Studio.Studio>.Instance).Field("m_TreeNodeCtrl").SetValue(go.AddComponent<TreeNodeCtrl>());
Traverse.Create(Singleton<Studio.Studio>.Instance).Field("_patternSelectListCtrl").SetValue(go.AddComponent<PatternSelectListCtrl>());
Singleton<Studio.Studio>.Instance.Init();
//StudioScene.CreatePatternList();
}
19
Source : FreeHRandom.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
private static void SetupCharacter(string filePath, CharacterType characterType)
{
var chaFileControl = new ChaFileControl();
if (chaFileControl.LoadCharaFile(filePath))
{
object member;
if (Singleton<FreeHScene>.Instance == null)
{
//Use reflection to get the VR version of the character select screen
Type VRHSceneType = Type.GetType("VRCharaSelectScene, replacedembly-CSharp");
var HSceneObject = FindObjectOfType(VRHSceneType);
member = HSceneObject.GetType().GetField("member", AccessTools.all).GetValue(HSceneObject);
}
else
member = Singleton<FreeHScene>.Instance.GetType().GetField("member", AccessTools.all).GetValue(Singleton<FreeHScene>.Instance);
switch (characterType)
{
case CharacterType.Heroine:
ReactiveProperty<SaveData.Heroine> heroine = (ReactiveProperty<SaveData.Heroine>)Traverse.Create(member).Field("resultHeroine").GetValue();
heroine.SetValueAndForceNotify(new SaveData.Heroine(chaFileControl, false));
break;
case CharacterType.Partner:
ReactiveProperty<SaveData.Heroine> resultPartner = (ReactiveProperty<SaveData.Heroine>)Traverse.Create(member).Field("resultPartner").GetValue();
resultPartner.SetValueAndForceNotify(new SaveData.Heroine(chaFileControl, false));
break;
case CharacterType.Female3P:
#if KK
if (GameObject.Find("Panel/3P/Stage1").activeInHierarchy)
#elif KKS
if (GameObject.Find("Panel/3P/main/Stage1").activeInHierarchy)
#endif
{
ReactiveProperty<SaveData.Heroine> heroine3P = (ReactiveProperty<SaveData.Heroine>)Traverse.Create(member).Field("resultHeroine").GetValue();
heroine3P.SetValueAndForceNotify(new SaveData.Heroine(chaFileControl, false));
}
else
{
ReactiveProperty<SaveData.Heroine> resultPartner3P = (ReactiveProperty<SaveData.Heroine>)Traverse.Create(member).Field("resultPartner").GetValue();
resultPartner3P.SetValueAndForceNotify(new SaveData.Heroine(chaFileControl, false));
}
break;
case CharacterType.Player:
ReactiveProperty<SaveData.Player> resultPlayer = (ReactiveProperty<SaveData.Player>)Traverse.Create(member).Field("resultPlayer").GetValue();
resultPlayer.SetValueAndForceNotify(new SaveData.Player(chaFileControl, false));
break;
}
}
}
19
Source : Core.FKIK.UI.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
private static void SetupButton(string name, int offset, KinematicsType kinematicsType, ButtonType buttonType, int index)
{
Button btn = Instantiate(GetPanelObject<Button>("Button For Anime (2)"), FKIKPanel.transform);
btn.name = name;
btn.transform.localPosition = new Vector3(btn.transform.localPosition.x, PositionBase + PositionOffset * offset, btn.transform.localPosition.z);
string fieldname1 = kinematicsType == KinematicsType.FK ? "fkInfo" : "ikInfo";
string fieldname2 = buttonType == ButtonType.Anime ? "buttonAnimeSingle" : "buttonInitSingle";
btn.onClick.RemoveAllListeners();
btn.onClick.AddListener(() => Traverse.Create(FindObjectOfType<MPCharCtrl>()).Field(fieldname1).Field(fieldname2).GetValue<Button[]>()[index].onClick.Invoke());
}
19
Source : Core.HairAccessoryCustomizer.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
internal static void ShowAccColors(bool showButton)
{
if (!MakerAPI.InsideAndLoaded) return;
CvsAccessory cvsAccessory = AccessoriesApi.GetMakerAccessoryPageObject(AccessoriesApi.SelectedMakerAccSlot).GetComponent<CvsAccessory>();
cvsAccessory.ChangeUseColorVisible();
Traverse.Create(cvsAccessory).Field("btnInitColor").GetValue<Button>().transform.parent.gameObject.SetActive(showButton);
}
19
Source : EyeShaking.Hooks.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
internal static void EndProcVR(object __instance)
{
HFlag flags = (HFlag)Traverse.Create(__instance).Field("flags").GetValue();
GetController(flags.lstHeroine[0].chaCtrl).HSceneEnd();
}
19
Source : Core.FKIK.UI.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
private static void SetupToggle(ref Toggle tgl, ref Toggle tglRef, string name, int offset, KinematicsType kinematicsType, string referenceField)
{
Toggle tglOriginal = GetPanelObject<Toggle>("Toggle Neck");
tgl = Instantiate(tglOriginal, FKIKPanel.transform);
Toggle tglNew = tgl;
tglNew.name = name;
tglNew.transform.localPosition = new Vector3(tglNew.transform.localPosition.x, PositionBase + PositionOffset * offset, tglNew.transform.localPosition.z);
string fieldname = kinematicsType == KinematicsType.FK ? "fkInfo" : "ikInfo";
tglRef = Traverse.Create(FindObjectOfType<MPCharCtrl>()).Field(fieldname).Field(referenceField).GetValue<Toggle>();
Toggle tglRefNew = tglRef;
tglNew.onValueChanged.RemoveAllListeners();
tglNew.isOn = tglRefNew.isOn;
tglNew.onValueChanged.AddListener(value =>
{
if (!OverrideEvents)
tglRefNew.onValueChanged.Invoke(value);
});
tglRefNew.onValueChanged.AddListener(value =>
{
if (!OverrideEvents)
tglNew.isOn = value;
});
}
19
Source : KK.FreeHStudioSceneLoader.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
[HarmonyPrefix, HarmonyPatch(typeof(TreeNodeCtrl), nameof(TreeNodeCtrl.AddNode), typeof(string), typeof(TreeNodeObject))]
private static bool TreeNodeCtrl_AddNode(TreeNodeCtrl __instance, TreeNodeObject _parent, ref TreeNodeObject __result, ref List<TreeNodeObject> ___m_TreeNodeObject)
{
if (IsStudio) return true;
GameObject gob = new GameObject();
TreeNodeObject com = gob.AddComponent<TreeNodeObject>();
Traverse.Create(com).Field("m_TreeNodeCtrl").SetValue(__instance);
if (_parent != null)
com.SetParent(_parent);
else
___m_TreeNodeObject.Add(com);
__result = com;
return false;
}
19
Source : ItemBlacklist.UI.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
private void ShowMenu()
{
if (CustomBase.Instance == null) return;
InitUI();
SetMenuVisibility(false);
if (CurrentCustomSelectInfoComponent == null) return;
if (!MouseIn) return;
var xPosition = Input.mousePosition.x / Screen.width + 0.01f;
var yPosition = Input.mousePosition.y / Screen.height - UIHeight - 0.01f;
ContextMenuPanel.transform.SetRect(xPosition, yPosition, UIWidth + xPosition, UIHeight + yPosition);
SetMenuVisibility(true);
List<CustomSelectInfo> lstSelectInfo = (List<CustomSelectInfo>)Traverse.Create(CustomSelectListCtrlInstance).Field("lstSelectInfo").GetValue();
int index = CurrentCustomSelectInfoComponent.info.index;
var customSelectInfo = lstSelectInfo.First(x => x.index == index);
string guid = null;
int category = customSelectInfo.category;
int id = index;
if (index >= UniversalAutoResolver.BaseSlotID)
{
ResolveInfo info = UniversalAutoResolver.TryGetResolutionInfo((ChaListDefine.CategoryNo)customSelectInfo.category, customSelectInfo.index);
if (info != null)
{
guid = info.GUID;
id = info.Slot;
}
}
if (ListVisibility.TryGetValue(CustomSelectListCtrlInstance, out var listVisibilityType))
FilterDropdown.Set((int)listVisibilityType);
BlacklistButton.onClick.RemoveAllListeners();
BlacklistModButton.onClick.RemoveAllListeners();
InfoButton.onClick.RemoveAllListeners();
if (guid == null)
{
BlacklistButton.enabled = false;
BlacklistModButton.enabled = false;
}
else
{
BlacklistButton.enabled = true;
BlacklistModButton.enabled = true;
if (CheckBlacklist(guid, category, id))
{
BlacklistButton.GetComponentInChildren<Text>().text = "Unhide this item";
BlacklistButton.onClick.AddListener(() => Unblacklisreplacedem(guid, category, id, index));
BlacklistModButton.GetComponentInChildren<Text>().text = "Unhide all items from this mod";
BlacklistModButton.onClick.AddListener(() => UnblacklistMod(guid));
}
else
{
BlacklistButton.GetComponentInChildren<Text>().text = "Hide this item";
BlacklistButton.onClick.AddListener(() => Blacklisreplacedem(guid, category, id, index));
BlacklistModButton.GetComponentInChildren<Text>().text = "Hide all items from this mod";
BlacklistModButton.onClick.AddListener(() => BlacklistMod(guid));
}
}
InfoButton.onClick.AddListener(() => PrintInfo(index));
}
19
Source : ReloadCharaListOnChange.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
private static void RefreshList()
{
try
{
//Turn off resolving to prevent spam since modded stuff isn't relevant for making this list.
ExtendedSave.LoadEventsEnabled = false;
switch (EventType)
{
case CardEventType.CharaMakerCharacter:
var initializeChara = typeof(CustomCharaFile).GetMethod("Initialize", AccessTools.all);
if (initializeChara != null)
if (initializeChara.GetParameters().Length == 0)
initializeChara.Invoke(FindObjectOfType<CustomCharaFile>(), null);
else
initializeChara.Invoke(FindObjectOfType<CustomCharaFile>(), new object[] { true, false });
break;
case CardEventType.CharaMakerCoordinate:
var initializeCoordinate = typeof(CustomCoordinateFile).GetMethod("Initialize", AccessTools.all);
if (initializeCoordinate != null)
if (initializeCoordinate.GetParameters().Length == 0)
initializeCoordinate.Invoke(FindObjectOfType<CustomCoordinateFile>(), null);
else
initializeCoordinate.Invoke(FindObjectOfType<CustomCoordinateFile>(), new object[] { true, false });
break;
#if !EC
case CardEventType.StudioFemale:
StudioFemaleListInstance.InitCharaList(true);
break;
case CardEventType.StudioMale:
StudioMaleListInstance.InitCharaList(true);
break;
case CardEventType.StudioCoordinate:
var sex = Traverse.Create(StudioCoordinateListInstance).Field("sex").GetValue();
typeof(Studio.MPCharCtrl).GetNestedType("CostumeInfo", BindingFlags.NonPublic).GetMethod("InitList", AccessTools.all)?.Invoke(StudioCoordinateListInstance, new object[] { 100 });
Traverse.Create(StudioCoordinateListInstance).Field("sex").SetValue(sex);
break;
#endif
}
}
catch (Exception ex)
{
Logger.Log(LogLevel.Error | LogLevel.Message, "An error occured attempting to refresh the list.");
Logger.Log(LogLevel.Error, $"KK_ReloadCharaListOnChange error: {ex.Message}");
Logger.Log(LogLevel.Error, ex);
}
finally
{
ExtendedSave.LoadEventsEnabled = true;
}
}
19
Source : KKS.Subtitles.Caption.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
internal static void DisplayHSubreplacedle(string replacedet, string bundle, GameObject voiceObject)
{
List<HActionBase> lstProc = (List<HActionBase>)AccessTools.Field(typeof(HSceneProc), "lstProc").GetValue(HSceneInstance);
HFlag flags = (HFlag)Traverse.Create(HSceneInstance).Field("flags").GetValue();
HActionBase mode = lstProc[(int)flags.mode];
HVoiceCtrl voicectrl = (HVoiceCtrl)AccessTools.Field(typeof(HActionBase), "voice").GetValue(mode);
//At the start of the H scene, all the text was loaded. Look through the loaded stuff and find the text for the current spoken voice.
foreach (var a in voicectrl.dicVoiceIntos)
foreach (var b in a)
foreach (var c in b.Value)
{
var text = c.Value.Where(x => x.Value.pathreplacedet == bundle && x.Value.nameFile == replacedet).Select(x => x.Value.word).FirstOrDefault();
if (!text.IsNullOrEmpty())
{
// try to replace name tags in subreplacedle ([P], etc.) before displaying
DisplaySubreplacedle(voiceObject, PrepareSubreplacedle(text));
return;
}
}
}
19
Source : Core.Pushup.SliderManager.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
private void SetupSlider(float baseValue, Action<float> sliderSetter, Action<float> bodySetter, string fieldname, PushupController pushupController, object cvsBreast)
{
//Find the sliders for the chest area
var slider = (Slider)Traverse.Create(cvsBreast).Field($"sld{fieldname}").GetValue();
var input = (TMP_InputField)Traverse.Create(cvsBreast).Field($"inp{fieldname}").GetValue();
bodySetter(baseValue);
slider.value = baseValue;
input.text = CustomBase.ConvertTextFromRate(0, 100, baseValue);
if (!DoEvents) return;
slider.onValueChanged.AsObservable().Subscribe(value =>
{
if (!DoEvents) return;
//When user is updating the chest sliders set the BaseData
sliderSetter(value);
input.text = Math.Round(value * 100).ToString(CultureInfo.InvariantCulture);
pushupController.RecalculateBody();
});
}
19
Source : KK.Subtitles.Caption.cs
with GNU General Public License v3.0
from IllusionMods
with GNU General Public License v3.0
from IllusionMods
internal static void DisplayHSubreplacedle(LoadAudioBase voice)
{
List<HActionBase> lstProc = (List<HActionBase>)AccessTools.Field(HSceneType, "lstProc").GetValue(HSceneInstance);
HFlag flags = (HFlag)Traverse.Create(HSceneInstance).Field("flags").GetValue();
HActionBase mode = lstProc[(int)flags.mode];
HVoiceCtrl voicectrl = (HVoiceCtrl)AccessTools.Field(typeof(HActionBase), "voice").GetValue(mode);
//At the start of the H scene, all the text was loaded. Look through the loaded stuff and find the text for the current spoken voice.
foreach (var a in voicectrl.dicVoiceIntos)
foreach (var b in a)
foreach (var c in b.Value)
{
var text = c.Value.Where(x => x.Value.pathreplacedet == voice.replacedetBundleName && x.Value.nameFile == voice.replacedetName).Select(x => x.Value.word).FirstOrDefault();
if (!text.IsNullOrEmpty())
{
if (HSceneType == typeof(HSceneProc))
DisplaySubreplacedle(voice.gameObject, text);
else
DisplayVRSubreplacedle(voice.gameObject, text);
return;
}
}
}
19
Source : AI_LocalizationDumpHelper.cs
with MIT License
from IllusionMods
with MIT License
from IllusionMods
protected virtual IEnumerable<ITranslationDumper> GetHAnimationLocalizers()
{
var hSceneTable = Traverse.Create(Singleton<Resources>.Instance.HSceneTable);
var replacedetNames = hSceneTable.Field("replacedetNames").GetValue<string[]>();
var animListArray = hSceneTable.Field("lstAnimInfo").GetValue<List<HScene.AnimationListInfo>[]>();
for (var i = 0; i < animListArray.Length; i++)
{
var animList = animListArray[i];
var animListName = replacedetNames[i];
var category = i;
Dictionary<string, string> Localizer()
{
var results = new Dictionary<string, string>();
foreach (var info in animList)
{
var hname = string.Empty;
#if LOCALIZE
hname = Singleton<Resources>.Instance.Localize.GetHName(category, info.id);
#endif
AddLocalizationToResults(results, info.nameAnimation, hname);
}
return results;
}
yield return new StringTranslationDumper($"Manager/Resources/HName/{animListName}", Localizer);
}
}
19
Source : AI_INT_LocalizationDumpHelper.Helpers.cs
with MIT License
from IllusionMods
with MIT License
from IllusionMods
protected IEnumerable<KeyValuePair<GameObject, Text>> EnumerateTexts(GameObject gameObject,
MonoBehaviour component, HashSet<object> handled = null, List<UIBinder> binders = null)
{
var _ = binders;
if (handled is null)
{
handled = new HashSet<object>();
}
if (!handled.Contains(component))
{
handled.Add(component);
if (component is Text text)
{
//Logger.LogInfo($"EnumerateTexts: {gameObject} yield {text}");
yield return new KeyValuePair<GameObject, Text>(gameObject, text);
}
else
{
var trav = Traverse.Create(component);
foreach (var fieldName in trav.Fields())
{
var field = trav.Field(fieldName);
var fieldType = field.GetValueType();
if (fieldType == typeof(Text))
{
var fieldValue = field.GetValue<Text>();
if (fieldValue != null && !handled.Contains(fieldValue))
{
//Logger.LogInfo($"EnumerateTexts: {gameObject} field {fieldName} text {fieldValue}");
yield return new KeyValuePair<GameObject, Text>(gameObject, fieldValue);
}
}
else if (typeof(MonoBehaviour).IsreplacedignableFrom(fieldType))
{
var subBehaviour = field.GetValue<MonoBehaviour>();
if (subBehaviour != null && !handled.Contains(subBehaviour))
{
foreach (var subValue in EnumerateTexts(gameObject, subBehaviour, handled))
{
yield return subValue;
}
}
}
/*
else if (typeof(GameObject).IsreplacedignableFrom(fieldType))
{
var subObject = field.GetValue<GameObject>();
if (subObject != null && !handled.Contains(subObject))
{
handled.Add(subObject);
Logger.LogInfo($"EnumerateTexts: {gameObject} field {fieldName} GameObject {subObject}");
foreach (var subValue in EnumerateTexts(subObject, handled))
{
yield return subValue;
}
}
}
*/
}
}
}
}
19
Source : Core.ModTextDump.cs
with MIT License
from IllusionMods
with MIT License
from IllusionMods
private SimpleTextTranslationCache GetCurrentTranslatorCache()
{
try
{
var settingsType =
typeof(IPluginEnvironment).replacedembly.GetType(
"XUnity.AutoTranslator.Plugin.Core.Configuration.Settings",
true);
var autoTranslationsFilePath =
Traverse.Create(settingsType).Field<string>("AutoTranslationsFilePath").Value;
return new SimpleTextTranslationCache(autoTranslationsFilePath, true, false, true);
}
catch
{
return null;
}
}
19
Source : Core.ParamAssetLoadedHandler.cs
with MIT License
from IllusionMods
with MIT License
from IllusionMods
protected List<TParam> DefaultGetParams(T replacedet)
{
return Traverse.Create(replacedet).Field<List<TParam>>("param")?.Value ??
Traverse.Create(replacedet).Property<List<TParam>>("param")?.Value;
}
19
Source : HS2.MapInfoHandler.cs
with MIT License
from IllusionMods
with MIT License
from IllusionMods
[HarmonyPostfix]
[HarmonyPatch(typeof(LobbyMainUI), "LoadMapImage")]
internal static void LoadMapImagePostfix(LobbyMainUI __instance)
{
if (Instance == null) return;
var txtMap = Traverse.Create(__instance).Field<Text>("txtMap").Value;
if (txtMap != null && Instance._mapLookup.TryGetValue(txtMap.text, out var translation))
{
txtMap.text = translation;
}
}
19
Source : KKS_LocalizationDumpHelper.cs
with MIT License
from IllusionMods
with MIT License
from IllusionMods
protected static IEnumerable<KeyValuePair<GameObject, Component>> EnumerateTextComponents(GameObject gameObject,
Component component, HashSet<object> handled = null, List<UIBinder> binders = null)
{
var _ = binders;
if (handled is null)
{
handled = new HashSet<object>();
}
if (!handled.Contains(component))
{
handled.Add(component);
if (IsSupportedForEnumeration(component))
{
//Logger.LogInfo($"EnumerateTextComponents: {gameObject} yield {text}");
yield return new KeyValuePair<GameObject, Component>(gameObject, component);
}
else
{
var trav = Traverse.Create(component);
foreach (var fieldName in trav.Fields())
{
var field = trav.Field(fieldName);
var fieldType = field.GetValueType();
if (IsSupportedForEnumeration(fieldType))
{
var fieldValue = field.GetValue<Component>();
if (fieldValue != null && !handled.Contains(fieldValue))
{
//Logger.LogInfo($"EnumerateTextComponents: {gameObject} field {fieldName} text {fieldValue}");
yield return new KeyValuePair<GameObject, Component>(gameObject, fieldValue);
}
}
else if (typeof(Component).IsreplacedignableFrom(fieldType))
{
var subComponent = field.GetValue<Component>();
if (subComponent != null && !handled.Contains(subComponent))
{
foreach (var subValue in EnumerateTextComponents(gameObject, subComponent, handled))
{
yield return subValue;
}
}
}
}
}
}
}
19
Source : Core.Extensions.cs
with MIT License
from IllusionMods
with MIT License
from IllusionMods
public static Dictionary<string, string> BuildReverseDictionary(this SimpleTextTranslationCache cache)
{
var translations = Traverse.Create(cache).Field<Dictionary<string, string>>("_translations").Value;
var reverse = new Dictionary<string, string>();
foreach (var entry in translations)
{
reverse[entry.Value] = entry.Key;
}
return reverse;
}
19
Source : Core.ParamAssetLoadedHandler.cs
with MIT License
from IllusionMods
with MIT License
from IllusionMods
protected virtual bool DefaultUpdateParam(string calculatedModificationPath, SimpleTextTranslationCache cache,
TParam param, params string[] membersToUpdate)
{
var result = false;
foreach (var memberName in membersToUpdate)
{
var field = Traverse.Create(param).Field<string>(memberName);
if (field != null)
{
void DoUpdateField(string modPath, TParam paramToUpdate, string newValue)
{
field.Value = newValue;
}
if (DefaultUpdateParam(calculatedModificationPath, cache, param, field.Value, DoUpdateField))
{
result = true;
}
continue;
}
var prop = Traverse.Create(param).Property<string>(memberName);
if (prop != null)
{
void DoUpdateProp(string modPath, TParam paramToUpdate, string newValue)
{
prop.Value = newValue;
}
if (DefaultUpdateParam(calculatedModificationPath, cache, param, prop.Value, DoUpdateProp))
{
result = true;
}
continue;
}
WarnMissingMember(memberName);
}
return result;
}
19
Source : KKS_LocalizationDumpHelper.cs
with MIT License
from IllusionMods
with MIT License
from IllusionMods
protected IEnumerable<KeyValuePair<GameObject, Text>> EnumerateTexts(GameObject gameObject,
MonoBehaviour component, HashSet<object> handled = null, List<UIBinder> binders = null)
{
var _ = binders;
if (handled is null)
{
handled = new HashSet<object>();
}
if (!handled.Contains(component))
{
handled.Add(component);
if (component is Text text)
{
//Logger.LogInfo($"EnumerateTexts: {gameObject} yield {text}");
yield return new KeyValuePair<GameObject, Text>(gameObject, text);
}
else
{
var trav = Traverse.Create(component);
foreach (var fieldName in trav.Fields())
{
var field = trav.Field(fieldName);
var fieldType = field.GetValueType();
if (fieldType == typeof(Text))
{
var fieldValue = field.GetValue<Text>();
if (fieldValue != null && !handled.Contains(fieldValue))
{
//Logger.LogInfo($"EnumerateTexts: {gameObject} field {fieldName} text {fieldValue}");
yield return new KeyValuePair<GameObject, Text>(gameObject, fieldValue);
}
}
else if (typeof(MonoBehaviour).IsreplacedignableFrom(fieldType))
{
var subBehaviour = field.GetValue<MonoBehaviour>();
if (subBehaviour != null && !handled.Contains(subBehaviour))
{
foreach (var subValue in EnumerateTexts(gameObject, subBehaviour, handled))
{
yield return subValue;
}
}
}
}
}
}
}
19
Source : Core.ParamAssetLoadedHandler.cs
with MIT License
from IllusionMods
with MIT License
from IllusionMods
private bool TryGetMemberValue(TParam param, string memberName, out string value)
{
value = null;
var field = Traverse.Create(param).Field<string>(memberName);
if (field != null)
{
value = field.Value;
return true;
}
var prop = Traverse.Create(param).Property<string>(memberName);
if (prop == null) return false;
value = prop.Value;
return true;
}
19
Source : UnlockPositionsHooks.cs
with GNU General Public License v3.0
from ManlyMarco
with GNU General Public License v3.0
from ManlyMarco
private static bool CreateListAnimationFileNameUnlockPatch(object __instance, ref bool _isAnimListCreate, ref int _list)
{
// Need to use traverse because the instance could be one of two different types
var traverse = Traverse.Create(__instance);
_fixUi = false;
var oneFem = traverse.Field<HFlag>("flags").Value.lstHeroine.Count == 1;
var peeping = traverse.Field<OpenHData.Data>("dataH").Value.peepCategory?.FirstOrDefault() != 0;
if (_isAnimListCreate)
traverse.Method("CreateAllAnimationList").GetValue();
var lstAnimInfo = traverse.Field("lstAnimInfo").GetValue<List<HSceneProc.AnimationListInfo>[]>();
var lstUseAnimInfo = traverse.Field("lstUseAnimInfo").GetValue<List<HSceneProc.AnimationListInfo>[]>();
var categorys = traverse.Field<List<int>>("categorys").Value;
for (int i = 0; i < lstAnimInfo.Length; i++)
{
lstUseAnimInfo[i] = new List<HSceneProc.AnimationListInfo>();
if (_list == -1 || i == _list)
{
for (int j = 0; j < lstAnimInfo[i].Count; j++)
{
if ((UnlockAll && oneFem && !peeping) || lstAnimInfo[i][j].lstCategory.Any(c => categorys.Contains(c.category)))
{
if (oneFem) _fixUi = true;
lstUseAnimInfo[i].Add(lstAnimInfo[i][j]);
}
}
}
}
return false;
}
19
Source : SkinEffectGameController.cs
with GNU General Public License v3.0
from ManlyMarco
with GNU General Public License v3.0
from ManlyMarco
private static IEnumerator HsceneUpdate(HSceneProc proc, HFlag flags)
{
yield return new WaitWhile(SceneApi.GetIsNowLoadingFade);
var controllers = flags.lstHeroine.Select(x => x?.chaCtrl != null ? x.chaCtrl.GetComponent<SkinEffectsController>() : null).ToArray();
var roughTouchTimers = new float[controllers.Length];
var previousButtLevel = new int[controllers.Length];
var hands = new[] { proc.hand, proc.hand1 };
var aibuItems = Traverse.Create(proc.hand).Field<HandCtrl.AibuItem[]>("useItems").Value;
const int secondsPerLevel = 10;
while (proc)
{
var isAibu = flags.mode == HFlag.EMode.aibu;
var fastSpeed = flags.speed >= 1f; // max 1.5
var slowSpeed = flags.speed >= 0.5f;
for (int i = 0; i < controllers.Length; i++)
{
var ctrl = controllers[i];
if (ctrl == null) continue;
var anyChanged = false;
var hand = hands[i];
var timer = roughTouchTimers[i];
if (previousButtLevel[i] != ctrl.ButtLevel)
{
// Something outside of this loop changed ButtLevel, respect it and don't overwrite it
timer = (ctrl.ButtLevel + 0.5f) * secondsPerLevel;
}
// Touching during 3p and some other positions, also additional contact damage during touch position
var kindTouch = hand.SelectKindTouch;
var touchedSiri = kindTouch == HandCtrl.AibuColliderKind.siriL ||
kindTouch == HandCtrl.AibuColliderKind.siriR ||
kindTouch == HandCtrl.AibuColliderKind.reac_bodydown;
if (touchedSiri && hand.hitReaction.IsPlay())
{
timer += Time.deltaTime * 2;
anyChanged = true;
}
// Touching during touch position, only works in 1v1 scenes not 3p
if (i == 0 && isAibu && (fastSpeed || slowSpeed))
{
if (aibuItems.Any(x => x != null && (x.kindTouch == HandCtrl.AibuColliderKind.siriL || x.kindTouch == HandCtrl.AibuColliderKind.siriR)))
{
timer += fastSpeed ? Time.deltaTime : Time.deltaTime / 2;
anyChanged = true;
}
}
// Slow decay, but don't go below lvl 1
if (!anyChanged && timer > secondsPerLevel) timer -= Time.deltaTime / 9;
var level = (int)(timer / secondsPerLevel);
// Don't go back to lvl 0, the change is too noticeable
if (level > 0) ctrl.ButtLevel = level;
roughTouchTimers[i] = timer;
previousButtLevel[i] = ctrl.ButtLevel;
//if (timer > 0) Console.WriteLine(timer);
}
yield return null;
}
}
19
Source : PregnancyGui.StatusIcons.cs
with GNU General Public License v3.0
from ManlyMarco
with GNU General Public License v3.0
from ManlyMarco
[HarmonyPostfix]
[HarmonyPatch(typeof(StatusUI), "RefreshAgentContent", typeof(int))]
private static void StatusUI_RefreshAgentContent(StatusUI __instance, int id)
{
// PregnancyPlugin.Logger.LogDebug("Preg - StatusUI_RefreshAgentContent");
var objImageRoot = Traverse.Create(__instance).Field("_cardRawImage").GetValue<RawImage>();
if (objImageRoot == null) return;
//Ignore player status tab, only want actors
if (id == 0)
{
var existingIcon = objImageRoot.transform.Find(ICON_NAME);
if (existingIcon) Destroy(existingIcon.gameObject);
return;
}
Singleton<Manager.Map>.Instance.AgentTable.TryGetValue((id - 1), out AgentActor _heroine);
if (_heroine == null) return;
SpawnGUI();
IEnumerator HeroineCanvasPreviewUpdateCo()
{
yield return new WaitForEndOfFrame();
_currentHeroine.Clear();
// :right :up
SetQuickStatusIcon(objImageRoot.gameObject, _heroine.AgentData, 95f, -80f);
}
_pluginInstance.StartCoroutine(HeroineCanvasPreviewUpdateCo());
}
19
Source : PregnancyGui.StatusIcons.cs
with GNU General Public License v3.0
from ManlyMarco
with GNU General Public License v3.0
from ManlyMarco
[HarmonyPostfix]
[HarmonyPatch(typeof(StatusUI), "RefreshPlayerContent")]
private static void StatusUI_RefreshAgentContent(StatusUI __instance)
{
var objImageRoot = Traverse.Create(__instance).Field("_cardRawImage").GetValue<RawImage>();
if (objImageRoot == null) return;
var existingIcon = objImageRoot.transform.Find(ICON_NAME);
if (existingIcon) Destroy(existingIcon.gameObject);
}
19
Source : PregnancyPlugin.Hooks.cs
with GNU General Public License v3.0
from ManlyMarco
with GNU General Public License v3.0
from ManlyMarco
[HarmonyPrefix]
[HarmonyPatch(typeof(Sonyu), "PullProc", typeof(float), typeof(int))]
public static void Sonyu_PullProc(Sonyu __instance)
{
//Get current inserted state
var ctrlFlag = Traverse.Create(__instance).Field("ctrlFlag").GetValue<HSceneFlagCtrl>();
// PregnancyPlugin.Logger.LogDebug($"Preg - PullProc {ctrlFlag.isInsert}");
if (ctrlFlag.isInsert && _lastPullProc != ctrlFlag.isInsert)
{
var heroine = GetLeadHeroine();
var controller = GetEffectController(heroine);
controller.DrainInflation(Mathf.Max(3, Mathf.CeilToInt(InflationMaxCount.Value / 2.2f)));
}
_lastPullProc = ctrlFlag.isInsert;
}
19
Source : PregnancyPlugin.Hooks.cs
with GNU General Public License v3.0
from ManlyMarco
with GNU General Public License v3.0
from ManlyMarco
[HarmonyPrefix]
[HarmonyPatch(typeof(Sonyu), "Proc", typeof(int), typeof(HScene.AnimationListInfo))]
public static void Sonyu_Proc(Sonyu __instance)
{
//Get current user button click type
var ctrlFlag = Traverse.Create(__instance).Field("ctrlFlag").GetValue<HSceneFlagCtrl>();
DetermineInflationState(ctrlFlag);
}
19
Source : PregnancyPlugin.Hooks.cs
with GNU General Public License v3.0
from ManlyMarco
with GNU General Public License v3.0
from ManlyMarco
[HarmonyPrefix]
[HarmonyPatch(typeof(Houshi), "Proc", typeof(int), typeof(HScene.AnimationListInfo))]
public static void Houshi_Proc(Houshi __instance)
{
//Get current user button click type
var ctrlFlag = Traverse.Create(__instance).Field("ctrlFlag").GetValue<HSceneFlagCtrl>();
DetermineInflationState(ctrlFlag);
}
19
Source : Hooks.PersistClothes.cs
with GNU General Public License v3.0
from ManlyMarco
with GNU General Public License v3.0
from ManlyMarco
private static void PreTalkSceneIteratorEndHook(object __instance)
{
// __instance is of the compiler_generated type TalkScene+<TalkEnd>c__Iterator5
// $PC is the number of times yield return has been called
// We want this to run just before the third yield return in TalkScene.TalkEnd, just before fading out
int? counter = Traverse.Create(__instance)?.Field("$PC")?.GetValue<int>();
if (counter == 2)
{
var heroine = GameAPI.GetCurrentHeroine();
var controller = GetEffectController(heroine);
if (controller != null)
SkinEffectGameController.SavePersistData(heroine, controller);
}
}
19
Source : PregnancyGui.StatusIcons.cs
with GNU General Public License v3.0
from ManlyMarco
with GNU General Public License v3.0
from ManlyMarco
[HarmonyPostfix]
[HarmonyPatch(typeof(ParamUI), "SetHeroine", typeof(SaveData.Heroine))]
private static void ParamUI_SetHeroine(ParamUI __instance, SaveData.Heroine _heroine)
{
var objFemaleRoot = Traverse.Create(__instance).Field("objFemaleRoot").GetValue<GameObject>();
if (objFemaleRoot == null) return;
SpawnGUI();
IEnumerator HeroineCanvasPreviewUpdateCo()
{
yield return new WaitForEndOfFrame();
_currentHeroine.Clear();
SetQuickStatusIcon(objFemaleRoot, _heroine, -214f, -26f);
}
_pluginInstance.StartCoroutine(HeroineCanvasPreviewUpdateCo());
}
19
Source : AI_ExtraGirls.cs
with GNU General Public License v3.0
from Mantas-2155X
with GNU General Public License v3.0
from Mantas-2155X
private static void AddElements(object type, bool migrate = false)
{
var trav = Traverse.Create(type);
trav.Field("_infos").SetValue(new GameLoadCharaFileSystem.GameCharaFileInfo[girlCount]);
var oldelements = trav.Field("_elements").GetValue<RectTransform[]>();
var newelements = new List<RectTransform>();
newelements.AddRange(oldelements);
var oldcharaButtons = trav.Field("_charaButtons").GetValue<Button[]>();
var newCharaButtons = new List<Button>();
newCharaButtons.AddRange(oldcharaButtons);
var oldcharaTexts = trav.Field("_charaTexts").GetValue<Text[]>();
var newCharaTexts = new List<Text>();
newCharaTexts.AddRange(oldcharaTexts);
var newCharaArrowButtons = new List<Button>();
if (migrate)
{
var oldcharaArrowButtons = trav.Field("_charaArrowButtons").GetValue<Button[]>();
newCharaArrowButtons.AddRange(oldcharaArrowButtons);
}
var oldElementsLength = oldelements.Length;
for (var i = 0; i < girlCount - oldElementsLength; i++)
{
var copy = Instantiate(oldelements[oldElementsLength - 1], oldelements[oldElementsLength - 1].transform.parent);
copy.name = $"Element_{i+oldElementsLength:00}";
newelements.Add(copy);
newCharaButtons.Add(copy.transform.Find("Button").GetComponent<Button>());
newCharaTexts.Add(copy.transform.Find("Button/Text").GetComponent<Text>());
if(migrate)
newCharaArrowButtons.Add(copy.transform.Find("arrow").GetComponent<Button>());
}
trav.Field("_elements").SetValue(newelements.ToArray());
trav.Field("_charaButtons").SetValue(newCharaButtons.ToArray());
trav.Field("_charaTexts").SetValue(newCharaTexts.ToArray());
if(migrate)
trav.Field("_charaArrowButtons").SetValue(newCharaArrowButtons.ToArray());
}
19
Source : AI_ExtraGirls.cs
with GNU General Public License v3.0
from Mantas-2155X
with GNU General Public License v3.0
from Mantas-2155X
[HarmonyPrefix, HarmonyPatch(typeof(StatusUI), "OnBeforeStart")]
public static void StatusUI_OnBeforeStart_AddElementsAndBackgrounds(StatusUI __instance)
{
var trav = Traverse.Create(__instance);
var oldcharaButtons = trav.Field("_charaButtons").GetValue<Button[]>();
var newCharaButtons = new List<Button>();
newCharaButtons.AddRange(oldcharaButtons);
var oldCharaButtonsLength = oldcharaButtons.Length;
for (var i = 0; i < 1 + girlCount - oldCharaButtonsLength; i++)
{
var copy = Instantiate(oldcharaButtons[oldCharaButtonsLength - 1], oldcharaButtons[oldCharaButtonsLength - 1].transform.parent);
copy.name = $"Chara ({oldCharaButtonsLength + i - 1:0})";
newCharaButtons.Add(copy.GetComponent<Button>());
}
var backgrounds = new List<Dictionary<int, CanvasGroup>>
{
trav.Field("_equipmentBackgrounds").GetValue<Dictionary<int, CanvasGroup>>(),
trav.Field("_equipmentFlavorBackgrounds").GetValue<Dictionary<int, CanvasGroup>>(),
trav.Field("_skillBackgrounds").GetValue<Dictionary<int, CanvasGroup>>(),
trav.Field("_skillFlavorBackgrounds").GetValue<Dictionary<int, CanvasGroup>>()
};
foreach (var category in backgrounds.Where(category => category.Count < girlCount + 1))
{
for (var i = 0; i < 1 + girlCount; i++)
{
if (i < defaultGirlCount + 1 || category.Count >= girlCount + 1)
continue;
var bgData = Instantiate(category[category.Count - 1], category[category.Count - 1].transform.parent);
bgData.name = $"Chara ({i:0})";
category.Add(category.Count, bgData);
}
}
trav.Field("_equipmentBackgrounds").SetValue(backgrounds[0]);
trav.Field("_equipmentFlavorBackgrounds").SetValue(backgrounds[1]);
trav.Field("_skillBackgrounds").SetValue(backgrounds[2]);
trav.Field("_skillFlavorBackgrounds").SetValue(backgrounds[3]);
trav.Field("_charaButtons").SetValue(newCharaButtons.ToArray());
trav = Traverse.Create(__instance.Observer);
var mainBackgrounds = trav.Field("_backgrounds").GetValue<Dictionary<int, CanvasGroup>>();
for (var i = 0; i < 2 + girlCount; i++)
{
if (i < defaultGirlCount + 2 || mainBackgrounds.Count >= girlCount + 2)
continue;
var bgData = Instantiate(
mainBackgrounds[defaultGirlCount],
mainBackgrounds[defaultGirlCount].transform.parent
);
bgData.name = $"Chara ({i - 2:0})";
mainBackgrounds.Add(mainBackgrounds.Count - 1, bgData);
}
trav.Field("_backgrounds").SetValue(mainBackgrounds);
StatusUI_AddScroll();
}
19
Source : AI_ExtraGirls.cs
with GNU General Public License v3.0
from Mantas-2155X
with GNU General Public License v3.0
from Mantas-2155X
[HarmonyPostfix, HarmonyPatch(typeof(StatusUI), "OpenCoroutine")]
public static void StatusUI_OpenCoroutine_SetCharaButtonsVisibility(StatusUI __instance)
{
var trav = Traverse.Create(__instance);
var charaButtons = trav.Field("_charaButtons").GetValue<Button[]>();
var actorTable = Singleton<Map>.Instance.ActorTable;
for(var i = 1; i < charaButtons.Length; i++)
charaButtons[i].gameObject.SetActiveIfDifferent(actorTable.ContainsKey(i - 1));
}
19
Source : AI_ExtraGirls.cs
with GNU General Public License v3.0
from Mantas-2155X
with GNU General Public License v3.0
from Mantas-2155X
[HarmonyPostfix, HarmonyPatch(typeof(Manager.Resources), "Awake")]
public static void Resources_Awake_SetMaxAgents(Manager.Resources __instance) => Traverse.Create(__instance.DefinePack.MapDefines).Field("_agentMax").SetValue(girlCount);
19
Source : Tools.cs
with GNU General Public License v3.0
from Mantas-2155X
with GNU General Public License v3.0
from Mantas-2155X
public static void SetGotoWeaknessCount(int num) => hFlagCtrlTrav?.Field("gotoFaintnessCount").SetValue(num);
See More Examples