/// <summary> /// Cancels <see cref="SessionState.Selection"/> mode without completing the pending /// command.</summary> /// <remarks><para> /// <b>Cancel</b> resets the current <see cref="Session.State"/> to <see /// cref="SessionState.Human"/> which implicitly calls <see cref="Clear"/> to clear all data /// managed by the <see cref="TargetSelection"/> class. /// </para><para> /// If the pending command was a <see cref="BuildCommand"/> or a <see cref="PlaceCommand"/>, /// <b>Cancel</b> then calls <see cref="HumanAction.Build"/> or <see /// cref="HumanAction.ManageEntities"/>, allowing the local human player to continue /// building or placing entities, respectively. /// </para><para> /// <b>Cancel</b> does nothing if the current <see cref="Session.State"/> does not equal /// <see cref="SessionState.Selection"/>. Thus, implicit target selection is unaffected. /// </para></remarks> public void Cancel() { // check for active Selection mode if (Session.State != SessionState.Selection) { return; } // remember command type for continuation Type commandType = this._commandType; // cancel explicit Selection mode Session.State = SessionState.Human; // let user build or place more entities if (commandType == typeof(BuildCommand)) { HumanAction.Build(); } else if (commandType == typeof(PlaceCommand)) { HumanAction.ManageEntities(Dialog.ShowEntitiesMode.Unplaced); } }