Forgive me for the absolutely abominable title of my question, but what I mean is: There is an object A
that has a method mA
that executes a method mB
from an object B
, then that method (mB
) executes mC
from the same object, finally, mC
executes a virtual method mD
from an object C
, which I have overridden.
In code:
class A
{
B b;
void mA()
{
b.mB();
}
}
class B
{
public void mB()
{
mC();
}
D d;
void mC()
{
d.mD();
}
}
class C
{
public virtual void mD() { }
}
class D : C
{
public override void mD()
{
A a = // Somehow get the A object that executed this
}
}
Now that you know the very confusing situation, could you tell me how I would get object A
from mD
? (I do mean object, not class)
Before anyone tries to murder for crimes against good code, I just want to clarify that I'm making a mod, and cannot edit any of the classes (other than D
). So this has to be solved some other way, I'm guessing through some reflection shenanigans, which I am okay with.
Thank you in advance.