/// <summary> /// On WaitForAction state /// </summary> /// <returns>Seconds to be delayed before next call.</returns> private double OnRockAction() { if (this.currentAction?.IsValid() == false) { this.currentAction = null; } if (this.currentAction?.IsDone() == true) { var scene = this.pegasus.SnapshotScene(this.sessionId, this.actionId); this.bot.ReportActionResult(scene); } if (this.currentAction == null || this.currentAction.IsDone()) { this.actionId += 1; var scene = this.pegasus.SnapshotScene(this.sessionId, this.actionId); var playAction = this.bot.GetPlayAction(scene); if (playAction.Objects != null && playAction.Objects.Count != 0) { var rockActionContext = new RockEngineAction(this.pegasus, playAction.Objects, playAction.Slot); if (rockActionContext.IsValid()) { this.currentAction = rockActionContext; this.ShowRockInfo(this.currentAction.Interpretation); } else { this.tracer.Warning("Invalid rockAction"); this.currentAction = null; return(3); } } else { this.ShowRockInfo("Job's Done"); this.pegasus.DoEndTurn(); this.currentAction = null; return(3); } } if (this.currentAction != null && this.currentAction.IsValid()) { this.currentAction.Apply(); } return(1); }
/// <summary> /// On WaitForAction state /// </summary> /// <returns>Seconds to be delayed before next call.</returns> private double OnRockAction() { if (EndTurnButton.Get().HasNoMorePlays()) { this.ShowRockInfo("Job's Done"); this.pegasus.DoEndTurn(); this.currentAction = null; return(3); } if (this.currentAction == null || this.currentAction.IsDone() || !this.currentAction.IsValid()) { var scene = this.pegasus.SnapshotScene(); var playAction = this.bot.GetPlayAction(scene); if (playAction.Objects != null && playAction.Objects.Count != 0) { var rockActionContext = new RockEngineAction(this.pegasus, playAction.Objects, playAction.Slot); if (rockActionContext.IsValid()) { this.currentAction = rockActionContext; this.ShowRockInfo(this.currentAction.Interpretation); } else { this.tracer.Warning("Invalid rockAction"); } } else { this.ShowRockInfo("Job's Done"); this.pegasus.DoEndTurn(); return(3); } } if (this.currentAction != null && this.currentAction.IsValid()) { this.currentAction.Apply(); } return(1); }