Скакун: глазница гаснет вместе с фарой
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9bf3c06e6b
commit
de5a6a22a7
@@ -1,4 +1,5 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NecromancerTome
|
namespace NecromancerTome
|
||||||
{
|
{
|
||||||
@@ -56,4 +57,55 @@ namespace NecromancerTome
|
|||||||
{
|
{
|
||||||
public static bool Prefix(VPEngine __instance) => !BoneSteedEngine.Is(__instance);
|
public static bool Prefix(VPEngine __instance) => !BoneSteedEngine.Is(__instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Глазница черепа гаснет вместе с фарой (01.10). Свечение глазницы - карта эмиссии
|
||||||
|
/// в текстуре вилки, ваниль её не переключает. На все уровни детализации вилки ставится
|
||||||
|
/// MaterialPropertyBlock (материал не копируется): эмиссия белая при включённой фаре, чёрная -
|
||||||
|
/// при выключенной. Обе ручки - _EmissionColor и _EmissionMultiply: какую из них читает
|
||||||
|
/// шейдер транспорта, по декомпилятору не видно, а лишняя не мешает.</summary>
|
||||||
|
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<Renderer>(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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>При появлении скакуна фара выключена - глазница тоже тёмная.</summary>
|
||||||
|
[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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user