The OnStateChanged method is the method that should trigger the StateChanged event. Not the method that will handle this event. That is why I have added the FunctionCalledWhenStateChanges method.
public abstract class GameStateBehaviour
{
public event EventHandler<GameStateEvents> StateChanged;
protected GameStateBehaviour()
{
StateChanged += (sender, events) => FunctionCalledWhenStateChanges();
}
public virtual void FunctionCalledWhenStateChanges()
{
// The called function
}
protected void OnStateChanged(GameStateEvents e)
{
if (StateChanged != null) StateChanged(this, e);
}
}
The solution above handles your own event. I think it is even better to implement the Template Method Pattern instead of responding to your own event. However I think you are not sure where to throw the event.