Code: Select all
public Chunk Plugin;
private void FilterReflexives()
{
FieldInfo[] fields = Plugin.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public);
for (int i = 0; i < fields.Length; i++)
{
FieldInfo f = fields[i];
if (f.FieldType.IsGenericType && (f.FieldType.GetGenericTypeDefinition() == typeof(Reflexive<>)))
{
Reflexives.Add((Reflexive<Chunk>)f.GetValue(Plugin));
Reflexives.AddRange(((Reflexive<Chunk>)f.GetValue(Plugin)).FilterReflexives().ToArray());
}
}
}
System.InvalidCastException was unhandled
Message="Unable to cast object of type 'HaloObjects.Reflexive`1[HaloObjects.sbsp+Collision_MaterialsBlock]' to type 'HaloObjects.Reflexive`1[HaloObjects.Chunk]'."
Note: I set the fields value with the Plugin object, but it doesn't work when I try to retrive it that way.