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 b5935ad commit dc8d35b
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion RW_ModularizationWeapon/CompModularizationWeapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,52 @@ public static implicit operator Thing(CompModularizationWeapon node)

public static implicit operator CompModularizationWeapon(Thing thing)
{
return thing?.TryGetComp<CompModularizationWeapon>();
List<ThingComp> comps = (thing as ThingWithComps)?.AllComps;
if (comps == null || comps.Count < 2 || ((CompChildNodeProccesser)thing) == null) return null;

CompNoCompMarker marker = comps[1] as CompNoCompMarker;
if (marker != null) return null;
CompModularizationWeapon result = comps[1] as CompModularizationWeapon;
int i = 2;
if (result != null) return result;
else
{
for (; i < comps.Count; i++)
{
result = comps[i] as CompModularizationWeapon;
if (result != null) break;
}
}
if (result != null)
{
comps.RemoveAt(i);
comps.Insert(1, result);
}
else
{
i = 2;
for (; i < comps.Count; i++)
{
marker = comps[i] as CompNoCompMarker;
if (marker != null) break;
}
if (marker != null)
{
comps.RemoveAt(i);
comps.Insert(1, marker);
}
else
{
marker = new CompNoCompMarker();
comps.Insert(1, marker);
}
}
return result;
}

internal class CompNoCompMarker : ThingComp
{

}
#endregion

Expand Down

0 comments on commit dc8d35b

Please sign in to comment.