diff --git a/HarmonySrc/BundleShaderFix.cs b/HarmonySrc/BundleShaderFix.cs new file mode 100644 index 0000000..466bc37 --- /dev/null +++ b/HarmonySrc/BundleShaderFix.cs @@ -0,0 +1,89 @@ +using System.Collections.Generic; +using HarmonyLib; +using UnityEngine; + +namespace NecromancerTome +{ + /// + /// Шейдер Standard из наших бандлов (10.10.2026). Тест в игре: останки красного трупа вышли бледно-бежевыми, хотя + /// в Unity тот же префаб тёмный и багровый (снимок NecroPreviewOne) - игра рисует копию Standard, приехавшую + /// в бандле, не так, как свой Standard. То же раньше было у крысы (RatModel.cs подменяет шейдер на свой) и у + /// пирамиды (маджента издалека). Здесь - общая подмена для новых моделей: останки (сущность necroRemains), + /// череп и нож-меч прилива (модели предметов). Материалы бандла общие - правится один раз на материал. + /// Очередь отрисовки сохраняется (у меча прилива - прозрачная, Fade). + /// + public static class BundleShaderFix + { + static Shader _std; + static readonly HashSet _done = new HashSet(); + + public static void Fix(Transform _root) + { + if (_root == null) + { + return; + } + if (_std == null) + { + _std = Shader.Find("Standard"); + if (_std == null) + { + return; + } + } + foreach (Renderer r in _root.GetComponentsInChildren(true)) + { + foreach (Material m in r.sharedMaterials) + { + if (m == null || m.shader == null || m.shader == _std || m.shader.name != "Standard" || !_done.Add(m.GetInstanceID())) + { + continue; + } + int queue = m.renderQueue; + m.shader = _std; + m.renderQueue = queue; + Debug.Log("[NecromancerTome] BundleShaderFix: материал '" + m.name + "' - встроенный Standard (очередь " + queue + ")"); + } + } + } + } + + /// Останки красного трупа - модель сущности. + [HarmonyPatch(typeof(EModelBase), nameof(EModelBase.createModel))] + public static class Patch_EModelBase_createModel_BundleShaderFix + { + static int _cls = int.MinValue; + + public static void Postfix(EModelBase __instance) + { + if (_cls == int.MinValue) + { + _cls = EntityClass.FromString(RemainsDecay.EntityClassName); + } + Entity e = __instance.entity; + if (e != null && e.entityClass == _cls) + { + BundleShaderFix.Fix(__instance.GetModelTransform()); + } + } + } + + /// Череп и нож (меч прилива) - модели предметов: в руке и на земле. + [HarmonyPatch(typeof(ItemClass), nameof(ItemClass.CloneModel))] + public static class Patch_ItemClass_CloneModel_BundleShaderFix + { + public static void Postfix(ItemClass __instance, AssetManagement.InstanceHandle __result) + { + string n = __instance?.Name; + if (n != "necroSkull" && n != SnakeMode.KnifeName) + { + return; + } + GameObject go = __result.Instance; + if (go != null) + { + BundleShaderFix.Fix(go.transform); + } + } + } +} diff --git a/HarmonySrc/RemainsDecay.cs b/HarmonySrc/RemainsDecay.cs index 6cab293..d107f7c 100644 --- a/HarmonySrc/RemainsDecay.cs +++ b/HarmonySrc/RemainsDecay.cs @@ -141,7 +141,7 @@ namespace NecromancerTome } // центр модели останков сдвинут от таза к груди: отодвинуть назад на полкорпуса, чтобы таз остался на месте Vector3 back = Quaternion.Euler(0f, yaw, 0f) * Vector3.back; - g += back * 0.16f; + g += back * 0.19f; // модель x1.2 (NecroRemainsSetup.Scale) if (!(EntityFactory.CreateEntity(cls, g, new Vector3(0f, yaw, 0f)) is EntityLootContainer rem)) { diff --git a/NecromancerHarmony.dll b/NecromancerHarmony.dll index 720becf..c5a3abb 100644 Binary files a/NecromancerHarmony.dll and b/NecromancerHarmony.dll differ diff --git a/NecromancerHarmony.pdb b/NecromancerHarmony.pdb index 7309122..c70f0d3 100644 Binary files a/NecromancerHarmony.pdb and b/NecromancerHarmony.pdb differ diff --git a/Resources/necroremains b/Resources/necroremains index 4cf445c..387acf6 100644 Binary files a/Resources/necroremains and b/Resources/necroremains differ diff --git a/UIAtlases/ItemIconAtlas/necroRemains.png b/UIAtlases/ItemIconAtlas/necroRemains.png index ce9df7b..cb9ae3a 100644 Binary files a/UIAtlases/ItemIconAtlas/necroRemains.png and b/UIAtlases/ItemIconAtlas/necroRemains.png differ