private bool SetBuildControl(bool enabled) { // Note: Can't be used to change tye type of the build control. if (enabled) { if (mBuildCon != null) { return(true); } IBuildControl con; if (mContext.Build.BuildData.IsTiled) { con = new MultiTileBuildControl(); } else { con = new SingleTileBuildControl(); } if (con.Enter(mContext, mDebugContext)) { mBuildCon = con; return(true); } return(false); } if (mBuildCon != null) { mBuildCon.Exit(); mBuildCon = null; } return(true); }
private void PerformStateTransition() { mContext.Selection.ClearSelection(); mSelectedControl = 0; // Will always change during a transition. if (mOverrideControl != null) { // Always get rid of the override control. A new one // will be created as needed. mOverrideControl.Exit(); mOverrideControl = null; } NavmeshBuild build = mContext.Build; // Note: Caller already checked for null. NavmeshBuildState buildState = build.BuildState; // No early exits after this point. // Debug.Log("Transition: " + buildState); switch (buildState) { case NavmeshBuildState.Inactive: // Needs first time compile of input data. ExitChildControls(); if (SetInputControl(true)) { mSelectedControl = ControlType.Input; } break; case NavmeshBuildState.InputCompiled: // Let user update config before preparing the build. SetBuildControl(false); if (SetConfigControl(true) && SetInputControl(true)) { mSelectedControl = ControlType.Config; } break; case NavmeshBuildState.NeedsRecovery: ExitChildControls(); SetCriticalFailure("Internal error: Unexpected loss of input data."); break; case NavmeshBuildState.Buildable: if (SetBuildControl(true) && SetConfigControl(true) && SetInputControl(true)) { mSelectedControl = ControlType.Build; } break; case NavmeshBuildState.Invalid: ExitChildControls(); mOverrideControl = new CoreFailureControl(); mOverrideControl.Enter(mContext, mDebugContext); break; default: SetCriticalFailure("Internal error. Unhandled build state: " + buildState); break; } // Note: Don't requery the build. This is the state that was // handled. mLastBuildState = buildState; mDebugContext.NeedsRepaint = true; }