Search the Community
Showing results for tags 'state'.
-
Hello all! I am working on reverse-engineering a mod and I have run into an issue with my understanding of C#. The mod has this method: public class CivilianPopulationRegulator : BaseConverter { public override void OnStart(PartModule.StartState state) { if (!HighLogic.LoadedSceneIsFlight) { base.OnStart(state); return; } if (this.vessel == null) { base.OnStart(state); return; } //do some stuff later base.OnStart(state);//Not sure what this does at the moment. } } Looking at the "base" keyword, it is used to call a method in the base class that is being overriden or it is used to call a constructor. Unless OnStart is a constructor, isn't this going into the extended class (BaseConverter, which extends PartModule) and run OnStart again? At the end of which, OnStart will be called yet again. And so on infinitely? So since the code is not infinitely recursive, I must be mistaken in either my understanding of OnStart or the "base" keyword. Would any of you guys know why this works and/or where I could learn more about this?