Skip to content

Commit 81b8ed1

Browse files
committed
add GetRelay
1 parent 96a345f commit 81b8ed1

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

2.44 KB
Binary file not shown.

CathodeLib/Scripts/CATHODE/CommandsPAK/Helpers/ParameterUtils.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public static class ParameterUtils
1414
private static byte[] _functionInfo;
1515
private static Dictionary<FunctionType, Dictionary<ParameterVariant, int>> _functionVariantOffsets = new Dictionary<FunctionType, Dictionary<ParameterVariant, int>>();
1616
private static Dictionary<FunctionType, FunctionType?> _functionBaseClasses = new Dictionary<FunctionType, FunctionType?>();
17+
private static Tuple<int, int> _relayInfoOffset;
1718

1819
//this really needs deprecating
1920
public static Commands LinkedCommands => _commands;
@@ -47,6 +48,8 @@ static ParameterUtils()
4748
variantOffsets.Add((ParameterVariant)reader.ReadInt32(), reader.ReadInt32());
4849
}
4950
}
51+
52+
_relayInfoOffset = new Tuple<int, int>(reader.ReadInt32(), reader.ReadInt32());
5053
}
5154
}
5255

@@ -754,5 +757,22 @@ public static ParameterData CreateDefaultParameterData(FunctionType function, Sh
754757
}
755758
return null;
756759
}
760+
761+
/* Get the relay pin for a given method pin */
762+
public static ShortGuid GetRelay(ShortGuid guid)
763+
{
764+
using (BinaryReader reader = new BinaryReader(new MemoryStream(_functionInfo)))
765+
{
766+
reader.BaseStream.Position = _relayInfoOffset.Item1;
767+
for (int i = 0; i < _relayInfoOffset.Item2; i++)
768+
{
769+
UInt32 method = reader.ReadUInt32();
770+
UInt32 relay = reader.ReadUInt32();
771+
if (method == guid.ToUInt32())
772+
return new ShortGuid(relay);
773+
}
774+
}
775+
return ShortGuid.Invalid;
776+
}
757777
}
758778
}

0 commit comments

Comments
 (0)