Skip to content

Instantly share code, notes, and snippets.

View RealityMachina's full-sized avatar

A. T. RealityMachina

  • Toronto, Ontario
View GitHub Profile
@RealityMachina
RealityMachina / Battletech_Reflection_notes.txt
Created May 9, 2018 00:01
Battletech C# Reflection notes
Type type = __instance.GetType();
MethodInfo methodInfo = type.GetMethod("OnImpact", BindingFlags.NonPublic | BindingFlags.Instance);
object[] parametersArray = new object[] { __instance.weapon.DamagePerShot };
methodInfo.Invoke(__instance, parametersArray);
this is a method execute with a parameter
Type type3 = __instance.GetType();
FieldInfo field= type3.GetField("hitIndex", BindingFlags.NonPublic | BindingFlags.Instance);
field.SetValue(__instance, shotcount - 1);
setting a field
and setting a parameter is the same with paramater instead of field