From a966ca0c7babaf12472497b9416cd14e4396f90c Mon Sep 17 00:00:00 2001 From: Future <1609605489@qq.com> Date: Tue, 27 Feb 2024 12:40:16 +0800 Subject: [PATCH] new implicit transfer method --- RW_NodeTree/CompChildNodeProccesser.cs | 31 ++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/RW_NodeTree/CompChildNodeProccesser.cs b/RW_NodeTree/CompChildNodeProccesser.cs index 2666c0a..3575827 100644 --- a/RW_NodeTree/CompChildNodeProccesser.cs +++ b/RW_NodeTree/CompChildNodeProccesser.cs @@ -361,7 +361,14 @@ public static bool CheckVerbDatasVaildityAndAdapt(Type ownerType, Thing thing, r public void ResetRenderedTexture() { for (int i = 0; i < nodeRenderingInfos.Length; i++) nodeRenderingInfos[i] = null; - if (parent.Spawned && parent.def.drawerType >= DrawerType.MapMeshOnly) parent.DirtyMapMesh(parent.Map); + try + { + if (parent.Spawned && parent.def.drawerType >= DrawerType.MapMeshOnly) parent.DirtyMapMesh(parent.Map); + } + catch (Exception ex) + { + Log.Warning(ex.ToString()); + } ParentProccesser?.ResetRenderedTexture(); } @@ -743,7 +750,27 @@ public static implicit operator Thing(CompChildNodeProccesser node) public static implicit operator CompChildNodeProccesser(Thing thing) { - return thing?.TryGetComp(); + List comps = (thing as ThingWithComps)?.AllComps; + if (comps != null && comps.Count > 0) + { + CompChildNodeProccesser result = comps[0] as CompChildNodeProccesser; + if (result == null) + { + int i = 1; + for (; i < comps.Count; i++) + { + result = comps[i] as CompChildNodeProccesser; + if (result != null) break; + } + if (result != null) + { + comps.RemoveAt(i); + comps.Insert(0, result); + } + } + return result; + } + return null; } #endregion