public abstract class Display { }
public abstract class Display<TLogic> : Display where TLogic : Logic<Display<TLogic>>
{
private TLogic logic;
protected Display(){ }
public void SetLogic(TLogic log)=> logic = log;
}
public abstract class Logic { }
public abstract class Logic<TDisplay> : Logic where TDisplay : Display<Logic<TDisplay>>, new()
{
private TDisplay display;
public void OnStart()
{
display = new TDisplay();
display.SetLogic(this);
}
}
I’m trying to have a system where Display and Logic would be able to communicate in the sub classes.
This way, I can have MyDisplay inheriting from Display and getting a reference to MyLogic class. The latter also gets its MyDisplay reference by inheriting from Logic.