internal override void SetMaterialShaderName(int slot, Material material, string value, GameObject go) => MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).SetMaterialShader(slot, material, value, go);
public override void RemoveRendererProperty(object data, Renderer renderer, RendererProperties property, GameObject go) { ObjectData objectData = (ObjectData)data; MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).RemoveRendererProperty(objectData.Slot, objectData.ObjectType, renderer, property, go); }
public override string GetMaterialShaderNameOriginal(object data, Material material, GameObject go) { ObjectData objectData = (ObjectData)data; return(MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).GetMaterialShaderOriginal(objectData.Slot, objectData.ObjectType, material, go)); }
private static KoiClothesOverlayController GetOverlayController() { return(MakerAPI.GetCharacterControl().gameObject.GetComponent <KoiClothesOverlayController>()); }
private void AccessoriesApi_AccessoriesCopied(object sender, AccessoryCopyEventArgs e) => GetCharaController(MakerAPI.GetCharacterControl())?.AccessoriesCopiedEvent(sender, e);
public static void ChangeUseColorVisible(ChaCustom.CvsAccessory __instance) { if (AccessoriesApi.SelectedMakerAccSlot == (int)__instance.slotNo && HairAccessoryCustomizer.GetController(MakerAPI.GetCharacterControl()).IsHairAccessory((int)__instance.slotNo) && HairAccessoryCustomizer.ColorMatchToggle.GetSelectedValue()) { HairAccessoryCustomizer.HideAccColors(); } }
internal static void ChangeUseColorVisible(ChaCustom.CvsAccessory __instance) { if (!MakerAPI.InsideAndLoaded) { return; } if (AccessoriesApi.SelectedMakerAccSlot == (int)__instance.slotNo && GetController(MakerAPI.GetCharacterControl()).IsHairAccessory((int)__instance.slotNo) && ColorMatchToggle.GetSelectedValue()) { HideAccColors(); } }
internal override void SetMaterialColorProperty(int slot, Material material, string propertyName, Color value, GameObject go) => MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).SetMaterialColorProperty(slot, material, propertyName, value, go);
internal override float?GetMaterialFloatPropertyValueOriginal(int slot, Material material, string propertyName, GameObject go) => MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).GetMaterialFloatPropertyValueOriginal(slot, material, propertyName, go);
internal override Vector2?GetMaterialTextureScaleOriginal(int slot, Material material, string propertyName, GameObject go) => MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).GetMaterialTextureScaleOriginal(slot, material, propertyName, go);
internal override void SetMaterialTextureScale(int slot, Material material, string propertyName, Vector2 value, GameObject go) => MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).SetMaterialTextureScale(slot, material, propertyName, value, go);
internal override void SetMaterialTexture(int slot, Material material, string propertyName, string filePath, GameObject go) => MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).SetMaterialTextureFromFile(slot, material, propertyName, filePath, go, true);
internal override void RemoveMaterialShaderRenderQueue(int slot, Material material, GameObject go) => MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).RemoveMaterialShaderRenderQueue(slot, material, go);
internal override int?GetMaterialShaderRenderQueueOriginal(int slot, Material material, GameObject go) => MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).GetMaterialShaderRenderQueueOriginal(slot, material, go);
private static BecomeTrapController GetMakerController() { return(MakerAPI.GetCharacterControl().gameObject.GetComponent <BecomeTrapController>()); }
internal override void RemoveMaterialFloatProperty(int slot, Material material, string propertyName, GameObject go) => MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).RemoveMaterialFloatProperty(slot, material, propertyName, go);
private void MakerAPI_RegisterCustomSubCategories(object sender, RegisterSubCategoriesEvent e) { var randomizerBody = new RandomizerBody(); var randomizerFace = new RandomizerFace(); var randomizerHair = new RandomizerHair(); var parentCat = MakerConstants.Body.All; var cat = new MakerCategory(parentCat.CategoryName, "RandomCharacterGeneratorCategory", parentCat.Position + 5, "Randomize"); e.AddSubCategory(cat); e.AddControl(new MakerButton("Set current character as template", cat, this)).OnClick.AddListener(() => { randomizerBody.SetTemplate(); randomizerFace.SetTemplate(); }); var randButton = e.AddControl(new MakerButton("Randomize!", cat, this)); e.AddControl(new MakerSeparator(cat, this)); var randomizeBodySliders = e.AddControl(new MakerToggle(cat, "Randomize body sliders", this)); var randomizeBody = e.AddControl(new MakerToggle(cat, "Randomize body type", this)); _skinColorRadio = e.AddControl(new MakerRadioButtons(cat, this, "Skin color", "White", "Brown", "Unchanged")); e.AddControl(new MakerSeparator(cat, this)); var randomizeFaceSliders = e.AddControl(new MakerToggle(cat, "Randomize face sliders", this)); var randomizeFaceEyes = e.AddControl(new MakerToggle(cat, "Randomize eyes", this)); var randomizeFaceEtc = e.AddControl(new MakerToggle(cat, "Randomize face type", this)); e.AddControl(new MakerSeparator(cat, this)); var randomizeHair = e.AddControl(new MakerToggle(cat, "Randomize hair type", this)); var randomizeHairColor = e.AddControl(new MakerToggle(cat, "Randomize hair color", this)); e.AddControl(new MakerSeparator(cat, this)); _deviationSlider = e.AddControl(new MakerSlider(cat, "Deviation", 0, 1, 0.1f, this)); randomizeBodySliders.Value = true; randomizeFaceSliders.Value = true; randButton.OnClick.AddListener(() => { if (randomizeBody.Value) { RandomizerBody.RandomizeBody(); } if (randomizeBodySliders.Value) { randomizerBody.RandomizeSliders(); } if (randomizeFaceEyes.Value) { RandomizerFace.RandomizeEyes(); } if (randomizeFaceEtc.Value) { RandomizerFace.RandomizeEtc(); } if (randomizeFaceSliders.Value) { randomizerFace.RandomizeSliders(); } if (randomizeHair.Value) { RandomizerHair.RandomizeType(); } if (randomizeHair.Value) { RandomizerHair.RandomizeEtc(); } if (randomizeHairColor.Value) { RandomizerHair.RandomizeColor(); } MakerAPI.GetCharacterControl().Reload(); }); }
public override void RemoveMaterialShaderRenderQueue(object data, Material material, GameObject go) { ObjectData objectData = (ObjectData)data; MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).RemoveMaterialShaderRenderQueue(objectData.Slot, objectData.ObjectType, material, go); }
private void Start() { CharacterApi.RegisterExtraBehaviour <MaterialRouterController>(GUID); HooksInstance = Harmony.CreateAndPatchAll(typeof(Hooks)); BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue("com.deathweasel.bepinex.materialeditor", out PluginInfo PluginInfo); Type MaterialEditorCharaController = PluginInfo.Instance.GetType().Assembly.GetType("KK_Plugins.MaterialEditor.MaterialEditorCharaController"); HooksInstance.Patch(MaterialEditorCharaController.GetMethod("OnReload", AccessTools.all, null, new[] { typeof(GameMode), typeof(bool) }, null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.MaterialEditorCharaController_OnReload_Prefix))); HooksInstance.Patch(MaterialEditorCharaController.GetMethod("OnCoordinateBeingLoaded", AccessTools.all, null, new[] { typeof(ChaFileCoordinate), typeof(bool) }, null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.MaterialEditorCharaController_OnCoordinateBeingLoaded_Prefix))); HooksInstance.Patch(MaterialEditorCharaController.GetMethod("CorrectTongue", AccessTools.all, null, new Type[0], null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.MaterialEditorCharaController_CorrectTongue_Prefix))); Type MaterialEditorMaterialAPI = PluginInfo.Instance.GetType().Assembly.GetType("MaterialEditorAPI.MaterialAPI"); if (MaterialEditorMaterialAPI.GetMethods().Single(x => x.Name == "SetTexture").GetParameters().ElementAtOrDefault(3)?.ParameterType == typeof(Texture)) { HooksInstance.Patch(MaterialEditorMaterialAPI.GetMethod("SetTexture", AccessTools.all, null, new[] { typeof(GameObject), typeof(string), typeof(string), typeof(Texture) }, null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.MaterialAPI_SetTexture_Prefix))); } else { HooksInstance.Patch(MaterialEditorMaterialAPI.GetMethod("SetTexture", AccessTools.all, null, new[] { typeof(GameObject), typeof(string), typeof(string), typeof(Texture2D) }, null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.MaterialAPI_SetTexture_Prefix))); } MakerAPI.MakerBaseLoaded += (object sender, RegisterCustomControlsEvent ev) => { HooksMakerInstance = Harmony.CreateAndPatchAll(typeof(HooksMaker)); }; MakerAPI.MakerFinishedLoading += (object sender, EventArgs ev) => { btmGetTemplate.Visible.OnNext(false); btmImportSetting.Visible.OnNext(false); btmRemoveSetting.Visible.OnNext(false); }; AccessoriesApi.SelectedMakerAccSlotChanged += (object sender, AccessorySlotEventArgs ev) => { InitCurrentSlot(); }; MakerAPI.MakerExiting += (object sender, EventArgs ev) => { HooksMakerInstance.UnpatchAll(HooksMakerInstance.Id); HooksMakerInstance = null; }; AccessoriesApi.AccessoryTransferred += (object sender, AccessoryTransferEventArgs ev) => { MaterialRouterController pluginCtrl = GetController(MakerAPI.GetCharacterControl()); pluginCtrl.AccessoryTransferEvent(ev); }; AccessoriesApi.AccessoriesCopied += (object sender, AccessoryCopyEventArgs ev) => { MaterialRouterController pluginCtrl = GetController(MakerAPI.GetCharacterControl()); pluginCtrl.AccessoryCopyEvent(ev); }; MakerAPI.RegisterCustomSubCategories += (object sender, RegisterSubCategoriesEvent ev) => { ChaControl chaCtrl = MakerAPI.GetCharacterControl(); MaterialRouterController pluginCtrl = GetController(chaCtrl); MakerCategory category = new MakerCategory("05_ParameterTop", "tglMaterialRouter", MakerConstants.Parameter.Attribute.Position + 1, "Router"); ev.AddSubCategory(category); ev.AddControl(new MakerText("BodyTrigger", category, this)); ev.AddControl(new MakerButton("Export", category, this)).OnClick.AddListener(delegate { pluginCtrl.ExportBodyTrigger(); }); ev.AddControl(new MakerButton("Import", category, this)).OnClick.AddListener(delegate { pluginCtrl.ImportBodyTrigger(); }); ev.AddControl(new MakerButton("Reset", category, this)).OnClick.AddListener(delegate { pluginCtrl.ResetBodyTrigger(); }); ev.AddControl(new MakerSeparator(category, this)); ev.AddControl(new MakerText("OutfitTriggers", category, this)); ev.AddControl(new MakerButton("Export", category, this)).OnClick.AddListener(delegate { pluginCtrl.ExportOutfitTrigger(); }); ev.AddControl(new MakerButton("Import", category, this)).OnClick.AddListener(delegate { pluginCtrl.ImportOutfitTrigger(); }); ev.AddControl(new MakerButton("Reset", category, this)).OnClick.AddListener(delegate { pluginCtrl.ResetOutfitTrigger(); }); ev.AddControl(new MakerSeparator(category, this)); ev.AddControl(new MakerText("Config", category, this)); tglSkipCloned = ev.AddControl(new MakerToggle(category, "Get Template Skip Cloned", CfgSkipCloned.Value, this)); tglSkipCloned.ValueChanged.Subscribe(value => CfgSkipCloned.Value = value); ev.AddControl(new MakerSeparator(category, this)); ev.AddControl(new MakerText("Tools", category, this)); ev.AddControl(new MakerButton("Reload", category, Instance)).OnClick.AddListener(delegate { string CardPath = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(Paths.ExecutablePath) + "_MaterialRouter.png"); chaCtrl.chaFile.SaveCharaFile(CardPath, byte.MaxValue, false); chaCtrl.chaFile.LoadFileLimited(CardPath); if (chaCtrl.chaFile.GetLastErrorCode() != 0) { throw new Exception("LoadFileLimited failed"); } chaCtrl.ChangeCoordinateType(true); chaCtrl.Reload(); CustomBase.Instance.updateCustomUI = true; }); ev.AddControl(new MakerButton("Info", category, Instance)).OnClick.AddListener(delegate { Logger.LogInfo($"[BodyTrigger][{pluginCtrl?.BodyTrigger?.Count}]"); for (int i = 0; i < chaCtrl.chaFile.coordinate.Length; i++) { Logger.LogInfo($"[OutfitTriggers][{i}][{pluginCtrl?.OutfitTriggers?[i].Count}]"); } }); ev.AddControl(new MakerButton("Head Get Template", MakerConstants.Face.All, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objHead, true)); ev.AddControl(new MakerButton("Body Get Template", MakerConstants.Face.All, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objBody, true)); const string labelConsolePrint = "Console Output"; const string labelGenerateSetting = "Generate Setting"; const string labelRemoveSetting = "Remove Setting"; ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.Top, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[0])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.Bottom, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[1])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.Bra, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[2])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.Shorts, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[3])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.Gloves, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[4])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.Panst, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[5])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.Socks, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[6])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.InnerShoes, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[7])); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Clothes.OuterShoes, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objClothes[8])); btmGetTemplate = MakerAPI.AddAccessoryWindowControl(new MakerButton(labelConsolePrint, null, this)); btmGetTemplate.OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.GetAccessoryObject(AccessoriesApi.SelectedMakerAccSlot))); btmImportSetting = MakerAPI.AddAccessoryWindowControl(new MakerButton(labelGenerateSetting, null, this)); btmImportSetting.OnClick.AddListener(() => pluginCtrl.ImportFromRendererInfo(AccessoriesApi.SelectedMakerAccSlot)); btmRemoveSetting = MakerAPI.AddAccessoryWindowControl(new MakerButton(labelRemoveSetting, null, this)); btmRemoveSetting.OnClick.AddListener(() => pluginCtrl.RemoveAccSlotInfo(AccessoriesApi.SelectedMakerAccSlot)); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Hair.Back, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objHair[0], true)); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Hair.Front, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objHair[1], true)); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Hair.Side, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objHair[2], true)); ev.AddControl(new MakerButton(labelConsolePrint, MakerConstants.Hair.Extension, this)).OnClick.AddListener(() => PrintRendererInfo(chaCtrl, chaCtrl.objHair[3], true)); }; }
public override void SetMaterialTexture(object data, Material material, string propertyName, string filePath, GameObject go) { ObjectData objectData = (ObjectData)data; MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).SetMaterialTextureFromFile(objectData.Slot, objectData.ObjectType, material, propertyName, filePath, go, true); }
private void MakerAPI_RegisterCustomSubCategories(object sender, RegisterSubCategoriesEvent e) { InvisibleToggle = e.AddControl(new MakerToggle(MakerConstants.Body.All, "Invisible Body", false, this)); InvisibleToggle.ValueChanged.Subscribe(Observer.Create <bool>(delegate { GetController(MakerAPI.GetCharacterControl()).Visible = !InvisibleToggle.Value; })); }
public override void SetMaterialTextureScale(object data, Material material, string propertyName, Vector2 value, GameObject go) { ObjectData objectData = (ObjectData)data; MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).SetMaterialTextureScale(objectData.Slot, objectData.ObjectType, material, propertyName, value, go); }
private void AccessoriesApi_SelectedMakerAccSlotChanged(object sender, AccessorySlotEventArgs e) => GetCharaController(MakerAPI.GetCharacterControl())?.AccessorySelectedSlotChangeEvent(sender, e);
public override float?GetMaterialFloatPropertyValueOriginal(object data, Material material, string propertyName, GameObject go) { ObjectData objectData = (ObjectData)data; return(MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).GetMaterialFloatPropertyValueOriginal(objectData.Slot, objectData.ObjectType, material, propertyName, go)); }
public override string GetRendererPropertyValueOriginal(object data, Renderer renderer, RendererProperties property, GameObject go) { ObjectData objectData = (ObjectData)data; return(MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).GetRendererPropertyValueOriginal(objectData.Slot, objectData.ObjectType, renderer, property, go)); }
public override void RemoveMaterialFloatProperty(object data, Material material, string propertyName, GameObject go) { ObjectData objectData = (ObjectData)data; MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).RemoveMaterialFloatProperty(objectData.Slot, objectData.ObjectType, material, propertyName, go); }
public override void MaterialPasteEdits(object data, Material material, GameObject go) { ObjectData objectData = (ObjectData)data; MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).MaterialPasteEdits(objectData.Slot, objectData.ObjectType, material, go); }
internal static void Init() { Hooks.InitHooks(); // Cards ------------------------- ExtendedSave.CardBeingSaved += OnCardBeingSaved; MakerAPI.ChaFileLoaded += (sender, args) => { var chaControl = MakerAPI.GetCharacterControl(); if (chaControl != null) { #if AI var chaFile = MakerAPI.Hooks.InternalLastLoadedChaFile; KoikatuAPI.Instance.StartCoroutine(new object[] { // Need to wait until clothes and accs are fully loaded null, new WaitForEndOfFrame(), CoroutineUtils.CreateCoroutine(() => { // Needed to fix losing ext data because the chafile gets replaced by chafiles from the list being reloaded MakerAPI.Hooks.InternalLastLoadedChaFile = chaFile; ReloadChara(chaControl); }) }.GetEnumerator()); #else ReloadChara(chaControl); #endif } }; // Coordinates ------------------- ExtendedSave.CoordinateBeingSaved += file => { if (file == null) { return; } // Safe to assume we're in maker var character = MakerAPI.GetCharacterControl(); if (character == null) { KoikatuAPI.Logger.LogError("OnCoordinateBeingSaved fired outside chara maker for " + file.coordinateName); KoikatuAPI.Logger.LogInfo(new StackTrace()); return; } OnCoordinateBeingSaved(character, file); }; ExtendedSave.CoordinateBeingLoaded += file => { if (Hooks.ClothesFileControlLoading || file == null) { return; } // Coord cards are loaded by loading into the character's nowCoordinate var cf = ChaControls.FirstOrDefault(x => x.nowCoordinate == file); if (cf != null) { #if AI KoikatuAPI.Instance.StartCoroutine(CoroutineUtils.CreateCoroutine(new WaitForEndOfFrame(), () => OnCoordinateBeingLoaded(cf, file))); #else OnCoordinateBeingLoaded(cf, file); #endif } }; if (KoikatuAPI.EnableDebugLogging) { RegisterExtraBehaviour <TestCharaCustomFunctionController>(null); } }
public override void SetMaterialShaderName(object data, Material material, string value, GameObject go) { ObjectData objectData = (ObjectData)data; MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).SetMaterialShader(objectData.Slot, objectData.ObjectType, material, value, go); }
internal override void MaterialPasteEdits(int slot, Material material, GameObject go) => MaterialEditorPlugin.GetCharaController(MakerAPI.GetCharacterControl()).MaterialPasteEdits(slot, material, go);