diff --git a/HarmonySrc/BoneSteedEnginePatch.cs b/HarmonySrc/BoneSteedEnginePatch.cs index 5efde16..ebc47f4 100644 --- a/HarmonySrc/BoneSteedEnginePatch.cs +++ b/HarmonySrc/BoneSteedEnginePatch.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using UnityEngine; namespace NecromancerTome { @@ -56,4 +57,55 @@ namespace NecromancerTome { public static bool Prefix(VPEngine __instance) => !BoneSteedEngine.Is(__instance); } + + /// Глазница черепа гаснет вместе с фарой (01.10). Свечение глазницы - карта эмиссии + /// в текстуре вилки, ваниль её не переключает. На все уровни детализации вилки ставится + /// MaterialPropertyBlock (материал не копируется): эмиссия белая при включённой фаре, чёрная - + /// при выключенной. Обе ручки - _EmissionColor и _EmissionMultiply: какую из них читает + /// шейдер транспорта, по декомпилятору не видно, а лишняя не мешает. + public static class BoneSteedEye + { + static readonly MaterialPropertyBlock block = new MaterialPropertyBlock(); + + public static void Apply(EntityVehicle e, bool on) + { + if (e == null) + return; + foreach (Renderer r in e.transform.GetComponentsInChildren(true)) + { + if (!r.name.StartsWith("frontFork_LOD")) + continue; + r.GetPropertyBlock(block); + block.SetColor("_EmissionColor", on ? Color.white : Color.black); + block.SetFloat("_EmissionMultiply", on ? 1f : 0f); + r.SetPropertyBlock(block); + } + } + } + + [HarmonyPatch(typeof(VPHeadlight), nameof(VPHeadlight.UpdateOn))] + public static class Patch_VPHeadlight_UpdateOn_BoneSteedEye + { + public static void Postfix(VPHeadlight __instance) + { + if (BoneSteedEngine.Is(__instance)) + BoneSteedEye.Apply(__instance.vehicle.entity, __instance.IsOn()); + } + } + + /// При появлении скакуна фара выключена - глазница тоже тёмная. + [HarmonyPatch(typeof(EntityVehicle), nameof(EntityVehicle.PostInit))] + public static class Patch_EntityVehicle_PostInit_BoneSteedEye + { + public static void Postfix(EntityVehicle __instance) + { + if (!BoneSteed.Is(__instance)) + return; + VPHeadlight light = null; + foreach (VehiclePart part in __instance.GetVehicle().vehicleParts) + if (part is VPHeadlight h) + light = h; + BoneSteedEye.Apply(__instance, light != null && light.IsOn()); + } + } } diff --git a/NecromancerHarmony.dll b/NecromancerHarmony.dll index b48fee4..e3e5e0e 100644 Binary files a/NecromancerHarmony.dll and b/NecromancerHarmony.dll differ diff --git a/NecromancerHarmony.pdb b/NecromancerHarmony.pdb index 6c6662f..687f54f 100644 Binary files a/NecromancerHarmony.pdb and b/NecromancerHarmony.pdb differ