Skip to content

Commit

Permalink
update implicit transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
Cn-mjt44 committed Feb 28, 2024
1 parent a966ca0 commit a3e8992
Showing 1 changed file with 41 additions and 16 deletions.
57 changes: 41 additions & 16 deletions RW_NodeTree/CompChildNodeProccesser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -751,26 +751,51 @@ public static implicit operator Thing(CompChildNodeProccesser node)
public static implicit operator CompChildNodeProccesser(Thing thing)
{
List<ThingComp> comps = (thing as ThingWithComps)?.AllComps;
if (comps != null && comps.Count > 0)
if (comps.NullOrEmpty()) return null;

CompNoCompMarker marker = comps[0] as CompNoCompMarker;
if (marker != null) return null;
CompChildNodeProccesser result = comps[0] as CompChildNodeProccesser;
int i = 1;
if (result != null) return result;
else
{
CompChildNodeProccesser result = comps[0] as CompChildNodeProccesser;
if (result == null)
for (; i < comps.Count; i++)
{
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);
}
result = comps[i] as CompChildNodeProccesser;
if (result != null) break;
}
return result;
}
return null;
if (result != null)
{
comps.RemoveAt(i);
comps.Insert(0, result);
}
else
{
i = 1;
for (; i < comps.Count; i++)
{
marker = comps[i] as CompNoCompMarker;
if (marker != null) break;
}
if (marker != null)
{
comps.RemoveAt(i);
comps.Insert(0, marker);
}
else
{
marker = new CompNoCompMarker();
comps.Insert(0, marker);
}
}
return result;
}

internal class CompNoCompMarker : ThingComp
{

}
#endregion

Expand Down

0 comments on commit a3e8992

Please sign in to comment.